Skip to content

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant