fix(core,core/rawdb): clean up XDPoS snapshot on SetHead - #2481
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
22f4215 to
ef41e81
Compare
There was a problem hiding this comment.
Pull request overview
This PR tightens SetHead’s XDPoS snapshot cleanup so it only targets block heights that are eligible to have persisted XDPoS snapshots (based on Epoch/Gap), and adds a rawdb helper plus a SetHead-focused unit test to reflect the new behavior.
Changes:
- Add
rawdb.DeleteXdposSnapshotwith “V2 first, then V1 fallback” semantics. - Gate snapshot deletion during
BlockChainrewind to heights satisfying(num + gap) % epoch == 0. - Add a
SetHeadtest that exercises V2 deletion and V1 fallback deletion paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| core/rawdb/accessors_xdc.go | Adds XDPoS snapshot deletion helpers and an exported delete entrypoint. |
| core/blockchain.go | Gates XDPoS snapshot cleanup during SetHead rewinds using epoch/gap rules. |
| core/blockchain_sethead_test.go | Adds a SetHead unit test covering XDPoS snapshot cleanup behavior. |
904bb87 to
e81d2ff
Compare
e846654 to
a2b200c
Compare
Restrict SetHead snapshot cleanup to block numbers that can persist XDPoS snapshots based on epoch/gap rules. Keep unified deletion semantics (V2 first, then V1 fallback) and align SetHead tests with XDPoS gating.
a2b200c to
37e3f08
Compare
Proposed changes
Restrict SetHead snapshot cleanup to block numbers that can persist XDPoS snapshots based on epoch/gap rules.
Keep unified deletion semantics (V2 first, then V1 fallback) and align SetHead tests with XDPoS gating.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that