diff --git a/core/types/arbitrum_signer.go b/core/types/arbitrum_signer.go index 5f2656b14b36..bd3381d48100 100644 --- a/core/types/arbitrum_signer.go +++ b/core/types/arbitrum_signer.go @@ -6,6 +6,9 @@ import ( "github.com/ethereum/go-ethereum/common" ) +const ArbosVersion_FixRedeemGas = uint64(11) +const ArbosVersion_Stylus = uint64(30) + var ArbosAddress = common.HexToAddress("0xa4b05") var ArbosStateAddress = common.HexToAddress("0xA4B05FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") var ArbSysAddress = common.HexToAddress("0x64") diff --git a/core/vm/evm.go b/core/vm/evm.go index 30eacd4ca897..dd54ce3afbef 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -521,9 +521,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, // Reject code starting with 0xEF if EIP-3541 is enabled. if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsLondon { err = ErrInvalidCode - // Arbitrum: We do not reject Stylus programs and instead store them in the DB - // alongside normal EVM bytecode. - if evm.chainRules.IsArbitrum && state.IsStylusProgram(ret) { + + // Arbitrum: retain Stylus programs and instead store them in the DB alongside normal EVM bytecode. + if evm.IsStylus() && state.IsStylusProgram(ret) { err = nil } } diff --git a/core/vm/evm_arbitrum.go b/core/vm/evm_arbitrum.go index a77f2a7aa549..20dd10744696 100644 --- a/core/vm/evm_arbitrum.go +++ b/core/vm/evm_arbitrum.go @@ -37,6 +37,10 @@ func (evm *EVM) DecrementDepth() { evm.depth -= 1 } +func (evm *EVM) IsStylus() bool { + return evm.chainRules.IsArbitrum && evm.Context.ArbOSVersion >= types.ArbosVersion_Stylus +} + type TxProcessingHook interface { StartTxHook() (bool, uint64, error, []byte) // return 4-tuple rather than *struct to avoid an import cycle GasChargingHook(gasRemaining *uint64) (common.Address, error) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 3c4ecf5594d8..8447473a7f66 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -170,7 +170,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( } // Arbitrum: handle Stylus programs - if in.evm.chainRules.IsArbitrum && state.IsStylusProgram(contract.Code) { + if in.evm.IsStylus() && state.IsStylusProgram(contract.Code) { ret, err = in.evm.ProcessingHook.ExecuteWASM(callContext, input, in) return }