Skip to content

core: cleanup txlookup entries during chain rewind#33487

Closed
the-shadow-coder wants to merge 5 commits intoethereum:masterfrom
the-shadow-coder:fix/txlookup
Closed

core: cleanup txlookup entries during chain rewind#33487
the-shadow-coder wants to merge 5 commits intoethereum:masterfrom
the-shadow-coder:fix/txlookup

Conversation

@the-shadow-coder
Copy link
Contributor

This PR addresses a todo on core/blockchain.go

		// Ignore the error here since light client won't hit this path
		frozen, _ := bc.db.Ancients()
		if num+1 <= frozen {
			// The chain segment, such as the block header, canonical hash,
			// body, and receipt, will be removed from the ancient store
			// in one go.
			//
			// The hash-to-number mapping in the key-value store will be
			// removed by the hc.SetHead function.
		} else {
			// Remove the associated body and receipts from the key-value store.
			// The header, hash-to-number mapping, and canonical hash will be
			// removed by the hc.SetHead function.
			rawdb.DeleteBody(db, hash, num)
			rawdb.DeleteReceipts(db, hash, num)
		}
		// Todo(rjl493456442) txlookup, log index, etc
	}
	

It addresses the todo by cleaning up txlookup entries during a chain rewind. When delFn deletes a block body, it now iterates through the transactions and removes their corresponding lookup indices, preventing stale "zombie" entries from persisting in the database. A regression test TestSetHeadTxLookupCleanup has been added to verify this behavior.

@the-shadow-coder the-shadow-coder marked this pull request as draft January 29, 2026 10:53
@the-shadow-coder the-shadow-coder marked this pull request as ready for review January 29, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant