mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
eth/txtracker: seed lastFinalNum at startup to prevent genesis backfill
lastFinalNum started at 0, so the first checkFinalization after startup iterated from block 1 to the current finalized head (~20M blocks on mainnet) under the mutex, stalling the tracker and potentially awarding bogus credit for ancient txs whose hashes happened to match recently-received ones. Seed lastFinalNum from chain.CurrentFinalBlock() in Start() so only blocks finalized after startup are processed.
This commit is contained in:
parent
8bfddee2ea
commit
e99330b2bc
1 changed files with 4 additions and 0 deletions
|
|
@ -74,6 +74,10 @@ func New() *Tracker {
|
|||
// Start begins listening for chain head events.
|
||||
func (t *Tracker) Start(chain Chain) {
|
||||
t.chain = chain
|
||||
// Seed lastFinalNum so checkFinalization doesn't backfill from genesis.
|
||||
if fh := chain.CurrentFinalBlock(); fh != nil {
|
||||
t.lastFinalNum = fh.Number.Uint64()
|
||||
}
|
||||
t.headCh = make(chan core.ChainHeadEvent, 128)
|
||||
t.sub = chain.SubscribeChainHeadEvent(t.headCh)
|
||||
t.wg.Add(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue