mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
all: fixups
This commit is contained in:
parent
d92543bdc2
commit
88cec4da3b
6 changed files with 54 additions and 9 deletions
|
|
@ -62,7 +62,8 @@ func (al *accessList) Contains(address common.Address, slot common.Hash) (addres
|
|||
// newAccessList creates a new accessList.
|
||||
func newAccessList() *accessList {
|
||||
return &accessList{
|
||||
addresses: make(map[common.Address]int),
|
||||
addresses: make(map[common.Address]int),
|
||||
addressCodes: make(map[common.Address]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -471,8 +471,11 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
|||
}
|
||||
|
||||
// Check whether the init code size has been exceeded.
|
||||
if rules.IsShanghai && contractCreation && len(msg.Data) > params.MaxInitCodeSize {
|
||||
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize)
|
||||
if rules.IsOsaka && contractCreation && len(msg.Data) > params.MaxInitCodeSizeEIP7907 {
|
||||
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSizeEIP7907)
|
||||
}
|
||||
if !rules.IsOsaka && rules.IsShanghai && contractCreation && len(msg.Data) > params.MaxInitCodeSizeEIP3860 {
|
||||
return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSizeEIP3860)
|
||||
}
|
||||
|
||||
// Execute the preparatory steps for state transition which includes:
|
||||
|
|
|
|||
|
|
@ -547,4 +547,6 @@ func enable7907(jt *JumpTable) {
|
|||
jt[STATICCALL].dynamicGas = gasStaticCallEIP7907
|
||||
jt[DELEGATECALL].dynamicGas = gasDelegateCallEIP7907
|
||||
jt[EXTCODECOPY].dynamicGas = gasExtCodeCopyEIP7907
|
||||
jt[CREATE].dynamicGas = gasCreateEip7907
|
||||
jt[CREATE2].dynamicGas = gasCreate2Eip7907
|
||||
}
|
||||
|
|
|
|||
|
|
@ -530,10 +530,10 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address) ([]b
|
|||
}
|
||||
|
||||
// Check whether the max code size has been exceeded, assign err if the case.
|
||||
if evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSizeEIP170 {
|
||||
if evm.chainRules.IsOsaka && len(ret) > params.MaxCodeSizeEIP7907 {
|
||||
return ret, ErrMaxCodeSizeExceeded
|
||||
}
|
||||
if evm.chainRules.IsOsaka && len(ret) > params.MaxCodeSizeEIP7907 {
|
||||
if !evm.chainRules.IsOsaka && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSizeEIP170 {
|
||||
return ret, ErrMaxCodeSizeExceeded
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -344,6 +344,45 @@ func gasCreate2Eip3860(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
|
|||
return gas, nil
|
||||
}
|
||||
|
||||
func gasCreateEip7907(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||
gas, err := memoryGasCost(mem, memorySize)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
size, overflow := stack.Back(2).Uint64WithOverflow()
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
if size > params.MaxInitCodeSizeEIP7907 {
|
||||
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size)
|
||||
}
|
||||
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
||||
moreGas := params.InitCodeWordGas * ((size + 31) / 32)
|
||||
if gas, overflow = math.SafeAdd(gas, moreGas); overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
return gas, nil
|
||||
}
|
||||
func gasCreate2Eip7907(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||
gas, err := memoryGasCost(mem, memorySize)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
size, overflow := stack.Back(2).Uint64WithOverflow()
|
||||
if overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
if size > params.MaxInitCodeSizeEIP7907 {
|
||||
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size)
|
||||
}
|
||||
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
||||
moreGas := (params.InitCodeWordGas + params.Keccak256WordGas) * ((size + 31) / 32)
|
||||
if gas, overflow = math.SafeAdd(gas, moreGas); overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
}
|
||||
return gas, nil
|
||||
}
|
||||
|
||||
func gasExpFrontier(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||
expByteLen := uint64((stack.data[stack.len()-2].BitLen() + 7) / 8)
|
||||
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ const (
|
|||
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
|
||||
InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.
|
||||
|
||||
MaxCodeSizeEIP170 = 24576 // Maximum bytecode to permit for a contract
|
||||
MaxCodeSizeEIP7907 = 268435456 // Maximum bytecode permitted per contract after EIP-7907
|
||||
MaxInitCodeSizeEIP3860 = 2 * MaxCodeSizeEIP170 // Maximum initcode to permit in a creation transaction and create instructions
|
||||
MaxInitCodeSizeEIP7903 = 2 * MaxCodeSizeEIP170 // Maximum initcode to permit in a creation transaction and create instructions
|
||||
MaxCodeSizeEIP170 = 24576 // Maximum bytecode to permit for a contract
|
||||
MaxCodeSizeEIP7907 = 268435456 // Maximum bytecode permitted per contract after EIP-7907
|
||||
MaxInitCodeSizeEIP3860 = 2 * MaxCodeSizeEIP170 // Maximum initcode to permit in a creation transaction and create instructions
|
||||
MaxInitCodeSizeEIP7907 = 2 * MaxCodeSizeEIP7907 // Maximum initcode to permit in a creation transaction and create instructions
|
||||
|
||||
// Precompiled contract gas prices
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue