Skip to content

Commit

Permalink
remove electra feature flag in verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Feb 17, 2025
1 parent 88f3c9c commit 857e654
Show file tree
Hide file tree
Showing 9 changed files with 367 additions and 62 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
- pectra-updates

pull_request_target:
types: [opened, synchronize]

Expand Down Expand Up @@ -80,7 +82,7 @@ jobs:

- name: check no-std
run: |
cargo check -p ${{ matrix.crate }} --no-default-features --target=wasm32-unknown-unknown --locked
cargo check -p ${{ matrix.crate }} --no-default-features --target=wasm32-unknown-unknown --locked
check-workspace:
name: Check Workspace
Expand Down Expand Up @@ -349,9 +351,23 @@ jobs:
- name: sync-committee integration tests
run: |
cargo test -p sync-committee-prover -- --nocapture --ignored
docker-compose -f ./eth-pos-devnet/docker-compose.yml down
sudo rm -rf ./eth-pos-devnet
- name: Run Eth POS Devnet Electra
run: |
git clone --branch david/electra https://github.com/polytope-labs/eth-pos-devnet.git
DOCKER_CLIENT_TIMEOUT=300 COMPOSE_HTTP_TIMEOUT=300 docker-compose -f ./eth-pos-devnet/docker-compose.yml up -d
./scripts/wait_for_tcp_port_opening.sh localhost 3500
./scripts/wait_for_tcp_port_opening.sh localhost 8545
- name: sync-committee electra integration tests
run: |
cargo test -p sync-committee-prover --features electra -- --nocapture --ignored
# - name: polygon pos integration tests
# run: |
#
# cargo test -p polygon-pos-prover -- --nocapture --ignored

- name: Binance Smart Chain integration tests
Expand Down
101 changes: 68 additions & 33 deletions modules/consensus/sync-committee/primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,15 @@ pub const MAX_EXTRA_DATA_BYTES: usize = 32;
pub const DEPOSIT_PROOF_LENGTH: usize = 33;

pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee;
#[cfg(not(feature = "electra"))]

pub const FINALIZED_ROOT_INDEX: u64 = 52;
#[cfg(not(feature = "electra"))]
pub const EXECUTION_PAYLOAD_INDEX: u64 = 56;
#[cfg(not(feature = "electra"))]
pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55;

#[cfg(feature = "electra")]
pub const FINALIZED_ROOT_INDEX: u64 = 84;
#[cfg(feature = "electra")]
pub const EXECUTION_PAYLOAD_INDEX: u64 = 88;
#[cfg(feature = "electra")]
pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 87;

#[cfg(not(feature = "electra"))]
pub const FINALIZED_ROOT_INDEX_LOG2: u64 = 5;
#[cfg(not(feature = "electra"))]
pub const EXECUTION_PAYLOAD_INDEX_LOG2: u64 = 5;
#[cfg(not(feature = "electra"))]
pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 5;

#[cfg(feature = "electra")]
pub const FINALIZED_ROOT_INDEX_LOG2: u64 = 6;
#[cfg(feature = "electra")]
pub const EXECUTION_PAYLOAD_INDEX_LOG2: u64 = 6;
#[cfg(feature = "electra")]
pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 6;

pub const ETH1_DATA_VOTES_BOUND_ETH: usize = (EPOCHS_PER_ETH1_VOTING_PERIOD * 32) as usize;
pub const ETH1_DATA_VOTES_BOUND_GNO: usize = (EPOCHS_PER_ETH1_VOTING_PERIOD * 16) as usize;

