Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat(eth-lc): electra fork #3878

wants to merge 3 commits into from

Conversation

hussein-aitlahcen
Copy link
Contributor

@hussein-aitlahcen hussein-aitlahcen commented Feb 26, 2025

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

Copy link

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
site ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 5:16pm

@hussein-aitlahcen hussein-aitlahcen force-pushed the ethereum-electra branch 3 times, most recently from 41de505 to 8be7bf4 Compare February 26, 2025 17:13
Comment on lines +401 to +407
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;
Copy link
Contributor

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?

Comment on lines +287 to 297
// 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();
}
Copy link
Contributor

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?

Comment on lines +46 to +81
// 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
}

Copy link
Contributor

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants