staticcall does not modify states so no need to push to stack

This commit is contained in:
Trung Nguyen 2018-12-11 16:54:18 -05:00
parent 089841e036
commit 67c9b4332f
No known key found for this signature in database
GPG Key ID: 4636434ED9505EB7
1 changed files with 4 additions and 6 deletions

View File

@ -335,9 +335,6 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
return nil, gas, nil
}
evm.Push(getDualState(evm, addr))
defer func() { evm.Pop() }()
// Fail if we're trying to execute above the call depth limit
if evm.depth > int(params.CallCreateDepth) {
return nil, gas, ErrDepth
@ -352,20 +349,21 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
var (
to = AccountRef(addr)
snapshot = evm.StateDB.Snapshot()
stateDb = getDualState(evm, addr)
snapshot = stateDb.Snapshot()
)
// Initialise a new contract and set the code that is to be used by the
// EVM. The contract is a scoped environment for this execution context
// only.
contract := NewContract(caller, to, new(big.Int), gas)
contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr))
contract.SetCallCode(&addr, stateDb.GetCodeHash(addr), stateDb.GetCode(addr))
// When an error was returned by the EVM or when setting the creation code
// above we revert to the snapshot and consume any gas remaining. Additionally
// when we're in Homestead this also counts for code storage gas errors.
ret, err = run(evm, contract, input)
if err != nil {
evm.StateDB.RevertToSnapshot(snapshot)
stateDb.RevertToSnapshot(snapshot)
if err != errExecutionReverted {
contract.UseGas(contract.Gas)
}