Skip to content

Commit

Permalink
move stylus hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Feb 21, 2023
1 parent df0296f commit 0f0de0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/vm/evm_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type TxProcessingHook interface {
L1BlockHash(blockCtx BlockContext, l1BlocKNumber uint64) (common.Hash, error)
GasPriceOp(evm *EVM) *big.Int
FillReceiptInfo(receipt *types.Receipt)
ExecuteWASM(contract *Contract, input []byte, interpreter *EVMInterpreter) ([]byte, error)
ExecuteWASM(scope *ScopeContext, input []byte, interpreter *EVMInterpreter) ([]byte, error)
}

type DefaultTxProcessor struct {
Expand Down Expand Up @@ -96,7 +96,7 @@ func (p DefaultTxProcessor) GasPriceOp(evm *EVM) *big.Int {

func (p DefaultTxProcessor) FillReceiptInfo(*types.Receipt) {}

func (p DefaultTxProcessor) ExecuteWASM(contract *Contract, input []byte, interpreter *EVMInterpreter) ([]byte, error) {
func (p DefaultTxProcessor) ExecuteWASM(scope *ScopeContext, input []byte, interpreter *EVMInterpreter) ([]byte, error) {
log.Crit("tried to execute WASM with default processing hook")
return nil, nil
}
12 changes: 7 additions & 5 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
return nil, nil
}

// Arbitrum: handle Stylus programs
if in.evm.chainRules.IsArbitrum && state.IsStylusProgram(contract.Code) {
return in.evm.ProcessingHook.ExecuteWASM(contract, input, in)
}

var (
op OpCode // current opcode
mem = NewMemory() // bound memory
Expand Down Expand Up @@ -181,6 +176,13 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
}
}()
}

// Arbitrum: handle Stylus programs
if in.evm.chainRules.IsArbitrum && state.IsStylusProgram(contract.Code) {
ret, err = in.evm.ProcessingHook.ExecuteWASM(callContext, input, in)
return
}

// The Interpreter main run loop (contextual). This loop runs until either an
// explicit STOP, RETURN or SELFDESTRUCT is executed, an error occurred during
// the execution of one of the operations or until the done flag is set by the
Expand Down
4 changes: 4 additions & 0 deletions core/vm/interpreter_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ func (in *EVMInterpreter) Evm() *EVM {
func (in *EVMInterpreter) ReadOnly() bool {
return in.readOnly
}

func (in *EVMInterpreter) SetReturnData(data []byte) {
in.returnData = data
}

0 comments on commit 0f0de0b

Please sign in to comment.