-
Notifications
You must be signed in to change notification settings - Fork 3
Fork choice #18
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
Fork choice #18
Conversation
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
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.
Pull Request Overview
Implements fork choice logic and adds comprehensive unit tests for vote targeting, head selection, attestation validation/processing, and time advancement per the linked spec.
- Add ForkChoiceStore core logic (safe target, head updates, attestation processing, time ticking) and helper API.
- Introduce supporting types/constants (ValidatorIndex, Interval, ceilDiv, Checkpoint::from) and wire into build.
- Add unit tests covering fork-choice behaviors and time advancement scenarios.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| vcpkg-overlay/qtils/portfile.cmake | Bump qtils port to v0.1.5 to use updated test/outcome utilities. |
| src/blockchain/fork_choice.hpp | New public API and data structures for fork choice. |
| src/blockchain/fork_choice.cpp | Implementation of fork choice logic (safe target, head update, attestation handling, time ticking, and head selection). |
| src/utils/ceil_div.hpp | New ceilDiv utility. |
| src/types/checkpoint.hpp | Default-initialize slot; add Checkpoint::from factory. |
| src/types/block.hpp | Allow setHash() on const Blocks by making hash cache mutable. |
| src/types/constants.hpp | Add second-based slot/interval constants. |
| src/types/slot.hpp | Add Interval alias. |
| src/types/validator_index.hpp | Add ValidatorIndex alias. |
| src/types/vote.hpp | Default-initialize validator_id and slot. |
| src/blockchain/CMakeLists.txt | Link new fork_choice.cpp into blockchain lib. |
| tests/unit/blockchain/fork_choice_test.cpp | New unit tests for fork choice behaviors. |
| tests/unit/blockchain/CMakeLists.txt | Add fork_choice_test target. |
| DEPRECATED.md | Note naming convention differences from spec (comment-only). |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
https://github.com/leanEthereum/leanSpec/blob/main/docs/client/forkchoice.md
https://github.com/leanEthereum/leanSpec/tree/main/tests/lean_spec/subspecs/forkchoice