-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(eth-lc): electra fork #3878
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
41de505
to
8be7bf4
Compare
8be7bf4
to
249756f
Compare
pub const FINALIZED_ROOT_GINDEX: u64 = 105; | ||
/// `get_generalized_index(BeaconState, "current_sync_committee")` | ||
pub const CURRENT_SYNC_COMMITTEE_INDEX: u64 = 54; | ||
pub const CURRENT_SYNC_COMMITTEE_GINDEX: u64 = 54; | ||
/// `get_generalized_index(BeaconState, "next_sync_committee")` | ||
pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; | ||
pub const NEXT_SYNC_COMMITTEE_GINDEX: u64 = 55; | ||
/// `get_generalized_index(BeaconBlockBody, "execution_payload")` | ||
pub const EXECUTION_PAYLOAD_INDEX: u64 = 25; | ||
pub const EXECUTION_PAYLOAD_GINDEX: u64 = 25; |
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.
rename the old ones to deneb?
// Now new field in electra | ||
if epoch >= fork_parameters.electra.epoch { | ||
return TryInto::<ExecutionPayloadHeaderSsz<C>>::try_into(header.execution.clone()) | ||
.unwrap() | ||
.tree_hash_root(); | ||
} | ||
if epoch >= fork_parameters.deneb.epoch { | ||
return TryInto::<ExecutionPayloadHeaderSsz<C>>::try_into(header.execution.clone()) | ||
.unwrap() | ||
.tree_hash_root(); | ||
} |
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.
these branches are the same?
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#finalized_root_gindex_at_slot | ||
pub fn finalized_root_gindex_at_slot<C: ChainSpec>( | ||
fork_parameters: &ForkParameters, | ||
slot: Slot, | ||
) -> u64 { | ||
let epoch = compute_epoch_at_slot::<C>(slot); | ||
if epoch >= fork_parameters.electra.epoch { | ||
return FINALIZED_ROOT_GINDEX_ELECTRA; | ||
} | ||
FINALIZED_ROOT_GINDEX | ||
} | ||
|
||
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#current_sync_committee_gindex_at_slot | ||
pub fn current_sync_committee_gindex_at_slot<C: ChainSpec>( | ||
fork_parameters: &ForkParameters, | ||
slot: Slot, | ||
) -> u64 { | ||
let epoch = compute_epoch_at_slot::<C>(slot); | ||
if epoch >= fork_parameters.electra.epoch { | ||
return CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA; | ||
} | ||
CURRENT_SYNC_COMMITTEE_GINDEX | ||
} | ||
|
||
// https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#next_sync_committee_gindex_at_slot | ||
pub fn next_sync_committee_gindex_at_slot<C: ChainSpec>( | ||
fork_parameters: &ForkParameters, | ||
slot: Slot, | ||
) -> u64 { | ||
let epoch = compute_epoch_at_slot::<C>(slot); | ||
if epoch >= fork_parameters.electra.epoch { | ||
return NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA; | ||
} | ||
NEXT_SYNC_COMMITTEE_GINDEX | ||
} | ||
|
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.
small nit but make the links doc comments: /// <link>
This PR introduces the new constants and refactor the existing LC to handle electra fork.
See https://github.com/ethereum/consensus-specs/blob/dev/specs/electra/light-client/sync-protocol.md