core: transition db now also returns the required gas amount

Exposes some core methods to transition and compute new state
information and adds an additional return value to the transition db
method to fetch required gas for that particular message (excluding gas
refunds from any SSTORE[X] = 0 and SUICIDE.

Fixes #2395
This commit is contained in:
Jeffrey Wilcke
2016-04-01 00:30:21 +02:00
parent 9055c16efa
commit 1f3596c25a
2 changed files with 27 additions and 10 deletions

View File

@ -674,11 +674,11 @@ func (s *PublicBlockChainAPI) doCall(args CallArgs, blockNr rpc.BlockNumber) (st
vmenv := core.NewEnv(stateDb, s.config, s.bc, msg, block.Header(), s.config.VmConfig)
gp := new(core.GasPool).AddGas(common.MaxBig)
res, gas, err := core.ApplyMessage(vmenv, msg, gp)
res, requiredGas, _, err := core.NewStateTransition(vmenv, msg, gp).TransitionDb()
if len(res) == 0 { // backwards compatibility
return "0x", gas, err
return "0x", requiredGas, err
}
return common.ToHex(res), gas, err
return common.ToHex(res), requiredGas, err
}
// Call executes the given transaction on the state for the given block number.