mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Amend EIP-3860 per EIPs/pull/6249 (#6502)
See https://github.com/ethereum/EIPs/pull/6249 and https://github.com/ethereum/tests/pull/1125
This commit is contained in:
parent
b251e31fdc
commit
ac1428e15e
@ -32,7 +32,6 @@ var (
|
||||
ErrInsufficientBalance = errors.New("insufficient balance for transfer")
|
||||
ErrContractAddressCollision = errors.New("contract address collision")
|
||||
ErrExecutionReverted = errors.New("execution reverted")
|
||||
ErrMaxInitCodeSizeExceeded = errors.New("max initcode size exceeded")
|
||||
ErrMaxCodeSizeExceeded = errors.New("max code size exceeded")
|
||||
ErrInvalidJump = errors.New("invalid jump destination")
|
||||
ErrWriteProtection = errors.New("write protection")
|
||||
|
@ -334,10 +334,6 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||
if !evm.context.CanTransfer(evm.intraBlockState, caller.Address(), value) {
|
||||
return nil, common.Address{}, gas, ErrInsufficientBalance
|
||||
}
|
||||
// Check whether the init code size has been exceeded.
|
||||
if evm.config.HasEip3860(evm.chainRules) && len(codeAndHash.code) > params.MaxInitCodeSize {
|
||||
return nil, address, gas, ErrMaxInitCodeSizeExceeded
|
||||
}
|
||||
if incrementNonce {
|
||||
nonce := evm.intraBlockState.GetNonce(caller.Address())
|
||||
if nonce+1 < nonce {
|
||||
|
@ -313,19 +313,15 @@ func gasCreateEip3860(evm *EVM, contract *Contract, stack *stack.Stack, mem *Mem
|
||||
return 0, err
|
||||
}
|
||||
len, overflow := stack.Back(2).Uint64WithOverflow()
|
||||
if overflow {
|
||||
if overflow || len > params.MaxInitCodeSize {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
if len <= params.MaxInitCodeSize {
|
||||
numWords := ToWordSize(len)
|
||||
wordGas, overflow := math.SafeMul(numWords, params.InitCodeWordGas)
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
gas, overflow = math.SafeAdd(gas, wordGas)
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
numWords := ToWordSize(len)
|
||||
// Since size <= params.MaxInitCodeSize, this multiplication cannot overflow
|
||||
wordGas := params.InitCodeWordGas * numWords
|
||||
gas, overflow = math.SafeAdd(gas, wordGas)
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
return gas, nil
|
||||
}
|
||||
@ -336,18 +332,12 @@ func gasCreate2Eip3860(evm *EVM, contract *Contract, stack *stack.Stack, mem *Me
|
||||
return 0, err
|
||||
}
|
||||
len, overflow := stack.Back(2).Uint64WithOverflow()
|
||||
if overflow {
|
||||
if overflow || len > params.MaxInitCodeSize {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
wordCost := params.Keccak256WordGas
|
||||
if len <= params.MaxInitCodeSize {
|
||||
wordCost += params.InitCodeWordGas
|
||||
}
|
||||
numWords := ToWordSize(len)
|
||||
wordGas, overflow := math.SafeMul(numWords, wordCost)
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
// Since size <= params.MaxInitCodeSize, this multiplication cannot overflow
|
||||
wordGas := (params.InitCodeWordGas + params.Keccak256WordGas) * numWords
|
||||
gas, overflow = math.SafeAdd(gas, wordGas)
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
|
@ -38,6 +38,9 @@ func TestBlockchain(t *testing.T) {
|
||||
// For speedier CI-runs those are skipped.
|
||||
bt.skipLoad(`^GeneralStateTests/`)
|
||||
|
||||
// Skipping due to https://github.com/ethereum/tests/issues/1133
|
||||
bt.skipLoad(`^EIPTests/bc4895-withdrawals/`)
|
||||
|
||||
// Currently it fails because SpawnStageHeaders doesn't accept any PoW blocks after PoS transition
|
||||
// TODO(yperbasis): make it work
|
||||
bt.skipLoad(`^TransitionTests/bcArrowGlacierToMerge/powToPosBlockRejection\.json`)
|
||||
|
@ -259,6 +259,24 @@ var Forks = map[string]*params.ChainConfig{
|
||||
TerminalTotalDifficultyPassed: true,
|
||||
ShanghaiTime: big.NewInt(0),
|
||||
},
|
||||
"MergeToShanghaiAtTime15k": {
|
||||
ChainID: big.NewInt(1),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
TangerineWhistleBlock: big.NewInt(0),
|
||||
SpuriousDragonBlock: big.NewInt(0),
|
||||
ByzantiumBlock: big.NewInt(0),
|
||||
ConstantinopleBlock: big.NewInt(0),
|
||||
PetersburgBlock: big.NewInt(0),
|
||||
IstanbulBlock: big.NewInt(0),
|
||||
MuirGlacierBlock: big.NewInt(0),
|
||||
BerlinBlock: big.NewInt(0),
|
||||
LondonBlock: big.NewInt(0),
|
||||
ArrowGlacierBlock: big.NewInt(0),
|
||||
GrayGlacierBlock: big.NewInt(0),
|
||||
TerminalTotalDifficulty: big.NewInt(0),
|
||||
TerminalTotalDifficultyPassed: true,
|
||||
ShanghaiTime: big.NewInt(15_000),
|
||||
},
|
||||
}
|
||||
|
||||
// Returns the set of defined fork names
|
||||
|
@ -44,7 +44,7 @@ func TestState(t *testing.T) {
|
||||
st := new(testMatcher)
|
||||
|
||||
// EOF is not implemented yet
|
||||
st.skipLoad(`^stEIP3540/`)
|
||||
st.skipLoad(`^EIPTests/stEOF/`)
|
||||
|
||||
// Very time consuming
|
||||
st.skipLoad(`^stTimeConsuming/`)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9e058e565e664ae2ba93f9a25c4beb105df07480
|
||||
Subproject commit 04c87e9eec259988d59b776534099869b4c3d219
|
Loading…
Reference in New Issue
Block a user