Skip to content

Commit

Permalink
doc: warning about allowing recursive calling
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR4N committed Sep 13, 2024
1 parent ae29ca8 commit 090601d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions core/vm/contracts.libevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type evmCallArgs struct {
value *uint256.Int
// args:end

// evm.interpreter.readOnly is only set in a call to EVMInterpreter.Run().
// If a precompile is called directly with StaticCall() then it won't have
// been set yet. StaticCall() MUST set this to true and all others to false;
// i.e. the same boolean passed to EVMInterpreter.Run().
// evm.interpreter.readOnly is only set to true via a call to
// EVMInterpreter.Run() so, if a precompile is called directly with
// StaticCall(), then readOnly might not be set yet. StaticCall() MUST set
// this to true and all other methods MUST set it to false; i.e. the same
// boolean as they each pass to EVMInterpreter.Run().
forceReadOnly bool
}

Expand Down Expand Up @@ -91,6 +92,18 @@ type PrecompileEnvironment interface {
Addresses() *libevm.AddressContext
}

//
// ****** SECURITY ******
//
// If you are updating PrecompileEnvironment to provide the ability to call back
// into another contract, you MUST revisit the evmCallArgs.forceReadOnly flag.
//
// It is possible that forceReadOnly is true but evm.interpreter.readOnly is
// false. This is safe for now, but may not be if recursive calling *from* a
// precompile is enabled.
//
// ****** SECURITY ******

var _ PrecompileEnvironment = (*evmCallArgs)(nil)

func (args *evmCallArgs) Rules() params.Rules { return args.evm.chainRules }
Expand Down

0 comments on commit 090601d

Please sign in to comment.