core: ensure coinbase account is created during block processing

This commit is contained in:
Gustav Simonsson 2015-09-01 17:17:23 +02:00
parent fd512fa12c
commit 78692003f7
2 changed files with 8 additions and 6 deletions

View file

@ -73,7 +73,7 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
coinbase.SetGasLimit(block.GasLimit()) coinbase.SetGasLimit(block.GasLimit())
// Process the transactions on to parent state // Process the transactions on to parent state
receipts, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess) receipts, err = sm.ApplyTransactions(statedb, block, block.Transactions(), transientProcess)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -81,8 +81,10 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
return receipts, nil return receipts, nil
} }
func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error) { func (self *BlockProcessor) ApplyTransaction(statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error) {
cb := statedb.GetStateObject(coinbase.Address()) cb := statedb.GetOrNewStateObject(header.Coinbase)
cb.SetGasLimit(header.GasLimit)
_, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb) _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -118,7 +120,7 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
return self.bc return self.bc
} }
func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) { func (self *BlockProcessor) ApplyTransactions(statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
var ( var (
receipts types.Receipts receipts types.Receipts
totalUsedGas = big.NewInt(0) totalUsedGas = big.NewInt(0)
@ -130,7 +132,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
for i, tx := range txs { for i, tx := range txs {
statedb.StartRecord(tx.Hash(), block.Hash(), i) statedb.StartRecord(tx.Hash(), block.Hash(), i)
receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess) receipt, txGas, err := self.ApplyTransaction(statedb, header, tx, totalUsedGas, transientProcess)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -619,7 +619,7 @@ func (env *Work) commitTransactions(transactions types.Transactions, gasPrice *b
func (env *Work) commitTransaction(tx *types.Transaction, proc *core.BlockProcessor) error { func (env *Work) commitTransaction(tx *types.Transaction, proc *core.BlockProcessor) error {
snap := env.state.Copy() snap := env.state.Copy()
receipt, _, err := proc.ApplyTransaction(env.coinbase, env.state, env.header, tx, env.header.GasUsed, true) receipt, _, err := proc.ApplyTransaction(env.state, env.header, tx, env.header.GasUsed, true)
if err != nil { if err != nil {
env.state.Set(snap) env.state.Set(snap)
return err return err