Expand Down Expand Up @@ -126,9 +107,13 @@ pub trait Config {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64;
const FINALIZED_ROOT_INDEX_ELECTRA: u64;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64;
const ELECTRA_FORK_VERSION: Version;
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch;
const ID: [u8; 4];
}
Expand Down Expand Up @@ -159,10 +144,14 @@ pub mod sepolia {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("90000074");
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch = Epoch::MAX;
const ELECTRA_FORK_EPOCH: Epoch = 222464;
const ID: [u8; 4] = BEACON_CONSENSUS_ID;
}
}
Expand Down Expand Up @@ -190,9 +179,13 @@ pub mod mainnet {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("05000000");
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch = Epoch::MAX;
const ID: [u8; 4] = BEACON_CONSENSUS_ID;
}
Expand Down Expand Up @@ -221,9 +214,13 @@ pub mod gnosis {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("05000064");
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch = Epoch::MAX;
const ID: [u8; 4] = GNOSIS_CONSENSUS_ID;
}
Expand All @@ -248,9 +245,13 @@ pub mod gnosis {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("0500006f");
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch = Epoch::MAX;
const ID: [u8; 4] = GNOSIS_CONSENSUS_ID;
}
Expand All @@ -262,6 +263,8 @@ pub mod devnet {

#[derive(Default)]
pub struct Devnet;
#[derive(Default)]
pub struct ElectraDevnet;

impl Config for Devnet {
const SLOTS_PER_EPOCH: Slot = 32;
Expand All @@ -280,9 +283,41 @@ pub mod devnet {
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
#[cfg(feature = "electra")]
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("52525505");
const ELECTRA_FORK_EPOCH: Epoch = Epoch::MAX;
const ID: [u8; 4] = BEACON_CONSENSUS_ID;
}

impl Config for ElectraDevnet {
const SLOTS_PER_EPOCH: Slot = 32;
const GENESIS_VALIDATORS_ROOT: [u8; 32] =
hex_literal::hex!("83431ec7fcf92cfc44947fc0418e831c25e1d0806590231c439830db7ad54fda");
const BELLATRIX_FORK_VERSION: Version = hex!("52525502");
const ALTAIR_FORK_VERSION: Version = hex!("52525501");
const GENESIS_FORK_VERSION: Version = hex!("52525500");
const ALTAIR_FORK_EPOCH: Epoch = 0;
const BELLATRIX_FORK_EPOCH: Epoch = 0;
const CAPELLA_FORK_EPOCH: Epoch = 0;
const CAPELLA_FORK_VERSION: Version = hex!("52525503");
const DENEB_FORK_EPOCH: Epoch = 0;
const DENEB_FORK_VERSION: Version = hex!("52525504");
const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: Epoch = 4;
const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 34;
const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 38;
const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 41;
const EXECUTION_PAYLOAD_INDEX_ELECTRA: u64 = 88;
const NEXT_SYNC_COMMITTEE_INDEX_ELECTRA: u64 = 87;
const FINALIZED_ROOT_INDEX_ELECTRA: u64 = 84;
const FINALIZED_ROOT_INDEX_LOG2_ELECTRA: u64 = 6;
const EXECUTION_PAYLOAD_INDEX_LOG2_ELECTRA: u64 = 6;
const NEXT_SYNC_COMMITTEE_INDEX_LOG2_ELECTRA: u64 = 6;
const ELECTRA_FORK_VERSION: Version = hex_literal::hex!("52525505");
#[cfg(feature = "electra")]
const ELECTRA_FORK_EPOCH: Epoch = 0;
const ID: [u8; 4] = BEACON_CONSENSUS_ID;
}
Expand Down
1 change: 1 addition & 0 deletions modules/consensus/sync-committee/primitives/src/electra.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::constants::{
BlsPublicKey, BlsSignature, Bytes32, Epoch, ExecutionAddress, Gwei, Slot, ValidatorIndex,
};
use alloc::{vec, vec::Vec};
use ssz_rs::{prelude::*, Deserialize};

#[derive(Default, Debug, SimpleSerialize, codec::Encode, codec::Decode, Clone, PartialEq, Eq)]
Expand Down
17 changes: 0 additions & 17 deletions modules/consensus/sync-committee/primitives/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@ pub fn compute_epoch_at_slot<C: Config>(slot: u64) -> u64 {
slot / C::SLOTS_PER_EPOCH
}

#[cfg(not(feature = "electra"))]
/// Return the fork version at the given ``epoch``.
pub fn compute_fork_version<C: Config>(epoch: u64) -> [u8; 4] {
if epoch >= C::DENEB_FORK_EPOCH {
C::DENEB_FORK_VERSION
} else if epoch >= C::CAPELLA_FORK_EPOCH {
C::CAPELLA_FORK_VERSION
} else if epoch >= C::BELLATRIX_FORK_EPOCH {
C::BELLATRIX_FORK_VERSION
} else if epoch >= C::ALTAIR_FORK_EPOCH {
C::ALTAIR_FORK_VERSION
} else {
C::GENESIS_FORK_VERSION
}
}

#[cfg(feature = "electra")]
/// Return the fork version at the given ``epoch``.
pub fn compute_fork_version<C: Config>(epoch: u64) -> [u8; 4] {
if epoch >= C::ELECTRA_FORK_EPOCH {
Expand Down
Loading

0 comments on commit 857e654

Please sign in to comment.