feat: add cached PTC window to the state#9211
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the implementation to align with Ethereum consensus-specs v1.7.0-alpha.4, primarily focusing on the introduction and management of the Payload Timeliness Committee (PTC) window for the Gloas fork. Key changes include the addition of the ptcWindow field to the BeaconState, the implementation of logic to initialize and rotate this window during epoch transitions, and updates to the EpochCache to support PTC lookups for the previous, current, and next epochs. Feedback focuses on potential performance optimizations regarding the use of toValue() on large SSZ views during PTC window processing.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27a2075434
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Performance Report✔️ no performance regression detected Full benchmark results
|
| // processPtcWindow() already rotated the canonical state field earlier in process_epoch. | ||
| // Copy the previous/current epoch slices into epochCtx so validation stays on cached arrays. | ||
| ({ | ||
| previousPayloadTimelinessCommittees: this.previousPayloadTimelinessCommittees, |
There was a problem hiding this comment.
shifting previous + current payloadTimelinessComimittees should be cheaper, especially in terms of memory allocation
only extract the nextPayloadTimelinessCommittees
| // PTC for current epoch, computed eagerly at epoch transition | ||
| payloadTimelinessCommittees: Uint32Array[]; | ||
| // PTC for next epoch, precomputed from the ptc window for future duty serving | ||
| nextPayloadTimelinessCommittees: Uint32Array[]; |
There was a problem hiding this comment.
I think this is a fragile approach because spec says we now store 2 + MIN_SEED_LOOKAHEAD epochs of ptc committees in the state. If MIN_SEED_LOOKAHEAD increases in the future, we would need to add more fields here.
But for now, it is fine.
There was a problem hiding this comment.
yeah was thinking about that too, it seems fine as is for now, at least in the state-transition we should handle it like we do in processProposerLookahead but I don't wanna deal with that now
| // `meta` is typed as `any` so SSZ `Type<T>.deserialize(data, opts?)` satisfies the shape. | ||
| // Route-specific deserializers (e.g. `WithVersion`) cast to their expected meta internally. | ||
| // biome-ignore lint/suspicious/noExplicitAny: contravariant workaround for ssz Type.deserialize(opts?) | ||
| deserialize: (data: Uint8Array, meta: any) => T; // client |
There was a problem hiding this comment.
this is due to ChainSafe/ssz#503 which we aren't even making use of but this is not a big deal, we can revisit this later cc @wemeetagain
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #9211 +/- ##
============================================
- Coverage 52.53% 52.53% -0.01%
============================================
Files 848 848
Lines 61405 61402 -3
Branches 4525 4525
============================================
- Hits 32259 32256 -3
Misses 29081 29081
Partials 65 65 🚀 New features to boost your workflow:
|
This implements minimal changes to pass
alpha.4spec testsptc_windowto state based on #4979v1.7.0-alpha.4NOTE: this does not implement any other changes from alpha.4 besides ethereum/consensus-specs#4979