Merge pull request #59 from shemnon/eof/osaka

Move EOF activation to Osaka
This commit is contained in:
Marius van der Wijden 2025-02-07 09:31:29 +01:00 committed by GitHub
commit 57f5e80603
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 55 additions and 11 deletions

View File

@ -485,7 +485,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
vmerr error // vm errors do not effect consensus and are therefore not assigned to err vmerr error // vm errors do not effect consensus and are therefore not assigned to err
) )
if contractCreation { if contractCreation {
ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value, rules.IsPrague) ret, _, st.gasRemaining, vmerr = st.evm.Create(sender, msg.Data, st.gasRemaining, value, rules.IsOsaka)
// Special case for EOF, if the initcode or deployed code is // Special case for EOF, if the initcode or deployed code is
// invalid, the tx is considered valid (so update nonce), but // invalid, the tx is considered valid (so update nonce), but
// gas for initcode execution is not consumed. // gas for initcode execution is not consumed.

View File

@ -309,7 +309,7 @@ func BenchmarkRJUMPV(b *testing.B) {
} }
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
_, err := validateCode(code, 0, container, &pragueInstructionSet, false) _, err := validateCode(code, 0, container, &eofInstructionSet, false)
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -357,7 +357,7 @@ func BenchmarkEOFValidation(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil { if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err) b.Fatal(err)
} }
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil { if err := container2.ValidateCode(&eofInstructionSet, false); err != nil {
b.Fatal(err) b.Fatal(err)
} }
} }
@ -412,7 +412,7 @@ func BenchmarkEOFValidation2(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil { if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err) b.Fatal(err)
} }
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil { if err := container2.ValidateCode(&eofInstructionSet, false); err != nil {
b.Fatal(err) b.Fatal(err)
} }
} }
@ -468,7 +468,7 @@ func BenchmarkEOFValidation3(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil { if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err) b.Fatal(err)
} }
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil { if err := container2.ValidateCode(&eofInstructionSet, false); err != nil {
b.Fatal(err) b.Fatal(err)
} }
} }
@ -494,7 +494,7 @@ func BenchmarkRJUMPI_2(b *testing.B) {
} }
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
_, err := validateCode(code, 0, container, &pragueInstructionSet, false) _, err := validateCode(code, 0, container, &eofInstructionSet, false)
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
@ -512,6 +512,6 @@ func FuzzValidate(f *testing.F) {
f.Fuzz(func(_ *testing.T, code []byte, maxStack uint16) { f.Fuzz(func(_ *testing.T, code []byte, maxStack uint16) {
var container Container var container Container
container.types = append(container.types, &functionMetadata{inputs: 0, outputs: 0x80, maxStackHeight: maxStack}) container.types = append(container.types, &functionMetadata{inputs: 0, outputs: 0x80, maxStackHeight: maxStack})
validateCode(code, 0, &container, &pragueInstructionSet, true) validateCode(code, 0, &container, &eofInstructionSet, true)
}) })
} }

View File

@ -572,8 +572,8 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address, valu
// Reject code starting with 0xEF if EIP-3541 is enabled. // Reject code starting with 0xEF if EIP-3541 is enabled.
if len(ret) >= 1 && HasEOFByte(ret) { if len(ret) >= 1 && HasEOFByte(ret) {
if evm.chainRules.IsPrague && isInitcodeEOF { if evm.chainRules.IsOsaka && isInitcodeEOF {
// Don't reject EOF contracts after Prague // Don't reject EOF contracts after Osaka
} else if evm.chainRules.IsLondon { } else if evm.chainRules.IsLondon {
return ret, ErrInvalidCode return ret, ErrInvalidCode
} }
@ -691,7 +691,7 @@ func (evm *EVM) GetVMContext() *tracing.VMContext {
// parseContainer tries to parse an EOF container if the Shanghai fork is active. It expects the code to already be validated. // parseContainer tries to parse an EOF container if the Shanghai fork is active. It expects the code to already be validated.
func (evm *EVM) parseContainer(b []byte) *Container { func (evm *EVM) parseContainer(b []byte) *Container {
if evm.chainRules.IsPrague { if evm.chainRules.IsOsaka {
var c Container var c Container
if err := c.UnmarshalBinary(b, false); err != nil && strings.HasPrefix(err.Error(), "invalid magic") { if err := c.UnmarshalBinary(b, false); err != nil && strings.HasPrefix(err.Error(), "invalid magic") {
return nil return nil

View File

@ -183,7 +183,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
input, input,
cfg.GasLimit, cfg.GasLimit,
uint256.MustFromBig(cfg.Value), uint256.MustFromBig(cfg.Value),
rules.IsPrague, rules.IsOsaka,
) )
if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil { if cfg.EVMConfig.Tracer != nil && cfg.EVMConfig.Tracer.OnTxEnd != nil {
cfg.EVMConfig.Tracer.OnTxEnd(&types.Receipt{GasUsed: cfg.GasLimit - leftOverGas}, err) cfg.EVMConfig.Tracer.OnTxEnd(&types.Receipt{GasUsed: cfg.GasLimit - leftOverGas}, err)

View File

@ -454,6 +454,50 @@ var Forks = map[string]*params.ChainConfig{
OsakaTime: u64(15_000), OsakaTime: u64(15_000),
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress, DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
}, },
"Osaka": {
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: 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),
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
ShanghaiTime: u64(0),
CancunTime: u64(0),
PragueTime: u64(0),
OsakaTime: u64(0),
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
},
"PragueToOsakaAtTime15k": {
ChainID: big.NewInt(1),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: 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),
MergeNetsplitBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
ShanghaiTime: u64(0),
CancunTime: u64(0),
PragueTime: u64(0),
OsakaTime: u64(15_000),
DepositContractAddress: params.MainnetChainConfig.DepositContractAddress,
},
} }
// AvailableForks returns the set of defined fork names // AvailableForks returns the set of defined fork names