mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
Ensure coinbase state object exists for each tx during block proc
This commit is contained in:
parent
9dc23ce284
commit
d056824683
3 changed files with 13 additions and 5 deletions
|
|
@ -89,7 +89,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
|
|||
}
|
||||
|
||||
// Update the state with pending changes
|
||||
statedb.SyncIntermediate()
|
||||
statedb.SyncIntermediate(header.Coinbase, header.GasLimit)
|
||||
|
||||
usedGas.Add(usedGas, gas)
|
||||
receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ func (b *BlockGen) AddTx(tx *types.Transaction) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
b.statedb.SyncIntermediate()
|
||||
b.statedb.SyncIntermediate(common.Address{}, b.header.GasLimit)
|
||||
b.header.GasUsed.Add(b.header.GasUsed, gas)
|
||||
receipt := types.NewReceipt(b.statedb.Root().Bytes(), b.header.GasUsed)
|
||||
logs := b.statedb.GetLogs(tx.Hash())
|
||||
|
|
@ -151,7 +151,7 @@ func GenerateChain(parent *types.Block, db common.Database, n int, gen func(int,
|
|||
gen(i, b)
|
||||
}
|
||||
AccumulateRewards(statedb, h, b.uncles)
|
||||
statedb.SyncIntermediate()
|
||||
statedb.SyncIntermediate(h.Coinbase, h.GasLimit)
|
||||
h.Root = statedb.Root()
|
||||
return types.NewBlock(h, b.txs, b.uncles, b.receipts)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -349,13 +349,21 @@ func (self *StateDB) Refunds() *big.Int {
|
|||
}
|
||||
|
||||
// SyncIntermediate updates the intermediate state and all mid steps
|
||||
func (self *StateDB) SyncIntermediate() {
|
||||
func (self *StateDB) SyncIntermediate(headerCoinbase common.Address, headerGasLimit *big.Int) {
|
||||
self.refund = new(big.Int)
|
||||
|
||||
for _, stateObject := range self.stateObjects {
|
||||
if stateObject.dirty {
|
||||
if stateObject.remove {
|
||||
self.DeleteStateObject(stateObject)
|
||||
if stateObject.address == headerCoinbase {
|
||||
gasPoolCopy := new(big.Int).Set(stateObject.gasPool)
|
||||
self.DeleteStateObject(stateObject)
|
||||
coinbase := self.CreateAccount(headerCoinbase)
|
||||
coinbase.SetGasLimit(headerGasLimit)
|
||||
coinbase.gasPool = gasPoolCopy
|
||||
} else {
|
||||
self.DeleteStateObject(stateObject)
|
||||
}
|
||||
} else {
|
||||
stateObject.Update()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue