Skip to content

Commit abf6d0e

Browse files
Merge pull request #40 from OffchainLabs/stylus-arbos-30
Reject wasms until ArbOS 30
2 parents 527c512 + 33ee405 commit abf6d0e

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

core/types/arbitrum_signer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"github.com/ethereum/go-ethereum/common"
77
)
88

9+
const ArbosVersion_FixRedeemGas = uint64(11)
10+
const ArbosVersion_Stylus = uint64(30)
11+
912
var ArbosAddress = common.HexToAddress("0xa4b05")
1013
var ArbosStateAddress = common.HexToAddress("0xA4B05FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
1114
var ArbSysAddress = common.HexToAddress("0x64")

core/vm/evm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
521521
// Reject code starting with 0xEF if EIP-3541 is enabled.
522522
if err == nil && len(ret) >= 1 && ret[0] == 0xEF && evm.chainRules.IsLondon {
523523
err = ErrInvalidCode
524-
// Arbitrum: We do not reject Stylus programs and instead store them in the DB
525-
// alongside normal EVM bytecode.
526-
if evm.chainRules.IsArbitrum && state.IsStylusProgram(ret) {
524+
525+
// Arbitrum: retain Stylus programs and instead store them in the DB alongside normal EVM bytecode.
526+
if evm.IsStylus() && state.IsStylusProgram(ret) {
527527
err = nil
528528
}
529529
}

core/vm/evm_arbitrum.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func (evm *EVM) DecrementDepth() {
3737
evm.depth -= 1
3838
}
3939

40+
func (evm *EVM) IsStylus() bool {
41+
return evm.chainRules.IsArbitrum && evm.Context.ArbOSVersion >= types.ArbosVersion_Stylus
42+
}
43+
4044
type TxProcessingHook interface {
4145
StartTxHook() (bool, uint64, error, []byte) // return 4-tuple rather than *struct to avoid an import cycle
4246
GasChargingHook(gasRemaining *uint64) (common.Address, error)

core/vm/interpreter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
170170
}
171171

172172
// Arbitrum: handle Stylus programs
173-
if in.evm.chainRules.IsArbitrum && state.IsStylusProgram(contract.Code) {
173+
if in.evm.IsStylus() && state.IsStylusProgram(contract.Code) {
174174
ret, err = in.evm.ProcessingHook.ExecuteWASM(callContext, input, in)
175175
return
176176
}

0 commit comments

Comments
 (0)