mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
refactor: separate error clearing from inner functionality
`EVMInterpreter.Run` was clearing the `errStopToken`, which is useful in some projects that customize the EVM.
This commit is contained in:
parent
5fb8ebc9ec
commit
bd220bc950
1 changed files with 13 additions and 7 deletions
|
|
@ -98,13 +98,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
|
|||
return &EVMInterpreter{evm: evm, table: table}
|
||||
}
|
||||
|
||||
// Run loops and evaluates the contract's code with the given input data and returns
|
||||
// the return byte-slice and an error if one occurred.
|
||||
//
|
||||
// It's important to note that any errors returned by the interpreter should be
|
||||
// considered a revert-and-consume-all-gas operation except for
|
||||
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
||||
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
||||
// Similar to `Run`, except that it doesn't clear stop token error
|
||||
func (in *EVMInterpreter) RunAndKeepStopToken(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
||||
// Increment the call depth which is restricted to 1024
|
||||
in.evm.depth++
|
||||
defer func() { in.evm.depth-- }()
|
||||
|
|
@ -233,6 +228,17 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||
}
|
||||
pc++
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Run loops and evaluates the contract's code with the given input data and returns
|
||||
// the return byte-slice and an error if one occurred.
|
||||
//
|
||||
// It's important to note that any errors returned by the interpreter should be
|
||||
// considered a revert-and-consume-all-gas operation except for
|
||||
// ErrExecutionReverted which means revert-and-keep-gas-left.
|
||||
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
|
||||
res, err := in.RunAndKeepStopToken(contract, input, readOnly)
|
||||
|
||||
if err == errStopToken {
|
||||
err = nil // clear stop token error
|
||||
|
|
|
|||
Loading…
Reference in a new issue