Skip to content

Commit

Permalink
Ensure pending block is finalized and assembled
Browse files Browse the repository at this point in the history
Before introducing this change gas estimations against the pending block
would sometimes be lower than they should be.
  • Loading branch information
piersy committed Feb 25, 2022
1 parent cd60990 commit 6ad68f2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ func (w *worker) constructPendingStateBlock(ctx context.Context, txsCh chan core
}
w.updatePendingBlock(b)

_, err = b.finalizeAndAssemble(w)
if err != nil {
log.Error("Failed to finalize and assemble the block", "err", err)
return
}
w.updatePendingBlock(b)

w.mu.RLock()
txFeeRecipient := w.txFeeRecipient
if !w.chainConfig.IsDonut(b.header.Number) && w.txFeeRecipient != w.validator {
Expand Down Expand Up @@ -347,6 +354,11 @@ func (w *worker) constructPendingStateBlock(ctx context.Context, txsCh chan core
// Only update the snapshot if any new transactons were added
// to the pending block
if tcount != b.tcount {
_, err = b.finalizeAndAssemble(w)
if err != nil {
log.Error("Failed to finalize and assemble the block", "err", err)
return
}
w.updatePendingBlock(b)
}
}
Expand Down

0 comments on commit 6ad68f2

Please sign in to comment.