diff --git a/runtime/runtime.go b/runtime/runtime.go index 22accbde1..4229145c3 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -59,8 +59,8 @@ var baseChainConfig = vm.ChainConfig{ Ethash: nil, Clique: nil, }, - IstanbulBlock: nil, - ShanghaiBlock: nil, + IstanbulBlock: nil, + GalacticaBlock: nil, } // Output output of clause execution. @@ -99,7 +99,7 @@ func New( currentChainConfig := baseChainConfig currentChainConfig.ConstantinopleBlock = big.NewInt(int64(forkConfig.ETH_CONST)) currentChainConfig.IstanbulBlock = big.NewInt(int64(forkConfig.ETH_IST)) - currentChainConfig.ShanghaiBlock = big.NewInt(int64(forkConfig.GALACTICA)) + currentChainConfig.GalacticaBlock = big.NewInt(int64(forkConfig.GALACTICA)) if chain != nil { // use genesis id as chain id currentChainConfig.ChainID = new(big.Int).SetBytes(chain.GenesisID().Bytes()) @@ -107,7 +107,7 @@ func New( // alloc precompiled contracts if forkConfig.GALACTICA == ctx.Number { - for addr := range vm.PrecompiledContractsShanghai { + for addr := range vm.PrecompiledContractsGalactica { if err := state.SetCode(thor.Address(addr), EmptyRuntimeBytecode); err != nil { panic(err) } diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index 3543c3ef1..088f743e0 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -312,13 +312,12 @@ func TestEVMFunction(t *testing.T) { abi: "", methodName: "", testFunc: func(ctx *context, t *testing.T) { - exec, _ := runtime.New(ctx.chain, ctx.state, &xenv.BlockContext{}, thor.ForkConfig{}). + exec, _ := runtime.New(ctx.chain, ctx.state, &xenv.BlockContext{BaseFee: common.Big0}, thor.ForkConfig{GALACTICA: 0}). PrepareClause(tx.NewClause(&target), 0, math.MaxUint64, &xenv.TransactionContext{}) out, _, err := exec() assert.Nil(t, err) assert.Nil(t, out.VMErr) - assert.True(t, new(big.Int).SetBytes(out.Data).Cmp(big.NewInt(0)) == 0) assert.Equal(t, uint64(2), math.MaxUint64-out.LeftOverGas) }, }, @@ -328,13 +327,13 @@ func TestEVMFunction(t *testing.T) { abi: "", methodName: "", testFunc: func(ctx *context, t *testing.T) { - exec, _ := runtime.New(ctx.chain, ctx.state, &xenv.BlockContext{}, thor.ForkConfig{}). + expectedBaseFee := big.NewInt(100_000) + exec, _ := runtime.New(ctx.chain, ctx.state, &xenv.BlockContext{BaseFee: expectedBaseFee}, thor.ForkConfig{GALACTICA: 0}). PrepareClause(tx.NewClause(&target), 0, math.MaxUint64, &xenv.TransactionContext{}) out, _, err := exec() assert.Nil(t, err) assert.Nil(t, out.VMErr) - - assert.True(t, new(big.Int).SetBytes(out.Data).Cmp(big.NewInt(0)) == 0) + assert.True(t, new(big.Int).SetBytes(out.Data).Cmp(expectedBaseFee) == 0) }, }, { @@ -589,7 +588,7 @@ func TestPreForkOpCode(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - exec, _ := runtime.New(chain, state, &xenv.BlockContext{}, thor.NoFork). + exec, _ := runtime.New(chain, state, &xenv.BlockContext{BaseFee: common.Big0}, thor.NoFork). PrepareClause(tx.NewClause(nil).WithData(tt.code), 0, math.MaxUint64, &xenv.TransactionContext{}) out, _, err := exec() assert.Nil(t, err) @@ -597,7 +596,7 @@ func TestPreForkOpCode(t *testing.T) { assert.Equal(t, fmt.Sprintf("invalid opcode 0x%x", int(tt.op)), out.VMErr.Error()) // this one applies a fork config that forks from the start - exec, _ = runtime.New(chain, state, &xenv.BlockContext{}, thor.ForkConfig{}). + exec, _ = runtime.New(chain, state, &xenv.BlockContext{BaseFee: common.Big0}, thor.ForkConfig{}). PrepareClause(tx.NewClause(nil).WithData(tt.code), 0, math.MaxUint64, &xenv.TransactionContext{}) out, _, err = exec() assert.Nil(t, err) diff --git a/vm/chain_config.go b/vm/chain_config.go index 669db03ef..50f0a86ae 100644 --- a/vm/chain_config.go +++ b/vm/chain_config.go @@ -46,7 +46,7 @@ type Rules struct { IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsByzantium bool IsIstanbul bool - IsShanghai bool + IsGalactica bool } // Rules ensures c's ChainID is not nil. @@ -63,6 +63,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num), IsIstanbul: c.IsIstanbul((num)), - IsShanghai: c.IsShanghai((num)), + IsGalactica: c.IsGalactica((num)), } } diff --git a/vm/contracts.go b/vm/contracts.go index 46c3a6381..ad211f070 100644 --- a/vm/contracts.go +++ b/vm/contracts.go @@ -77,11 +77,11 @@ var PrecompiledContractsIstanbul = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{9}): &blake2F{}, } -// PrecompiledContractsShanghai contains the default set of pre-compiled Ethereum +// PrecompiledContractsGalactica contains the default set of pre-compiled Ethereum // contracts used in the Shanghai release. // NOTE: Shanghai release does not introduce any changes in precompiled contracts. // We are catching up from Istanbul, so Shanghai in thor includes eip1108 and eip2565. -var PrecompiledContractsShanghai = map[common.Address]PrecompiledContract{ +var PrecompiledContractsGalactica = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{1}): &safeEcrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, @@ -94,7 +94,7 @@ var PrecompiledContractsShanghai = map[common.Address]PrecompiledContract{ } var ( - PrecompiledAddressesShanghai []common.Address + PrecompiledAddressesGalactica []common.Address PrecompiledAddressesIstanbul []common.Address PrecompiledAddressesByzantium []common.Address PrecompiledAddressesHomestead []common.Address @@ -110,16 +110,16 @@ func init() { for k := range PrecompiledContractsIstanbul { PrecompiledAddressesIstanbul = append(PrecompiledAddressesIstanbul, k) } - for k := range PrecompiledContractsShanghai { - PrecompiledAddressesShanghai = append(PrecompiledAddressesShanghai, k) + for k := range PrecompiledContractsGalactica { + PrecompiledAddressesGalactica = append(PrecompiledAddressesGalactica, k) } } // ActivePrecompiles returns the precompiles enabled with the current configuration. func ActivePrecompiles(rules Rules) []common.Address { switch { - case rules.IsShanghai: - return PrecompiledAddressesShanghai + case rules.IsGalactica: + return PrecompiledAddressesGalactica case rules.IsIstanbul: return PrecompiledAddressesIstanbul case rules.IsByzantium: diff --git a/vm/evm.go b/vm/evm.go index fcba8ed32..79fbebcdf 100644 --- a/vm/evm.go +++ b/vm/evm.go @@ -52,8 +52,8 @@ type ( func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) { var precompiles map[common.Address]PrecompiledContract switch { - case evm.chainRules.IsShanghai: - precompiles = PrecompiledContractsShanghai + case evm.chainRules.IsGalactica: + precompiles = PrecompiledContractsGalactica case evm.chainRules.IsIstanbul: precompiles = PrecompiledContractsIstanbul case evm.chainRules.IsByzantium: @@ -492,7 +492,7 @@ func (evm *EVM) create(caller ContractRef, code []byte, gas uint64, value *big.I } // Reject code starting with 0xEF if EIP-3541 is enabled. - if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsShanghai { + if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsGalactica { err = ErrInvalidCode } diff --git a/vm/interpreter.go b/vm/interpreter.go index f4ff5cf7e..25c827b9a 100644 --- a/vm/interpreter.go +++ b/vm/interpreter.go @@ -59,7 +59,7 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter { // we'll set the default jump table. if cfg.JumpTable == nil { switch { - case evm.ChainConfig().IsShanghai(evm.BlockNumber): + case evm.ChainConfig().IsGalactica(evm.BlockNumber): cfg.JumpTable = shanghaiInstructionSet case evm.ChainConfig().IsIstanbul(evm.BlockNumber): cfg.JumpTable = istanbulInstructionSet