diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 2c68659945..f0ed7f2b9c 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -109,6 +109,9 @@ type rejectedTx struct { func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, txs types.Transactions, miningReward int64, getTracerFn func(txIndex int, txHash common.Hash) (tracer vm.EVMLogger, err error)) (*state.StateDB, *ExecutionResult, error) { + if chainConfig.IsArbitrum() { + return nil, nil, NewError(ErrorConfig, fmt.Errorf("chain config has arbitrum enabled")) + } // Capture errors for BLOCKHASH operation, if we haven't been supplied the // required blockhashes var hashError error diff --git a/cmd/evm/internal/t8ntool/transaction.go b/cmd/evm/internal/t8ntool/transaction.go index 21279e8f0a..0fe084a073 100644 --- a/cmd/evm/internal/t8ntool/transaction.go +++ b/cmd/evm/internal/t8ntool/transaction.go @@ -140,7 +140,7 @@ func Transaction(ctx *cli.Context) error { } // Check intrinsic gas if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, - chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(0)); err != nil { + chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(0, 0)); err != nil { r.Error = err results = append(results, r) continue @@ -172,7 +172,7 @@ func Transaction(ctx *cli.Context) error { r.Error = errors.New("gas * maxFeePerGas exceeds 256 bits") } // Check whether the init code size has been exceeded. - if chainConfig.IsShanghai(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { + if chainConfig.IsShanghai(0, 0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { r.Error = errors.New("max initcode size exceeded") } results = append(results, r) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index cb7466d86c..4270ebf779 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -262,7 +262,7 @@ func Transition(ctx *cli.Context) error { return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section")) } } - if chainConfig.IsShanghai(prestate.Env.Number) && prestate.Env.Withdrawals == nil { + if chainConfig.IsShanghai(prestate.Env.Number, 0) && prestate.Env.Withdrawals == nil { return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section")) } isMerged := chainConfig.TerminalTotalDifficulty != nil && chainConfig.TerminalTotalDifficulty.BitLen() == 0 diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index eb5aa58ca8..b738c15ceb 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -261,7 +261,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa return err } // Verify existence / non-existence of withdrawalsHash. - shanghai := chain.Config().IsShanghai(header.Time) + shanghai := chain.Config().IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) if shanghai && header.WithdrawalsHash == nil { return fmt.Errorf("missing withdrawalsHash") } @@ -354,7 +354,7 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea if !beacon.IsPoSHeader(header) { return beacon.ethone.FinalizeAndAssemble(chain, header, state, txs, uncles, receipts, nil) } - shanghai := chain.Config().IsShanghai(header.Time) + shanghai := chain.Config().IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) if shanghai { // All blocks after Shanghai must include a withdrawals root. if withdrawals == nil { diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 4706bbac1c..be4a4528ad 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -298,7 +298,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H if header.GasLimit > params.MaxGasLimit { return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit) } - if chain.Config().IsShanghai(header.Time) { + if chain.Config().IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) { return fmt.Errorf("clique does not support shanghai fork") } // If all checks passed, validate any special fields for hard forks diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index da29e16597..5a6ce3136f 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -310,7 +310,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 { return consensus.ErrInvalidNumber } - if chain.Config().IsShanghai(header.Time) { + if chain.Config().IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) { return fmt.Errorf("ethash does not support shanghai fork") } // Verify the engine specific seal securing the block diff --git a/core/evm.go b/core/evm.go index 35e12338ef..25aef80a09 100644 --- a/core/evm.go +++ b/core/evm.go @@ -56,16 +56,17 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common random = &header.MixDigest } return vm.BlockContext{ - CanTransfer: CanTransfer, - Transfer: Transfer, - GetHash: GetHashFn(header, chain), - Coinbase: beneficiary, - BlockNumber: new(big.Int).Set(header.Number), - Time: header.Time, - Difficulty: new(big.Int).Set(header.Difficulty), - BaseFee: baseFee, - GasLimit: header.GasLimit, - Random: random, + CanTransfer: CanTransfer, + Transfer: Transfer, + GetHash: GetHashFn(header, chain), + Coinbase: beneficiary, + BlockNumber: new(big.Int).Set(header.Number), + Time: header.Time, + Difficulty: new(big.Int).Set(header.Difficulty), + BaseFee: baseFee, + GasLimit: header.GasLimit, + Random: random, + ArbOSVersion: types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion, } } diff --git a/core/genesis.go b/core/genesis.go index a522b20dc5..88be75025f 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -466,7 +466,7 @@ func (g *Genesis) ToBlock() *types.Block { } } var withdrawals []*types.Withdrawal - if g.Config != nil && g.Config.IsShanghai(g.Timestamp) { + if g.Config != nil && g.Config.IsShanghai(g.Timestamp, types.DeserializeHeaderExtraInformation(head).ArbOSFormatVersion) { head.WithdrawalsHash = &types.EmptyWithdrawalsHash withdrawals = make([]*types.Withdrawal, 0) } diff --git a/core/state_processor.go b/core/state_processor.go index 599221ad63..60ce3838e5 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -87,7 +87,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } // Fail if Shanghai not enabled and len(withdrawals) is non-zero. withdrawals := block.Withdrawals() - if len(withdrawals) > 0 && !p.config.IsShanghai(block.Time()) { + if len(withdrawals) > 0 && !p.config.IsShanghai(block.Time(), types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) { return nil, nil, 0, fmt.Errorf("withdrawals before shanghai") } // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 2ed2de2ef8..e182f54f05 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -403,7 +403,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr if config.IsLondon(header.Number) { header.BaseFee = misc.CalcBaseFee(config, parent.Header()) } - if config.IsShanghai(header.Time) { + if config.IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) { header.WithdrawalsHash = &types.EmptyWithdrawalsHash } var receipts []*types.Receipt @@ -423,7 +423,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr } header.Root = common.BytesToHash(hasher.Sum(nil)) // Assemble and return the final block for sealing - if config.IsShanghai(header.Time) { + if config.IsShanghai(header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion) { return types.NewBlockWithWithdrawals(header, txs, nil, receipts, []*types.Withdrawal{}, trie.NewStackTrie(nil)) } return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)) diff --git a/core/state_transition.go b/core/state_transition.go index af5ad4ac45..d98f205ac8 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -351,7 +351,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { var ( msg = st.msg sender = vm.AccountRef(msg.From()) - rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time) + rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time, st.evm.Context.ArbOSVersion) contractCreation = msg.To() == nil ) diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index c805201866..e44e42b712 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -1312,7 +1312,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) { pool.istanbul = pool.chainconfig.IsIstanbul(next) pool.eip2718 = pool.chainconfig.IsBerlin(next) pool.eip1559 = pool.chainconfig.IsLondon(next) - pool.shanghai = pool.chainconfig.IsShanghai(uint64(time.Now().Unix())) + pool.shanghai = pool.chainconfig.IsShanghai(uint64(time.Now().Unix()), types.DeserializeHeaderExtraInformation(newHead).ArbOSFormatVersion) } // promoteExecutables moves transactions that have become processable from the diff --git a/core/types/arb_types.go b/core/types/arb_types.go index 84be0cbc57..aa99308b7e 100644 --- a/core/types/arb_types.go +++ b/core/types/arb_types.go @@ -3,7 +3,6 @@ package types import ( "context" "encoding/binary" - "fmt" "math/big" "github.com/ethereum/go-ethereum/common/hexutil" @@ -444,19 +443,16 @@ func (info HeaderInfo) UpdateHeaderWithInfo(header *Header) { header.Extra = info.extra() } -func DeserializeHeaderExtraInformation(header *Header) (HeaderInfo, error) { - if header.BaseFee == nil || header.BaseFee.Sign() == 0 || len(header.Extra) == 0 { +func DeserializeHeaderExtraInformation(header *Header) HeaderInfo { + if header.BaseFee == nil || header.BaseFee.Sign() == 0 || len(header.Extra) != 32 || header.Difficulty.Cmp(common.Big1) != 0 { // imported blocks have no base fee // The genesis block doesn't have an ArbOS encoded extra field - return HeaderInfo{}, nil - } - if len(header.Extra) != 32 { - return HeaderInfo{}, fmt.Errorf("unexpected header extra field length %v", len(header.Extra)) + return HeaderInfo{} } extra := HeaderInfo{} copy(extra.SendRoot[:], header.Extra) extra.SendCount = binary.BigEndian.Uint64(header.MixDigest[:8]) extra.L1BlockNumber = binary.BigEndian.Uint64(header.MixDigest[8:16]) extra.ArbOSFormatVersion = binary.BigEndian.Uint64(header.MixDigest[16:24]) - return extra, nil + return extra } diff --git a/core/vm/evm.go b/core/vm/evm.go index 5f6fece400..4a2e00ef23 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -78,6 +78,9 @@ type BlockContext struct { Difficulty *big.Int // Provides information for DIFFICULTY BaseFee *big.Int // Provides information for BASEFEE Random *common.Hash // Provides information for PREVRANDAO + + // Arbitrum information + ArbOSVersion uint64 } // TxContext provides the EVM with information about a transaction. @@ -136,7 +139,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig StateDB: statedb, Config: config, chainConfig: chainConfig, - chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time), + chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time, blockCtx.ArbOSVersion), } evm.ProcessingHook = DefaultTxProcessor{evm: evm} evm.interpreter = NewEVMInterpreter(evm) @@ -171,7 +174,7 @@ func (evm *EVM) SetBlockContext(blockCtx BlockContext) { evm.Context = blockCtx num := blockCtx.BlockNumber timestamp := blockCtx.Time - evm.chainRules = evm.chainConfig.Rules(num, blockCtx.Random != nil, timestamp) + evm.chainRules = evm.chainConfig.Rules(num, blockCtx.Random != nil, timestamp, blockCtx.ArbOSVersion) } // Call executes the contract associated with the addr with the given input as diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index dcb0974284..8885b10af9 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -22,6 +22,9 @@ import ( ) func NewEnv(cfg *Config) *vm.EVM { + if cfg.ChainConfig.IsArbitrum() { + panic("chain config has arbitrum enabled") + } txContext := vm.TxContext{ Origin: cfg.Origin, GasPrice: cfg.GasPrice, diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 56ff5eeabe..1544ed649d 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -113,7 +113,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { address = common.BytesToAddress([]byte("contract")) vmenv = NewEnv(cfg) sender = vm.AccountRef(cfg.Origin) - rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time) + rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time, vmenv.Context.ArbOSVersion) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) @@ -146,7 +146,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) { var ( vmenv = NewEnv(cfg) sender = vm.AccountRef(cfg.Origin) - rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time) + rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time, vmenv.Context.ArbOSVersion) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) @@ -174,7 +174,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, uint64, er vmenv = NewEnv(cfg) sender = cfg.State.GetOrNewStateObject(cfg.Origin) statedb = cfg.State - rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time) + rules = cfg.ChainConfig.Rules(vmenv.Context.BlockNumber, vmenv.Context.Random != nil, vmenv.Context.Time, vmenv.Context.ArbOSVersion) ) // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 95eed408f0..d11692be38 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -173,7 +173,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV1(update engine.ForkchoiceStateV1, pa if payloadAttributes.Withdrawals != nil { return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("withdrawals not supported in V1")) } - if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp) { + if api.eth.BlockChain().Config().IsShanghai(payloadAttributes.Timestamp, types.DeserializeHeaderExtraInformation(api.eth.BlockChain().CurrentHeader()).ArbOSFormatVersion) { return engine.STATUS_INVALID, engine.InvalidParams.With(fmt.Errorf("forkChoiceUpdateV1 called post-shanghai")) } } @@ -191,7 +191,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV2(update engine.ForkchoiceStateV1, pa } func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) error { - if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp) { + if !api.eth.BlockChain().Config().IsShanghai(attr.Timestamp, types.DeserializeHeaderExtraInformation(api.eth.BlockChain().CurrentHeader()).ArbOSFormatVersion) { // Reject payload attributes with withdrawals before shanghai if attr.Withdrawals != nil { return errors.New("withdrawals before shanghai") @@ -417,7 +417,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl // NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) { - if api.eth.BlockChain().Config().IsShanghai(params.Timestamp) { + if api.eth.BlockChain().Config().IsShanghai(params.Timestamp, types.DeserializeHeaderExtraInformation(api.eth.BlockChain().CurrentHeader()).ArbOSFormatVersion) { if params.Withdrawals == nil { return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil withdrawals post-shanghai")) } diff --git a/eth/tracers/js/goja.go b/eth/tracers/js/goja.go index 9b72341bc5..546b66cb9d 100644 --- a/eth/tracers/js/goja.go +++ b/eth/tracers/js/goja.go @@ -249,7 +249,7 @@ func (t *jsTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Addr t.ctx["value"] = valueBig t.ctx["block"] = t.vm.ToValue(env.Context.BlockNumber.Uint64()) // Update list of precompiles based on current block - rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Random != nil, env.Context.Time) + rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Random != nil, env.Context.Time, env.Context.ArbOSVersion) t.activePrecompiles = vm.ActivePrecompiles(rules) } diff --git a/eth/tracers/native/4byte.go b/eth/tracers/native/4byte.go index 1b4649baa3..d36a7b9956 100644 --- a/eth/tracers/native/4byte.go +++ b/eth/tracers/native/4byte.go @@ -81,7 +81,7 @@ func (t *fourByteTracer) store(id []byte, size int) { // CaptureStart implements the EVMLogger interface to initialize the tracing operation. func (t *fourByteTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { // Update list of precompiles based on current block - rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Random != nil, env.Context.Time) + rules := env.ChainConfig().Rules(env.Context.BlockNumber, env.Context.Random != nil, env.Context.Time, env.Context.ArbOSVersion) t.activePrecompiles = vm.ActivePrecompiles(rules) // Save the outer calldata also diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9cceb6e834..a8841c7088 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1343,14 +1343,10 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *param } func fillArbitrumNitroHeaderInfo(header *types.Header, fields map[string]interface{}) { - info, err := types.DeserializeHeaderExtraInformation(header) - if err != nil { - log.Error("Expected header to contain arbitrum data", "blockHash", header.Hash()) - } else { - fields["l1BlockNumber"] = hexutil.Uint64(info.L1BlockNumber) - fields["sendRoot"] = info.SendRoot - fields["sendCount"] = hexutil.Uint64(info.SendCount) - } + info := types.DeserializeHeaderExtraInformation(header) + fields["l1BlockNumber"] = hexutil.Uint64(info.L1BlockNumber) + fields["sendRoot"] = info.SendRoot + fields["sendCount"] = hexutil.Uint64(info.SendCount) } // rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires @@ -1631,7 +1627,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH } isPostMerge := header.Difficulty.Cmp(common.Big0) == 0 // Retrieve the precompiles since they don't need to be added to the access list - precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time)) + precompiles := vm.ActivePrecompiles(b.ChainConfig().Rules(header.Number, isPostMerge, header.Time, types.DeserializeHeaderExtraInformation(header).ArbOSFormatVersion)) // Create an initial tracer prevTracer := logger.NewAccessListTracer(nil, args.from(), to, precompiles) @@ -1868,12 +1864,7 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common. } if s.b.ChainConfig().IsArbitrumNitro(header.Number) { fields["effectiveGasPrice"] = hexutil.Uint64(header.BaseFee.Uint64()) - info, err := types.DeserializeHeaderExtraInformation(header) - if err != nil { - log.Error("Expected header to contain arbitrum data", "blockHash", blockHash) - } else { - fields["l1BlockNumber"] = hexutil.Uint64(info.L1BlockNumber) - } + fields["l1BlockNumber"] = hexutil.Uint64(types.DeserializeHeaderExtraInformation(header).L1BlockNumber) } else { inner := tx.GetInner() arbTx, ok := inner.(*types.ArbitrumLegacyTxData) diff --git a/light/txpool.go b/light/txpool.go index e59dc3e774..83b5aac0ce 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -318,7 +318,7 @@ func (pool *TxPool) setNewHead(head *types.Header) { next := new(big.Int).Add(head.Number, big.NewInt(1)) pool.istanbul = pool.config.IsIstanbul(next) pool.eip2718 = pool.config.IsBerlin(next) - pool.shanghai = pool.config.IsShanghai(uint64(time.Now().Unix())) + pool.shanghai = pool.config.IsShanghai(uint64(time.Now().Unix()), types.DeserializeHeaderExtraInformation(head).ArbOSFormatVersion) } // Stop stops the light transaction pool diff --git a/params/config.go b/params/config.go index 97eaf61d53..a922186470 100644 --- a/params/config.go +++ b/params/config.go @@ -345,7 +345,7 @@ var ( Clique: nil, ArbitrumChainParams: DisableArbitrumParams(), } - TestRules = TestChainConfig.Rules(new(big.Int), false, 0) + TestRules = TestChainConfig.Rules(new(big.Int), false, 0, 0) ) // NetworkNames are user friendly names to use in the chain spec banner. @@ -650,7 +650,10 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi } // IsShanghai returns whether time is either equal to the Shanghai fork time or greater. -func (c *ChainConfig) IsShanghai(time uint64) bool { +func (c *ChainConfig) IsShanghai(time uint64, currentArbosVersion uint64) bool { + if c.IsArbitrum() { + return currentArbosVersion >= 11 + } return isTimestampForked(c.ShanghaiTime, time) } @@ -974,7 +977,7 @@ type Rules struct { } // Rules ensures c's ChainID is not nil. -func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules { +func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64, currentArbosVersion uint64) Rules { chainID := c.ChainID if chainID == nil { chainID = new(big.Int) @@ -993,7 +996,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules IsBerlin: c.IsBerlin(num), IsLondon: c.IsLondon(num), IsMerge: isMerge, - IsShanghai: c.IsShanghai(timestamp), + IsShanghai: c.IsShanghai(timestamp, currentArbosVersion), isCancun: c.IsCancun(timestamp), isPrague: c.IsPrague(timestamp), } diff --git a/params/config_test.go b/params/config_test.go index 5634569e29..0b3578f5e7 100644 --- a/params/config_test.go +++ b/params/config_test.go @@ -124,15 +124,18 @@ func TestConfigRules(t *testing.T) { ShanghaiTime: newUint64(500), } var stamp uint64 - if r := c.Rules(big.NewInt(0), true, stamp); r.IsShanghai { - t.Errorf("expected %v to not be shanghai", stamp) + var currentArbosVersion uint64 + if r := c.Rules(big.NewInt(0), true, stamp, currentArbosVersion); r.IsShanghai { + t.Errorf("expected %v to not be shanghai", currentArbosVersion) } stamp = 500 - if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai { - t.Errorf("expected %v to be shanghai", stamp) + currentArbosVersion = 11 + if r := c.Rules(big.NewInt(0), true, stamp, currentArbosVersion); !r.IsShanghai { + t.Errorf("expected %v to be shanghai", currentArbosVersion) } stamp = math.MaxInt64 - if r := c.Rules(big.NewInt(0), true, stamp); !r.IsShanghai { - t.Errorf("expected %v to be shanghai", stamp) + currentArbosVersion = math.MaxInt64 + if r := c.Rules(big.NewInt(0), true, stamp, currentArbosVersion); !r.IsShanghai { + t.Errorf("expected %v to be shanghai", currentArbosVersion) } } diff --git a/tests/state_test.go b/tests/state_test.go index 7dd2f678c6..9e6b645e04 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -183,7 +183,7 @@ func runBenchmark(b *testing.B, t *StateTest) { b.Error(err) return } - var rules = config.Rules(new(big.Int), false, 0) + var rules = config.Rules(new(big.Int), false, 0, 0) vmconfig.ExtraEips = eips block := t.genesis(config).ToBlock()