fixes `rpcMakeCall`: using parent.stateRoot

instead of using header.stateRoot, now it is using parent.stateRoot
This commit is contained in:
jangko 2021-05-04 13:56:10 +07:00
parent c200cebb1d
commit 728f3a24be
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 4 additions and 4 deletions

View File

@ -63,10 +63,10 @@ proc rpcDoCall*(call: RpcCallData, header: BlockHeader, chain: BaseChainDB): Hex
proc rpcMakeCall*(call: RpcCallData, header: BlockHeader, chain: BaseChainDB): (string, GasInt, bool) =
# TODO: handle revert
var
# we use current header stateRoot, unlike block validation
# which use previous block stateRoot
vmState = newBaseVMState(header.stateRoot, header, chain)
comp = rpcSetupComputation(vmState, call, call.gas)
parent = chain.getBlockHeader(header.parentHash)
vmState = newBaseVMState(parent.stateRoot, header, chain)
fork = toFork(chain.config, header.blockNumber)
comp = rpcSetupComputation(vmState, call, call.gas, some(fork))
let gas = comp.gasMeter.gasRemaining
comp.execComputation()