-
Notifications
You must be signed in to change notification settings - Fork 417
feat(chain)!: make CheckPoint data field optional
#2024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cf98f58 to
eddadd4
Compare
evanlinjin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
|
Some recommended test scenarios:
With the above tests:
|
e805152 to
86968bb
Compare
e1166b6 to
46bd424
Compare
oleonardolima
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cACK c24dd6a
It looking good code-wise, though we probably need further discussion on what's the best approach, as discussed by Evan and VM in discord.
ba55b7e to
a216494
Compare
a216494 to
ae040c2
Compare
ae040c2 to
460bc46
Compare
|
@LagginTimes please review the modifications I made to This implementation builds upon and improves the original PR's approach to optional checkpoint data in several key ways:
|
b301866 to
7ce4d91
Compare
* Base tip must always have data. * Update should be able to introduce data to a placeholder checkpoint in the original chain. * Remove unnecessary logic.
Add comprehensive tests for CheckPoint::push error cases: - Push fails when height is not greater than current - Push fails when prev_blockhash conflicts with self - Push succeeds when prev_blockhash matches - Push creates placeholder for non-contiguous heights Include tests for CheckPoint::insert conflict handling: - Insert with conflicting prev_blockhash - Insert purges conflicting tail - Insert between conflicting checkpoints 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1939dd2 to
1f62476
Compare
|
@LagginTimes I've rebased on master. Would you be okay if I took over this PR? |
Rework CheckPoint::insert to properly handle conflicts: - Split chain into base (below insert height) and tail (at/above) - Rebuild chain by pushing tail items back, handling conflicts - Displace checkpoints to placeholders when prev_blockhash conflicts - Purge orphaned checkpoints that can no longer connect to chain - Fix edge cases where placeholders weren't handled correctly Improve CheckPoint::push: - Remove trailing placeholder checkpoints before pushing - Maintain existing behavior of creating placeholders for gaps Documentation improvements: - Clarify displacement vs purging rules without complex if-else chains - Add concrete examples showing the behavior - Add inline comments explaining the complex rebuild logic Add comprehensive test coverage for displacement scenarios including inserting at new/existing heights with various conflict types.
1f62476 to
bd7a0db
Compare
| let new_tip = match base { | ||
| Some(base) => base | ||
| .extend(extension) | ||
| .expect("extension is strictly greater than base"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expect is now wrong. A block in the extension may have a prev_blockhash that doesn't line up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a lot of additional logic in LocalChain to manage ChangeSets. This is non-ideal as the mutating logic of CheckPoint is now more complex - so we really want to keep the complexity in CheckPoint only.
Instead of having apply_changeset_to_checkpoint, I'm thinking of using methods of CheckPoint directly and comparing the original and updated checkpoint chains to derive the checkpoint.
| update_tip: CheckPoint<D>, | ||
| ) -> Result<(CheckPoint<D>, ChangeSet<D>), CannotConnectError> | ||
| where | ||
| D: ToBlockHash + fmt::Debug + Copy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the + Copy here will be problematic.
Resolves #2021.
Description
This PR makes the
CheckPoint::datafield optional. Gaps inferred fromprev_blockhashare represented as placeholder checkpoints wheredataisNone. Subsequentinsert()s will providedatafor the placeholders when a matching block arrives.See: #2017 (comment)
Notes to the reviewers
WIP
Changelog notice
Checklists
All Submissions:
New Features:
Bugfixes: