Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Rewrite of method for fetching client updates (#30)
Browse files Browse the repository at this point in the history
* refactor of prover

* nit

* some fixes

* cargo update

* fix lower bound for valid signature block search

* doc

* nit

* nit

* minor fix
  • Loading branch information
Wizdave97 authored Sep 12, 2023
1 parent 13f2034 commit 106f53e
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: |
git clone https://github.com/polytope-labs/eth-pos-devnet.git
cd eth-pos-devnet
docker compose up &
docker compose up -d
../scripts/wait_for_tcp_port_opening.sh localhost 3500
../scripts/wait_for_tcp_port_opening.sh localhost 8545
Expand Down
64 changes: 62 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub const BLS_SIGNATURE_BYTES_LEN: usize = 96;

pub const SYNC_COMMITTEE_SIZE: usize = 512;
pub const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: Epoch = 256;
pub const MAX_WITHDRAWALS_PER_PAYLOAD: usize = 16;
pub const MAX_BLS_TO_EXECUTION_CHANGES: usize = 16;
pub const MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: usize = 16384;

pub const MAX_VALIDATORS_PER_COMMITTEE: usize = 2048;
pub const EPOCHS_PER_ETH1_VOTING_PERIOD: Epoch = 64;
Expand Down Expand Up @@ -95,9 +98,6 @@ pub mod testnet {
pub const BELLATRIX_FORK_EPOCH: Epoch = 112260;
pub const CAPELLA_FORK_EPOCH: Epoch = u64::MAX;
pub const CAPELLA_FORK_VERSION: Version = [3, 0, 16, 32];
pub const MAX_WITHDRAWALS_PER_PAYLOAD: usize = 16;
pub const MAX_BLS_TO_EXECUTION_CHANGES: usize = 16;
pub const MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: usize = 16384;
}

#[cfg(feature = "mainnet")]
Expand All @@ -113,9 +113,6 @@ pub mod mainnet {
pub const BELLATRIX_FORK_EPOCH: Epoch = 144896;
pub const CAPELLA_FORK_EPOCH: Epoch = u64::MAX;
pub const CAPELLA_FORK_VERSION: Version = [3, 0, 0, 0];
pub const MAX_WITHDRAWALS_PER_PAYLOAD: usize = 16;
pub const MAX_BLS_TO_EXECUTION_CHANGES: usize = 16;
pub const MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: usize = 16384;
}

#[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))]
Expand All @@ -132,7 +129,4 @@ pub mod devnet {
pub const BELLATRIX_FORK_EPOCH: Epoch = 0;
pub const CAPELLA_FORK_EPOCH: Epoch = 2;
pub const CAPELLA_FORK_VERSION: Version = hex!("52525503");
pub const MAX_WITHDRAWALS_PER_PAYLOAD: usize = 16;
pub const MAX_BLS_TO_EXECUTION_CHANGES: usize = 16;
pub const MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP: usize = 16384;
}
8 changes: 4 additions & 4 deletions primitives/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ pub struct AncestorBlock {
}

/// Holds the latest sync committee as well as an ssz proof for it's existence
/// in a finalized header.
/// in an attested header.
#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)]
pub struct SyncCommitteeUpdate {
// actual sync committee
/// actual sync committee
pub next_sync_committee: SyncCommittee<SYNC_COMMITTEE_SIZE>,
// sync committee, ssz merkle proof.
/// next sync committee, ssz merkle proof.
pub next_sync_committee_branch: Vec<Node>,
}

Expand All @@ -90,7 +90,7 @@ pub struct LightClientState {
pub finalized_header: BeaconBlockHeader,
/// Latest finalized epoch
pub latest_finalized_epoch: u64,
// Sync committees corresponding to the finalized header
/// Sync committees corresponding to the finalized header
pub current_sync_committee: SyncCommittee<SYNC_COMMITTEE_SIZE>,
pub next_sync_committee: SyncCommittee<SYNC_COMMITTEE_SIZE>,
}
Expand Down
10 changes: 8 additions & 2 deletions primitives/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
consensus_types::ForkData,
constants::{
Domain, Root, Version, ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, BELLATRIX_FORK_EPOCH,
Domain, Root, Slot, Version, ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, BELLATRIX_FORK_EPOCH,
BELLATRIX_FORK_VERSION, CAPELLA_FORK_EPOCH, CAPELLA_FORK_VERSION,
EPOCHS_PER_SYNC_COMMITTEE_PERIOD, GENESIS_FORK_VERSION, SLOTS_PER_EPOCH,
},
Expand All @@ -11,7 +11,13 @@ use alloc::{vec, vec::Vec};
use anyhow::anyhow;
use ssz_rs::prelude::*;

/// Return the sync committe period at the given ``epoch``
/// Returns true if the next epoch is the start of a new sync committee period
pub fn should_get_sync_committee_update(slot: Slot) -> bool {
let next_epoch = compute_epoch_at_slot(slot) + 1;
next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0
}

/// Return the sync committee period at the given ``epoch``
pub fn compute_sync_committee_period(epoch: u64) -> u64 {
epoch / EPOCHS_PER_SYNC_COMMITTEE_PERIOD
}
Expand Down
4 changes: 3 additions & 1 deletion prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ primitive-types = { version = "0.12.1", features = ["serde_no_std", "impl-codec"
log = "0.4.20"
hex = "0.4.3"


[dev-dependencies]
env_logger = "0.10.0"
sync-committee-primitives = { path= "../primitives" }
sync-committee-verifier = { path= "../verifier" }
ethers = { version = "2.0.8", features = ["ws"] }
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"]}

parity-scale-codec = "3.2.2"
reqwest-eventsource = "0.4.0"

[features]
default = ["std"]
Expand Down
Loading

0 comments on commit 106f53e

Please sign in to comment.