Skip to content

Commit

Permalink
fix(vm): set callcode to use readOnly mode for precompile calls (ethe…
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann committed May 15, 2023
1 parent 359caee commit d7a6593
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
}
}

// It is allowed to call precompiles, even via call -- as opposed to callcode, staticcall and delegatecall it can also modify state
if isPrecompile {
ret, gas, err = evm.RunPrecompiledContract(p, caller, input, gas, value, false)
} else {
Expand Down Expand Up @@ -270,9 +271,9 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
}(gas)
}

// It is allowed to call precompiles, even via delegatecall
// It is allowed to call precompiles, even via callcode, but only for reading
if p, isPrecompile := evm.Precompile(addr); isPrecompile {
ret, gas, err = evm.RunPrecompiledContract(p, caller, input, gas, value, false)
ret, gas, err = evm.RunPrecompiledContract(p, caller, input, gas, value, true)
} else {
addrCopy := addr
// Initialise a new contract and set the code that is to be used by the EVM.
Expand Down

0 comments on commit d7a6593

Please sign in to comment.