From 3dc7f7cc65676e884abf05762713b4ef058cc233 Mon Sep 17 00:00:00 2001 From: dharjeezy Date: Tue, 27 Dec 2022 00:30:08 +0100 Subject: [PATCH 001/100] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..eb9389959 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# ethereum-beacon-light-client +Implementation of the Ethereum beacon chain light client in Rust From c79de47c3bd46abf05d37701daf6cc432d09568b Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 27 Dec 2022 00:34:16 +0100 Subject: [PATCH 002/100] Initialized repo Spec out primitives Implement BeaconBlockBody --- src/primitives/beacon.rs | 119 +++++++++++++++++++++++++++++++++ src/primitives/consts.rs | 56 ++++++++++++++++ src/primitives/light_client.rs | 1 + src/primitives/mod.rs | 4 ++ src/primitives/sync.rs | 1 + src/util.rs | 1 + 6 files changed, 182 insertions(+) create mode 100644 src/primitives/beacon.rs create mode 100644 src/primitives/consts.rs create mode 100644 src/primitives/light_client.rs create mode 100644 src/primitives/mod.rs create mode 100644 src/primitives/sync.rs create mode 100644 src/util.rs diff --git a/src/primitives/beacon.rs b/src/primitives/beacon.rs new file mode 100644 index 000000000..6af3b624a --- /dev/null +++ b/src/primitives/beacon.rs @@ -0,0 +1,119 @@ +use crate::primitives::consts::{ + DEPOSIT_CONTRACT_TREE_DEPTH, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SYNC_COMMITTEE_SIZE, +}; +use sp_core::H256; + +struct ValidatorIndex(u64); +struct Slot(u64); +struct BLSSignature([u8; 24]); +struct BLSPubkey([u8; 12]); +struct Root([u8; 32]); +struct CommitteeIndex(u64); +struct Epoch(u64); +struct Gwei(u64); + +struct Eth1Data { + deposit_root: H256, + deposit_count: u64, + block_hash: H256, +} + +struct ProposerSlashing { + signed_header_1: SignedBeaconBlockHeader, + signed_header_2: SignedBeaconBlockHeader, +} + +struct SignedBeaconBlockHeader { + message: BeaconBlockHeader, + signature: BLSSignature, +} + +struct AttesterSlashing { + attestation_1: IndexedAttestation, + attestation_2: IndexedAttestation, +} + +struct IndexedAttestation { + attesting_indices: Vec<[ValidatorIndex; MAX_VALIDATORS_PER_COMMITTEE as usize]>, + data: AttestationData, + signature: BLSSignature, +} + +struct AttestationData { + slot: Slot, + index: CommitteeIndex, + //LMD GHOST vote, + beacon_block_root: H256, + //FFG vote, + source: Checkpoint, + target: Checkpoint, +} + +struct Checkpoint { + epoch: Epoch, + root: H256, +} + +struct Attestation { + aggregation_bits: Vec<[u64; MAX_VALIDATORS_PER_COMMITTEE as usize]>, + data: AttestationData, + signature: BLSSignature, +} + +pub struct SignedVoluntaryExit { + message: VoluntaryExit, + signature: BLSSignature, +} + +struct VoluntaryExit { + epoch: Epoch, + validator_index: ValidatorIndex, +} + +struct SyncAggregate { + sync_committee_bits: Vec<[u64; SYNC_COMMITTEE_SIZE as usize]>, + sync_committee_signature: BLSSignature, +} + +struct Deposit { + proof: Vec<([u8; 4], [u64; (DEPOSIT_CONTRACT_TREE_DEPTH + 1) as usize])>, + data: DepositData, +} + +struct DepositData { + pubkey: BLSPubkey, + withdrawal_credentials: [u8; 32], + amount: Gwei, + signature: BLSSignature, +} + +/// The beacon block header +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader) +pub struct BeaconBlockHeader { + /// current slot for this block + slot: Slot, + /// validator index + proposer_index: ValidatorIndex, + /// ssz root of parent block + parent_root: H256, + /// ssz root of associated [`BeaconState`] + state_root: H256, + /// ssz root of associated [`BeaconBlockBody`] + body_root: H256, +} + +/// The beacon block body +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#beaconblockbody) +struct BeaconBlockBody { + randao_reveal: BLSSignature, + eth1_data: Eth1Data, // Eth1 data vote + graffiti: H256, // Arbitrary data + // Operations + proposer_slashings: [ProposerSlashing; MAX_PROPOSER_SLASHINGS as usize], + attester_slashings: [AttesterSlashing; MAX_ATTESTER_SLASHINGS as usize], + attestations: [Attestation; MAX_ATTESTATIONS as usize], + deposits: [Deposit; MAX_DEPOSITS as usize], + voluntary_exits: [SignedVoluntaryExit; MAX_VOLUNTARY_EXITS as usize], + sync_aggregate: SyncAggregate, +} diff --git a/src/primitives/consts.rs b/src/primitives/consts.rs new file mode 100644 index 000000000..28e743592 --- /dev/null +++ b/src/primitives/consts.rs @@ -0,0 +1,56 @@ +use sp_core::H256; + +/// The block root and state root for every slot are stored in the state for `SLOTS_PER_HISTORICAL_ROOT` slots. +/// When that list is full, both lists are Merkleized into a single Merkle root, +/// which is added to the ever-growing state.historical_roots list. +/// [source](https://eth2book.info/bellatrix/part3/config/preset/#slots_per_historical_root) +const SLOTS_PER_HISTORICAL_ROOT: u64 = 2 ^ 13; // 8,192 + +/// Every `SLOTS_PER_HISTORICAL_ROOT` slots, the list of block roots and the list of state roots in the beacon state +/// are Merkleized and added to state.historical_roots list. Although state.historical_roots is in principle unbounded, +/// all SSZ lists must have maximum sizes specified. +/// +/// The size `HISTORICAL_ROOTS_LIMIT` will be fine for the next few millennia, after which it will be somebody else's problem. +/// The list grows at less than 10 KB per year. Storing past roots like this allows Merkle proofs to be constructed +/// about anything in the beacon chain's history if required. +/// [source](https://eth2book.info/bellatrix/part3/config/preset/#historical_roots_limit) +const HISTORICAL_ROOTS_LIMIT: u64 = 2 ^ 24; // 16,777,216 + +/// Generalized merkle tree index for the latest finalized header +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#constants) +const FINALIZED_ROOT_INDEX: u64 = 105; + +/// Generalized merkle tree index for the next sync committee +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#constants) +const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#domain-types) +pub const DOMAIN_SYNC_COMMITTEE: [u8; 4] = [7, 0, 0, 0]; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#sync-committee) +const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: u64 = 2 ^ 8; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters) +const SLOTS_PER_EPOCH: u64 = 2 ^ 5; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/fork.md#configuration) +const ALTAIR_FORK_EPOCH: u64 = 74240; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/fork.md#configuration) +const ALTAIR_FORK_VERSION: [u8; 4] = [1, 0, 0, 0]; + +/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#genesis-settings) +const GENESIS_FORK_VERSION: [u8; 4] = [0, 0, 0, 0]; + +const GENESIS_VALIDATORS_ROOT: H256 = H256([0u8; 32]); + +pub const MAX_PROPOSER_SLASHINGS: u64 = 2 ^ 4; +pub const MAX_ATTESTER_SLASHINGS: u64 = 2 ^ 4; +pub const MAX_ATTESTATIONS: u64 = 2 ^ 4; +pub const MAX_DEPOSITS: u64 = 2 ^ 4; +pub const MAX_VOLUNTARY_EXITS: u64 = 2 ^ 4; +pub const MAX_VALIDATORS_PER_COMMITTEE: u64 = 2 ^ 11; + +pub const SYNC_COMMITTEE_SIZE: u64 = 2 ^ 9; + +pub const DEPOSIT_CONTRACT_TREE_DEPTH: u64 = 2 ^ 5; diff --git a/src/primitives/light_client.rs b/src/primitives/light_client.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/primitives/light_client.rs @@ -0,0 +1 @@ + diff --git a/src/primitives/mod.rs b/src/primitives/mod.rs new file mode 100644 index 000000000..0cbab59aa --- /dev/null +++ b/src/primitives/mod.rs @@ -0,0 +1,4 @@ +mod beacon; +pub mod consts; +mod light_client; +mod sync; diff --git a/src/primitives/sync.rs b/src/primitives/sync.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/primitives/sync.rs @@ -0,0 +1 @@ + diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 000000000..d905d9da8 --- /dev/null +++ b/src/util.rs @@ -0,0 +1 @@ +e From d3d7e82ca35312c9885362ac260ca1dc5e95f69a Mon Sep 17 00:00:00 2001 From: David Salami Date: Sun, 8 Jan 2023 05:45:12 +0100 Subject: [PATCH 003/100] init folder structure --- .gitignore | 35 ++++++++++++++++++++++++++++++ Cargo.toml | 7 ++++++ ics15-ethereum/Cargo.toml | 9 ++++++++ ics15-ethereum/src/lib.rs | 14 ++++++++++++ light-client-primitives/Cargo.toml | 9 ++++++++ light-client-primitives/src/lib.rs | 14 ++++++++++++ light-client-verifier/Cargo.toml | 9 ++++++++ light-client-verifier/src/lib.rs | 14 ++++++++++++ 8 files changed, 111 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 ics15-ethereum/Cargo.toml create mode 100644 ics15-ethereum/src/lib.rs create mode 100644 light-client-primitives/Cargo.toml create mode 100644 light-client-primitives/src/lib.rs create mode 100644 light-client-verifier/Cargo.toml create mode 100644 light-client-verifier/src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..34a7e4e83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ + +# Generated by Cargo +# will have compiled files and executables +**/target/ +# These are backup files generated by rustfmt +**/*.rs.bk + +.DS_Store + +# The cache for docker container dependency +.cargo + +# The cache for chain data in container +.local + +# direnv cache +.direnv + +node_modules + +# don't add vim swap files +.*.swp + +.idea +.fleet + +# ignore user vscode sttings +.vscode/* +# but include tasks +!.vscode/tasks.json + +.rust-analyzer +target +.env + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..ff86a5654 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[workspace] +resolver = "2" +members = [ + "light-client-verifier", + "light-client-primitives", + "ics15-ethereum" +] \ No newline at end of file diff --git a/ics15-ethereum/Cargo.toml b/ics15-ethereum/Cargo.toml new file mode 100644 index 000000000..bc7bf5b27 --- /dev/null +++ b/ics15-ethereum/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ics15-ethereum" +version = "0.1.0" +edition = "2021" +authors = ["Polytope Labs"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/ics15-ethereum/src/lib.rs b/ics15-ethereum/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/ics15-ethereum/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml new file mode 100644 index 000000000..50c7f3522 --- /dev/null +++ b/light-client-primitives/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "eth-beacon-light-client-primitives" +version = "0.1.0" +edition = "2021" +authors = ["Polytope Labs"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/light-client-primitives/src/lib.rs b/light-client-primitives/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/light-client-primitives/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml new file mode 100644 index 000000000..ddb6e0fd0 --- /dev/null +++ b/light-client-verifier/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "eth-beacon-light-client-verifier" +version = "0.1.0" +edition = "2021" +authors = ["Polytope Labs"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/light-client-verifier/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From c3a7204808808d0f1c00651af27af0242dd2071b Mon Sep 17 00:00:00 2001 From: Damilare Date: Sun, 8 Jan 2023 22:18:42 +0100 Subject: [PATCH 004/100] uncommitted files --- .gitignore | 5 +++++ Cargo.toml | 9 +++++++++ src/lib.rs | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..925d4330b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +/Cargo.lock + +*.iml + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..52f880a0c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "ethereum-beacon-light-client" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..e0e52886a --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,16 @@ +mod primitives; + +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} From 6993c8d8bfb6930ef3d91f85983b7086ab4eacb7 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sun, 8 Jan 2023 22:45:55 +0100 Subject: [PATCH 005/100] started implementing spec types in primitives --- Cargo.toml | 11 --- light-client-primitives/Cargo.toml | 1 + light-client-primitives/src/lib.rs | 18 ++-- light-client-primitives/src/types.rs | 65 +++++++++++++++ src/lib.rs | 2 - src/primitives/beacon.rs | 119 --------------------------- src/primitives/consts.rs | 56 ------------- src/primitives/light_client.rs | 1 - src/primitives/mod.rs | 4 - src/primitives/sync.rs | 1 - src/util.rs | 1 - 11 files changed, 72 insertions(+), 207 deletions(-) create mode 100644 light-client-primitives/src/types.rs delete mode 100644 src/primitives/beacon.rs delete mode 100644 src/primitives/consts.rs delete mode 100644 src/primitives/light_client.rs delete mode 100644 src/primitives/mod.rs delete mode 100644 src/primitives/sync.rs delete mode 100644 src/util.rs diff --git a/Cargo.toml b/Cargo.toml index cb50c3900..1544c2ba5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,3 @@ -[package] -name = "ethereum-beacon-light-client" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } - - [workspace] resolver = "2" members = [ diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index 50c7f3522..af8570aa7 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -7,3 +7,4 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } diff --git a/light-client-primitives/src/lib.rs b/light-client-primitives/src/lib.rs index 7d12d9af8..3ca2408f0 100644 --- a/light-client-primitives/src/lib.rs +++ b/light-client-primitives/src/lib.rs @@ -1,14 +1,8 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} +#![cfg_attr(not(feature = "std"), no_std)] -#[cfg(test)] -mod tests { - use super::*; +#[cfg(not(feature = "std"))] +extern crate alloc; +#[cfg(not(feature = "std"))] +extern crate core; - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +pub mod types; diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs new file mode 100644 index 000000000..f70762279 --- /dev/null +++ b/light-client-primitives/src/types.rs @@ -0,0 +1,65 @@ +use ethereum_consensus::primitives::Hash32; +use alloc::vec::Vec; +use ethereum_consensus::altair::{BeaconBlockHeader, SyncCommittee}; + +/// This holds the relevant data required to prove the state root in the execution payload. +struct ExecutionPayloadProof { + /// The state root in the `ExecutionPayload` which represents the commitment to + /// the ethereum world state in the yellow paper. + state_root: Hash32, + /// the block number of the execution header. + block_number: u64, + /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. + multi_proof: Vec, + /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. + execution_payload_branch: Vec, +} + + +/// Holds the neccessary proofs required to verify a header in the `block_roots` field +/// either in [`BeaconState`] or [`HistoricalBatch`]. +struct BlockRootsProof { + /// Generalized index of the header in the `block_roots` list. + block_header_index: u64, + /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` + block_header_branch: Vec, +} + +/// The block header ancestry proof, this is an enum because the header may either exist in +/// `state.block_roots` or `state.historical_roots`. +enum AncestryProof { + /// This variant defines the proof data for a beacon chain header in the `state.block_roots` + BlockRoots { + /// Proof for the header in `state.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] + block_roots_branch: Vec, + }, + /// This variant defines the neccessary proofs for a beacon chain header in the + /// `state.historical_roots`. + HistoricalRoots { + /// Proof for the header in `historical_batch.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the `historical_batch.block_roots`, needed to reconstruct + /// `hash_tree_root(historical_batch)` + historical_batch_proof: Vec, + /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` + historical_roots_proof: Vec, + /// The generalized index for the historical_batch in `state.historical_roots`. + historical_roots_index: u64, + /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in + /// [`BeaconState`] + historical_roots_branch: Vec, + }, +} + +/// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized +/// header. +struct AncestorBlock { + /// The actual beacon chain header + header: BeaconBlockHeader, + /// Associated execution header proofs + execution_payload: ExecutionPayloadProof, + /// Ancestry proofs of the beacon chain header. + ancestry_proof: AncenstryProof, +} diff --git a/src/lib.rs b/src/lib.rs index e0e52886a..7d12d9af8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -mod primitives; - pub fn add(left: usize, right: usize) -> usize { left + right } diff --git a/src/primitives/beacon.rs b/src/primitives/beacon.rs deleted file mode 100644 index 6af3b624a..000000000 --- a/src/primitives/beacon.rs +++ /dev/null @@ -1,119 +0,0 @@ -use crate::primitives::consts::{ - DEPOSIT_CONTRACT_TREE_DEPTH, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SYNC_COMMITTEE_SIZE, -}; -use sp_core::H256; - -struct ValidatorIndex(u64); -struct Slot(u64); -struct BLSSignature([u8; 24]); -struct BLSPubkey([u8; 12]); -struct Root([u8; 32]); -struct CommitteeIndex(u64); -struct Epoch(u64); -struct Gwei(u64); - -struct Eth1Data { - deposit_root: H256, - deposit_count: u64, - block_hash: H256, -} - -struct ProposerSlashing { - signed_header_1: SignedBeaconBlockHeader, - signed_header_2: SignedBeaconBlockHeader, -} - -struct SignedBeaconBlockHeader { - message: BeaconBlockHeader, - signature: BLSSignature, -} - -struct AttesterSlashing { - attestation_1: IndexedAttestation, - attestation_2: IndexedAttestation, -} - -struct IndexedAttestation { - attesting_indices: Vec<[ValidatorIndex; MAX_VALIDATORS_PER_COMMITTEE as usize]>, - data: AttestationData, - signature: BLSSignature, -} - -struct AttestationData { - slot: Slot, - index: CommitteeIndex, - //LMD GHOST vote, - beacon_block_root: H256, - //FFG vote, - source: Checkpoint, - target: Checkpoint, -} - -struct Checkpoint { - epoch: Epoch, - root: H256, -} - -struct Attestation { - aggregation_bits: Vec<[u64; MAX_VALIDATORS_PER_COMMITTEE as usize]>, - data: AttestationData, - signature: BLSSignature, -} - -pub struct SignedVoluntaryExit { - message: VoluntaryExit, - signature: BLSSignature, -} - -struct VoluntaryExit { - epoch: Epoch, - validator_index: ValidatorIndex, -} - -struct SyncAggregate { - sync_committee_bits: Vec<[u64; SYNC_COMMITTEE_SIZE as usize]>, - sync_committee_signature: BLSSignature, -} - -struct Deposit { - proof: Vec<([u8; 4], [u64; (DEPOSIT_CONTRACT_TREE_DEPTH + 1) as usize])>, - data: DepositData, -} - -struct DepositData { - pubkey: BLSPubkey, - withdrawal_credentials: [u8; 32], - amount: Gwei, - signature: BLSSignature, -} - -/// The beacon block header -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader) -pub struct BeaconBlockHeader { - /// current slot for this block - slot: Slot, - /// validator index - proposer_index: ValidatorIndex, - /// ssz root of parent block - parent_root: H256, - /// ssz root of associated [`BeaconState`] - state_root: H256, - /// ssz root of associated [`BeaconBlockBody`] - body_root: H256, -} - -/// The beacon block body -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#beaconblockbody) -struct BeaconBlockBody { - randao_reveal: BLSSignature, - eth1_data: Eth1Data, // Eth1 data vote - graffiti: H256, // Arbitrary data - // Operations - proposer_slashings: [ProposerSlashing; MAX_PROPOSER_SLASHINGS as usize], - attester_slashings: [AttesterSlashing; MAX_ATTESTER_SLASHINGS as usize], - attestations: [Attestation; MAX_ATTESTATIONS as usize], - deposits: [Deposit; MAX_DEPOSITS as usize], - voluntary_exits: [SignedVoluntaryExit; MAX_VOLUNTARY_EXITS as usize], - sync_aggregate: SyncAggregate, -} diff --git a/src/primitives/consts.rs b/src/primitives/consts.rs deleted file mode 100644 index 28e743592..000000000 --- a/src/primitives/consts.rs +++ /dev/null @@ -1,56 +0,0 @@ -use sp_core::H256; - -/// The block root and state root for every slot are stored in the state for `SLOTS_PER_HISTORICAL_ROOT` slots. -/// When that list is full, both lists are Merkleized into a single Merkle root, -/// which is added to the ever-growing state.historical_roots list. -/// [source](https://eth2book.info/bellatrix/part3/config/preset/#slots_per_historical_root) -const SLOTS_PER_HISTORICAL_ROOT: u64 = 2 ^ 13; // 8,192 - -/// Every `SLOTS_PER_HISTORICAL_ROOT` slots, the list of block roots and the list of state roots in the beacon state -/// are Merkleized and added to state.historical_roots list. Although state.historical_roots is in principle unbounded, -/// all SSZ lists must have maximum sizes specified. -/// -/// The size `HISTORICAL_ROOTS_LIMIT` will be fine for the next few millennia, after which it will be somebody else's problem. -/// The list grows at less than 10 KB per year. Storing past roots like this allows Merkle proofs to be constructed -/// about anything in the beacon chain's history if required. -/// [source](https://eth2book.info/bellatrix/part3/config/preset/#historical_roots_limit) -const HISTORICAL_ROOTS_LIMIT: u64 = 2 ^ 24; // 16,777,216 - -/// Generalized merkle tree index for the latest finalized header -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#constants) -const FINALIZED_ROOT_INDEX: u64 = 105; - -/// Generalized merkle tree index for the next sync committee -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#constants) -const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#domain-types) -pub const DOMAIN_SYNC_COMMITTEE: [u8; 4] = [7, 0, 0, 0]; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/beacon-chain.md#sync-committee) -const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: u64 = 2 ^ 8; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#time-parameters) -const SLOTS_PER_EPOCH: u64 = 2 ^ 5; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/fork.md#configuration) -const ALTAIR_FORK_EPOCH: u64 = 74240; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/fork.md#configuration) -const ALTAIR_FORK_VERSION: [u8; 4] = [1, 0, 0, 0]; - -/// [source](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#genesis-settings) -const GENESIS_FORK_VERSION: [u8; 4] = [0, 0, 0, 0]; - -const GENESIS_VALIDATORS_ROOT: H256 = H256([0u8; 32]); - -pub const MAX_PROPOSER_SLASHINGS: u64 = 2 ^ 4; -pub const MAX_ATTESTER_SLASHINGS: u64 = 2 ^ 4; -pub const MAX_ATTESTATIONS: u64 = 2 ^ 4; -pub const MAX_DEPOSITS: u64 = 2 ^ 4; -pub const MAX_VOLUNTARY_EXITS: u64 = 2 ^ 4; -pub const MAX_VALIDATORS_PER_COMMITTEE: u64 = 2 ^ 11; - -pub const SYNC_COMMITTEE_SIZE: u64 = 2 ^ 9; - -pub const DEPOSIT_CONTRACT_TREE_DEPTH: u64 = 2 ^ 5; diff --git a/src/primitives/light_client.rs b/src/primitives/light_client.rs deleted file mode 100644 index 8b1378917..000000000 --- a/src/primitives/light_client.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/primitives/mod.rs b/src/primitives/mod.rs deleted file mode 100644 index 0cbab59aa..000000000 --- a/src/primitives/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod beacon; -pub mod consts; -mod light_client; -mod sync; diff --git a/src/primitives/sync.rs b/src/primitives/sync.rs deleted file mode 100644 index 8b1378917..000000000 --- a/src/primitives/sync.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/util.rs b/src/util.rs deleted file mode 100644 index d905d9da8..000000000 --- a/src/util.rs +++ /dev/null @@ -1 +0,0 @@ -e From 60916aefa72aa2ea388b3456d7c5a9ab9d22cf11 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sun, 8 Jan 2023 22:48:13 +0100 Subject: [PATCH 006/100] typo fix --- light-client-primitives/src/types.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index f70762279..bd82c734f 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -61,5 +61,5 @@ struct AncestorBlock { /// Associated execution header proofs execution_payload: ExecutionPayloadProof, /// Ancestry proofs of the beacon chain header. - ancestry_proof: AncenstryProof, + ancestry_proof: AncestryProof, } From b2f241e4d3c49f6de1ba8b5deab3d5807e003b1f Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 9 Jan 2023 21:41:27 +0100 Subject: [PATCH 007/100] other types spec --- light-client-primitives/src/lib.rs | 2 -- light-client-primitives/src/types.rs | 45 ++++++++++++++++++++++++++-- src/lib.rs | 14 --------- 3 files changed, 43 insertions(+), 18 deletions(-) delete mode 100644 src/lib.rs diff --git a/light-client-primitives/src/lib.rs b/light-client-primitives/src/lib.rs index 3ca2408f0..5c785ebad 100644 --- a/light-client-primitives/src/lib.rs +++ b/light-client-primitives/src/lib.rs @@ -2,7 +2,5 @@ #[cfg(not(feature = "std"))] extern crate alloc; -#[cfg(not(feature = "std"))] -extern crate core; pub mod types; diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index bd82c734f..a6f4f518b 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -1,6 +1,9 @@ -use ethereum_consensus::primitives::Hash32; +use ethereum_consensus::primitives::{Hash32, Slot}; use alloc::vec::Vec; -use ethereum_consensus::altair::{BeaconBlockHeader, SyncCommittee}; +use ethereum_consensus::altair::{BeaconBlockHeader, SyncAggregate, SyncCommittee}; + +const NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2: usize = 10; +const FINALIZED_ROOT_INDEX_FLOOR_LOG_2: usize = 10; /// This holds the relevant data required to prove the state root in the execution payload. struct ExecutionPayloadProof { @@ -63,3 +66,41 @@ struct AncestorBlock { /// Ancestry proofs of the beacon chain header. ancestry_proof: AncestryProof, } + +/// Holds the latest sync committee as well as an ssz proof for it's existence +/// in a finalized header. +struct SyncCommitteeUpdate { + // actual sync committee + next_sync_committee: SyncCommittee, + // sync committee, ssz merkle proof. + next_sync_committee_branch: [Hash32; NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2], +} + +/// Minimum state required by the light client to validate new sync committee attestations +struct LightClientState { + /// The latest recorded finalized header + finalized_header: BeaconBlockHeader, + // Sync committees corresponding to the finalized header + current_sync_committee: SyncCommittee, + next_sync_committee: SyncCommittee, +} + +/// Data required to advance the state of the light client. +struct LightClientUpdate { + /// the header that the sync committee signed + attested_header: BeaconBlockHeader, + /// the sync committee has potentially changed, here's an ssz proof for that. + sync_committee_update: Option>, + /// the actual header which was finalized by the ethereum attestation protocol. + finalized_header: BeaconBlockHeader, + /// execution payload of the finalized header + execution_payload: ExecutionPayloadProof, + /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 epochs. + finality_branch: [Hash32; FINALIZED_ROOT_INDEX_FLOOR_LOG_2], + /// signature & participation bits + sync_aggregate: SyncAggregate, + /// slot at which signature was produced + signature_slot: Slot, + /// ancestors of the finalized block to be verified, may be empty. + ancestor_blocks: Vec, +} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 7d12d9af8..000000000 --- a/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} From 578dac52e0a749eee34f2d9d7e06b931a77cd771 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 10 Jan 2023 11:39:05 +0100 Subject: [PATCH 008/100] make types public and derive macros --- light-client-primitives/src/types.rs | 70 +++++++++++++++------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index a6f4f518b..ab8f0ee12 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -1,36 +1,36 @@ use ethereum_consensus::primitives::{Hash32, Slot}; use alloc::vec::Vec; -use ethereum_consensus::altair::{BeaconBlockHeader, SyncAggregate, SyncCommittee}; - -const NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2: usize = 10; -const FINALIZED_ROOT_INDEX_FLOOR_LOG_2: usize = 10; +use ethereum_consensus::altair::{BeaconBlockHeader, SyncAggregate, SyncCommittee, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, FINALIZED_ROOT_INDEX_FLOOR_LOG_2}; /// This holds the relevant data required to prove the state root in the execution payload. -struct ExecutionPayloadProof { +#[derive(Debug, Clone)] +pub struct ExecutionPayloadProof { /// The state root in the `ExecutionPayload` which represents the commitment to /// the ethereum world state in the yellow paper. - state_root: Hash32, + pub state_root: Hash32, /// the block number of the execution header. - block_number: u64, + pub block_number: u64, /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. - multi_proof: Vec, + pub multi_proof: Vec, /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. - execution_payload_branch: Vec, + pub execution_payload_branch: Vec, } /// Holds the neccessary proofs required to verify a header in the `block_roots` field /// either in [`BeaconState`] or [`HistoricalBatch`]. -struct BlockRootsProof { +#[derive(Debug, Clone)] +pub struct BlockRootsProof { /// Generalized index of the header in the `block_roots` list. - block_header_index: u64, + pub block_header_index: u64, /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` - block_header_branch: Vec, + pub block_header_branch: Vec, } /// The block header ancestry proof, this is an enum because the header may either exist in /// `state.block_roots` or `state.historical_roots`. -enum AncestryProof { +#[derive(Debug, Clone)] +pub enum AncestryProof { /// This variant defines the proof data for a beacon chain header in the `state.block_roots` BlockRoots { /// Proof for the header in `state.block_roots` @@ -58,49 +58,53 @@ enum AncestryProof { /// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized /// header. -struct AncestorBlock { +#[derive(Debug, Clone)] +pub struct AncestorBlock { /// The actual beacon chain header - header: BeaconBlockHeader, + pub header: BeaconBlockHeader, /// Associated execution header proofs - execution_payload: ExecutionPayloadProof, + pub execution_payload: ExecutionPayloadProof, /// Ancestry proofs of the beacon chain header. - ancestry_proof: AncestryProof, + pub ancestry_proof: AncestryProof, } /// Holds the latest sync committee as well as an ssz proof for it's existence /// in a finalized header. -struct SyncCommitteeUpdate { +#[derive(Debug, Clone)] +pub struct SyncCommitteeUpdate { // actual sync committee - next_sync_committee: SyncCommittee, + pub next_sync_committee: SyncCommittee, // sync committee, ssz merkle proof. - next_sync_committee_branch: [Hash32; NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2], + pub next_sync_committee_branch: [Hash32; NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2], } /// Minimum state required by the light client to validate new sync committee attestations -struct LightClientState { +#[derive(Debug, Clone)] +pub struct LightClientState { /// The latest recorded finalized header - finalized_header: BeaconBlockHeader, + pub finalized_header: BeaconBlockHeader, // Sync committees corresponding to the finalized header - current_sync_committee: SyncCommittee, - next_sync_committee: SyncCommittee, + pub current_sync_committee: SyncCommittee, + pub next_sync_committee: SyncCommittee, } /// Data required to advance the state of the light client. -struct LightClientUpdate { +#[derive(Debug, Clone)] +pub struct LightClientUpdate { /// the header that the sync committee signed - attested_header: BeaconBlockHeader, + pub attested_header: BeaconBlockHeader, /// the sync committee has potentially changed, here's an ssz proof for that. - sync_committee_update: Option>, + pub sync_committee_update: Option>, /// the actual header which was finalized by the ethereum attestation protocol. - finalized_header: BeaconBlockHeader, + pub finalized_header: BeaconBlockHeader, /// execution payload of the finalized header - execution_payload: ExecutionPayloadProof, + pub execution_payload: ExecutionPayloadProof, /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 epochs. - finality_branch: [Hash32; FINALIZED_ROOT_INDEX_FLOOR_LOG_2], + pub finality_branch: [Hash32; FINALIZED_ROOT_INDEX_FLOOR_LOG_2], /// signature & participation bits - sync_aggregate: SyncAggregate, + pub sync_aggregate: SyncAggregate, /// slot at which signature was produced - signature_slot: Slot, + pub signature_slot: Slot, /// ancestors of the finalized block to be verified, may be empty. - ancestor_blocks: Vec, + pub ancestor_blocks: Vec, } From 96113ba0a040df14bd0cd8b071679b96732db224 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 10 Jan 2023 11:39:33 +0100 Subject: [PATCH 009/100] cargo fmt --- light-client-primitives/src/types.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index ab8f0ee12..94ef450d7 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -1,6 +1,9 @@ -use ethereum_consensus::primitives::{Hash32, Slot}; use alloc::vec::Vec; -use ethereum_consensus::altair::{BeaconBlockHeader, SyncAggregate, SyncCommittee, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, FINALIZED_ROOT_INDEX_FLOOR_LOG_2}; +use ethereum_consensus::altair::{ + BeaconBlockHeader, SyncAggregate, SyncCommittee, FINALIZED_ROOT_INDEX_FLOOR_LOG_2, + NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, +}; +use ethereum_consensus::primitives::{Hash32, Slot}; /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] @@ -16,7 +19,6 @@ pub struct ExecutionPayloadProof { pub execution_payload_branch: Vec, } - /// Holds the neccessary proofs required to verify a header in the `block_roots` field /// either in [`BeaconState`] or [`HistoricalBatch`]. #[derive(Debug, Clone)] From 2c49406db7e550475b2819fbc9f1809d60b2d443 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 10 Jan 2023 23:35:02 +0100 Subject: [PATCH 010/100] the remaining utility functions --- light-client-primitives/Cargo.toml | 1 + light-client-primitives/src/lib.rs | 1 + light-client-primitives/src/util.rs | 34 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 light-client-primitives/src/util.rs diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index af8570aa7..f8e4197a3 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -8,3 +8,4 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +base2 = {version="0.2.2", default-features=false} diff --git a/light-client-primitives/src/lib.rs b/light-client-primitives/src/lib.rs index 5c785ebad..d28e53bb2 100644 --- a/light-client-primitives/src/lib.rs +++ b/light-client-primitives/src/lib.rs @@ -4,3 +4,4 @@ extern crate alloc; pub mod types; +pub mod util; diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs new file mode 100644 index 000000000..063643889 --- /dev/null +++ b/light-client-primitives/src/util.rs @@ -0,0 +1,34 @@ +use base2::Base2; +use ethereum_consensus::altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD; +use ethereum_consensus::configs::mainnet::{ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION}; +use ethereum_consensus::phase0::mainnet::SLOTS_PER_EPOCH; + +/// Calculate the subtree index from the ``generalized_index`` +pub fn get_subtree_index(generalized_index: u64) -> u64 { + generalized_index % 2 ^ (generalized_index.floor_log2() as u64) +} + +/// Return the sync committe period at the given ``epoch`` +pub fn compute_sync_committee_period(epoch: u64) -> u64 { + epoch / EPOCHS_PER_SYNC_COMMITTEE_PERIOD +} + +/// Return the epoch number at ``slot``. +pub fn compute_epoch_at_slot(slot: u64) -> u64 { + slot / SLOTS_PER_EPOCH +} + +/// Return the fork version at the given ``epoch``. +pub fn compute_fork_version(epoch: u64) -> [u8; 4] { + if epoch >= ALTAIR_FORK_EPOCH { + ALTAIR_FORK_VERSION + } else { + GENESIS_FORK_VERSION + } +} + +/// Return the sync committee period at ``slot`` +pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { + compute_sync_committee_period(compute_epoch_at_slot(slot)) +} + From 28ddad2cc0995f787d7bbef1da30a69b7f85c461 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 11 Jan 2023 16:11:29 +0100 Subject: [PATCH 011/100] change fork import --- light-client-primitives/src/types.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index 94ef450d7..083ada75a 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -1,7 +1,7 @@ use alloc::vec::Vec; -use ethereum_consensus::altair::{ - BeaconBlockHeader, SyncAggregate, SyncCommittee, FINALIZED_ROOT_INDEX_FLOOR_LOG_2, - NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, +use ethereum_consensus::altair::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; +use ethereum_consensus::bellatrix::{ + BeaconBlockHeader, SyncAggregate, SyncCommittee }; use ethereum_consensus::primitives::{Hash32, Slot}; From a5c8be3a690bd6ae2112c7fe0d8d35145249f054 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 11 Jan 2023 21:26:45 +0100 Subject: [PATCH 012/100] init verifier with struct and errors --- light-client-primitives/Cargo.toml | 2 +- light-client-primitives/src/types.rs | 6 ++--- light-client-primitives/src/util.rs | 5 ++-- light-client-verifier/Cargo.toml | 5 +++- light-client-verifier/src/lib.rs | 16 +++--------- light-client-verifier/src/light_client.rs | 30 +++++++++++++++++++++++ 6 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 light-client-verifier/src/light_client.rs diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index f8e4197a3..a94a97281 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "eth-beacon-light-client-primitives" +name = "light-client-primitives" version = "0.1.0" edition = "2021" authors = ["Polytope Labs"] diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index 083ada75a..d665a7120 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -1,8 +1,8 @@ use alloc::vec::Vec; -use ethereum_consensus::altair::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; -use ethereum_consensus::bellatrix::{ - BeaconBlockHeader, SyncAggregate, SyncCommittee +use ethereum_consensus::altair::{ + FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, }; +use ethereum_consensus::bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}; use ethereum_consensus::primitives::{Hash32, Slot}; /// This holds the relevant data required to prove the state root in the execution payload. diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index 063643889..a6fe7a10b 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -1,6 +1,8 @@ use base2::Base2; use ethereum_consensus::altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD; -use ethereum_consensus::configs::mainnet::{ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION}; +use ethereum_consensus::configs::mainnet::{ + ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION, +}; use ethereum_consensus::phase0::mainnet::SLOTS_PER_EPOCH; /// Calculate the subtree index from the ``generalized_index`` @@ -31,4 +33,3 @@ pub fn compute_fork_version(epoch: u64) -> [u8; 4] { pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { compute_sync_committee_period(compute_epoch_at_slot(slot)) } - diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index ddb6e0fd0..aedd24a6b 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "eth-beacon-light-client-verifier" +name = "light-client-verifier" version = "0.1.0" edition = "2021" authors = ["Polytope Labs"] @@ -7,3 +7,6 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +base2 = {version="0.2.2", default-features=false} +light-client-primitives = {path="../light-client-primitives"} diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs index 7d12d9af8..3dfb4bbd6 100644 --- a/light-client-verifier/src/lib.rs +++ b/light-client-verifier/src/lib.rs @@ -1,14 +1,6 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} +#![cfg_attr(not(feature = "std"), no_std)] -#[cfg(test)] -mod tests { - use super::*; +#[cfg(not(feature = "std"))] +extern crate alloc; - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} +pub mod light_client; diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs new file mode 100644 index 000000000..6c963b6f9 --- /dev/null +++ b/light-client-verifier/src/light_client.rs @@ -0,0 +1,30 @@ +use core::fmt::{Display, Formatter}; +use light_client_primitives::types::{LightClientState, LightClientUpdate}; + +#[derive(Debug)] +pub enum Error { + SyncCommitteeParticiapntsTooLow, + InvalidUpdate, +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self { + Error::SyncCommitteeParticiapntsTooLow => { + write!(f, "Sync committee participants are too low") + } + Error::InvalidUpdate => write!(f, "Invalid update"), + } + } +} + +struct EthLightClient {} + +impl EthLightClient { + pub fn verify_sync_committee_attestation( + trusted_state: LightClientState, + update: LightClientUpdate, + ) -> Result<(), Error> { + Ok(()) + } +} From a13d628d437001df235614260134f840d38be212 Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 12 Jan 2023 00:01:28 +0100 Subject: [PATCH 013/100] further implementation --- light-client-primitives/Cargo.toml | 1 + light-client-primitives/src/util.rs | 7 ++ light-client-verifier/Cargo.toml | 2 + light-client-verifier/src/error.rs | 28 ++++++ light-client-verifier/src/lib.rs | 1 + light-client-verifier/src/light_client.rs | 110 ++++++++++++++++++---- 6 files changed, 129 insertions(+), 20 deletions(-) create mode 100644 light-client-verifier/src/error.rs diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index a94a97281..fddf74dde 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -9,3 +9,4 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } base2 = {version="0.2.2", default-features=false} +ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index a6fe7a10b..b0af478f6 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -4,6 +4,8 @@ use ethereum_consensus::configs::mainnet::{ ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION, }; use ethereum_consensus::phase0::mainnet::SLOTS_PER_EPOCH; +use ethereum_consensus::primitives::Root; +use ssz_rs::Node; /// Calculate the subtree index from the ``generalized_index`` pub fn get_subtree_index(generalized_index: u64) -> u64 { @@ -33,3 +35,8 @@ pub fn compute_fork_version(epoch: u64) -> [u8; 4] { pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { compute_sync_committee_period(compute_epoch_at_slot(slot)) } + +// TODO: We probably need to change this +pub fn genesis_validator_root() -> Root { + Node::from_bytes([0u8; 32]).into() +} diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index aedd24a6b..6652f1f76 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -10,3 +10,5 @@ authors = ["Polytope Labs"] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives"} +ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } +milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } diff --git a/light-client-verifier/src/error.rs b/light-client-verifier/src/error.rs new file mode 100644 index 000000000..7295018af --- /dev/null +++ b/light-client-verifier/src/error.rs @@ -0,0 +1,28 @@ +use core::fmt::{Display, Formatter}; + +#[derive(Debug)] +pub enum Error { + SyncCommitteeParticiapntsTooLow, + InvalidUpdate, + DomainError, + FastAggregateError(ethereum_consensus::crypto::Error), +} + +impl From for Error { + fn from(error: ethereum_consensus::crypto::Error) -> Self { + Error::FastAggregateError(error) + } +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self { + Error::SyncCommitteeParticiapntsTooLow => { + write!(f, "Sync committee participants are too low") + } + Error::InvalidUpdate => write!(f, "Invalid update"), + Error::DomainError => write!(f, "Couldn't get domain"), + Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), + } + } +} diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs index 3dfb4bbd6..3fc6cd500 100644 --- a/light-client-verifier/src/lib.rs +++ b/light-client-verifier/src/lib.rs @@ -3,4 +3,5 @@ #[cfg(not(feature = "std"))] extern crate alloc; +pub mod error; pub mod light_client; diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 6c963b6f9..e5acaf097 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -1,30 +1,100 @@ +use crate::error::Error; +use alloc::vec::Vec; use core::fmt::{Display, Formatter}; -use light_client_primitives::types::{LightClientState, LightClientUpdate}; +use ethereum_consensus::altair::mainnet::SYNC_COMMITTEE_SIZE; +use ethereum_consensus::bellatrix::compute_domain; +use ethereum_consensus::domains::DomainType; +use ethereum_consensus::primitives::Root; +use ethereum_consensus::signing::compute_signing_root; +use ethereum_consensus::state_transition::Context; +use light_client_primitives::util::{ + compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, + genesis_validator_root, +}; +use ssz_rs::Node; -#[derive(Debug)] -pub enum Error { - SyncCommitteeParticiapntsTooLow, - InvalidUpdate, -} +pub type LightClientState = light_client_primitives::types::LightClientState; +pub type LightClientUpdate = light_client_primitives::types::LightClientUpdate; -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { - match self { - Error::SyncCommitteeParticiapntsTooLow => { - write!(f, "Sync committee participants are too low") - } - Error::InvalidUpdate => write!(f, "Invalid update"), - } - } -} +//TODO: we might change this +const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; -struct EthLightClient {} +pub struct EthLightClient {} impl EthLightClient { - pub fn verify_sync_committee_attestation( - trusted_state: LightClientState, - update: LightClientUpdate, + /// This function simply verifies a sync committee's attestation & it's finalized counterpart. + pub fn verify_sync_committee_attestation( + state: LightClientState, + mut update: LightClientUpdate, ) -> Result<(), Error> { + // Verify sync committee has super majority participants + let sync_committee_bits = update.sync_aggregate.sync_committee_bits; + let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; + if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { + Err(Error::SyncCommitteeParticiapntsTooLow)? + } + + // Verify update does not skip a sync committee period + let is_valid_update = update.signature_slot > update.attested_header.slot + && update.attested_header.slot >= update.finalized_header.slot; + if !is_valid_update { + Err(Error::InvalidUpdate)? + } + + let state_period = compute_sync_committee_period_at_slot(state.finalized_header.slot); + let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); + if !(state_period..=state_period + 1).contains(&update_signature_period) { + Err(Error::InvalidUpdate)? + } + + // Verify update is relevant + let update_attested_period = + compute_sync_committee_period_at_slot(update.attested_header.slot); + let update_has_next_sync_committee = + update.sync_committee_update.is_some() && update_attested_period == state_period; + + if !(update.attested_header.slot > state.finalized_header.slot + || update_has_next_sync_committee) + { + Err(Error::InvalidUpdate)? + } + + // Verify sync committee aggregate signature + let sync_committee = if update_signature_period == state_period { + state.current_sync_committee + } else { + state.next_sync_committee + }; + + let sync_committee_pubkeys = sync_committee.public_keys; + + let participant_pubkeys = sync_committee_bits + .iter() + .zip(sync_committee_pubkeys.iter()) + .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) + .collect::>(); + + let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); + //TODO: we probably need to construct context + let domain = compute_domain( + DOMAIN_SYNC_COMMITTEE, + Some(fork_version), + Some(genesis_validator_root()), + &Context::default(), + ); + + if domain.is_err() { + Err(Error::InvalidUpdate)? + } + let signing_root = compute_signing_root(&mut update.attested_header, domain.unwrap()); + + //TODO: not sure if we are to use update to get the signature + ethereum_consensus::crypto::fast_aggregate_verify( + &*participant_pubkeys, + signing_root.unwrap().as_bytes(), + &update.sync_aggregate.sync_committee_signature, + )?; + Ok(()) } } From 524cadc7374022df68e1840f2723025f82118c6c Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 13 Jan 2023 01:35:48 +0100 Subject: [PATCH 014/100] switch to seun's branch work on std for now finish verify_sync_committee_attestation() function --- light-client-primitives/src/util.rs | 11 +- light-client-verifier/Cargo.toml | 4 +- light-client-verifier/src/error.rs | 2 + light-client-verifier/src/lib.rs | 1 + light-client-verifier/src/light_client.rs | 308 +++++++++++++++++++++- 5 files changed, 316 insertions(+), 10 deletions(-) diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index b0af478f6..41ec198d2 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -4,8 +4,8 @@ use ethereum_consensus::configs::mainnet::{ ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION, }; use ethereum_consensus::phase0::mainnet::SLOTS_PER_EPOCH; -use ethereum_consensus::primitives::Root; -use ssz_rs::Node; +use ethereum_consensus::primitives::{Hash32, Root}; +use ssz_rs::{MerkleizationError, Node}; /// Calculate the subtree index from the ``generalized_index`` pub fn get_subtree_index(generalized_index: u64) -> u64 { @@ -40,3 +40,10 @@ pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { pub fn genesis_validator_root() -> Root { Node::from_bytes([0u8; 32]).into() } + +pub fn hash_tree_root( + mut object: T, +) -> Result { + let root = object.hash_tree_root()?.try_into().unwrap(); + Ok(root) +} diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 6652f1f76..72b303c1b 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives"} -ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } diff --git a/light-client-verifier/src/error.rs b/light-client-verifier/src/error.rs index 7295018af..5cb2d2a24 100644 --- a/light-client-verifier/src/error.rs +++ b/light-client-verifier/src/error.rs @@ -6,6 +6,7 @@ pub enum Error { InvalidUpdate, DomainError, FastAggregateError(ethereum_consensus::crypto::Error), + InvalidMerkleBranch, } impl From for Error { @@ -23,6 +24,7 @@ impl Display for Error { Error::InvalidUpdate => write!(f, "Invalid update"), Error::DomainError => write!(f, "Couldn't get domain"), Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), + Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), } } } diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs index 3fc6cd500..5d23718fb 100644 --- a/light-client-verifier/src/lib.rs +++ b/light-client-verifier/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(adt_const_params)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index e5acaf097..7de1921ae 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -1,5 +1,7 @@ use crate::error::Error; use alloc::vec::Vec; +use base2::Base2; +use core::borrow::Borrow; use core::fmt::{Display, Formatter}; use ethereum_consensus::altair::mainnet::SYNC_COMMITTEE_SIZE; use ethereum_consensus::bellatrix::compute_domain; @@ -7,23 +9,37 @@ use ethereum_consensus::domains::DomainType; use ethereum_consensus::primitives::Root; use ethereum_consensus::signing::compute_signing_root; use ethereum_consensus::state_transition::Context; +use light_client_primitives::types::AncestryProof; use light_client_primitives::util::{ compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, - genesis_validator_root, + genesis_validator_root, get_subtree_index, hash_tree_root, }; -use ssz_rs::Node; +use ssz_rs::prelude::is_valid_merkle_branch; +use ssz_rs::Merkleized; +use ssz_rs::{calculate_merkle_root, calculate_multi_merkle_root, GeneralizedIndex, Node}; pub type LightClientState = light_client_primitives::types::LightClientState; pub type LightClientUpdate = light_client_primitives::types::LightClientUpdate; -//TODO: we might change this +//TODO: we need to change this const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; +//TODO: we need to change all these consts to the right value +const FINALIZED_ROOT_INDEX: u64 = 0; +const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: GeneralizedIndex = GeneralizedIndex(0 as usize); +const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: GeneralizedIndex = GeneralizedIndex(0 as usize); +const EXECUTION_PAYLOAD_INDEX: u64 = 0; +const NEXT_SYNC_COMMITTEE_INDEX: u64 = 0; + pub struct EthLightClient {} impl EthLightClient { /// This function simply verifies a sync committee's attestation & it's finalized counterpart. - pub fn verify_sync_committee_attestation( + pub fn verify_sync_committee_attestation< + const BLOCK_ROOTS_INDEX: u64, + const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: GeneralizedIndex, + const HISTORICAL_ROOTS_INDEX: u64, + >( state: LightClientState, mut update: LightClientUpdate, ) -> Result<(), Error> { @@ -61,9 +77,9 @@ impl EthLightClient { // Verify sync committee aggregate signature let sync_committee = if update_signature_period == state_period { - state.current_sync_committee + state.clone().current_sync_committee } else { - state.next_sync_committee + state.clone().next_sync_committee }; let sync_committee_pubkeys = sync_committee.public_keys; @@ -95,6 +111,286 @@ impl EthLightClient { &update.sync_aggregate.sync_committee_signature, )?; + // Verify that the `finality_branch` confirms `finalized_header` + // to match the finalized checkpoint root saved in the state of `attested_header`. + // Note that the genesis finalized checkpoint root is represented as a zero hash. + let finalized_root = &Node::from_bytes( + light_client_primitives::util::hash_tree_root(update.finalized_header.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ); + + let branch = update + .finality_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + finalized_root, + branch.iter(), + FINALIZED_ROOT_INDEX.floor_log2() as usize, + get_subtree_index(FINALIZED_ROOT_INDEX) as usize, + &Node::from_bytes( + update + .attested_header + .state_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + + if is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + + // verify the associated execution header of the finalized beacon header. + let mut execution_payload = update.execution_payload; + let multi_proof_vec = execution_payload.multi_proof; + let multi_proof_nodes = multi_proof_vec + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), + execution_payload.block_number.hash_tree_root().unwrap(), + ], + &multi_proof_nodes, + &[ + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + ], + ); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, + &Node::from_bytes( + update + .finalized_header + .clone() + .body_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + + if let Some(sync_committee_update) = update.sync_committee_update { + if update_attested_period == state_period { + if sync_committee_update.next_sync_committee != state.clone().next_sync_committee { + Err(Error::InvalidUpdate)? + } + } + + let next_sync_committee_branch = sync_committee_update + .next_sync_committee_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + light_client_primitives::util::hash_tree_root( + sync_committee_update.next_sync_committee, + ) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize, + &Node::from_bytes( + update + .attested_header + .state_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + } + + // verify the ancestry proofs + for ancestor in update.ancestor_blocks { + match ancestor.ancestry_proof { + AncestryProof::BlockRoots { + block_roots_proof, + block_roots_branch, + } => { + let block_header_branch = block_roots_proof + .block_header_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let block_roots_root = calculate_merkle_root( + &Node::from_bytes( + hash_tree_root(ancestor.header.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + &*block_header_branch, + &GeneralizedIndex(block_roots_proof.block_header_index as usize), + ); + + let block_roots_branch_node = block_roots_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &block_roots_root, + block_roots_branch_node.iter(), + BLOCK_ROOTS_INDEX.floor_log2() as usize, + get_subtree_index(BLOCK_ROOTS_INDEX) as usize, + &Node::from_bytes( + update + .finalized_header + .state_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + } + AncestryProof::HistoricalRoots { + block_roots_proof, + historical_batch_proof, + historical_roots_proof, + historical_roots_index, + historical_roots_branch, + } => { + let block_header_branch = block_roots_proof + .block_header_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let block_roots_root = calculate_merkle_root( + &Node::from_bytes( + hash_tree_root(ancestor.header.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + &block_header_branch, + &GeneralizedIndex(block_roots_proof.block_header_index as usize), + ); + + let historical_batch_proof_nodes = historical_batch_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let historical_batch_root = calculate_merkle_root( + &block_roots_root, + &historical_batch_proof_nodes, + &HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, + ); + + let historical_roots_proof_nodes = historical_roots_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let historical_roots_root = calculate_merkle_root( + &historical_batch_root, + &historical_roots_proof_nodes, + &GeneralizedIndex(historical_roots_index as usize), + ); + + let historical_roots_branch_nodes = historical_roots_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &historical_roots_root, + historical_roots_branch_nodes.iter(), + HISTORICAL_ROOTS_INDEX.floor_log2() as usize, + get_subtree_index(HISTORICAL_ROOTS_INDEX) as usize, + &Node::from_bytes( + update + .finalized_header + .state_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + } + }; + + // verify the associated execution paylaod header. + let execution_payload = ancestor.execution_payload; + let multi_proof = execution_payload + .multi_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), + Node::from_bytes( + hash_tree_root(execution_payload.block_number) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + ], + &multi_proof, + &[ + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + ], + ); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, + &Node::from_bytes(ancestor.header.body_root.as_ref().try_into().unwrap()), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + } Ok(()) } } From f2622f3c1e05a50cfc9e77624c05ecd38042a599 Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 13 Jan 2023 01:47:59 +0100 Subject: [PATCH 015/100] use generic const types instead push cargo lock --- Cargo.lock | 1405 +++++++++++++++++++++ light-client-verifier/src/light_client.rs | 16 +- 2 files changed, 1411 insertions(+), 10 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..a083d13b4 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1405 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#df115f52c3ab4c32f89c188607b6130687a561e7" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "sha2 0.9.9", + "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fields-iter" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3edfbdc0f742f479dece939ba9c3999962c95d324849ae764dfcebd419fb884b" +dependencies = [ + "fields-iter-macros", +] + +[[package]] +name = "fields-iter-macros" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d7d1a714a91ae8b40f541b455eb63c84157511ec30bee8649ca8db27453412" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "ics15-ethereum" +version = "0.1.0" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "light-client-primitives" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", +] + +[[package]] +name = "light-client-verifier" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "light-client-primitives", + "milagro_bls", + "ssz-rs 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "rand", + "zeroize", +] + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" +dependencies = [ + "bitvec", + "hex", + "lazy_static", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", + "thiserror", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#6969b00ea8244c9282b8a580037d700f787c614c" +dependencies = [ + "as-any", + "bitvec", + "fields-iter", + "hex", + "itertools", + "lazy_static", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#6969b00ea8244c9282b8a580037d700f787c614c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 7de1921ae..f01c62759 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -21,21 +21,17 @@ use ssz_rs::{calculate_merkle_root, calculate_multi_merkle_root, GeneralizedInde pub type LightClientState = light_client_primitives::types::LightClientState; pub type LightClientUpdate = light_client_primitives::types::LightClientUpdate; -//TODO: we need to change this -const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; - -//TODO: we need to change all these consts to the right value -const FINALIZED_ROOT_INDEX: u64 = 0; -const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: GeneralizedIndex = GeneralizedIndex(0 as usize); -const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: GeneralizedIndex = GeneralizedIndex(0 as usize); -const EXECUTION_PAYLOAD_INDEX: u64 = 0; -const NEXT_SYNC_COMMITTEE_INDEX: u64 = 0; - pub struct EthLightClient {} impl EthLightClient { /// This function simply verifies a sync committee's attestation & it's finalized counterpart. pub fn verify_sync_committee_attestation< + const DOMAIN_SYNC_COMMITTEE: DomainType, + const FINALIZED_ROOT_INDEX: u64, + const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: GeneralizedIndex, + const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: GeneralizedIndex, + const EXECUTION_PAYLOAD_INDEX: u64, + const NEXT_SYNC_COMMITTEE_INDEX: u64, const BLOCK_ROOTS_INDEX: u64, const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: GeneralizedIndex, const HISTORICAL_ROOTS_INDEX: u64, From 7d01d951d04496a3306fd3ddb2c58d704fdf523f Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 13 Jan 2023 01:52:35 +0100 Subject: [PATCH 016/100] GENESIS_VALIDATORS_ROOT generic const --- light-client-primitives/src/util.rs | 7 ++----- light-client-verifier/src/light_client.rs | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index 41ec198d2..63851cb8f 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -36,11 +36,8 @@ pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { compute_sync_committee_period(compute_epoch_at_slot(slot)) } -// TODO: We probably need to change this -pub fn genesis_validator_root() -> Root { - Node::from_bytes([0u8; 32]).into() -} - +/// method for hashing objects into a single root by utilizing a hash tree structure, as defined in +/// the SSZ spec. pub fn hash_tree_root( mut object: T, ) -> Result { diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index f01c62759..b43f0cff3 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -12,7 +12,7 @@ use ethereum_consensus::state_transition::Context; use light_client_primitives::types::AncestryProof; use light_client_primitives::util::{ compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, - genesis_validator_root, get_subtree_index, hash_tree_root, + get_subtree_index, hash_tree_root, }; use ssz_rs::prelude::is_valid_merkle_branch; use ssz_rs::Merkleized; @@ -35,6 +35,7 @@ impl EthLightClient { const BLOCK_ROOTS_INDEX: u64, const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: GeneralizedIndex, const HISTORICAL_ROOTS_INDEX: u64, + const GENESIS_VALIDATORS_ROOT: Root, >( state: LightClientState, mut update: LightClientUpdate, @@ -91,7 +92,7 @@ impl EthLightClient { let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), - Some(genesis_validator_root()), + Some(GENESIS_VALIDATORS_ROOT), &Context::default(), ); From ec476072b2493d46c3a3c4eb2e37b53effee887d Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 13 Jan 2023 19:53:27 +0100 Subject: [PATCH 017/100] return error result/error instead --- light-client-primitives/src/util.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index 63851cb8f..a0f34f5d6 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -38,9 +38,9 @@ pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { /// method for hashing objects into a single root by utilizing a hash tree structure, as defined in /// the SSZ spec. -pub fn hash_tree_root( - mut object: T, -) -> Result { - let root = object.hash_tree_root()?.try_into().unwrap(); - Ok(root) -} + pub fn hash_tree_root( + mut object: T, + ) -> Result { + let root = object.hash_tree_root()?; + Ok(root) + } From 11d4ef42702ebde23044f9d366caf2f8c9e118ec Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 13 Jan 2023 21:57:10 +0100 Subject: [PATCH 018/100] remove generic consts --- light-client-primitives/src/types.rs | 14 +++++- light-client-primitives/src/util.rs | 12 ++--- light-client-verifier/src/light_client.rs | 56 +++++++++++------------ 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index d665a7120..d4e9b1694 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -3,7 +3,19 @@ use ethereum_consensus::altair::{ FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, }; use ethereum_consensus::bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}; -use ethereum_consensus::primitives::{Hash32, Slot}; +use ethereum_consensus::domains::DomainType; +use ethereum_consensus::primitives::{Hash32, Root, Slot}; + +pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; +pub const FINALIZED_ROOT_INDEX: u64 = 0; +pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 0; +pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 0; +pub const EXECUTION_PAYLOAD_INDEX: u64 = 0; +pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 0; +pub const BLOCK_ROOTS_INDEX: u64 = 0; +pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; +pub const HISTORICAL_ROOTS_INDEX: u64 = 0; +pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = [0u8; 32]; /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index a0f34f5d6..b272ce849 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -38,9 +38,9 @@ pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { /// method for hashing objects into a single root by utilizing a hash tree structure, as defined in /// the SSZ spec. - pub fn hash_tree_root( - mut object: T, - ) -> Result { - let root = object.hash_tree_root()?; - Ok(root) - } +pub fn hash_tree_root( + mut object: T, +) -> Result { + let root = object.hash_tree_root()?; + Ok(root) +} diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index b43f0cff3..0e807adf6 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -9,7 +9,12 @@ use ethereum_consensus::domains::DomainType; use ethereum_consensus::primitives::Root; use ethereum_consensus::signing::compute_signing_root; use ethereum_consensus::state_transition::Context; -use light_client_primitives::types::AncestryProof; +use light_client_primitives::types::{ + AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, + GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, + NEXT_SYNC_COMMITTEE_INDEX, +}; use light_client_primitives::util::{ compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, get_subtree_index, hash_tree_root, @@ -21,24 +26,13 @@ use ssz_rs::{calculate_merkle_root, calculate_multi_merkle_root, GeneralizedInde pub type LightClientState = light_client_primitives::types::LightClientState; pub type LightClientUpdate = light_client_primitives::types::LightClientUpdate; -pub struct EthLightClient {} +pub struct EthLightClient; impl EthLightClient { /// This function simply verifies a sync committee's attestation & it's finalized counterpart. - pub fn verify_sync_committee_attestation< - const DOMAIN_SYNC_COMMITTEE: DomainType, - const FINALIZED_ROOT_INDEX: u64, - const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: GeneralizedIndex, - const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: GeneralizedIndex, - const EXECUTION_PAYLOAD_INDEX: u64, - const NEXT_SYNC_COMMITTEE_INDEX: u64, - const BLOCK_ROOTS_INDEX: u64, - const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: GeneralizedIndex, - const HISTORICAL_ROOTS_INDEX: u64, - const GENESIS_VALIDATORS_ROOT: Root, - >( - state: LightClientState, - mut update: LightClientUpdate, + pub fn verify_sync_committee_attestation( + trusted_state: LightClientState, + update: LightClientUpdate, ) -> Result<(), Error> { // Verify sync committee has super majority participants let sync_committee_bits = update.sync_aggregate.sync_committee_bits; @@ -54,7 +48,8 @@ impl EthLightClient { Err(Error::InvalidUpdate)? } - let state_period = compute_sync_committee_period_at_slot(state.finalized_header.slot); + let state_period = + compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); if !(state_period..=state_period + 1).contains(&update_signature_period) { Err(Error::InvalidUpdate)? @@ -66,7 +61,7 @@ impl EthLightClient { let update_has_next_sync_committee = update.sync_committee_update.is_some() && update_attested_period == state_period; - if !(update.attested_header.slot > state.finalized_header.slot + if !(update.attested_header.slot > trusted_state.finalized_header.slot || update_has_next_sync_committee) { Err(Error::InvalidUpdate)? @@ -74,9 +69,9 @@ impl EthLightClient { // Verify sync committee aggregate signature let sync_committee = if update_signature_period == state_period { - state.clone().current_sync_committee + trusted_state.clone().current_sync_committee } else { - state.clone().next_sync_committee + trusted_state.clone().next_sync_committee }; let sync_committee_pubkeys = sync_committee.public_keys; @@ -92,14 +87,17 @@ impl EthLightClient { let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), - Some(GENESIS_VALIDATORS_ROOT), + Some(Root::from_bytes( + GENESIS_VALIDATORS_ROOT.as_ref().try_into().unwrap(), + )), &Context::default(), ); if domain.is_err() { Err(Error::InvalidUpdate)? } - let signing_root = compute_signing_root(&mut update.attested_header, domain.unwrap()); + let signing_root = + compute_signing_root(&mut update.attested_header.clone(), domain.unwrap()); //TODO: not sure if we are to use update to get the signature ethereum_consensus::crypto::fast_aggregate_verify( @@ -158,8 +156,8 @@ impl EthLightClient { ], &multi_proof_nodes, &[ - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, - EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), ], ); @@ -191,7 +189,9 @@ impl EthLightClient { if let Some(sync_committee_update) = update.sync_committee_update { if update_attested_period == state_period { - if sync_committee_update.next_sync_committee != state.clone().next_sync_committee { + if sync_committee_update.next_sync_committee + != trusted_state.clone().next_sync_committee + { Err(Error::InvalidUpdate)? } } @@ -308,7 +308,7 @@ impl EthLightClient { let historical_batch_root = calculate_merkle_root( &block_roots_root, &historical_batch_proof_nodes, - &HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, + &GeneralizedIndex(HISTORICAL_BATCH_BLOCK_ROOTS_INDEX as usize), ); let historical_roots_proof_nodes = historical_roots_proof @@ -366,8 +366,8 @@ impl EthLightClient { ], &multi_proof, &[ - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, - EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), ], ); From 19b823814f4a59436a71460c036bbbfa2e697141 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 14 Jan 2023 12:16:18 +0100 Subject: [PATCH 019/100] return new LightClientState --- light-client-verifier/src/light_client.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 0e807adf6..21add1f37 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -33,7 +33,7 @@ impl EthLightClient { pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, - ) -> Result<(), Error> { + ) -> Result { // Verify sync committee has super majority participants let sync_committee_bits = update.sync_aggregate.sync_committee_bits; let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; @@ -187,7 +187,7 @@ impl EthLightClient { Err(Error::InvalidMerkleBranch)?; } - if let Some(sync_committee_update) = update.sync_committee_update { + if let Some(sync_committee_update) = update.sync_committee_update.clone() { if update_attested_period == state_period { if sync_committee_update.next_sync_committee != trusted_state.clone().next_sync_committee @@ -388,6 +388,13 @@ impl EthLightClient { Err(Error::InvalidMerkleBranch)?; } } - Ok(()) + + let new_light_client_state = LightClientState { + finalized_header: update.finalized_header.clone(), + current_sync_committee: trusted_state.current_sync_committee, + next_sync_committee: update.sync_committee_update.unwrap().next_sync_committee, + }; + + Ok(new_light_client_state) } } From 688a2354c91831f6fdf047a80c1de15551545b36 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 14 Jan 2023 12:56:19 +0100 Subject: [PATCH 020/100] put in the right consts values --- Cargo.lock | 1 + light-client-primitives/src/types.rs | 17 +++++++++-------- light-client-verifier/Cargo.toml | 1 + light-client-verifier/src/light_client.rs | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a083d13b4..2a1014b72 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,6 +548,7 @@ version = "0.1.0" dependencies = [ "base2", "ethereum-consensus", + "hex", "light-client-primitives", "milagro_bls", "ssz-rs 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index d4e9b1694..08f1adf3a 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -7,15 +7,16 @@ use ethereum_consensus::domains::DomainType; use ethereum_consensus::primitives::{Hash32, Root, Slot}; pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; -pub const FINALIZED_ROOT_INDEX: u64 = 0; -pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 0; -pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 0; -pub const EXECUTION_PAYLOAD_INDEX: u64 = 0; -pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 0; -pub const BLOCK_ROOTS_INDEX: u64 = 0; +pub const FINALIZED_ROOT_INDEX: u64 = 105; +pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; +pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; +pub const EXECUTION_PAYLOAD_INDEX: u64 = 25; +pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; +pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; -pub const HISTORICAL_ROOTS_INDEX: u64 = 0; -pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = [0u8; 32]; +pub const HISTORICAL_ROOTS_INDEX: u64 = 39; +pub const GENESIS_VALIDATORS_ROOT: &str = + "4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"; /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 72b303c1b..71ba43d96 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -12,3 +12,4 @@ base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives"} ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } +hex = {version = "0.4.3" } diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 21add1f37..2216aa762 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -83,12 +83,13 @@ impl EthLightClient { .collect::>(); let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); + let genesis_validators_root_bytes = hex::decode(GENESIS_VALIDATORS_ROOT).unwrap(); //TODO: we probably need to construct context let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes( - GENESIS_VALIDATORS_ROOT.as_ref().try_into().unwrap(), + genesis_validators_root_bytes.try_into().unwrap(), )), &Context::default(), ); From bdfeb81cbdb89ffe33a35d7acc0168220bd47a8f Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 17 Jan 2023 00:02:21 +0100 Subject: [PATCH 021/100] use hex_literal refractor cloning --- Cargo.lock | 8 ++++- light-client-primitives/Cargo.toml | 1 + light-client-primitives/src/types.rs | 4 +-- light-client-verifier/Cargo.toml | 3 +- light-client-verifier/src/error.rs | 4 +-- light-client-verifier/src/lib.rs | 1 - light-client-verifier/src/light_client.rs | 39 ++++++++++++----------- 7 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a1014b72..b3b81c58b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -432,6 +432,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + [[package]] name = "hmac" version = "0.12.1" @@ -539,6 +545,7 @@ version = "0.1.0" dependencies = [ "base2", "ethereum-consensus", + "hex-literal", "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", ] @@ -548,7 +555,6 @@ version = "0.1.0" dependencies = [ "base2", "ethereum-consensus", - "hex", "light-client-primitives", "milagro_bls", "ssz-rs 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index fddf74dde..3852ccb25 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -10,3 +10,4 @@ authors = ["Polytope Labs"] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } base2 = {version="0.2.2", default-features=false} ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } +hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index 08f1adf3a..17b63b292 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -15,8 +15,8 @@ pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; -pub const GENESIS_VALIDATORS_ROOT: &str = - "4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"; +pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 71ba43d96..99fd897df 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -9,7 +9,6 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } base2 = {version="0.2.2", default-features=false} -light-client-primitives = {path="../light-client-primitives"} +light-client-primitives = {path="../light-client-primitives", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } -hex = {version = "0.4.3" } diff --git a/light-client-verifier/src/error.rs b/light-client-verifier/src/error.rs index 5cb2d2a24..cde16f2ba 100644 --- a/light-client-verifier/src/error.rs +++ b/light-client-verifier/src/error.rs @@ -2,7 +2,7 @@ use core::fmt::{Display, Formatter}; #[derive(Debug)] pub enum Error { - SyncCommitteeParticiapntsTooLow, + SyncCommitteeParticipantsTooLow, InvalidUpdate, DomainError, FastAggregateError(ethereum_consensus::crypto::Error), @@ -18,7 +18,7 @@ impl From for Error { impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self { - Error::SyncCommitteeParticiapntsTooLow => { + Error::SyncCommitteeParticipantsTooLow => { write!(f, "Sync committee participants are too low") } Error::InvalidUpdate => write!(f, "Invalid update"), diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs index 5d23718fb..3fc6cd500 100644 --- a/light-client-verifier/src/lib.rs +++ b/light-client-verifier/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(adt_const_params)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 2216aa762..eb6aeeac4 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -38,7 +38,7 @@ impl EthLightClient { let sync_committee_bits = update.sync_aggregate.sync_committee_bits; let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { - Err(Error::SyncCommitteeParticiapntsTooLow)? + Err(Error::SyncCommitteeParticipantsTooLow)? } // Verify update does not skip a sync committee period @@ -69,9 +69,9 @@ impl EthLightClient { // Verify sync committee aggregate signature let sync_committee = if update_signature_period == state_period { - trusted_state.clone().current_sync_committee + trusted_state.current_sync_committee.clone() } else { - trusted_state.clone().next_sync_committee + trusted_state.next_sync_committee.clone() }; let sync_committee_pubkeys = sync_committee.public_keys; @@ -83,24 +83,19 @@ impl EthLightClient { .collect::>(); let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); - let genesis_validators_root_bytes = hex::decode(GENESIS_VALIDATORS_ROOT).unwrap(); //TODO: we probably need to construct context let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes( - genesis_validators_root_bytes.try_into().unwrap(), + GENESIS_VALIDATORS_ROOT.try_into().unwrap(), )), &Context::default(), - ); + ) + .map_err(|_| Error::InvalidUpdate)?; - if domain.is_err() { - Err(Error::InvalidUpdate)? - } - let signing_root = - compute_signing_root(&mut update.attested_header.clone(), domain.unwrap()); + let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain); - //TODO: not sure if we are to use update to get the signature ethereum_consensus::crypto::fast_aggregate_verify( &*participant_pubkeys, signing_root.unwrap().as_bytes(), @@ -191,7 +186,7 @@ impl EthLightClient { if let Some(sync_committee_update) = update.sync_committee_update.clone() { if update_attested_period == state_period { if sync_committee_update.next_sync_committee - != trusted_state.clone().next_sync_committee + != trusted_state.next_sync_committee.clone() { Err(Error::InvalidUpdate)? } @@ -390,11 +385,19 @@ impl EthLightClient { } } - let new_light_client_state = LightClientState { - finalized_header: update.finalized_header.clone(), - current_sync_committee: trusted_state.current_sync_committee, - next_sync_committee: update.sync_committee_update.unwrap().next_sync_committee, - }; + let new_light_client_state = + if let Some(sync_committee_update) = update.sync_committee_update { + LightClientState { + finalized_header: update.finalized_header, + current_sync_committee: trusted_state.next_sync_committee, + next_sync_committee: sync_committee_update.next_sync_committee, + } + } else { + LightClientState { + finalized_header: update.finalized_header, + ..trusted_state + } + }; Ok(new_light_client_state) } From a7061593f787688ebb2ff17a124b94a0cbe4ca58 Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 19 Jan 2023 10:49:51 +0100 Subject: [PATCH 022/100] use hex_literal refractor cloning --- light-client-primitives/src/util.rs | 2 +- light-client-verifier/src/error.rs | 4 ++ light-client-verifier/src/light_client.rs | 75 +++++++++++++++-------- 3 files changed, 54 insertions(+), 27 deletions(-) diff --git a/light-client-primitives/src/util.rs b/light-client-primitives/src/util.rs index b272ce849..6685bf4f5 100644 --- a/light-client-primitives/src/util.rs +++ b/light-client-primitives/src/util.rs @@ -40,7 +40,7 @@ pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { /// the SSZ spec. pub fn hash_tree_root( mut object: T, -) -> Result { +) -> Result { let root = object.hash_tree_root()?; Ok(root) } diff --git a/light-client-verifier/src/error.rs b/light-client-verifier/src/error.rs index cde16f2ba..6d703b41d 100644 --- a/light-client-verifier/src/error.rs +++ b/light-client-verifier/src/error.rs @@ -7,6 +7,8 @@ pub enum Error { DomainError, FastAggregateError(ethereum_consensus::crypto::Error), InvalidMerkleBranch, + InvalidRoot, + MerkleizationError, } impl From for Error { @@ -25,6 +27,8 @@ impl Display for Error { Error::DomainError => write!(f, "Couldn't get domain"), Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), + Error::InvalidRoot => write!(f, "Invalid root"), + Error::MerkleizationError => write!(f, "Merkleization error"), } } } diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index eb6aeeac4..496505585 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -88,7 +88,9 @@ impl EthLightClient { DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes( - GENESIS_VALIDATORS_ROOT.try_into().unwrap(), + GENESIS_VALIDATORS_ROOT + .try_into() + .map_err(|_| Error::InvalidRoot)?, )), &Context::default(), ) @@ -98,7 +100,7 @@ impl EthLightClient { ethereum_consensus::crypto::fast_aggregate_verify( &*participant_pubkeys, - signing_root.unwrap().as_bytes(), + signing_root.map_err(|_| Error::InvalidRoot)?.as_bytes(), &update.sync_aggregate.sync_committee_signature, )?; @@ -107,10 +109,10 @@ impl EthLightClient { // Note that the genesis finalized checkpoint root is represented as a zero hash. let finalized_root = &Node::from_bytes( light_client_primitives::util::hash_tree_root(update.finalized_header.clone()) - .unwrap() + .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ); let branch = update @@ -130,7 +132,7 @@ impl EthLightClient { .state_root .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ); @@ -147,8 +149,17 @@ impl EthLightClient { .collect::>(); let execution_payload_root = calculate_multi_merkle_root( &[ - Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), - execution_payload.block_number.hash_tree_root().unwrap(), + Node::from_bytes( + execution_payload + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + execution_payload + .block_number + .hash_tree_root() + .map_err(|_| Error::InvalidRoot)?, ], &multi_proof_nodes, &[ @@ -175,7 +186,7 @@ impl EthLightClient { .body_root .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ); @@ -184,12 +195,11 @@ impl EthLightClient { } if let Some(sync_committee_update) = update.sync_committee_update.clone() { - if update_attested_period == state_period { - if sync_committee_update.next_sync_committee + if update_attested_period == state_period + && sync_committee_update.next_sync_committee != trusted_state.next_sync_committee.clone() - { - Err(Error::InvalidUpdate)? - } + { + Err(Error::InvalidUpdate)? } let next_sync_committee_branch = sync_committee_update @@ -202,10 +212,10 @@ impl EthLightClient { light_client_primitives::util::hash_tree_root( sync_committee_update.next_sync_committee, ) - .unwrap() + .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, @@ -216,7 +226,7 @@ impl EthLightClient { .state_root .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ); @@ -241,10 +251,10 @@ impl EthLightClient { let block_roots_root = calculate_merkle_root( &Node::from_bytes( hash_tree_root(ancestor.header.clone()) - .unwrap() + .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), &*block_header_branch, &GeneralizedIndex(block_roots_proof.block_header_index as usize), @@ -266,7 +276,7 @@ impl EthLightClient { .state_root .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ); if !is_merkle_branch_valid { @@ -288,10 +298,10 @@ impl EthLightClient { let block_roots_root = calculate_merkle_root( &Node::from_bytes( hash_tree_root(ancestor.header.clone()) - .unwrap() + .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), &block_header_branch, &GeneralizedIndex(block_roots_proof.block_header_index as usize), @@ -332,7 +342,7 @@ impl EthLightClient { .state_root .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ); @@ -351,13 +361,19 @@ impl EthLightClient { .collect::>(); let execution_payload_root = calculate_multi_merkle_root( &[ - Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), + Node::from_bytes( + execution_payload + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), Node::from_bytes( hash_tree_root(execution_payload.block_number) - .unwrap() + .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() - .unwrap(), + .map_err(|_| Error::InvalidRoot)?, ), ], &multi_proof, @@ -377,7 +393,14 @@ impl EthLightClient { execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, - &Node::from_bytes(ancestor.header.body_root.as_ref().try_into().unwrap()), + &Node::from_bytes( + ancestor + .header + .body_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), ); if !is_merkle_branch_valid { From 01ae22f2b6fdce425ebf784ef2af54fea9014381 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 25 Jan 2023 01:52:31 +0100 Subject: [PATCH 023/100] init prover --- Cargo.toml | 3 ++- sync-committee-prover/Cargo.toml | 11 ++++++++++ sync-committee-prover/src/lib.rs | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 sync-committee-prover/Cargo.toml create mode 100644 sync-committee-prover/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 1544c2ba5..b87e07965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ resolver = "2" members = [ "light-client-verifier", "light-client-primitives", - "ics15-ethereum" + "ics15-ethereum", + "sync-committee-prover" ] diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml new file mode 100644 index 000000000..372b9bb37 --- /dev/null +++ b/sync-committee-prover/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "sync-committee-prover" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +reqwest = {version="0.11.14", features=["json"]} + diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs new file mode 100644 index 000000000..554ace02c --- /dev/null +++ b/sync-committee-prover/src/lib.rs @@ -0,0 +1,36 @@ +use ethereum_consensus::bellatrix::{BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee}; + +pub fn header_route(block_id: String) -> String { + format!("/eth/v1/beacon/headers/{}", block_id) +} + +pub struct SyncCommitteeProver { + pub node_url: String, +} + +impl SyncCommitteeProver { + + pub fn new(node_url: String) -> Self { + SyncCommitteeProver { node_url } + } + + pub async fn fetch_header(&self, block_id: String) -> Result { + let mut node_url = self.node_url.clone(); + let path = header_route(block_id); + node_url.push_str(&path); + + let client = reqwest::Client::new(); + let response = client + .get(node_url).send() + .await?; + + + let beacon_block_header = response.json::().await; + + beacon_block_header + } + /*pub async fn fetch_block(block_id: String) -> BeaconBlock { } + pub async fn fetch_sync_committee(state_id: String) -> SyncCommittee { } + pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } + pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ +} From b1c6cedcfbf3458978e1061afe97529ff1b8cf35 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 25 Jan 2023 02:17:09 +0100 Subject: [PATCH 024/100] fetch block header and sync committee --- sync-committee-prover/src/lib.rs | 107 ++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 15 deletions(-) diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 554ace02c..391af98a6 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -1,36 +1,113 @@ -use ethereum_consensus::bellatrix::{BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee}; +use ethereum_consensus::bellatrix::{ + BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, +}; +use reqwest::Client; + +//TODO: Remove all these and use the light client primitive consts in the other PR +const MAX_PROPOSER_SLASHINGS: usize = 0; +const MAX_VALIDATORS_PER_COMMITTEE: usize = 0; +const MAX_ATTESTER_SLASHINGS: usize = 0; +const MAX_ATTESTATIONS: usize = 0; +const MAX_DEPOSITS: usize = 0; +const MAX_VOLUNTARY_EXITS: usize = 0; +const SYNC_COMMITTEE_SIZE: usize = 0; +const BYTES_PER_LOGS_BLOOM: usize = 0; +const MAX_EXTRA_DATA_BYTES: usize = 0; +const MAX_BYTES_PER_TRANSACTION: usize = 0; +const MAX_TRANSACTIONS_PER_PAYLOAD: usize = 0; pub fn header_route(block_id: String) -> String { format!("/eth/v1/beacon/headers/{}", block_id) } +pub fn block_route(block_id: String) -> String { + format!("/eth/v2/beacon/blocks/{}", block_id) +} + +pub fn sync_committee_route(state_id: String) -> String { + format!("/eth/v1/beacon/states/{}/sync_committees", state_id) +} + pub struct SyncCommitteeProver { pub node_url: String, + pub client: Client, } impl SyncCommitteeProver { - pub fn new(node_url: String) -> Self { - SyncCommitteeProver { node_url } - } + let client = reqwest::Client::new(); - pub async fn fetch_header(&self, block_id: String) -> Result { - let mut node_url = self.node_url.clone(); - let path = header_route(block_id); - node_url.push_str(&path); + SyncCommitteeProver { node_url, client } + } - let client = reqwest::Client::new(); - let response = client - .get(node_url).send() - .await?; + pub async fn fetch_header( + &self, + block_id: String, + ) -> Result { + let path = header_route(block_id); + let full_url = format!("{}/{}", self.node_url.clone(), path); + let response = self.client.get(full_url).send().await?; let beacon_block_header = response.json::().await; beacon_block_header } - /*pub async fn fetch_block(block_id: String) -> BeaconBlock { } - pub async fn fetch_sync_committee(state_id: String) -> SyncCommittee { } - pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } + pub async fn fetch_block( + &self, + block_id: String, + ) -> Result< + BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + reqwest::Error, + > { + let path = block_route(block_id); + let full_url = format!("{}/{}", self.node_url.clone(), path); + + let response = self.client.get(full_url).send().await?; + + let beacon_block = response + .json::>() + .await; + + beacon_block + } + pub async fn fetch_sync_committee( + &self, + state_id: String, + ) -> Result, reqwest::Error> { + let path = sync_committee_route(state_id); + let full_url = format!("{}/{}", self.node_url.clone(), path); + + let response = self.client.get(full_url).send().await?; + + let sync_committee = response.json::>().await; + + sync_committee + } + /*pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ } From 4a51d86ab877085c9ad79da197adaae46386f401 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 25 Jan 2023 11:30:45 +0100 Subject: [PATCH 025/100] wrote tests --- sync-committee-prover/Cargo.toml | 3 +++ sync-committee-prover/src/lib.rs | 15 ++++++++++----- .../src/responses/beacon_block_response.rs | 19 +++++++++++++++++++ sync-committee-prover/src/responses/mod.rs | 1 + sync-committee-prover/src/test.rs | 12 ++++++++++++ 5 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 sync-committee-prover/src/responses/beacon_block_response.rs create mode 100644 sync-committee-prover/src/responses/mod.rs create mode 100644 sync-committee-prover/src/test.rs diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index 372b9bb37..00b852e6c 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -8,4 +8,7 @@ edition = "2021" [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } reqwest = {version="0.11.14", features=["json"]} +serde = { version = "1.0", features = ["derive"]} +serde_json = { version = "1.0.81"} +actix-rt = "*" diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 391af98a6..748266a9e 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -1,3 +1,8 @@ +#[cfg(test)] +mod test; +mod responses; + + use ethereum_consensus::bellatrix::{ BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, }; @@ -43,15 +48,15 @@ impl SyncCommitteeProver { pub async fn fetch_header( &self, block_id: String, - ) -> Result { + ) ->Result { let path = header_route(block_id); - let full_url = format!("{}/{}", self.node_url.clone(), path); - + let full_url = format!("{}{}", self.node_url.clone(), path); let response = self.client.get(full_url).send().await?; + let response_data = response.json::().await?; - let beacon_block_header = response.json::().await; + let beacon_block_header = response_data.data.header.message; - beacon_block_header + Ok(beacon_block_header) } pub async fn fetch_block( &self, diff --git a/sync-committee-prover/src/responses/beacon_block_response.rs b/sync-committee-prover/src/responses/beacon_block_response.rs new file mode 100644 index 000000000..ffc50176a --- /dev/null +++ b/sync-committee-prover/src/responses/beacon_block_response.rs @@ -0,0 +1,19 @@ +use ethereum_consensus::bellatrix::BeaconBlockHeader; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, )] +pub struct Response { + pub(crate) data: ResponseData, + execution_optimistic: bool +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, )] +pub struct ResponseData { + root: String, + canonical: bool, + pub(crate) header: ResponseDataBeaconBlockHeaderMessage, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ResponseDataBeaconBlockHeaderMessage { + pub message: BeaconBlockHeader +} diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs new file mode 100644 index 000000000..d345f28a8 --- /dev/null +++ b/sync-committee-prover/src/responses/mod.rs @@ -0,0 +1 @@ +pub mod beacon_block_response; diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs new file mode 100644 index 000000000..6b0b94bab --- /dev/null +++ b/sync-committee-prover/src/test.rs @@ -0,0 +1,12 @@ +use super::*; + +#[cfg(test)] +#[allow(non_snake_case)] + +#[actix_rt::test] +async fn fetches_block_header_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block_header = sync_committee_prover.fetch_header("100".to_string()).await; + assert!(block_header.is_ok()); +} From e5e28a9099685ea08208752dc92218655b22f4af Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 26 Jan 2023 00:26:51 +0100 Subject: [PATCH 026/100] beacon block impl --- sync-committee-prover/src/lib.rs | 9 ++-- .../responses/beacon_block_header_response.rs | 19 +++++++++ .../src/responses/beacon_block_response.rs | 42 ++++++++++++++----- sync-committee-prover/src/responses/mod.rs | 1 + sync-committee-prover/src/test.rs | 1 - 5 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 sync-committee-prover/src/responses/beacon_block_header_response.rs diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 748266a9e..929f49586 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -1,7 +1,6 @@ +mod responses; #[cfg(test)] mod test; -mod responses; - use ethereum_consensus::bellatrix::{ BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, @@ -48,11 +47,13 @@ impl SyncCommitteeProver { pub async fn fetch_header( &self, block_id: String, - ) ->Result { + ) -> Result { let path = header_route(block_id); let full_url = format!("{}{}", self.node_url.clone(), path); let response = self.client.get(full_url).send().await?; - let response_data = response.json::().await?; + let response_data = response + .json::() + .await?; let beacon_block_header = response_data.data.header.message; diff --git a/sync-committee-prover/src/responses/beacon_block_header_response.rs b/sync-committee-prover/src/responses/beacon_block_header_response.rs new file mode 100644 index 000000000..4ac4748ed --- /dev/null +++ b/sync-committee-prover/src/responses/beacon_block_header_response.rs @@ -0,0 +1,19 @@ +use ethereum_consensus::bellatrix::BeaconBlockHeader; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + pub(crate) data: ResponseData, + execution_optimistic: bool, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ResponseData { + root: String, + canonical: bool, + pub(crate) header: ResponseDataBeaconBlockHeaderMessage, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ResponseDataBeaconBlockHeaderMessage { + pub message: BeaconBlockHeader, +} diff --git a/sync-committee-prover/src/responses/beacon_block_response.rs b/sync-committee-prover/src/responses/beacon_block_response.rs index ffc50176a..b791c356c 100644 --- a/sync-committee-prover/src/responses/beacon_block_response.rs +++ b/sync-committee-prover/src/responses/beacon_block_response.rs @@ -1,19 +1,41 @@ -use ethereum_consensus::bellatrix::BeaconBlockHeader; +use ethereum_consensus::bellatrix::{BeaconBlock, BeaconBlockHeader}; -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, )] +//TODO: Remove all these and use the light client primitive consts in the other PR +const MAX_PROPOSER_SLASHINGS: usize = 0; +const MAX_VALIDATORS_PER_COMMITTEE: usize = 0; +const MAX_ATTESTER_SLASHINGS: usize = 0; +const MAX_ATTESTATIONS: usize = 0; +const MAX_DEPOSITS: usize = 0; +const MAX_VOLUNTARY_EXITS: usize = 0; +const SYNC_COMMITTEE_SIZE: usize = 0; +const BYTES_PER_LOGS_BLOOM: usize = 0; +const MAX_EXTRA_DATA_BYTES: usize = 0; +const MAX_BYTES_PER_TRANSACTION: usize = 0; +const MAX_TRANSACTIONS_PER_PAYLOAD: usize = 0; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { pub(crate) data: ResponseData, - execution_optimistic: bool + version: String, + execution_optimistic: bool, } -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, )] +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ResponseData { root: String, canonical: bool, - pub(crate) header: ResponseDataBeaconBlockHeaderMessage, -} - -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct ResponseDataBeaconBlockHeaderMessage { - pub message: BeaconBlockHeader + pub(crate) message: BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + pub signature: String, } diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs index d345f28a8..15a351a34 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/sync-committee-prover/src/responses/mod.rs @@ -1 +1,2 @@ +pub mod beacon_block_header_response; pub mod beacon_block_response; diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 6b0b94bab..014581440 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -2,7 +2,6 @@ use super::*; #[cfg(test)] #[allow(non_snake_case)] - #[actix_rt::test] async fn fetches_block_header_works() { let node_url: String = "http://localhost:3500".to_string(); From 82a465b816abfc327a68d3b316b8b4a00385b6b4 Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 26 Jan 2023 00:27:32 +0100 Subject: [PATCH 027/100] lock --- Cargo.lock | 1879 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1879 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..c472ff031 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1879 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cc" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64 0.13.1", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "eth-beacon-light-client-primitives" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", +] + +[[package]] +name = "eth-beacon-light-client-verifier" +version = "0.1.0" + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#248b5d1e53d87fde1d9368dc25ad483633ef0e4a" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown 0.13.2", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "sha2 0.9.9", + "ssz-rs", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "ics15-ethereum" +version = "0.1.0" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "rand", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" +dependencies = [ + "bitvec", + "hex", + "lazy_static", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-committee-prover" +version = "0.1.0" +dependencies = [ + "actix-rt", + "ethereum-consensus", + "reqwest", + "serde", + "serde_json", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" From 647b8b09d0c24c7d67872aa45f0b18e8206ba416 Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 26 Jan 2023 00:37:51 +0100 Subject: [PATCH 028/100] use the right const generic types --- Cargo.lock | 91 ++++++++++++++++--- sync-committee-prover/Cargo.toml | 1 + sync-committee-prover/src/lib.rs | 22 ++--- .../src/responses/beacon_block_response.rs | 21 ++--- 4 files changed, 98 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c472ff031..076dcb94e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,12 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + [[package]] name = "async-stream" version = "0.3.3" @@ -287,6 +293,12 @@ dependencies = [ "signature", ] +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + [[package]] name = "elliptic-curve" version = "0.12.3" @@ -344,18 +356,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "eth-beacon-light-client-primitives" -version = "0.1.0" -dependencies = [ - "base2", - "ethereum-consensus", -] - -[[package]] -name = "eth-beacon-light-client-verifier" -version = "0.1.0" - [[package]] name = "ethereum-consensus" version = "0.1.1" @@ -376,7 +376,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.9.9", - "ssz-rs", + "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", "thiserror", "tokio", "tokio-stream", @@ -559,6 +559,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + [[package]] name = "hmac" version = "0.12.1" @@ -696,6 +702,15 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.5" @@ -747,6 +762,27 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "light-client-primitives" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "hex-literal", + "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", +] + +[[package]] +name = "light-client-verifier" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "light-client-primitives", + "milagro_bls", + "ssz-rs 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", +] + [[package]] name = "lock_api" version = "0.4.9" @@ -1399,7 +1435,23 @@ dependencies = [ "num-bigint", "serde", "sha2 0.9.9", - "ssz-rs-derive", + "ssz-rs-derive 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", + "thiserror", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#ab1503da4dd1d93ad1095fbce5e468b79b0eda55" +dependencies = [ + "as-any", + "bitvec", + "hex", + "itertools", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", "thiserror", ] @@ -1413,6 +1465,16 @@ dependencies = [ "syn", ] +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#ab1503da4dd1d93ad1095fbce5e468b79b0eda55" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -1442,6 +1504,7 @@ version = "0.1.0" dependencies = [ "actix-rt", "ethereum-consensus", + "light-client-primitives", "reqwest", "serde", "serde_json", diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index 00b852e6c..ed60d1747 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +light-client-primitives = {path="../light-client-primitives", default-features = false } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 929f49586..2f1e50721 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -7,18 +7,16 @@ use ethereum_consensus::bellatrix::{ }; use reqwest::Client; -//TODO: Remove all these and use the light client primitive consts in the other PR -const MAX_PROPOSER_SLASHINGS: usize = 0; -const MAX_VALIDATORS_PER_COMMITTEE: usize = 0; -const MAX_ATTESTER_SLASHINGS: usize = 0; -const MAX_ATTESTATIONS: usize = 0; -const MAX_DEPOSITS: usize = 0; -const MAX_VOLUNTARY_EXITS: usize = 0; -const SYNC_COMMITTEE_SIZE: usize = 0; -const BYTES_PER_LOGS_BLOOM: usize = 0; -const MAX_EXTRA_DATA_BYTES: usize = 0; -const MAX_BYTES_PER_TRANSACTION: usize = 0; -const MAX_TRANSACTIONS_PER_PAYLOAD: usize = 0; +use ethereum_consensus::bellatrix::mainnet::{ + BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, +}; +use ethereum_consensus::phase0::mainnet::{ + EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, + HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, + SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, +}; pub fn header_route(block_id: String) -> String { format!("/eth/v1/beacon/headers/{}", block_id) diff --git a/sync-committee-prover/src/responses/beacon_block_response.rs b/sync-committee-prover/src/responses/beacon_block_response.rs index b791c356c..5a6a6a1d6 100644 --- a/sync-committee-prover/src/responses/beacon_block_response.rs +++ b/sync-committee-prover/src/responses/beacon_block_response.rs @@ -1,17 +1,16 @@ +use ethereum_consensus::bellatrix::mainnet::{ + BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, +}; use ethereum_consensus::bellatrix::{BeaconBlock, BeaconBlockHeader}; +use ethereum_consensus::phase0::mainnet::{ + EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, + HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, + SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, +}; //TODO: Remove all these and use the light client primitive consts in the other PR -const MAX_PROPOSER_SLASHINGS: usize = 0; -const MAX_VALIDATORS_PER_COMMITTEE: usize = 0; -const MAX_ATTESTER_SLASHINGS: usize = 0; -const MAX_ATTESTATIONS: usize = 0; -const MAX_DEPOSITS: usize = 0; -const MAX_VOLUNTARY_EXITS: usize = 0; -const SYNC_COMMITTEE_SIZE: usize = 0; -const BYTES_PER_LOGS_BLOOM: usize = 0; -const MAX_EXTRA_DATA_BYTES: usize = 0; -const MAX_BYTES_PER_TRANSACTION: usize = 0; -const MAX_TRANSACTIONS_PER_PAYLOAD: usize = 0; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { From 93ad1b8a7dbc391dbf0c790ee86da544adbb00fc Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 26 Jan 2023 01:41:29 +0100 Subject: [PATCH 029/100] implement and test beacon block implement sync committee --- Cargo.lock | 1942 ----------------- light-client-primitives/Cargo.toml | 3 +- light-client-verifier/Cargo.toml | 3 +- sync-committee-prover/Cargo.toml | 3 +- sync-committee-prover/src/lib.rs | 43 +- .../src/responses/beacon_block_response.rs | 4 - sync-committee-prover/src/responses/mod.rs | 1 + .../src/responses/sync_committee_response.rs | 11 + sync-committee-prover/src/test.rs | 13 +- 9 files changed, 54 insertions(+), 1969 deletions(-) delete mode 100644 Cargo.lock create mode 100644 sync-committee-prover/src/responses/sync_committee_response.rs diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 076dcb94e..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,1942 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "actix-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" -dependencies = [ - "actix-macros", - "futures-core", - "tokio", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", -] - -[[package]] -name = "amcl" -version = "0.3.0" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "as-any" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" - -[[package]] -name = "async-stream" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" -dependencies = [ - "async-stream-impl", - "futures-core", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base2" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" -dependencies = [ - "int", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" - -[[package]] -name = "base64ct" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "bumpalo" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" - -[[package]] -name = "cc" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const-oid" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "core2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" -dependencies = [ - "memchr", -] - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "data-encoding" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer 0.10.3", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.6", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "encoding_rs" -version = "0.8.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "enr" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" -dependencies = [ - "base64 0.13.1", - "bs58", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "version_check", -] - -[[package]] -name = "ethereum-consensus" -version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#248b5d1e53d87fde1d9368dc25ad483633ef0e4a" -dependencies = [ - "async-stream", - "bs58", - "enr", - "error-chain", - "getrandom", - "hashbrown 0.13.2", - "hex", - "integer-sqrt", - "milagro_bls", - "multiaddr", - "multihash", - "rand", - "serde", - "serde_json", - "sha2 0.9.9", - "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", - "thiserror", - "tokio", - "tokio-stream", -] - -[[package]] -name = "fastrand" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" -dependencies = [ - "instant", -] - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures-channel" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" - -[[package]] -name = "futures-sink" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" - -[[package]] -name = "futures-task" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" - -[[package]] -name = "futures-util" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" -dependencies = [ - "futures-core", - "futures-task", - "pin-project-lite", - "pin-utils", -] - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "h2" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.6", -] - -[[package]] -name = "http" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "ics15-ethereum" -version = "0.1.0" - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "int" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" -dependencies = [ - "num-traits", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "ipnet" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" - -[[package]] -name = "js-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "keccak" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "light-client-primitives" -version = "0.1.0" -dependencies = [ - "base2", - "ethereum-consensus", - "hex-literal", - "ssz-rs 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", -] - -[[package]] -name = "light-client-verifier" -version = "0.1.0" -dependencies = [ - "base2", - "ethereum-consensus", - "light-client-primitives", - "milagro_bls", - "ssz-rs 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", -] - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "milagro_bls" -version = "1.5.1" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" -dependencies = [ - "amcl", - "rand", - "zeroize", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mio" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys", -] - -[[package]] -name = "multiaddr" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" -dependencies = [ - "arrayref", - "bs58", - "byteorder", - "data-encoding", - "multihash", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - -[[package]] -name = "multihash" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" -dependencies = [ - "core2", - "digest 0.10.6", - "multihash-derive", - "sha2 0.10.6", - "unsigned-varint", -] - -[[package]] -name = "multihash-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "reqwest" -version = "0.11.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" -dependencies = [ - "base64 0.21.0", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rustc-hex", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "ryu" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" - -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "security-framework" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.6", -] - -[[package]] -name = "sha3" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" -dependencies = [ - "digest 0.10.6", - "keccak", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.6", - "rand_core", -] - -[[package]] -name = "slab" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "ssz-rs" -version = "0.8.0" -source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" -dependencies = [ - "bitvec", - "hex", - "lazy_static", - "num-bigint", - "serde", - "sha2 0.9.9", - "ssz-rs-derive 0.8.0 (git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution)", - "thiserror", -] - -[[package]] -name = "ssz-rs" -version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#ab1503da4dd1d93ad1095fbce5e468b79b0eda55" -dependencies = [ - "as-any", - "bitvec", - "hex", - "itertools", - "num-bigint", - "serde", - "sha2 0.9.9", - "ssz-rs-derive 0.8.0 (git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1)", - "thiserror", -] - -[[package]] -name = "ssz-rs-derive" -version = "0.8.0" -source = "git+https://github.com/Snowfork/ssz_rs?branch=feat/contribution#ea113b48f3ad134603f11c9be9f5fc696d30c259" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ssz-rs-derive" -version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#ab1503da4dd1d93ad1095fbce5e468b79b0eda55" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync-committee-prover" -version = "0.1.0" -dependencies = [ - "actix-rt", - "ethereum-consensus", - "light-client-primitives", - "reqwest", - "serde", - "serde_json", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" -dependencies = [ - "cfg-if", - "fastrand", - "libc", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "1.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys", -] - -[[package]] -name = "tokio-macros" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "unicode-bidi" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "unsigned-varint" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" - -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - -[[package]] -name = "web-sys" -version = "0.3.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "zeroize" -version = "1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index 3852ccb25..4cec7a852 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -7,7 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +ethereum-consensus = { path = "../../ethereum-consensus", default-features = false} base2 = {version="0.2.2", default-features=false} ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 99fd897df..29228c598 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -7,7 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +ethereum-consensus = { path = "../../ethereum-consensus" } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index ed60d1747..6a24dfadd 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -6,7 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +ethereum-consensus = { path = "../../ethereum-consensus" } light-client-primitives = {path="../light-client-primitives", default-features = false } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 2f1e50721..69296ce66 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -81,23 +81,24 @@ impl SyncCommitteeProver { let response = self.client.get(full_url).send().await?; - let beacon_block = response - .json::>() - .await; - - beacon_block + println!("gotten response, deserializzing..."); + println!("Response status {}", response.status()); + + let response_data = response + .json::() + .await?; + + println!("response data is {:?}", response_data); + + //println!("Response data {:?}", response.text().await); + + //TODO: proceess error + //let beacon_block_header = response_data.header.unwrap().message; + + + let beacon_block = response_data.data.message; + + Ok(beacon_block) } pub async fn fetch_sync_committee( &self, @@ -108,9 +109,13 @@ impl SyncCommitteeProver { let response = self.client.get(full_url).send().await?; - let sync_committee = response.json::>().await; + let response_data = response + .json::() + .await.unwrap(); + + let sync_committee = response_data.data; - sync_committee + Ok(sync_committee) } /*pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ diff --git a/sync-committee-prover/src/responses/beacon_block_response.rs b/sync-committee-prover/src/responses/beacon_block_response.rs index 5a6a6a1d6..e4f1a19c6 100644 --- a/sync-committee-prover/src/responses/beacon_block_response.rs +++ b/sync-committee-prover/src/responses/beacon_block_response.rs @@ -10,8 +10,6 @@ use ethereum_consensus::phase0::mainnet::{ SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }; -//TODO: Remove all these and use the light client primitive consts in the other PR - #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { pub(crate) data: ResponseData, @@ -21,8 +19,6 @@ pub struct Response { #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ResponseData { - root: String, - canonical: bool, pub(crate) message: BeaconBlock< MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs index 15a351a34..ab769a6ec 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/sync-committee-prover/src/responses/mod.rs @@ -1,2 +1,3 @@ pub mod beacon_block_header_response; pub mod beacon_block_response; +pub mod sync_committee_response; diff --git a/sync-committee-prover/src/responses/sync_committee_response.rs b/sync-committee-prover/src/responses/sync_committee_response.rs new file mode 100644 index 000000000..17f7ababe --- /dev/null +++ b/sync-committee-prover/src/responses/sync_committee_response.rs @@ -0,0 +1,11 @@ +use ethereum_consensus::bellatrix::mainnet::{ + SYNC_COMMITTEE_SIZE, +}; +use ethereum_consensus::bellatrix::{SyncCommittee}; + + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + pub(crate) data: SyncCommittee, + execution_optimistic: bool, +} diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 014581440..bfc06e87b 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -3,9 +3,20 @@ use super::*; #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -async fn fetches_block_header_works() { +async fn fetch_block_header_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let block_header = sync_committee_prover.fetch_header("100".to_string()).await; assert!(block_header.is_ok()); } + + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_sync_committee_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block = sync_committee_prover.fetch_sync_committee("117".to_string()).await; + assert!(block.is_ok()); +} From 6a234e3403c84cde31697f230241c27d615c7c1c Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 27 Jan 2023 02:21:15 +0100 Subject: [PATCH 030/100] node sync committee fetch validator --- light-client-primitives/Cargo.toml | 4 +-- light-client-verifier/Cargo.toml | 4 +-- sync-committee-prover/Cargo.toml | 5 +-- sync-committee-prover/src/lib.rs | 31 +++++++++++++++++-- sync-committee-prover/src/responses/mod.rs | 1 + .../src/responses/sync_committee_response.rs | 14 ++++----- .../src/responses/validator_response.rs | 15 +++++++++ sync-committee-prover/src/test.rs | 26 +++++++++++++++- 8 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 sync-committee-prover/src/responses/validator_response.rs diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index 4cec7a852..e127bd017 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } -ethereum-consensus = { path = "../../ethereum-consensus", default-features = false} +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } +#ethereum-consensus = { path = "../../ethereum-consensus", default-features = false} base2 = {version="0.2.2", default-features=false} ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 29228c598..51736979f 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -ethereum-consensus = { path = "../../ethereum-consensus" } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +#ethereum-consensus = { path = "../../ethereum-consensus" } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index 6a24dfadd..c8fbafa87 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -6,9 +6,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -#ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -ethereum-consensus = { path = "../../ethereum-consensus" } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +#ethereum-consensus = { path = "../../ethereum-consensus" } light-client-primitives = {path="../light-client-primitives", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 69296ce66..8b2f397fb 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -2,11 +2,13 @@ mod responses; #[cfg(test)] mod test; +use ethereum_consensus::altair::Validator; use ethereum_consensus::bellatrix::{ BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, }; use reqwest::Client; +use crate::responses::sync_committee_response::NodeSyncCommittee; use ethereum_consensus::bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, @@ -30,6 +32,10 @@ pub fn sync_committee_route(state_id: String) -> String { format!("/eth/v1/beacon/states/{}/sync_committees", state_id) } +pub fn validator_route(state_id: String, validator_index: String) -> String { + format!("/eth/v1/beacon/states/{}/validators/{}", state_id, validator_index) +} + pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, @@ -95,7 +101,6 @@ impl SyncCommitteeProver { //TODO: proceess error //let beacon_block_header = response_data.header.unwrap().message; - let beacon_block = response_data.data.message; Ok(beacon_block) @@ -103,7 +108,7 @@ impl SyncCommitteeProver { pub async fn fetch_sync_committee( &self, state_id: String, - ) -> Result, reqwest::Error> { + ) -> Result { let path = sync_committee_route(state_id); let full_url = format!("{}/{}", self.node_url.clone(), path); @@ -111,12 +116,32 @@ impl SyncCommitteeProver { let response_data = response .json::() - .await.unwrap(); + .await + .unwrap(); let sync_committee = response_data.data; Ok(sync_committee) } + pub async fn fetch_validator( + &self, + state_id: String, + validator_index: String, + ) -> Result { + let path = validator_route(state_id, validator_index); + let full_url = format!("{}/{}", self.node_url.clone(), path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response + .json::() + .await + .unwrap(); + + let validator= response_data.data.validator; + + Ok(validator) + } /*pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ } diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs index ab769a6ec..41b26cd36 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/sync-committee-prover/src/responses/mod.rs @@ -1,3 +1,4 @@ pub mod beacon_block_header_response; pub mod beacon_block_response; pub mod sync_committee_response; +pub mod validator_response; diff --git a/sync-committee-prover/src/responses/sync_committee_response.rs b/sync-committee-prover/src/responses/sync_committee_response.rs index 17f7ababe..80bbcd7d8 100644 --- a/sync-committee-prover/src/responses/sync_committee_response.rs +++ b/sync-committee-prover/src/responses/sync_committee_response.rs @@ -1,11 +1,11 @@ -use ethereum_consensus::bellatrix::mainnet::{ - SYNC_COMMITTEE_SIZE, -}; -use ethereum_consensus::bellatrix::{SyncCommittee}; - - #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { - pub(crate) data: SyncCommittee, + pub(crate) data: NodeSyncCommittee, execution_optimistic: bool, } + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct NodeSyncCommittee { + pub validators: Vec, + pub validator_aggregates: Vec>, +} diff --git a/sync-committee-prover/src/responses/validator_response.rs b/sync-committee-prover/src/responses/validator_response.rs new file mode 100644 index 000000000..4422a4b8f --- /dev/null +++ b/sync-committee-prover/src/responses/validator_response.rs @@ -0,0 +1,15 @@ +use ethereum_consensus::bellatrix::Validator; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + pub(crate) data: ValidatorData, + execution_optimistic: bool, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ValidatorData { + pub index: String, + pub balance: String, + pub status: String, + pub(crate) validator: Validator, +} diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index bfc06e87b..068dc8467 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -10,6 +10,15 @@ async fn fetch_block_header_works() { assert!(block_header.is_ok()); } +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_block_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block = sync_committee_prover.fetch_block("100".to_string()).await; + assert!(block.is_ok()); +} #[cfg(test)] #[allow(non_snake_case)] @@ -17,6 +26,21 @@ async fn fetch_block_header_works() { async fn fetch_sync_committee_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_sync_committee("117".to_string()).await; + let block = sync_committee_prover + .fetch_sync_committee("117".to_string()) + .await; assert!(block.is_ok()); } + + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_validator_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let validator = sync_committee_prover + .fetch_validator("2561".to_string(), "48".to_string()) + .await; + assert!(validator.is_ok()); +} From 1d6b75bdc7ea280a8e82d72c0308d299b6dcd43d Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 27 Jan 2023 03:16:43 +0100 Subject: [PATCH 031/100] processed sync committees --- sync-committee-prover/Cargo.toml | 4 ++- sync-committee-prover/src/lib.rs | 44 +++++++++++++++++++++++++++++-- sync-committee-prover/src/test.rs | 13 ++++++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index c8fbafa87..be7b0e655 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -9,7 +9,9 @@ edition = "2021" ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } #ethereum-consensus = { path = "../../ethereum-consensus" } light-client-primitives = {path="../light-client-primitives", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } +#ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } +ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } + reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 8b2f397fb..4e96d4644 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -13,12 +13,15 @@ use ethereum_consensus::bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, }; +use ethereum_consensus::crypto::{eth_aggregate_public_keys, PublicKey}; use ethereum_consensus::phase0::mainnet::{ EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }; +use ethereum_consensus::primitives::{BlsPublicKey, ValidatorIndex}; +use ssz_rs::{List, Vector}; pub fn header_route(block_id: String) -> String { format!("/eth/v1/beacon/headers/{}", block_id) @@ -33,7 +36,10 @@ pub fn sync_committee_route(state_id: String) -> String { } pub fn validator_route(state_id: String, validator_index: String) -> String { - format!("/eth/v1/beacon/states/{}/validators/{}", state_id, validator_index) + format!( + "/eth/v1/beacon/states/{}/validators/{}", + state_id, validator_index + ) } pub struct SyncCommitteeProver { @@ -138,10 +144,44 @@ impl SyncCommitteeProver { .await .unwrap(); - let validator= response_data.data.validator; + let validator = response_data.data.validator; Ok(validator) } + + pub async fn fetch_processed_sync_committee( + &self, + state_id: String, + ) -> Result, reqwest::Error> { + // fetches sync committee from Noe + let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; + + let mut validators: List = Default::default(); + let mut validator_indexes: Vec = Vec::new(); + + for mut validator_index in node_sync_committee.validators { + // fetches validator based on validator index + let validator = self + .fetch_validator(state_id.clone(), validator_index.clone()) + .await?; + validators.push(validator); + validator_indexes.push(validator_index.parse().unwrap()); + } + + let public_keys_vector = validator_indexes + .into_iter() + .map(|i| validators[i].public_key.clone()) + .collect::>(); + + let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); + + let sync_committee = SyncCommittee:: { + public_keys: public_keys_vector, + aggregate_public_key, + }; + + Ok(sync_committee) + } /*pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ } diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 068dc8467..9c863e320 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -32,7 +32,6 @@ async fn fetch_sync_committee_works() { assert!(block.is_ok()); } - #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] @@ -44,3 +43,15 @@ async fn fetch_validator_works() { .await; assert!(validator.is_ok()); } + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_processed_sync_committee_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let validator = sync_committee_prover + .fetch_processed_sync_committee("2561".to_string()) + .await; + assert!(validator.is_ok()); +} From 2ee656219ccd618e07f4463664d420f0045665ac Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 28 Jan 2023 20:48:48 +0100 Subject: [PATCH 032/100] signed beacon block signed beacon block header --- sync-committee-prover/src/lib.rs | 112 ++++++++++++++++++++++++++---- sync-committee-prover/src/test.rs | 35 ++++++++++ 2 files changed, 133 insertions(+), 14 deletions(-) diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 4e96d4644..99d78579a 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -13,7 +13,7 @@ use ethereum_consensus::bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, }; -use ethereum_consensus::crypto::{eth_aggregate_public_keys, PublicKey}; +use ethereum_consensus::crypto::{aggregate, eth_aggregate_public_keys, PublicKey}; use ethereum_consensus::phase0::mainnet::{ EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, @@ -42,6 +42,12 @@ pub fn validator_route(state_id: String, validator_index: String) -> String { ) } +#[derive(Debug)] +pub enum Error { + AggregateSignatureError, + EmptySignedBeaconBlock, +} + pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, @@ -93,20 +99,10 @@ impl SyncCommitteeProver { let response = self.client.get(full_url).send().await?; - println!("gotten response, deserializzing..."); - println!("Response status {}", response.status()); - let response_data = response .json::() .await?; - println!("response data is {:?}", response_data); - - //println!("Response data {:?}", response.text().await); - - //TODO: proceess error - //let beacon_block_header = response_data.header.unwrap().message; - let beacon_block = response_data.data.message; Ok(beacon_block) @@ -153,7 +149,7 @@ impl SyncCommitteeProver { &self, state_id: String, ) -> Result, reqwest::Error> { - // fetches sync committee from Noe + // fetches sync committee from Node let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; let mut validators: List = Default::default(); @@ -182,6 +178,94 @@ impl SyncCommitteeProver { Ok(sync_committee) } - /*pub fn signed_beacon_block(beacon_block: BeaconBlock) -> SignedBeaconBlock { } - pub fn signed_beacon_block_header(beacon_block: SignedBeaconBlock) -> SignedBeaconBlockHeader { }*/ + + pub fn signed_beacon_block( + &self, + beacon_block: BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + ) -> Option< + SignedBeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + > { + let attestations = beacon_block.body.attestations.clone(); + let signatures: Vec<_> = attestations + .iter() + .map(|sig| sig.signature.clone()) + .collect(); + + let aggregate_signature = + aggregate(signatures.as_ref()).map_err(|_| Error::AggregateSignatureError); + + let signed_beacon_block = SignedBeaconBlock::< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + > { + message: beacon_block, + signature: aggregate_signature.unwrap(), + }; + + Some(signed_beacon_block) + } + + pub fn signed_beacon_block_header( + &self, + signed_beacon_block: Option< + SignedBeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + >, + beacon_block_header: BeaconBlockHeader, + ) -> Result { + if signed_beacon_block.is_none() { + return Err(Error::EmptySignedBeaconBlock); + } + + let signed_beacon_block_header = SignedBeaconBlockHeader { + message: beacon_block_header, + signature: signed_beacon_block.unwrap().signature, + }; + + Ok(signed_beacon_block_header) + } } diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 9c863e320..3d1dce550 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -55,3 +55,38 @@ async fn fetch_processed_sync_committee_works() { .await; assert!(validator.is_ok()); } + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_signed_beacon_block_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block = sync_committee_prover.fetch_block("100".to_string()).await; + assert!(block.is_ok()); + let signed_beacon_block = sync_committee_prover.signed_beacon_block(block.unwrap()); + assert!(signed_beacon_block.is_some()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_signed_beacon_block_header_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + // fetch beacon block header + let header = sync_committee_prover.fetch_header("100".to_string()).await; + assert!(header.is_ok()); + + // fetch block + let block = sync_committee_prover.fetch_block("100".to_string()).await; + assert!(block.is_ok()); + // fetch signed beacon block + let signed_beacon_block = sync_committee_prover.signed_beacon_block(block.unwrap()); + assert!(signed_beacon_block.is_some()); + + // fetch sigend beacon block header + let signed_beacon_block_header = + sync_committee_prover.signed_beacon_block_header(signed_beacon_block, header.unwrap()); + assert!(signed_beacon_block_header.is_ok()); +} From 09f3999df9cec9d27d817e5709b23f426f6b345d Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 28 Jan 2023 20:55:50 +0100 Subject: [PATCH 033/100] error in it's crate --- light-client-primitives/Cargo.toml | 1 - light-client-verifier/Cargo.toml | 1 - sync-committee-prover/Cargo.toml | 2 -- sync-committee-prover/src/error.rs | 5 +++++ sync-committee-prover/src/lib.rs | 8 ++------ 5 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 sync-committee-prover/src/error.rs diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index e127bd017..3852ccb25 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -8,7 +8,6 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } -#ethereum-consensus = { path = "../../ethereum-consensus", default-features = false} base2 = {version="0.2.2", default-features=false} ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 51736979f..99fd897df 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -8,7 +8,6 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -#ethereum-consensus = { path = "../../ethereum-consensus" } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index be7b0e655..f44854438 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -7,9 +7,7 @@ edition = "2021" [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -#ethereum-consensus = { path = "../../ethereum-consensus" } light-client-primitives = {path="../light-client-primitives", default-features = false } -#ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} diff --git a/sync-committee-prover/src/error.rs b/sync-committee-prover/src/error.rs new file mode 100644 index 000000000..9ec588852 --- /dev/null +++ b/sync-committee-prover/src/error.rs @@ -0,0 +1,5 @@ +#[derive(Debug)] +pub enum Error { + AggregateSignatureError, + EmptySignedBeaconBlock, +} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 99d78579a..862f63a27 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -1,3 +1,4 @@ +mod error; mod responses; #[cfg(test)] mod test; @@ -8,6 +9,7 @@ use ethereum_consensus::bellatrix::{ }; use reqwest::Client; +use crate::error::Error; use crate::responses::sync_committee_response::NodeSyncCommittee; use ethereum_consensus::bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, @@ -42,12 +44,6 @@ pub fn validator_route(state_id: String, validator_index: String) -> String { ) } -#[derive(Debug)] -pub enum Error { - AggregateSignatureError, - EmptySignedBeaconBlock, -} - pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, From a166df20b6ab9741b098e2053a59cf6a45d0262b Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 28 Jan 2023 20:59:01 +0100 Subject: [PATCH 034/100] routes in it's crate --- sync-committee-prover/src/lib.rs | 21 ++------------------- sync-committee-prover/src/routes.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 sync-committee-prover/src/routes.rs diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 862f63a27..5cc5b1b40 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -1,5 +1,6 @@ mod error; mod responses; +mod routes; #[cfg(test)] mod test; @@ -11,6 +12,7 @@ use reqwest::Client; use crate::error::Error; use crate::responses::sync_committee_response::NodeSyncCommittee; +use crate::routes::*; use ethereum_consensus::bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, @@ -25,25 +27,6 @@ use ethereum_consensus::phase0::mainnet::{ use ethereum_consensus::primitives::{BlsPublicKey, ValidatorIndex}; use ssz_rs::{List, Vector}; -pub fn header_route(block_id: String) -> String { - format!("/eth/v1/beacon/headers/{}", block_id) -} - -pub fn block_route(block_id: String) -> String { - format!("/eth/v2/beacon/blocks/{}", block_id) -} - -pub fn sync_committee_route(state_id: String) -> String { - format!("/eth/v1/beacon/states/{}/sync_committees", state_id) -} - -pub fn validator_route(state_id: String, validator_index: String) -> String { - format!( - "/eth/v1/beacon/states/{}/validators/{}", - state_id, validator_index - ) -} - pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, diff --git a/sync-committee-prover/src/routes.rs b/sync-committee-prover/src/routes.rs new file mode 100644 index 000000000..e47b31607 --- /dev/null +++ b/sync-committee-prover/src/routes.rs @@ -0,0 +1,18 @@ +pub fn header_route(block_id: String) -> String { + format!("/eth/v1/beacon/headers/{}", block_id) +} + +pub fn block_route(block_id: String) -> String { + format!("/eth/v2/beacon/blocks/{}", block_id) +} + +pub fn sync_committee_route(state_id: String) -> String { + format!("/eth/v1/beacon/states/{}/sync_committees", state_id) +} + +pub fn validator_route(state_id: String, validator_index: String) -> String { + format!( + "/eth/v1/beacon/states/{}/validators/{}", + state_id, validator_index + ) +} From 8f516d2f2d150062ab5f24e449e51f7a14ec913d Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 28 Jan 2023 21:03:28 +0100 Subject: [PATCH 035/100] use types for SignedBeaconBlock and BeaconBlock --- sync-committee-prover/src/lib.rs | 84 ++++++++++++-------------------- 1 file changed, 32 insertions(+), 52 deletions(-) diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 5cc5b1b40..30c11d162 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -27,6 +27,34 @@ use ethereum_consensus::phase0::mainnet::{ use ethereum_consensus::primitives::{BlsPublicKey, ValidatorIndex}; use ssz_rs::{List, Vector}; +type BeaconBlockType = BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + +type SignedBeaconBlockType = SignedBeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, @@ -160,33 +188,9 @@ impl SyncCommitteeProver { pub fn signed_beacon_block( &self, - beacon_block: BeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, + beacon_block: BeaconBlockType ) -> Option< - SignedBeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, + SignedBeaconBlockType, > { let attestations = beacon_block.body.attestations.clone(); let signatures: Vec<_> = attestations @@ -197,19 +201,7 @@ impl SyncCommitteeProver { let aggregate_signature = aggregate(signatures.as_ref()).map_err(|_| Error::AggregateSignatureError); - let signed_beacon_block = SignedBeaconBlock::< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - > { + let signed_beacon_block = SignedBeaconBlockType { message: beacon_block, signature: aggregate_signature.unwrap(), }; @@ -220,19 +212,7 @@ impl SyncCommitteeProver { pub fn signed_beacon_block_header( &self, signed_beacon_block: Option< - SignedBeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, + SignedBeaconBlockType >, beacon_block_header: BeaconBlockHeader, ) -> Result { From 5f477103596384088cb52273b2f7494402967302 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 31 Jan 2023 00:05:11 +0100 Subject: [PATCH 036/100] fetch beacon state --- sync-committee-prover/Cargo.toml | 1 - sync-committee-prover/src/lib.rs | 55 ++++++++++++++----- .../src/responses/beacon_state_response.rs | 26 +++++++++ sync-committee-prover/src/responses/mod.rs | 1 + sync-committee-prover/src/routes.rs | 3 + sync-committee-prover/src/test.rs | 12 ++++ 6 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 sync-committee-prover/src/responses/beacon_state_response.rs diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index f44854438..69380d04e 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -9,7 +9,6 @@ edition = "2021" ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } light-client-primitives = {path="../light-client-primitives", default-features = false } ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } - reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 30c11d162..ee545ea1b 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -6,7 +6,8 @@ mod test; use ethereum_consensus::altair::Validator; use ethereum_consensus::bellatrix::{ - BeaconBlock, BeaconBlockHeader, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, + BeaconBlock, BeaconBlockHeader, BeaconState, SignedBeaconBlock, SignedBeaconBlockHeader, + SyncCommittee, }; use reqwest::Client; @@ -41,7 +42,7 @@ type BeaconBlockType = BeaconBlock< MAX_TRANSACTIONS_PER_PAYLOAD, >; -type SignedBeaconBlockType = SignedBeaconBlock< +type SignedBeaconBlockType = SignedBeaconBlock< MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_ATTESTER_SLASHINGS, @@ -125,8 +126,7 @@ impl SyncCommitteeProver { let response_data = response .json::() - .await - .unwrap(); + .await?; let sync_committee = response_data.data; @@ -144,14 +144,47 @@ impl SyncCommitteeProver { let response_data = response .json::() - .await - .unwrap(); + .await?; let validator = response_data.data.validator; Ok(validator) } + pub async fn fetch_beacon_state( + &self, + state_id: String, + ) -> Result< + BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + reqwest::Error, + > { + let path = beacon_state_route(state_id); + let full_url = format!("{}/{}", self.node_url.clone(), path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response + .json::() + .await?; + + let beacon_state = response_data.data; + + Ok(beacon_state) + } + pub async fn fetch_processed_sync_committee( &self, state_id: String, @@ -188,10 +221,8 @@ impl SyncCommitteeProver { pub fn signed_beacon_block( &self, - beacon_block: BeaconBlockType - ) -> Option< - SignedBeaconBlockType, - > { + beacon_block: BeaconBlockType, + ) -> Option { let attestations = beacon_block.body.attestations.clone(); let signatures: Vec<_> = attestations .iter() @@ -211,9 +242,7 @@ impl SyncCommitteeProver { pub fn signed_beacon_block_header( &self, - signed_beacon_block: Option< - SignedBeaconBlockType - >, + signed_beacon_block: Option, beacon_block_header: BeaconBlockHeader, ) -> Result { if signed_beacon_block.is_none() { diff --git a/sync-committee-prover/src/responses/beacon_state_response.rs b/sync-committee-prover/src/responses/beacon_state_response.rs new file mode 100644 index 000000000..d9155750b --- /dev/null +++ b/sync-committee-prover/src/responses/beacon_state_response.rs @@ -0,0 +1,26 @@ +use ethereum_consensus::bellatrix::BeaconState; + +use ethereum_consensus::bellatrix::mainnet::{ + BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, + ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, MAX_VALIDATORS_PER_COMMITTEE, SLOTS_PER_HISTORICAL_ROOT, + SYNC_COMMITTEE_SIZE, VALIDATOR_REGISTRY_LIMIT, +}; +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + version: String, + pub(crate) data: BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, +} diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs index 41b26cd36..2b5846289 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/sync-committee-prover/src/responses/mod.rs @@ -1,4 +1,5 @@ pub mod beacon_block_header_response; pub mod beacon_block_response; +pub mod beacon_state_response; pub mod sync_committee_response; pub mod validator_response; diff --git a/sync-committee-prover/src/routes.rs b/sync-committee-prover/src/routes.rs index e47b31607..d536a9e93 100644 --- a/sync-committee-prover/src/routes.rs +++ b/sync-committee-prover/src/routes.rs @@ -16,3 +16,6 @@ pub fn validator_route(state_id: String, validator_index: String) -> String { state_id, validator_index ) } +pub fn beacon_state_route(state_id: String) -> String { + format!("/eth/v2/debug/beacon/states/{}", state_id) +} diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 3d1dce550..cc221f7f4 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -90,3 +90,15 @@ async fn fetch_signed_beacon_block_header_works() { sync_committee_prover.signed_beacon_block_header(signed_beacon_block, header.unwrap()); assert!(signed_beacon_block_header.is_ok()); } + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_beacon_state_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let beacon_state = sync_committee_prover + .fetch_beacon_state("genesis".to_string()) + .await; + assert!(beacon_state.is_ok()); +} From ace675f22c587b693138fdaeddf5167a30367d7f Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 31 Jan 2023 15:59:50 +0100 Subject: [PATCH 037/100] state root and block header root matches --- sync-committee-prover/src/test.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index cc221f7f4..623c9200b 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -1,4 +1,5 @@ use super::*; +use ssz_rs::Merkleized; #[cfg(test)] #[allow(non_snake_case)] @@ -102,3 +103,25 @@ async fn fetch_beacon_state_works() { .await; assert!(beacon_state.is_ok()); } + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn state_root_and_block_header_root_matches() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let beacon_state = sync_committee_prover + .fetch_beacon_state("100".to_string()) + .await; + assert!(beacon_state.is_ok()); + + let block_header = sync_committee_prover.fetch_header("100".to_string()).await; + assert!(block_header.is_ok()); + + let state = beacon_state.unwrap(); + let block_header = block_header.unwrap(); + let hash_tree_root = state.clone().hash_tree_root(); + + assert!(block_header.state_root == hash_tree_root.unwrap()); + +} From f370fea3c04786d8a8d49f329aa70ca14d787c75 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 31 Jan 2023 22:55:58 +0100 Subject: [PATCH 038/100] remove redundant index storage introduce helper function --- sync-committee-prover/src/lib.rs | 27 ++++++++++++++++----------- sync-committee-prover/src/test.rs | 3 +-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index ee545ea1b..cd679dc5e 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -73,7 +73,7 @@ impl SyncCommitteeProver { block_id: String, ) -> Result { let path = header_route(block_id); - let full_url = format!("{}{}", self.node_url.clone(), path); + let full_url = self.generate_route(path); let response = self.client.get(full_url).send().await?; let response_data = response .json::() @@ -103,7 +103,7 @@ impl SyncCommitteeProver { reqwest::Error, > { let path = block_route(block_id); - let full_url = format!("{}/{}", self.node_url.clone(), path); + let full_url = self.generate_route(path); let response = self.client.get(full_url).send().await?; @@ -120,7 +120,7 @@ impl SyncCommitteeProver { state_id: String, ) -> Result { let path = sync_committee_route(state_id); - let full_url = format!("{}/{}", self.node_url.clone(), path); + let full_url = self.generate_route(path); let response = self.client.get(full_url).send().await?; @@ -138,7 +138,7 @@ impl SyncCommitteeProver { validator_index: String, ) -> Result { let path = validator_route(state_id, validator_index); - let full_url = format!("{}/{}", self.node_url.clone(), path); + let full_url = self.generate_route(path); let response = self.client.get(full_url).send().await?; @@ -172,7 +172,7 @@ impl SyncCommitteeProver { reqwest::Error, > { let path = beacon_state_route(state_id); - let full_url = format!("{}/{}", self.node_url.clone(), path); + let full_url = self.generate_route(path); let response = self.client.get(full_url).send().await?; @@ -193,20 +193,21 @@ impl SyncCommitteeProver { let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; let mut validators: List = Default::default(); - let mut validator_indexes: Vec = Vec::new(); - - for mut validator_index in node_sync_committee.validators { + for mut validator_index in node_sync_committee.validators.clone() { // fetches validator based on validator index let validator = self .fetch_validator(state_id.clone(), validator_index.clone()) .await?; validators.push(validator); - validator_indexes.push(validator_index.parse().unwrap()); } - let public_keys_vector = validator_indexes + let public_keys_vector = node_sync_committee + .validators .into_iter() - .map(|i| validators[i].public_key.clone()) + .map(|i| { + let validator_index: ValidatorIndex = i.parse().unwrap(); + validators[validator_index].public_key.clone() + }) .collect::>(); let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); @@ -256,4 +257,8 @@ impl SyncCommitteeProver { Ok(signed_beacon_block_header) } + + fn generate_route(&self, path: String) -> String { + format!("{}{}", self.node_url.clone(), path) + } } diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 623c9200b..44f7205e3 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -120,8 +120,7 @@ async fn state_root_and_block_header_root_matches() { let state = beacon_state.unwrap(); let block_header = block_header.unwrap(); - let hash_tree_root = state.clone().hash_tree_root(); + let hash_tree_root = state.clone().hash_tree_root(); assert!(block_header.state_root == hash_tree_root.unwrap()); - } From b130532ff7497bdf03207a1b3b4995d061a062bf Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 1 Feb 2023 17:42:06 +0100 Subject: [PATCH 039/100] provers --- Cargo.toml | 3 + light-client-primitives/Cargo.toml | 2 +- sync-committee-prover/Cargo.toml | 4 +- sync-committee-prover/src/lib.rs | 127 ++++++++++++++++++++++++----- 4 files changed, 113 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b87e07965..17f68bdd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,6 @@ members = [ "ics15-ethereum", "sync-committee-prover" ] + +[patch."https://github.com/ralexstokes/ssz-rs"] +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "seun/ssz-merkle-multi-proof-phase-1"} diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index 3852ccb25..b58cc2e4a 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -9,5 +9,5 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } base2 = {version="0.2.2", default-features=false} -ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev="ea113b48f3ad134603f11c9be9f5fc696d30c259", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index 69380d04e..c088253fb 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -8,9 +8,11 @@ edition = "2021" [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } light-client-primitives = {path="../light-client-primitives", default-features = false } -ssz-rs = { git = "https://github.com/Snowfork/ssz_rs", branch="feat/contribution", default-features=false, features=["serde", "std"] } +#ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev="ea113b48f3ad134603f11c9be9f5fc696d30c259", default-features=false, features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} +anyhow = "1.0.68" actix-rt = "*" diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index cd679dc5e..4b22efced 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -6,8 +6,8 @@ mod test; use ethereum_consensus::altair::Validator; use ethereum_consensus::bellatrix::{ - BeaconBlock, BeaconBlockHeader, BeaconState, SignedBeaconBlock, SignedBeaconBlockHeader, - SyncCommittee, + BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, SignedBeaconBlock, + SignedBeaconBlockHeader, SyncCommittee, }; use reqwest::Client; @@ -25,8 +25,13 @@ use ethereum_consensus::phase0::mainnet::{ MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }; -use ethereum_consensus::primitives::{BlsPublicKey, ValidatorIndex}; -use ssz_rs::{List, Vector}; +use ethereum_consensus::primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}; +use light_client_primitives::types::{ + ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, +}; +use light_client_primitives::util::get_subtree_index; +use ssz_rs::{List, Node, Vector}; type BeaconBlockType = BeaconBlock< MAX_PROPOSER_SLASHINGS, @@ -56,6 +61,21 @@ type SignedBeaconBlockType = SignedBeaconBlock< MAX_TRANSACTIONS_PER_PAYLOAD, >; +pub type BeaconStateType = BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, @@ -154,23 +174,7 @@ impl SyncCommitteeProver { pub async fn fetch_beacon_state( &self, state_id: String, - ) -> Result< - BeaconState< - SLOTS_PER_HISTORICAL_ROOT, - HISTORICAL_ROOTS_LIMIT, - ETH1_DATA_VOTES_BOUND, - VALIDATOR_REGISTRY_LIMIT, - EPOCHS_PER_HISTORICAL_VECTOR, - EPOCHS_PER_SLASHINGS_VECTOR, - MAX_VALIDATORS_PER_COMMITTEE, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, - reqwest::Error, - > { + ) -> Result { let path = beacon_state_route(state_id); let full_url = self.generate_route(path); @@ -258,7 +262,88 @@ impl SyncCommitteeProver { Ok(signed_beacon_block_header) } + async fn fetch_latest_finalized_block( + &self, + ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { + let block_header = self.fetch_header("finalized".to_string()).await?; + let block = self.fetch_block("finalized".to_string()).await?; + + Ok((block_header, block)) + } + fn generate_route(&self, path: String) -> String { format!("{}{}", self.node_url.clone(), path) } } + +fn get_attestation_slots_for_finalized_header(finalized_header: &BeaconBlockHeader) -> Slot { + let finalized_header_slot = finalized_header.slot; + + // given that an epoch is 32 slots and blocks are finalized every 2 epochs + // so the attested slot for a finalized block is 64 slots away + let attested_slot = finalized_header_slot + 64; + + attested_slot +} + +fn prove_beacon_state_values( + data: BeaconStateType, + indices: &[usize], +) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(data, indices)?; + Ok(proof) +} + +fn prove_beacon_block_values( + data: BeaconBlockType, + indices: &[usize], +) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(data, indices)?; + Ok(proof) +} + +fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result { + let indices = [ + EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, + ]; + // generate multi proofs + let multi_proof = ssz_rs::generate_proof( + block.body.execution_payload.clone(), + indices.as_slice() + )?; + + let execution_payload_index = [get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize]; + let execution_payload_branch = ssz_rs::generate_proof( + block.body.clone(), + execution_payload_index.as_slice(), + )?; + + Ok(ExecutionPayloadProof { + state_root: block.body.execution_payload.state_root, + block_number: block.body.execution_payload.block_number, + multi_proof: multi_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), + execution_payload_branch: execution_payload_branch + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), + }) +} + +fn prove_sync_committee_update_and_finalized_header( + state: BeaconStateType, +) -> anyhow::Result> { + let indices = [ + NEXT_SYNC_COMMITTEE_INDEX as usize, + get_subtree_index(FINALIZED_ROOT_INDEX) as usize, + ]; + let multi_proof = ssz_rs::generate_proof( + state.clone(), + indices.as_slice(), + )?; + + Ok(multi_proof) +} From 5fc5d3a220a7b5d002752e38a2b41c5d39225026 Mon Sep 17 00:00:00 2001 From: Damilare Date: Thu, 2 Feb 2023 00:38:29 +0100 Subject: [PATCH 040/100] fix errors relating ssz-rs --- Cargo.toml | 3 --- light-client-primitives/Cargo.toml | 4 ++-- light-client-verifier/Cargo.toml | 4 ++-- sync-committee-prover/Cargo.toml | 5 ++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 17f68bdd1..b87e07965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,3 @@ members = [ "ics15-ethereum", "sync-committee-prover" ] - -[patch."https://github.com/ralexstokes/ssz-rs"] -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "seun/ssz-merkle-multi-proof-phase-1"} diff --git a/light-client-primitives/Cargo.toml b/light-client-primitives/Cargo.toml index b58cc2e4a..4e83181c9 100644 --- a/light-client-primitives/Cargo.toml +++ b/light-client-primitives/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support", default-features = false } base2 = {version="0.2.2", default-features=false} -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev="ea113b48f3ad134603f11c9be9f5fc696d30c259", default-features=false, features=["serde", "std"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 99fd897df..124982664 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } base2 = {version="0.2.2", default-features=false} light-client-primitives = {path="../light-client-primitives", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index c088253fb..e205045ea 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -6,10 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } light-client-primitives = {path="../light-client-primitives", default-features = false } -#ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="seun/ssz-merkle-multi-proof-phase-1", features=["serde"] } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev="ea113b48f3ad134603f11c9be9f5fc696d30c259", default-features=false, features=["serde", "std"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} From 22dca4f764109ea95147f51f89a33bbef19d5109 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Thu, 2 Feb 2023 10:42:50 +0100 Subject: [PATCH 041/100] remove ics15-ethereum --- Cargo.lock | 1936 +++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 - ics15-ethereum/Cargo.toml | 9 - ics15-ethereum/src/lib.rs | 14 - 4 files changed, 1936 insertions(+), 24 deletions(-) create mode 100644 Cargo.lock delete mode 100644 ics15-ethereum/Cargo.toml delete mode 100644 ics15-ethereum/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..6097dadc3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1936 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64 0.13.1", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#9862cab0797fe80c27f435b5b0313f32c24708da" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown 0.13.2", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "sha2 0.9.9", + "ssz-rs", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" + +[[package]] +name = "futures-sink" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" + +[[package]] +name = "futures-task" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" + +[[package]] +name = "futures-util" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "light-client-primitives" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "hex-literal", + "ssz-rs", +] + +[[package]] +name = "light-client-verifier" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "light-client-primitives", + "milagro_bls", + "ssz-rs", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "rand", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +dependencies = [ + "as-any", + "bitvec", + "hex", + "itertools", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-committee-prover" +version = "0.1.0" +dependencies = [ + "actix-rt", + "anyhow", + "ethereum-consensus", + "light-client-primitives", + "reqwest", + "serde", + "serde_json", + "ssz-rs", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/Cargo.toml b/Cargo.toml index b87e07965..82f538aa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,5 @@ resolver = "2" members = [ "light-client-verifier", "light-client-primitives", - "ics15-ethereum", "sync-committee-prover" ] diff --git a/ics15-ethereum/Cargo.toml b/ics15-ethereum/Cargo.toml deleted file mode 100644 index bc7bf5b27..000000000 --- a/ics15-ethereum/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "ics15-ethereum" -version = "0.1.0" -edition = "2021" -authors = ["Polytope Labs"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/ics15-ethereum/src/lib.rs b/ics15-ethereum/src/lib.rs deleted file mode 100644 index 7d12d9af8..000000000 --- a/ics15-ethereum/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} From 710906b292bf98052b7df1a5d6c20cee6695d1d7 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 4 Feb 2023 09:26:53 +0100 Subject: [PATCH 042/100] test for prover --- light-client-primitives/src/types.rs | 4 +- light-client-verifier/src/light_client.rs | 7 ++ sync-committee-prover/Cargo.toml | 5 + sync-committee-prover/src/lib.rs | 102 ++++++--------- sync-committee-prover/src/test.rs | 145 ++++++++++++++++------ 5 files changed, 162 insertions(+), 101 deletions(-) diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs index 17b63b292..69305e0ee 100644 --- a/light-client-primitives/src/types.rs +++ b/light-client-primitives/src/types.rs @@ -90,7 +90,7 @@ pub struct SyncCommitteeUpdate { // actual sync committee pub next_sync_committee: SyncCommittee, // sync committee, ssz merkle proof. - pub next_sync_committee_branch: [Hash32; NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2], + pub next_sync_committee_branch: Vec, } /// Minimum state required by the light client to validate new sync committee attestations @@ -115,7 +115,7 @@ pub struct LightClientUpdate { /// execution payload of the finalized header pub execution_payload: ExecutionPayloadProof, /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 epochs. - pub finality_branch: [Hash32; FINALIZED_ROOT_INDEX_FLOOR_LOG_2], + pub finality_branch: Vec, /// signature & participation bits pub sync_aggregate: SyncAggregate, /// slot at which signature was produced diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 496505585..f5b69805b 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -3,6 +3,7 @@ use alloc::vec::Vec; use base2::Base2; use core::borrow::Borrow; use core::fmt::{Display, Formatter}; +use ethereum_consensus::altair::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; use ethereum_consensus::altair::mainnet::SYNC_COMMITTEE_SIZE; use ethereum_consensus::bellatrix::compute_domain; use ethereum_consensus::domains::DomainType; @@ -34,6 +35,12 @@ impl EthLightClient { trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { + if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize && + update.sync_committee_update.is_some() && + update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize { + Err(Error::InvalidUpdate)? + } + // Verify sync committee has super majority participants let sync_committee_bits = update.sync_aggregate.sync_committee_bits; let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index e205045ea..728120acd 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] light-client-primitives = {path="../light-client-primitives", default-features = false } +light-client-verifier = {path="../light-client-verifier", default-features = false } ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} @@ -14,4 +15,8 @@ serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} anyhow = "1.0.68" actix-rt = "*" +tokio = { version = "1.18.2", features = ["full"]} +tokio-stream = { version = "0.1.8" } +async-stream = { version = "0.3.3"} + diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 4b22efced..2fbcf76cc 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -26,12 +26,9 @@ use ethereum_consensus::phase0::mainnet::{ SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }; use ethereum_consensus::primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}; -use light_client_primitives::types::{ - ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, -}; +use light_client_primitives::types::{ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, BlockRootsProof}; use light_client_primitives::util::get_subtree_index; -use ssz_rs::{List, Node, Vector}; +use ssz_rs::{Bitlist, List, Node, Vector}; type BeaconBlockType = BeaconBlock< MAX_PROPOSER_SLASHINGS, @@ -224,44 +221,6 @@ impl SyncCommitteeProver { Ok(sync_committee) } - pub fn signed_beacon_block( - &self, - beacon_block: BeaconBlockType, - ) -> Option { - let attestations = beacon_block.body.attestations.clone(); - let signatures: Vec<_> = attestations - .iter() - .map(|sig| sig.signature.clone()) - .collect(); - - let aggregate_signature = - aggregate(signatures.as_ref()).map_err(|_| Error::AggregateSignatureError); - - let signed_beacon_block = SignedBeaconBlockType { - message: beacon_block, - signature: aggregate_signature.unwrap(), - }; - - Some(signed_beacon_block) - } - - pub fn signed_beacon_block_header( - &self, - signed_beacon_block: Option, - beacon_block_header: BeaconBlockHeader, - ) -> Result { - if signed_beacon_block.is_none() { - return Err(Error::EmptySignedBeaconBlock); - } - - let signed_beacon_block_header = SignedBeaconBlockHeader { - message: beacon_block_header, - signature: signed_beacon_block.unwrap().signature, - }; - - Ok(signed_beacon_block_header) - } - async fn fetch_latest_finalized_block( &self, ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { @@ -308,16 +267,12 @@ fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result anyhow::Result anyhow::Result> { - let indices = [ - NEXT_SYNC_COMMITTEE_INDEX as usize, - get_subtree_index(FINALIZED_ROOT_INDEX) as usize, - ]; - let multi_proof = ssz_rs::generate_proof( - state.clone(), - indices.as_slice(), - )?; +fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { + let indices = vec![get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize]; + let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; + + Ok(proof) +} + +fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { + let indices = vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; + let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; + + Ok(proof) +} + +// function that generates block roots proof +// block number and convert to get_subtree_index +// beacon state has a block roots vec, pass the block root to generate proof +fn prove_block_roots_proof(state: BeaconStateType, block_number: u64) -> anyhow::Result { + let indices = vec![get_subtree_index(block_number) as usize]; + let proof = ssz_rs::generate_proof(state.block_roots, indices.as_slice())?; - Ok(multi_proof) + Ok(BlockRootsProof { + block_header_index: block_number, + block_header_branch: proof.into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect() + }) } + +// prove the block roots vec inside the beacon state which will be the block roots branch + + +// when aggr sigs, create a new bit list diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 44f7205e3..f5df415ba 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -1,5 +1,13 @@ use super::*; use ssz_rs::Merkleized; +use tokio_stream::wrappers::IntervalStream; +use std::time::Duration; +use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; +use tokio::time; +use tokio_stream::StreamExt; +use light_client_primitives::types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}; +use light_client_primitives::util::compute_sync_committee_period_at_slot; +use light_client_verifier::light_client::EthLightClient; #[cfg(test)] #[allow(non_snake_case)] @@ -7,7 +15,7 @@ use ssz_rs::Merkleized; async fn fetch_block_header_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_header = sync_committee_prover.fetch_header("100".to_string()).await; + let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await; assert!(block_header.is_ok()); } @@ -57,40 +65,6 @@ async fn fetch_processed_sync_committee_works() { assert!(validator.is_ok()); } -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_signed_beacon_block_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_block("100".to_string()).await; - assert!(block.is_ok()); - let signed_beacon_block = sync_committee_prover.signed_beacon_block(block.unwrap()); - assert!(signed_beacon_block.is_some()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_signed_beacon_block_header_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - // fetch beacon block header - let header = sync_committee_prover.fetch_header("100".to_string()).await; - assert!(header.is_ok()); - - // fetch block - let block = sync_committee_prover.fetch_block("100".to_string()).await; - assert!(block.is_ok()); - // fetch signed beacon block - let signed_beacon_block = sync_committee_prover.signed_beacon_block(block.unwrap()); - assert!(signed_beacon_block.is_some()); - - // fetch sigend beacon block header - let signed_beacon_block_header = - sync_committee_prover.signed_beacon_block_header(signed_beacon_block, header.unwrap()); - assert!(signed_beacon_block_header.is_ok()); -} #[cfg(test)] #[allow(non_snake_case)] @@ -124,3 +98,104 @@ async fn state_root_and_block_header_root_matches() { assert!(block_header.state_root == hash_tree_root.unwrap()); } + +// use tokio interval(should run every 13 minutes) +// every 13 minutes, fetch latest finalized block +// then prove the execution payload +// prove the finality branch + +// prove sync committee if there is a sync committee update +// to prove sync comnmittee update, calculate state_period and the update_attested_period +// ensure they are the same, and then prove sync committee + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_prover() { + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(14 * 60))); + + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await.unwrap(); + + let state = sync_committee_prover.fetch_beacon_state("finalized".to_string()).await.unwrap(); + + let mut client_state = LightClientState { + finalized_header: block_header.clone(), + current_sync_committee: state.current_sync_committee, + next_sync_committee: state.next_sync_committee + }; + + + while let Some(_ts) = stream.next().await { + let block = sync_committee_prover.fetch_block("finalized".to_string()).await; + assert!(block.is_ok()); + + let block = block.unwrap(); + + let execution_payload_proof = prove_execution_payload(block.clone()); + assert!(execution_payload_proof.is_ok()); + + let state = sync_committee_prover.fetch_beacon_state(block.slot.to_string()).await; + assert!(state.is_ok()); + + let state = state.unwrap(); + + let finality_branch_proof = prove_finalized_header(state.clone()).unwrap(); + let finality_branch_proof = finality_branch_proof.into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + //let block_header = sync_committee_prover.fetch_header(block.slot.to_string()).await; + //let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await; + //dbg!(block_header.unwrap()); + //assert!(block_header); + + let block_header = block_header.clone(); + + let state_period = + compute_sync_committee_period_at_slot(block_header.slot); + + let attested_header_slot = get_attestation_slots_for_finalized_header(&block_header); + + let attested_header = sync_committee_prover.fetch_header(attested_header_slot.to_string()).await.unwrap(); + + let update_attested_period = + compute_sync_committee_period_at_slot(attested_header_slot); + + let sync_committee_update = if state_period == attested_header_slot{ + let sync_committee_proof = prove_sync_committee_update(state).unwrap(); + + let sync_committee_proof = sync_committee_proof.into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + + + let sync_committee = sync_committee_prover.fetch_processed_sync_committee(block.slot.to_string()).await; + assert!(sync_committee.is_ok()); + + let sync_committee = sync_committee.unwrap(); + + Some (SyncCommitteeUpdate { + next_sync_committee: sync_committee, + next_sync_committee_branch: sync_committee_proof + }) + } else { + None + }; + + + // construct light client + let light_client_update = LightClientUpdate { + attested_header, + sync_committee_update, + finalized_header: block_header, + execution_payload: execution_payload_proof.unwrap(), + finality_branch: finality_branch_proof, + sync_aggregate: block.body.sync_aggregate, + signature_slot: attested_header_slot, + ancestor_blocks: vec![] + }; + + let new_light_client_state = EthLightClient::verify_sync_committee_attestation(client_state.clone(), light_client_update); + } +} From 88224ddda2b40af14ffce315e1601c479e535c71 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 4 Feb 2023 09:34:15 +0100 Subject: [PATCH 043/100] lock --- Cargo.lock | 1944 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1944 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..75bfcc17e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1944 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.3", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64 0.13.1", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#9862cab0797fe80c27f435b5b0313f32c24708da" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown 0.13.2", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "sha2 0.9.9", + "ssz-rs", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" + +[[package]] +name = "futures-sink" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" + +[[package]] +name = "futures-task" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" + +[[package]] +name = "futures-util" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "ics15-ethereum" +version = "0.1.0" + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "light-client-primitives" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "hex-literal", + "ssz-rs", +] + +[[package]] +name = "light-client-verifier" +version = "0.1.0" +dependencies = [ + "base2", + "ethereum-consensus", + "light-client-primitives", + "milagro_bls", + "ssz-rs", +] + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "rand", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.42.0", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +dependencies = [ + "as-any", + "bitvec", + "hex", + "itertools", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-committee-prover" +version = "0.1.0" +dependencies = [ + "actix-rt", + "anyhow", + "async-stream", + "ethereum-consensus", + "light-client-primitives", + "light-client-verifier", + "reqwest", + "serde", + "serde_json", + "ssz-rs", + "tokio", + "tokio-stream", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.42.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" From 4ae36dd5c77559d4cfc8c51d44ee472cb0e16698 Mon Sep 17 00:00:00 2001 From: David Salami Date: Sat, 4 Feb 2023 11:45:05 +0100 Subject: [PATCH 044/100] try and rewrite integration test --- Cargo.lock | 5 +- light-client-verifier/src/light_client.rs | 17 ++- sync-committee-prover/Cargo.toml | 3 + sync-committee-prover/src/lib.rs | 80 +++++++---- sync-committee-prover/src/routes.rs | 26 ++-- sync-committee-prover/src/test.rs | 164 ++++++++++++---------- 6 files changed, 174 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75bfcc17e..0c5096417 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -651,10 +651,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "ics15-ethereum" -version = "0.1.0" - [[package]] name = "idna" version = "0.3.0" @@ -1478,6 +1474,7 @@ dependencies = [ "anyhow", "async-stream", "ethereum-consensus", + "hex", "light-client-primitives", "light-client-verifier", "reqwest", diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index f5b69805b..93f3496ac 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -3,8 +3,10 @@ use alloc::vec::Vec; use base2::Base2; use core::borrow::Borrow; use core::fmt::{Display, Formatter}; -use ethereum_consensus::altair::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; use ethereum_consensus::altair::mainnet::SYNC_COMMITTEE_SIZE; +use ethereum_consensus::altair::{ + FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, +}; use ethereum_consensus::bellatrix::compute_domain; use ethereum_consensus::domains::DomainType; use ethereum_consensus::primitives::Root; @@ -35,9 +37,16 @@ impl EthLightClient { trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { - if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize && - update.sync_committee_update.is_some() && - update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize { + if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize + && update.sync_committee_update.is_some() + && update + .clone() + .sync_committee_update + .unwrap() + .next_sync_committee_branch + .len() + != NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize + { Err(Error::InvalidUpdate)? } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index 728120acd..fabe30615 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -19,4 +19,7 @@ tokio = { version = "1.18.2", features = ["full"]} tokio-stream = { version = "0.1.8" } async-stream = { version = "0.3.3"} +[dev-dependencies] +hex = "0.4.3" + diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 2fbcf76cc..96a96bde2 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -6,7 +6,7 @@ mod test; use ethereum_consensus::altair::Validator; use ethereum_consensus::bellatrix::{ - BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, SignedBeaconBlock, + BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, Checkpoint, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, }; use reqwest::Client; @@ -26,7 +26,11 @@ use ethereum_consensus::phase0::mainnet::{ SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }; use ethereum_consensus::primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}; -use light_client_primitives::types::{ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, BlockRootsProof}; +use light_client_primitives::types::{ + BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, + NEXT_SYNC_COMMITTEE_INDEX, +}; use light_client_primitives::util::get_subtree_index; use ssz_rs::{Bitlist, List, Node, Vector}; @@ -85,12 +89,28 @@ impl SyncCommitteeProver { SyncCommitteeProver { node_url, client } } - pub async fn fetch_header( - &self, - block_id: String, - ) -> Result { + pub async fn fetch_finalized_checkpoint(&self) -> Result { + let full_url = self.generate_route(&finality_checkpoints("head")); + let response = self.client.get(full_url).send().await?; + #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] + struct Response { + execution_optimistic: bool, + data: ResponseData, + } + + #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] + struct ResponseData { + previous_justified: Checkpoint, + current_justified: Checkpoint, + final_justified: Checkpoint, + } + let response_data = response.json::().await?; + Ok(response_data.data.final_justified) + } + + pub async fn fetch_header(&self, block_id: &str) -> Result { let path = header_route(block_id); - let full_url = self.generate_route(path); + let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; let response_data = response .json::() @@ -102,7 +122,7 @@ impl SyncCommitteeProver { } pub async fn fetch_block( &self, - block_id: String, + block_id: &str, ) -> Result< BeaconBlock< MAX_PROPOSER_SLASHINGS, @@ -120,7 +140,7 @@ impl SyncCommitteeProver { reqwest::Error, > { let path = block_route(block_id); - let full_url = self.generate_route(path); + let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; @@ -134,10 +154,10 @@ impl SyncCommitteeProver { } pub async fn fetch_sync_committee( &self, - state_id: String, + state_id: &str, ) -> Result { let path = sync_committee_route(state_id); - let full_url = self.generate_route(path); + let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; @@ -151,11 +171,11 @@ impl SyncCommitteeProver { } pub async fn fetch_validator( &self, - state_id: String, - validator_index: String, + state_id: &str, + validator_index: &str, ) -> Result { let path = validator_route(state_id, validator_index); - let full_url = self.generate_route(path); + let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; @@ -170,10 +190,10 @@ impl SyncCommitteeProver { pub async fn fetch_beacon_state( &self, - state_id: String, + state_id: &str, ) -> Result { let path = beacon_state_route(state_id); - let full_url = self.generate_route(path); + let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; @@ -188,7 +208,7 @@ impl SyncCommitteeProver { pub async fn fetch_processed_sync_committee( &self, - state_id: String, + state_id: &str, ) -> Result, reqwest::Error> { // fetches sync committee from Node let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; @@ -197,7 +217,7 @@ impl SyncCommitteeProver { for mut validator_index in node_sync_committee.validators.clone() { // fetches validator based on validator index let validator = self - .fetch_validator(state_id.clone(), validator_index.clone()) + .fetch_validator(state_id.clone(), &validator_index) .await?; validators.push(validator); } @@ -224,23 +244,26 @@ impl SyncCommitteeProver { async fn fetch_latest_finalized_block( &self, ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { - let block_header = self.fetch_header("finalized".to_string()).await?; - let block = self.fetch_block("finalized".to_string()).await?; + let block_header = self.fetch_header("finalized").await?; + let block = self.fetch_block("finalized").await?; Ok((block_header, block)) } - fn generate_route(&self, path: String) -> String { + fn generate_route(&self, path: &str) -> String { format!("{}{}", self.node_url.clone(), path) } } -fn get_attestation_slots_for_finalized_header(finalized_header: &BeaconBlockHeader) -> Slot { +fn get_attestation_slots_for_finalized_header( + finalized_header: &BeaconBlockHeader, + slots_per_epoch: u64, +) -> Slot { let finalized_header_slot = finalized_header.slot; // given that an epoch is 32 slots and blocks are finalized every 2 epochs // so the attested slot for a finalized block is 64 slots away - let attested_slot = finalized_header_slot + 64; + let attested_slot = finalized_header_slot + (slots_per_epoch * 2); attested_slot } @@ -305,19 +328,22 @@ fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { // function that generates block roots proof // block number and convert to get_subtree_index // beacon state has a block roots vec, pass the block root to generate proof -fn prove_block_roots_proof(state: BeaconStateType, block_number: u64) -> anyhow::Result { +fn prove_block_roots_proof( + state: BeaconStateType, + block_number: u64, +) -> anyhow::Result { let indices = vec![get_subtree_index(block_number) as usize]; let proof = ssz_rs::generate_proof(state.block_roots, indices.as_slice())?; Ok(BlockRootsProof { block_header_index: block_number, - block_header_branch: proof.into_iter() + block_header_branch: proof + .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect() + .collect(), }) } // prove the block roots vec inside the beacon state which will be the block roots branch - // when aggr sigs, create a new bit list diff --git a/sync-committee-prover/src/routes.rs b/sync-committee-prover/src/routes.rs index d536a9e93..a7b398b28 100644 --- a/sync-committee-prover/src/routes.rs +++ b/sync-committee-prover/src/routes.rs @@ -1,21 +1,21 @@ -pub fn header_route(block_id: String) -> String { - format!("/eth/v1/beacon/headers/{}", block_id) +pub fn header_route(block_id: &str) -> String { + format!("/eth/v1/beacon/headers/{block_id}") } -pub fn block_route(block_id: String) -> String { - format!("/eth/v2/beacon/blocks/{}", block_id) +pub fn block_route(block_id: &str) -> String { + format!("/eth/v2/beacon/blocks/{block_id}") } -pub fn sync_committee_route(state_id: String) -> String { - format!("/eth/v1/beacon/states/{}/sync_committees", state_id) +pub fn sync_committee_route(state_id: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/sync_committees") } -pub fn validator_route(state_id: String, validator_index: String) -> String { - format!( - "/eth/v1/beacon/states/{}/validators/{}", - state_id, validator_index - ) +pub fn validator_route(state_id: &str, validator_index: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/validators/{validator_index}") } -pub fn beacon_state_route(state_id: String) -> String { - format!("/eth/v2/debug/beacon/states/{}", state_id) +pub fn beacon_state_route(state_id: &str) -> String { + format!("/eth/v2/debug/beacon/states/{state_id}") +} +pub fn finality_checkpoints(state_id: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/finality_checkpoints") } diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index f5df415ba..572fef566 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -1,13 +1,13 @@ use super::*; -use ssz_rs::Merkleized; -use tokio_stream::wrappers::IntervalStream; -use std::time::Duration; use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; -use tokio::time; -use tokio_stream::StreamExt; use light_client_primitives::types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}; use light_client_primitives::util::compute_sync_committee_period_at_slot; use light_client_verifier::light_client::EthLightClient; +use ssz_rs::Merkleized; +use std::time::Duration; +use tokio::time; +use tokio_stream::wrappers::IntervalStream; +use tokio_stream::StreamExt; #[cfg(test)] #[allow(non_snake_case)] @@ -15,7 +15,7 @@ use light_client_verifier::light_client::EthLightClient; async fn fetch_block_header_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await; + let block_header = sync_committee_prover.fetch_header("finalized").await; assert!(block_header.is_ok()); } @@ -25,7 +25,7 @@ async fn fetch_block_header_works() { async fn fetch_block_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_block("100".to_string()).await; + let block = sync_committee_prover.fetch_block("100").await; assert!(block.is_ok()); } @@ -35,9 +35,7 @@ async fn fetch_block_works() { async fn fetch_sync_committee_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover - .fetch_sync_committee("117".to_string()) - .await; + let block = sync_committee_prover.fetch_sync_committee("117").await; assert!(block.is_ok()); } @@ -47,9 +45,7 @@ async fn fetch_sync_committee_works() { async fn fetch_validator_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let validator = sync_committee_prover - .fetch_validator("2561".to_string(), "48".to_string()) - .await; + let validator = sync_committee_prover.fetch_validator("2561", "48").await; assert!(validator.is_ok()); } @@ -60,21 +56,18 @@ async fn fetch_processed_sync_committee_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let validator = sync_committee_prover - .fetch_processed_sync_committee("2561".to_string()) + .fetch_processed_sync_committee("2561") .await; assert!(validator.is_ok()); } - #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] async fn fetch_beacon_state_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let beacon_state = sync_committee_prover - .fetch_beacon_state("genesis".to_string()) - .await; + let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; assert!(beacon_state.is_ok()); } @@ -84,12 +77,10 @@ async fn fetch_beacon_state_works() { async fn state_root_and_block_header_root_matches() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let beacon_state = sync_committee_prover - .fetch_beacon_state("100".to_string()) - .await; + let beacon_state = sync_committee_prover.fetch_beacon_state("100").await; assert!(beacon_state.is_ok()); - let block_header = sync_committee_prover.fetch_header("100".to_string()).await; + let block_header = sync_committee_prover.fetch_header("100").await; assert!(block_header.is_ok()); let state = beacon_state.unwrap(); @@ -112,90 +103,117 @@ async fn state_root_and_block_header_root_matches() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_prover() { - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(14 * 60))); + // In test config an epoch is 6 slots and we expect finalization every two epochs, + // a slot is 12 seconds so that brings us to 144 seconds + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await.unwrap(); + let block_header = sync_committee_prover + .fetch_header("finalized") + .await + .unwrap(); - let state = sync_committee_prover.fetch_beacon_state("finalized".to_string()).await.unwrap(); + let state = sync_committee_prover + .fetch_beacon_state("finalized") + .await + .unwrap(); let mut client_state = LightClientState { finalized_header: block_header.clone(), current_sync_committee: state.current_sync_committee, - next_sync_committee: state.next_sync_committee + next_sync_committee: state.next_sync_committee, }; + while let Some(_ts) = stream.next().await { + let finality_checkpoint = sync_committee_prover + .fetch_finalized_checkpoint() + .await + .unwrap(); + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); - while let Some(_ts) = stream.next().await { - let block = sync_committee_prover.fetch_block("finalized".to_string()).await; - assert!(block.is_ok()); + if finalized_block.slot <= client_state.finalized_header.slot { + continue; + } - let block = block.unwrap(); + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - let execution_payload_proof = prove_execution_payload(block.clone()); - assert!(execution_payload_proof.is_ok()); + let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); - let state = sync_committee_prover.fetch_beacon_state(block.slot.to_string()).await; - assert!(state.is_ok()); + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); - let state = state.unwrap(); + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); - let finality_branch_proof = prove_finalized_header(state.clone()).unwrap(); - let finality_branch_proof = finality_branch_proof.into_iter() + let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + let finality_branch_proof = finality_branch_proof + .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect::>(); - //let block_header = sync_committee_prover.fetch_header(block.slot.to_string()).await; - //let block_header = sync_committee_prover.fetch_header("finalized".to_string()).await; - //dbg!(block_header.unwrap()); - //assert!(block_header); - - let block_header = block_header.clone(); - let state_period = - compute_sync_committee_period_at_slot(block_header.slot); + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - let attested_header_slot = get_attestation_slots_for_finalized_header(&block_header); + let attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await + .unwrap(); - let attested_header = sync_committee_prover.fetch_header(attested_header_slot.to_string()).await.unwrap(); + let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); - let update_attested_period = - compute_sync_committee_period_at_slot(attested_header_slot); + let sync_committee_update = if state_period == attested_header_slot { + let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); - let sync_committee_update = if state_period == attested_header_slot{ - let sync_committee_proof = prove_sync_committee_update(state).unwrap(); + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect::>(); - let sync_committee_proof = sync_committee_proof.into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); + let sync_committee = sync_committee_prover + .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .await + .unwrap(); - - let sync_committee = sync_committee_prover.fetch_processed_sync_committee(block.slot.to_string()).await; - assert!(sync_committee.is_ok()); - - let sync_committee = sync_committee.unwrap(); - - Some (SyncCommitteeUpdate { - next_sync_committee: sync_committee, - next_sync_committee_branch: sync_committee_proof - }) - } else { + Some(SyncCommitteeUpdate { + next_sync_committee: sync_committee, + next_sync_committee_branch: sync_committee_proof, + }) + } else { None - }; - + }; // construct light client - let light_client_update = LightClientUpdate { + let light_client_update = LightClientUpdate { attested_header, sync_committee_update, - finalized_header: block_header, - execution_payload: execution_payload_proof.unwrap(), + finalized_header, + execution_payload: execution_payload_proof, finality_branch: finality_branch_proof, - sync_aggregate: block.body.sync_aggregate, + sync_aggregate: finalized_block.body.sync_aggregate, signature_slot: attested_header_slot, - ancestor_blocks: vec![] + ancestor_blocks: vec![], }; - let new_light_client_state = EthLightClient::verify_sync_committee_attestation(client_state.clone(), light_client_update); + client_state = EthLightClient::verify_sync_committee_attestation( + client_state.clone(), + light_client_update, + ) + .unwrap(); + println!( + "Sucessfully verified Ethereum block at slot {:?}", + client_state.finalized_header.slot + ); } } From 83180e0ac62c648b76e8ca9b4fa261407251edc0 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 4 Feb 2023 18:43:28 +0100 Subject: [PATCH 045/100] lock --- Cargo.lock | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75bfcc17e..8e57056ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -651,10 +651,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "ics15-ethereum" -version = "0.1.0" - [[package]] name = "idna" version = "0.3.0" From 2ac76faa673deafdf0a9964339ca698ab1f4508e Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 4 Feb 2023 22:42:15 +0100 Subject: [PATCH 046/100] further work and testing --- sync-committee-prover/src/lib.rs | 21 +++---- .../responses/finality_checkpoint_response.rs | 14 +++++ sync-committee-prover/src/responses/mod.rs | 1 + sync-committee-prover/src/test.rs | 63 ++++++++++++++++--- 4 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 sync-committee-prover/src/responses/finality_checkpoint_response.rs diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 96a96bde2..259150f4e 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -9,7 +9,7 @@ use ethereum_consensus::bellatrix::{ BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, Checkpoint, SignedBeaconBlock, SignedBeaconBlockHeader, SyncCommittee, }; -use reqwest::Client; +use reqwest::{Client, StatusCode}; use crate::error::Error; use crate::responses::sync_committee_response::NodeSyncCommittee; @@ -92,26 +92,19 @@ impl SyncCommitteeProver { pub async fn fetch_finalized_checkpoint(&self) -> Result { let full_url = self.generate_route(&finality_checkpoints("head")); let response = self.client.get(full_url).send().await?; - #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - struct Response { - execution_optimistic: bool, - data: ResponseData, - } - #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] - struct ResponseData { - previous_justified: Checkpoint, - current_justified: Checkpoint, - final_justified: Checkpoint, - } - let response_data = response.json::().await?; - Ok(response_data.data.final_justified) + let response_data = response + .json::() + .await?; + Ok(response_data.data.finalized) } pub async fn fetch_header(&self, block_id: &str) -> Result { let path = header_route(block_id); let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; + let status = response.status().as_u16(); + let response_data = response .json::() .await?; diff --git a/sync-committee-prover/src/responses/finality_checkpoint_response.rs b/sync-committee-prover/src/responses/finality_checkpoint_response.rs new file mode 100644 index 000000000..f9e9a20eb --- /dev/null +++ b/sync-committee-prover/src/responses/finality_checkpoint_response.rs @@ -0,0 +1,14 @@ +use ethereum_consensus::bellatrix::Checkpoint; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub(crate) struct Response { + execution_optimistic: bool, + pub data: ResponseData, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ResponseData { + previous_justified: Checkpoint, + current_justified: Checkpoint, + pub finalized: Checkpoint, +} diff --git a/sync-committee-prover/src/responses/mod.rs b/sync-committee-prover/src/responses/mod.rs index 2b5846289..1d63bda98 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/sync-committee-prover/src/responses/mod.rs @@ -1,5 +1,6 @@ pub mod beacon_block_header_response; pub mod beacon_block_response; pub mod beacon_state_response; +pub mod finality_checkpoint_response; pub mod sync_committee_response; pub mod validator_response; diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 572fef566..c77dec2f5 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -4,6 +4,7 @@ use light_client_primitives::types::{LightClientState, LightClientUpdate, SyncCo use light_client_primitives::util::compute_sync_committee_period_at_slot; use light_client_verifier::light_client::EthLightClient; use ssz_rs::Merkleized; +use std::thread; use std::time::Duration; use tokio::time; use tokio_stream::wrappers::IntervalStream; @@ -15,7 +16,11 @@ use tokio_stream::StreamExt; async fn fetch_block_header_works() { let node_url: String = "http://localhost:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_header = sync_committee_prover.fetch_header("finalized").await; + let mut block_header = sync_committee_prover.fetch_header("1000").await; + while block_header.is_err() { + println!("I am running till i am ok. lol"); + block_header = sync_committee_prover.fetch_header("1000").await; + } assert!(block_header.is_ok()); } @@ -90,6 +95,16 @@ async fn state_root_and_block_header_root_matches() { assert!(block_header.state_root == hash_tree_root.unwrap()); } +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_finality_checkpoints_work() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; + assert!(finality_checkpoint.is_ok()); +} + // use tokio interval(should run every 13 minutes) // every 13 minutes, fetch latest finalized block // then prove the execution payload @@ -107,15 +122,27 @@ async fn test_prover() { // a slot is 12 seconds so that brings us to 144 seconds let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://127.0.0.1:3500".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_header = sync_committee_prover - .fetch_header("finalized") + + let finality_checkpoint = sync_committee_prover + .fetch_finalized_checkpoint() .await .unwrap(); + dbg!(&finality_checkpoint.root); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + dbg!(&block_id); + + let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); let state = sync_committee_prover - .fetch_beacon_state("finalized") + .fetch_beacon_state(&block_header.slot.to_string()) .await .unwrap(); @@ -130,14 +157,22 @@ async fn test_prover() { .fetch_finalized_checkpoint() .await .unwrap(); + dbg!(&finality_checkpoint.root); let block_id = { let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); block_id.insert_str(0, "0x"); block_id }; + + dbg!(&block_id); let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); if finalized_block.slot <= client_state.finalized_header.slot { + println!("finalized_block slot is {}", &finalized_block.slot); + println!( + "finalized_header slot is {}", + &client_state.finalized_header.slot + ); continue; } @@ -164,10 +199,22 @@ async fn test_prover() { let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - let attested_header = sync_committee_prover + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover .fetch_header(attested_header_slot.to_string().as_str()) - .await - .unwrap(); + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + } + + let attested_header = attested_header.unwrap(); let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); From d4c2acc765516c03a4d274053beec3feb72b7256 Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 8 Feb 2023 23:13:59 +0100 Subject: [PATCH 047/100] test execution_payload_proof passes --- Cargo.lock | 11 ++ light-client-verifier/Cargo.toml | 1 + light-client-verifier/src/light_client.rs | 75 ++++++++-- sync-committee-prover/Cargo.toml | 1 + sync-committee-prover/src/lib.rs | 2 +- sync-committee-prover/src/test.rs | 166 +++++++++++++++++++++- 6 files changed, 245 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c5096417..b51b461e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -761,6 +761,15 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "libc-print" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a574491aebd99996f31b32469bbd3b50e580c35f6305663d68f6d6b28eaced09" +dependencies = [ + "libc", +] + [[package]] name = "light-client-primitives" version = "0.1.0" @@ -777,6 +786,7 @@ version = "0.1.0" dependencies = [ "base2", "ethereum-consensus", + "libc-print", "light-client-primitives", "milagro_bls", "ssz-rs", @@ -1473,6 +1483,7 @@ dependencies = [ "actix-rt", "anyhow", "async-stream", + "base2", "ethereum-consensus", "hex", "light-client-primitives", diff --git a/light-client-verifier/Cargo.toml b/light-client-verifier/Cargo.toml index 124982664..5e18be9d1 100644 --- a/light-client-verifier/Cargo.toml +++ b/light-client-verifier/Cargo.toml @@ -12,3 +12,4 @@ light-client-primitives = {path="../light-client-primitives", default-features = ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } +libc-print = {version=" 0.1.20"} diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index 93f3496ac..da0ec01d7 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -12,6 +12,7 @@ use ethereum_consensus::domains::DomainType; use ethereum_consensus::primitives::Root; use ethereum_consensus::signing::compute_signing_root; use ethereum_consensus::state_transition::Context; +use libc_print::libc_println; use light_client_primitives::types::{ AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, @@ -47,28 +48,71 @@ impl EthLightClient { .len() != NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize { - Err(Error::InvalidUpdate)? + libc_println!("Invalid update "); + libc_println!( + "update finality branch length {} ", + update.finality_branch.len() + ); + libc_println!( + "FINALIZED_ROOT_INDEX_FLOOR_LOG_2 {}", + FINALIZED_ROOT_INDEX_FLOOR_LOG_2 + ); + libc_println!( + "update next sync committee branch length {} ", + update + .clone() + .sync_committee_update + .unwrap() + .next_sync_committee_branch + .len() + ); + libc_println!( + "NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 {}", + NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 + ); + //Err(Error::InvalidUpdate)? } // Verify sync committee has super majority participants let sync_committee_bits = update.sync_aggregate.sync_committee_bits; let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { - Err(Error::SyncCommitteeParticipantsTooLow)? + libc_println!("SyncCommitteeParticipantsTooLow "); + libc_println!("sync_aggregate_participants {} ", { + sync_aggregate_participants * 3 + }); + libc_println!("sync_committee_bits {}", { + sync_committee_bits.clone().len() * 2 + }); + //Err(Error::SyncCommitteeParticipantsTooLow)? } // Verify update does not skip a sync committee period let is_valid_update = update.signature_slot > update.attested_header.slot && update.attested_header.slot >= update.finalized_header.slot; if !is_valid_update { - Err(Error::InvalidUpdate)? + libc_println!("is_valid_update {} ", is_valid_update); + libc_println!( + "update.signature_slot {} update.attested_header.slot {}", + update.signature_slot, + update.attested_header.slot + ); + libc_println!( + "update.attested_header.slot {} update.finalized_header.slot {}", + update.attested_header.slot, + update.finalized_header.slot + ); + //Err(Error::InvalidUpdate)? } let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); if !(state_period..=state_period + 1).contains(&update_signature_period) { - Err(Error::InvalidUpdate)? + libc_println!("invalid update"); + libc_println!("state_period is {}", state_period); + libc_println!("update_signature_period is {}", update_signature_period); + //Err(Error::InvalidUpdate)? } // Verify update is relevant @@ -152,8 +196,13 @@ impl EthLightClient { ), ); - if is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + libc_println!( + "valid merkle branch for finalized_root {}", + is_merkle_branch_valid + ); + if !is_merkle_branch_valid { + libc_println!("invalid merkle branch for finalized root"); + //Err(Error::InvalidMerkleBranch)?; } // verify the associated execution header of the finalized beacon header. @@ -206,8 +255,10 @@ impl EthLightClient { ), ); + libc_println!("valid merkle branch for execution_payload_branch"); if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + libc_println!("invalid merkle branch for execution_payload_branch"); + //Err(Error::InvalidMerkleBranch)?; } if let Some(sync_committee_update) = update.sync_committee_update.clone() { @@ -215,7 +266,8 @@ impl EthLightClient { && sync_committee_update.next_sync_committee != trusted_state.next_sync_committee.clone() { - Err(Error::InvalidUpdate)? + libc_println!("invalid update for sync committee update"); + //rr(Error::InvalidUpdate)? } let next_sync_committee_branch = sync_committee_update @@ -246,8 +298,13 @@ impl EthLightClient { ), ); + libc_println!( + "valid merkle branch for sync committee {}", + is_merkle_branch_valid + ); if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + libc_println!("invalid merkle branch for sync committee"); + // Err(Error::InvalidMerkleBranch)?; } } diff --git a/sync-committee-prover/Cargo.toml b/sync-committee-prover/Cargo.toml index fabe30615..83216377d 100644 --- a/sync-committee-prover/Cargo.toml +++ b/sync-committee-prover/Cargo.toml @@ -18,6 +18,7 @@ actix-rt = "*" tokio = { version = "1.18.2", features = ["full"]} tokio-stream = { version = "0.1.8" } async-stream = { version = "0.3.3"} +base2 = {version="0.2.2", default-features=false} [dev-dependencies] hex = "0.4.3" diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 259150f4e..89e1e6b40 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -286,7 +286,7 @@ fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), + execution_payload.block_number.hash_tree_root().unwrap(), + ], + &multi_proof_nodes, + &[ + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + ], + ); + + println!("execution_payload_root {:?}", execution_payload_root); + + let execution_payload_hash_tree_root = finalized_block + .body + .execution_payload + .clone() + .hash_tree_root() + .unwrap(); + + println!( + "execution_payload_hash_tree_root {:?}", + execution_payload_hash_tree_root + ); + + assert_eq!(execution_payload_root, execution_payload_hash_tree_root); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + EXECUTION_PAYLOAD_INDEX as usize, + &Node::from_bytes( + finalized_header + .clone() + .body_root + .as_ref() + .try_into() + .unwrap(), + ), + ); + + assert_eq!(is_merkle_branch_valid, true); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_finality_proof() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let block_id = "finalized"; + let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); + + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); + + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); + + let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + } + + let attested_header = attested_header.unwrap(); + + let finality_branch_proof = finality_branch_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + + // verify the associated execution header of the finalized beacon header. + + // Verify that the `finality_branch` confirms `finalized_header` + // to match the finalized checkpoint root saved in the state of `attested_header`. + // Note that the genesis finalized checkpoint root is represented as a zero hash. + let finalized_root = &Node::from_bytes( + light_client_primitives::util::hash_tree_root(finalized_header.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ); + + let branch = finality_branch_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + println!("finalized_root {:?}", finalized_root.clone()); + + let finality_hash_tree_root = finalized_block.clone().hash_tree_root().unwrap(); + + assert_eq!(finalized_root, &finality_hash_tree_root); + + println!("finalized_root {:?}", finality_hash_tree_root); + let is_merkle_branch_valid = is_valid_merkle_branch( + finalized_root, + branch.iter(), + FINALIZED_ROOT_INDEX.floor_log2() as usize, + get_subtree_index(FINALIZED_ROOT_INDEX) as usize, + &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), + ); + + println!( + "is_merkle_branch_valid {:?}", + is_merkle_branch_valid.clone() + ); + + assert!(is_merkle_branch_valid, "{}", true); +} + // use tokio interval(should run every 13 minutes) // every 13 minutes, fetch latest finalized block // then prove the execution payload From 5fe44764e39644190bdc80914f94f6a7a3435b65 Mon Sep 17 00:00:00 2001 From: Damilare Date: Fri, 10 Feb 2023 18:34:03 +0100 Subject: [PATCH 048/100] sync committee proof test --- light-client-verifier/src/light_client.rs | 8 +- sync-committee-prover/src/lib.rs | 10 +- sync-committee-prover/src/test.rs | 143 +++++++++++++++++++++- 3 files changed, 152 insertions(+), 9 deletions(-) diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs index da0ec01d7..35a022299 100644 --- a/light-client-verifier/src/light_client.rs +++ b/light-client-verifier/src/light_client.rs @@ -185,7 +185,7 @@ impl EthLightClient { finalized_root, branch.iter(), FINALIZED_ROOT_INDEX.floor_log2() as usize, - get_subtree_index(FINALIZED_ROOT_INDEX) as usize, + FINALIZED_ROOT_INDEX as usize, &Node::from_bytes( update .attested_header @@ -243,7 +243,7 @@ impl EthLightClient { &execution_payload_root, execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, + EXECUTION_PAYLOAD_INDEX as usize, &Node::from_bytes( update .finalized_header @@ -342,7 +342,7 @@ impl EthLightClient { &block_roots_root, block_roots_branch_node.iter(), BLOCK_ROOTS_INDEX.floor_log2() as usize, - get_subtree_index(BLOCK_ROOTS_INDEX) as usize, + BLOCK_ROOTS_INDEX as usize, &Node::from_bytes( update .finalized_header @@ -465,7 +465,7 @@ impl EthLightClient { &execution_payload_root, execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - get_subtree_index(EXECUTION_PAYLOAD_INDEX) as usize, + EXECUTION_PAYLOAD_INDEX as usize, &Node::from_bytes( ancestor .header diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs index 89e1e6b40..add7b1cda 100644 --- a/sync-committee-prover/src/lib.rs +++ b/sync-committee-prover/src/lib.rs @@ -32,7 +32,9 @@ use light_client_primitives::types::{ NEXT_SYNC_COMMITTEE_INDEX, }; use light_client_primitives::util::get_subtree_index; -use ssz_rs::{Bitlist, List, Node, Vector}; +use ssz_rs::{ + get_generalized_index, Bitlist, GeneralizedIndex, List, Node, SszVariableOrIndex, Vector, +}; type BeaconBlockType = BeaconBlock< MAX_PROPOSER_SLASHINGS, @@ -286,7 +288,7 @@ fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result anyhow::Result anyhow::Result> { - let indices = vec![get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize]; + let indices = vec![NEXT_SYNC_COMMITTEE_INDEX as usize]; let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; Ok(proof) } fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { - let indices = vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; + let indices = [FINALIZED_ROOT_INDEX as usize]; //vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; Ok(proof) diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 7e57be24d..28150e157 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -165,7 +165,7 @@ async fn test_execution_payload_proof() { &execution_payload_root, execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - EXECUTION_PAYLOAD_INDEX as usize, + GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, &Node::from_bytes( finalized_header .clone() @@ -269,6 +269,147 @@ async fn test_finality_proof() { assert!(is_merkle_branch_valid, "{}", true); } +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_sync_committee_proof() { + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); + + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let finality_checkpoint = sync_committee_prover + .fetch_finalized_checkpoint() + .await + .unwrap(); + dbg!(&finality_checkpoint.root); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + dbg!(&block_id); + + let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + + let state = sync_committee_prover + .fetch_beacon_state(&block_header.slot.to_string()) + .await + .unwrap(); + + let mut client_state = LightClientState { + finalized_header: block_header.clone(), + current_sync_committee: state.current_sync_committee, + next_sync_committee: state.next_sync_committee, + }; + + while let Some(_ts) = stream.next().await { + let block_id = "finalized"; + let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); + + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); + + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + } + + let attested_header = attested_header.unwrap(); + + let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); + + let sync_committee_update = if state_period == attested_header_slot { + println!("sync committee present"); + let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); + + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect::>(); + + let sync_committee = sync_committee_prover + .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .await + .unwrap(); + + Some(SyncCommitteeUpdate { + next_sync_committee: sync_committee, + next_sync_committee_branch: sync_committee_proof, + }) + } else { + println!("No sync committee present"); + None + }; + + if let Some(sync_committee_update) = sync_committee_update.clone() { + if update_attested_period == state_period + && sync_committee_update.next_sync_committee + != client_state.next_sync_committee.clone() + { + println!("invalid update for sync committee update"); + //rr(Error::InvalidUpdate)? + } + + let next_sync_committee_branch = sync_committee_update + .next_sync_committee_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + light_client_primitives::util::hash_tree_root( + sync_committee_update.next_sync_committee, + ) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX as usize, + &Node::from_bytes(attested_header.state_root.as_ref().try_into().unwrap()), + ); + + println!( + "valid merkle branch for sync committee {}", + is_merkle_branch_valid + ); + if !is_merkle_branch_valid { + println!("invalid merkle branch for sync committee"); + // Err(Error::InvalidMerkleBranch)?; + } + } + } +} + // use tokio interval(should run every 13 minutes) // every 13 minutes, fetch latest finalized block // then prove the execution payload From c485cc3c74cd520775de79f0ac2a86d262478d9b Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 13 Feb 2023 22:29:16 +0100 Subject: [PATCH 049/100] sync committee proof test --- sync-committee-prover/src/test.rs | 165 +++++++++++++++--------------- 1 file changed, 81 insertions(+), 84 deletions(-) diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index 28150e157..cee965395 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -305,107 +305,104 @@ async fn test_sync_committee_proof() { next_sync_committee: state.next_sync_committee, }; - while let Some(_ts) = stream.next().await { - let block_id = "finalized"; - let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); + let block_id = "finalized"; + let mut finalized_block = sync_committee_prover.fetch_block(block_id).await; - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + while finalized_block.is_err() { + println!("I am running finalized block till i am ok. lol {}", &block_id); + finalized_block = sync_committee_prover.fetch_block(block_id).await; + } - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); + let finalized_block = finalized_block.unwrap(); - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); - let mut attested_header = sync_committee_prover + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover .fetch_header(attested_header_slot.to_string().as_str()) .await; + } - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } + let attested_header = attested_header.unwrap(); - let attested_header = attested_header.unwrap(); + let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); - let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); + let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); - let sync_committee_update = if state_period == attested_header_slot { - println!("sync committee present"); - let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect::>(); + let mut sync_committee = sync_committee_prover + .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .await; - let sync_committee = sync_committee_prover - .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) - .await - .unwrap(); + while sync_committee.is_err() { + println!("I am fetching sync committee till i am ok. lol {}", &block_id); + sync_committee = sync_committee_prover + .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .await; + } - Some(SyncCommitteeUpdate { - next_sync_committee: sync_committee, - next_sync_committee_branch: sync_committee_proof, - }) - } else { - println!("No sync committee present"); - None - }; + let sync_committee = sync_committee.unwrap(); - if let Some(sync_committee_update) = sync_committee_update.clone() { - if update_attested_period == state_period - && sync_committee_update.next_sync_committee - != client_state.next_sync_committee.clone() - { - println!("invalid update for sync committee update"); - //rr(Error::InvalidUpdate)? - } - - let next_sync_committee_branch = sync_committee_update - .next_sync_committee_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( - light_client_primitives::util::hash_tree_root( - sync_committee_update.next_sync_committee, - ) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - ), - next_sync_committee_branch.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, - NEXT_SYNC_COMMITTEE_INDEX as usize, - &Node::from_bytes(attested_header.state_root.as_ref().try_into().unwrap()), - ); + let sync_committee_update = Some(SyncCommitteeUpdate { + next_sync_committee: sync_committee, + next_sync_committee_branch: sync_committee_proof, + }); - println!( - "valid merkle branch for sync committee {}", - is_merkle_branch_valid - ); - if !is_merkle_branch_valid { - println!("invalid merkle branch for sync committee"); - // Err(Error::InvalidMerkleBranch)?; - } + if let Some(sync_committee_update) = sync_committee_update.clone() { + let next_sync_committee_branch = sync_committee_update + .next_sync_committee_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + light_client_primitives::util::hash_tree_root( + sync_committee_update.next_sync_committee, + ) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX as usize, + &Node::from_bytes(attested_header.state_root.as_ref().try_into().unwrap()), + ); + + println!( + "valid merkle branch for sync committee {}", + is_merkle_branch_valid + ); + if !is_merkle_branch_valid { + //println!("invalid merkle branch for sync committee"); + // Err(Error::InvalidMerkleBranch)?; } } } From 145f45eab16ae7047875694731aa998eb9e2ec2d Mon Sep 17 00:00:00 2001 From: Damilare Date: Wed, 15 Feb 2023 23:03:00 +0100 Subject: [PATCH 050/100] test sync committee changes --- sync-committee-prover/src/test.rs | 136 ++++++++++++++---------------- 1 file changed, 64 insertions(+), 72 deletions(-) diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs index cee965395..7e408823f 100644 --- a/sync-committee-prover/src/test.rs +++ b/sync-committee-prover/src/test.rs @@ -299,17 +299,14 @@ async fn test_sync_committee_proof() { .await .unwrap(); - let mut client_state = LightClientState { - finalized_header: block_header.clone(), - current_sync_committee: state.current_sync_committee, - next_sync_committee: state.next_sync_committee, - }; - - let block_id = "finalized"; + let block_id = "head"; let mut finalized_block = sync_committee_prover.fetch_block(block_id).await; while finalized_block.is_err() { - println!("I am running finalized block till i am ok. lol {}", &block_id); + println!( + "I am running finalized block till i am ok. lol {}", + &block_id + ); finalized_block = sync_committee_prover.fetch_block(block_id).await; } @@ -317,94 +314,89 @@ async fn test_sync_committee_proof() { let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); let finalized_state = sync_committee_prover .fetch_beacon_state(finalized_block.slot.to_string().as_str()) .await .unwrap(); - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); - - let mut attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } - - let attested_header = attested_header.unwrap(); - - let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); - - let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); + let sync_committee_proof = prove_sync_committee_update(finalized_state.clone()).unwrap(); let sync_committee_proof = sync_committee_proof .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect::>(); - let mut sync_committee = sync_committee_prover - .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) .await; while sync_committee.is_err() { - println!("I am fetching sync committee till i am ok. lol {}", &block_id); + println!( + "I am fetching sync committee till i am ok. lol {}", + &block_id + ); sync_committee = sync_committee_prover - .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) .await; } let sync_committee = sync_committee.unwrap(); - let sync_committee_update = Some(SyncCommitteeUpdate { - next_sync_committee: sync_committee, - next_sync_committee_branch: sync_committee_proof, - }); - - if let Some(sync_committee_update) = sync_committee_update.clone() { - let next_sync_committee_branch = sync_committee_update - .next_sync_committee_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( + let calculated_finalized_root = calculate_multi_merkle_root( + &[ + Node::from_bytes( light_client_primitives::util::hash_tree_root( - sync_committee_update.next_sync_committee, + sync_committee.clone(), ) - .unwrap() - .as_ref() - .try_into() - .unwrap(), + .unwrap() + .as_ref() + .try_into() + .unwrap(), ), - next_sync_committee_branch.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, - NEXT_SYNC_COMMITTEE_INDEX as usize, - &Node::from_bytes(attested_header.state_root.as_ref().try_into().unwrap()), - ); + ], + &sync_committee_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(), + &[ + GeneralizedIndex(NEXT_SYNC_COMMITTEE_INDEX as usize), + ], + ); - println!( - "valid merkle branch for sync committee {}", - is_merkle_branch_valid - ); - if !is_merkle_branch_valid { - //println!("invalid merkle branch for sync committee"); - // Err(Error::InvalidMerkleBranch)?; - } - } + let hash_tree_root = finalized_state + .clone() + .hash_tree_root() + .unwrap(); + + println!("calculated_finalized_root {:?}", calculated_finalized_root); + println!("finalized_state_root {:?}", finalized_header.state_root); + println!("hash_tree_root {:?}", hash_tree_root); + + + let next_sync_committee_branch = sync_committee_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + light_client_primitives::util::hash_tree_root( + sync_committee.clone(), + ) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX as usize, + &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), + ); + + println!( + "valid merkle branch for sync committee {}", + is_merkle_branch_valid + ); + assert!(is_merkle_branch_valid, "{}", true); } // use tokio interval(should run every 13 minutes) From 43d4990ad46ccce1319206b017fbe284cb8187e8 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Wed, 15 Feb 2023 19:21:46 -0400 Subject: [PATCH 051/100] clean up code --- Cargo.lock | 79 +-- Cargo.toml | 6 +- light-client-primitives/src/types.rs | 125 ---- light-client-verifier/src/error.rs | 34 -- light-client-verifier/src/lib.rs | 7 - light-client-verifier/src/light_client.rs | 500 ---------------- .../Cargo.toml | 5 +- .../src/lib.rs | 0 primitives/src/types.rs | 125 ++++ .../src/util.rs | 35 +- {sync-committee-prover => prover}/Cargo.toml | 4 +- prover/src/error.rs | 5 + prover/src/lib.rs | 346 +++++++++++ .../responses/beacon_block_header_response.rs | 12 +- prover/src/responses/beacon_block_response.rs | 40 ++ prover/src/responses/beacon_state_response.rs | 26 + .../responses/finality_checkpoint_response.rs | 10 +- .../src/responses/mod.rs | 2 + .../src/responses/sync_committee_response.rs | 8 +- .../src/responses/validator_response.rs | 12 +- prover/src/routes.rs | 21 + prover/src/test.rs | 508 ++++++++++++++++ rustfmt.toml | 23 + sync-committee-prover/src/error.rs | 5 - sync-committee-prover/src/lib.rs | 344 ----------- .../src/responses/beacon_block_response.rs | 36 -- .../src/responses/beacon_state_response.rs | 26 - sync-committee-prover/src/routes.rs | 21 - sync-committee-prover/src/test.rs | 560 ------------------ .../Cargo.toml | 10 +- verifier/src/error.rs | 34 ++ verifier/src/lib.rs | 461 ++++++++++++++ 32 files changed, 1684 insertions(+), 1746 deletions(-) delete mode 100644 light-client-primitives/src/types.rs delete mode 100644 light-client-verifier/src/error.rs delete mode 100644 light-client-verifier/src/lib.rs delete mode 100644 light-client-verifier/src/light_client.rs rename {light-client-primitives => primitives}/Cargo.toml (69%) rename {light-client-primitives => primitives}/src/lib.rs (100%) create mode 100644 primitives/src/types.rs rename {light-client-primitives => primitives}/src/util.rs (52%) rename {sync-committee-prover => prover}/Cargo.toml (82%) create mode 100644 prover/src/error.rs create mode 100644 prover/src/lib.rs rename {sync-committee-prover => prover}/src/responses/beacon_block_header_response.rs (67%) create mode 100644 prover/src/responses/beacon_block_response.rs create mode 100644 prover/src/responses/beacon_state_response.rs rename {sync-committee-prover => prover}/src/responses/finality_checkpoint_response.rs (63%) rename {sync-committee-prover => prover}/src/responses/mod.rs (85%) rename {sync-committee-prover => prover}/src/responses/sync_committee_response.rs (60%) rename {sync-committee-prover => prover}/src/responses/validator_response.rs (60%) create mode 100644 prover/src/routes.rs create mode 100644 prover/src/test.rs create mode 100644 rustfmt.toml delete mode 100644 sync-committee-prover/src/error.rs delete mode 100644 sync-committee-prover/src/lib.rs delete mode 100644 sync-committee-prover/src/responses/beacon_block_response.rs delete mode 100644 sync-committee-prover/src/responses/beacon_state_response.rs delete mode 100644 sync-committee-prover/src/routes.rs delete mode 100644 sync-committee-prover/src/test.rs rename {light-client-verifier => verifier}/Cargo.toml (59%) create mode 100644 verifier/src/error.rs create mode 100644 verifier/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index b51b461e9..4980c81fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,7 +96,16 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" dependencies = [ - "int", + "int 0.2.11", +] + +[[package]] +name = "base2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" +dependencies = [ + "int 0.3.0", ] [[package]] @@ -689,6 +698,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "int" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" +dependencies = [ + "num-traits", +] + [[package]] name = "integer-sqrt" version = "0.1.5" @@ -761,37 +779,6 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" -[[package]] -name = "libc-print" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a574491aebd99996f31b32469bbd3b50e580c35f6305663d68f6d6b28eaced09" -dependencies = [ - "libc", -] - -[[package]] -name = "light-client-primitives" -version = "0.1.0" -dependencies = [ - "base2", - "ethereum-consensus", - "hex-literal", - "ssz-rs", -] - -[[package]] -name = "light-client-verifier" -version = "0.1.0" -dependencies = [ - "base2", - "ethereum-consensus", - "libc-print", - "light-client-primitives", - "milagro_bls", - "ssz-rs", -] - [[package]] name = "lock_api" version = "0.4.9" @@ -1476,6 +1463,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync-committee-primitives" +version = "0.1.0" +dependencies = [ + "base2 0.3.1", + "ethereum-consensus", + "hex-literal", + "ssz-rs", +] + [[package]] name = "sync-committee-prover" version = "0.1.0" @@ -1483,19 +1480,31 @@ dependencies = [ "actix-rt", "anyhow", "async-stream", - "base2", + "base2 0.2.2", "ethereum-consensus", "hex", - "light-client-primitives", - "light-client-verifier", "reqwest", "serde", "serde_json", "ssz-rs", + "sync-committee-primitives", + "sync-committee-verifier", "tokio", "tokio-stream", ] +[[package]] +name = "sync-committee-verifier" +version = "0.1.0" +dependencies = [ + "base2 0.2.2", + "ethereum-consensus", + "log", + "milagro_bls", + "ssz-rs", + "sync-committee-primitives", +] + [[package]] name = "synstructure" version = "0.12.6" diff --git a/Cargo.toml b/Cargo.toml index 82f538aa2..37dfd2d6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = [ - "light-client-verifier", - "light-client-primitives", - "sync-committee-prover" + "verifier", + "primitives", + "prover" ] diff --git a/light-client-primitives/src/types.rs b/light-client-primitives/src/types.rs deleted file mode 100644 index 69305e0ee..000000000 --- a/light-client-primitives/src/types.rs +++ /dev/null @@ -1,125 +0,0 @@ -use alloc::vec::Vec; -use ethereum_consensus::altair::{ - FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, -}; -use ethereum_consensus::bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}; -use ethereum_consensus::domains::DomainType; -use ethereum_consensus::primitives::{Hash32, Root, Slot}; - -pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; -pub const FINALIZED_ROOT_INDEX: u64 = 105; -pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; -pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; -pub const EXECUTION_PAYLOAD_INDEX: u64 = 25; -pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; -pub const BLOCK_ROOTS_INDEX: u64 = 37; -pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; -pub const HISTORICAL_ROOTS_INDEX: u64 = 39; -pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = - hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); - -/// This holds the relevant data required to prove the state root in the execution payload. -#[derive(Debug, Clone)] -pub struct ExecutionPayloadProof { - /// The state root in the `ExecutionPayload` which represents the commitment to - /// the ethereum world state in the yellow paper. - pub state_root: Hash32, - /// the block number of the execution header. - pub block_number: u64, - /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. - pub multi_proof: Vec, - /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. - pub execution_payload_branch: Vec, -} - -/// Holds the neccessary proofs required to verify a header in the `block_roots` field -/// either in [`BeaconState`] or [`HistoricalBatch`]. -#[derive(Debug, Clone)] -pub struct BlockRootsProof { - /// Generalized index of the header in the `block_roots` list. - pub block_header_index: u64, - /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` - pub block_header_branch: Vec, -} - -/// The block header ancestry proof, this is an enum because the header may either exist in -/// `state.block_roots` or `state.historical_roots`. -#[derive(Debug, Clone)] -pub enum AncestryProof { - /// This variant defines the proof data for a beacon chain header in the `state.block_roots` - BlockRoots { - /// Proof for the header in `state.block_roots` - block_roots_proof: BlockRootsProof, - /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] - block_roots_branch: Vec, - }, - /// This variant defines the neccessary proofs for a beacon chain header in the - /// `state.historical_roots`. - HistoricalRoots { - /// Proof for the header in `historical_batch.block_roots` - block_roots_proof: BlockRootsProof, - /// The proof for the `historical_batch.block_roots`, needed to reconstruct - /// `hash_tree_root(historical_batch)` - historical_batch_proof: Vec, - /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` - historical_roots_proof: Vec, - /// The generalized index for the historical_batch in `state.historical_roots`. - historical_roots_index: u64, - /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in - /// [`BeaconState`] - historical_roots_branch: Vec, - }, -} - -/// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized -/// header. -#[derive(Debug, Clone)] -pub struct AncestorBlock { - /// The actual beacon chain header - pub header: BeaconBlockHeader, - /// Associated execution header proofs - pub execution_payload: ExecutionPayloadProof, - /// Ancestry proofs of the beacon chain header. - pub ancestry_proof: AncestryProof, -} - -/// Holds the latest sync committee as well as an ssz proof for it's existence -/// in a finalized header. -#[derive(Debug, Clone)] -pub struct SyncCommitteeUpdate { - // actual sync committee - pub next_sync_committee: SyncCommittee, - // sync committee, ssz merkle proof. - pub next_sync_committee_branch: Vec, -} - -/// Minimum state required by the light client to validate new sync committee attestations -#[derive(Debug, Clone)] -pub struct LightClientState { - /// The latest recorded finalized header - pub finalized_header: BeaconBlockHeader, - // Sync committees corresponding to the finalized header - pub current_sync_committee: SyncCommittee, - pub next_sync_committee: SyncCommittee, -} - -/// Data required to advance the state of the light client. -#[derive(Debug, Clone)] -pub struct LightClientUpdate { - /// the header that the sync committee signed - pub attested_header: BeaconBlockHeader, - /// the sync committee has potentially changed, here's an ssz proof for that. - pub sync_committee_update: Option>, - /// the actual header which was finalized by the ethereum attestation protocol. - pub finalized_header: BeaconBlockHeader, - /// execution payload of the finalized header - pub execution_payload: ExecutionPayloadProof, - /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 epochs. - pub finality_branch: Vec, - /// signature & participation bits - pub sync_aggregate: SyncAggregate, - /// slot at which signature was produced - pub signature_slot: Slot, - /// ancestors of the finalized block to be verified, may be empty. - pub ancestor_blocks: Vec, -} diff --git a/light-client-verifier/src/error.rs b/light-client-verifier/src/error.rs deleted file mode 100644 index 6d703b41d..000000000 --- a/light-client-verifier/src/error.rs +++ /dev/null @@ -1,34 +0,0 @@ -use core::fmt::{Display, Formatter}; - -#[derive(Debug)] -pub enum Error { - SyncCommitteeParticipantsTooLow, - InvalidUpdate, - DomainError, - FastAggregateError(ethereum_consensus::crypto::Error), - InvalidMerkleBranch, - InvalidRoot, - MerkleizationError, -} - -impl From for Error { - fn from(error: ethereum_consensus::crypto::Error) -> Self { - Error::FastAggregateError(error) - } -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { - match self { - Error::SyncCommitteeParticipantsTooLow => { - write!(f, "Sync committee participants are too low") - } - Error::InvalidUpdate => write!(f, "Invalid update"), - Error::DomainError => write!(f, "Couldn't get domain"), - Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), - Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), - Error::InvalidRoot => write!(f, "Invalid root"), - Error::MerkleizationError => write!(f, "Merkleization error"), - } - } -} diff --git a/light-client-verifier/src/lib.rs b/light-client-verifier/src/lib.rs deleted file mode 100644 index 3fc6cd500..000000000 --- a/light-client-verifier/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(not(feature = "std"))] -extern crate alloc; - -pub mod error; -pub mod light_client; diff --git a/light-client-verifier/src/light_client.rs b/light-client-verifier/src/light_client.rs deleted file mode 100644 index 35a022299..000000000 --- a/light-client-verifier/src/light_client.rs +++ /dev/null @@ -1,500 +0,0 @@ -use crate::error::Error; -use alloc::vec::Vec; -use base2::Base2; -use core::borrow::Borrow; -use core::fmt::{Display, Formatter}; -use ethereum_consensus::altair::mainnet::SYNC_COMMITTEE_SIZE; -use ethereum_consensus::altair::{ - FINALIZED_ROOT_INDEX_FLOOR_LOG_2, NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, -}; -use ethereum_consensus::bellatrix::compute_domain; -use ethereum_consensus::domains::DomainType; -use ethereum_consensus::primitives::Root; -use ethereum_consensus::signing::compute_signing_root; -use ethereum_consensus::state_transition::Context; -use libc_print::libc_println; -use light_client_primitives::types::{ - AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, - EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, - GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, - NEXT_SYNC_COMMITTEE_INDEX, -}; -use light_client_primitives::util::{ - compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, - get_subtree_index, hash_tree_root, -}; -use ssz_rs::prelude::is_valid_merkle_branch; -use ssz_rs::Merkleized; -use ssz_rs::{calculate_merkle_root, calculate_multi_merkle_root, GeneralizedIndex, Node}; - -pub type LightClientState = light_client_primitives::types::LightClientState; -pub type LightClientUpdate = light_client_primitives::types::LightClientUpdate; - -pub struct EthLightClient; - -impl EthLightClient { - /// This function simply verifies a sync committee's attestation & it's finalized counterpart. - pub fn verify_sync_committee_attestation( - trusted_state: LightClientState, - update: LightClientUpdate, - ) -> Result { - if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize - && update.sync_committee_update.is_some() - && update - .clone() - .sync_committee_update - .unwrap() - .next_sync_committee_branch - .len() - != NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize - { - libc_println!("Invalid update "); - libc_println!( - "update finality branch length {} ", - update.finality_branch.len() - ); - libc_println!( - "FINALIZED_ROOT_INDEX_FLOOR_LOG_2 {}", - FINALIZED_ROOT_INDEX_FLOOR_LOG_2 - ); - libc_println!( - "update next sync committee branch length {} ", - update - .clone() - .sync_committee_update - .unwrap() - .next_sync_committee_branch - .len() - ); - libc_println!( - "NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 {}", - NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 - ); - //Err(Error::InvalidUpdate)? - } - - // Verify sync committee has super majority participants - let sync_committee_bits = update.sync_aggregate.sync_committee_bits; - let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; - if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { - libc_println!("SyncCommitteeParticipantsTooLow "); - libc_println!("sync_aggregate_participants {} ", { - sync_aggregate_participants * 3 - }); - libc_println!("sync_committee_bits {}", { - sync_committee_bits.clone().len() * 2 - }); - //Err(Error::SyncCommitteeParticipantsTooLow)? - } - - // Verify update does not skip a sync committee period - let is_valid_update = update.signature_slot > update.attested_header.slot - && update.attested_header.slot >= update.finalized_header.slot; - if !is_valid_update { - libc_println!("is_valid_update {} ", is_valid_update); - libc_println!( - "update.signature_slot {} update.attested_header.slot {}", - update.signature_slot, - update.attested_header.slot - ); - libc_println!( - "update.attested_header.slot {} update.finalized_header.slot {}", - update.attested_header.slot, - update.finalized_header.slot - ); - //Err(Error::InvalidUpdate)? - } - - let state_period = - compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); - let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); - if !(state_period..=state_period + 1).contains(&update_signature_period) { - libc_println!("invalid update"); - libc_println!("state_period is {}", state_period); - libc_println!("update_signature_period is {}", update_signature_period); - //Err(Error::InvalidUpdate)? - } - - // Verify update is relevant - let update_attested_period = - compute_sync_committee_period_at_slot(update.attested_header.slot); - let update_has_next_sync_committee = - update.sync_committee_update.is_some() && update_attested_period == state_period; - - if !(update.attested_header.slot > trusted_state.finalized_header.slot - || update_has_next_sync_committee) - { - Err(Error::InvalidUpdate)? - } - - // Verify sync committee aggregate signature - let sync_committee = if update_signature_period == state_period { - trusted_state.current_sync_committee.clone() - } else { - trusted_state.next_sync_committee.clone() - }; - - let sync_committee_pubkeys = sync_committee.public_keys; - - let participant_pubkeys = sync_committee_bits - .iter() - .zip(sync_committee_pubkeys.iter()) - .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) - .collect::>(); - - let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); - //TODO: we probably need to construct context - let domain = compute_domain( - DOMAIN_SYNC_COMMITTEE, - Some(fork_version), - Some(Root::from_bytes( - GENESIS_VALIDATORS_ROOT - .try_into() - .map_err(|_| Error::InvalidRoot)?, - )), - &Context::default(), - ) - .map_err(|_| Error::InvalidUpdate)?; - - let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain); - - ethereum_consensus::crypto::fast_aggregate_verify( - &*participant_pubkeys, - signing_root.map_err(|_| Error::InvalidRoot)?.as_bytes(), - &update.sync_aggregate.sync_committee_signature, - )?; - - // Verify that the `finality_branch` confirms `finalized_header` - // to match the finalized checkpoint root saved in the state of `attested_header`. - // Note that the genesis finalized checkpoint root is represented as a zero hash. - let finalized_root = &Node::from_bytes( - light_client_primitives::util::hash_tree_root(update.finalized_header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ); - - let branch = update - .finality_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let is_merkle_branch_valid = is_valid_merkle_branch( - finalized_root, - branch.iter(), - FINALIZED_ROOT_INDEX.floor_log2() as usize, - FINALIZED_ROOT_INDEX as usize, - &Node::from_bytes( - update - .attested_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - libc_println!( - "valid merkle branch for finalized_root {}", - is_merkle_branch_valid - ); - if !is_merkle_branch_valid { - libc_println!("invalid merkle branch for finalized root"); - //Err(Error::InvalidMerkleBranch)?; - } - - // verify the associated execution header of the finalized beacon header. - let mut execution_payload = update.execution_payload; - let multi_proof_vec = execution_payload.multi_proof; - let multi_proof_nodes = multi_proof_vec - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let execution_payload_root = calculate_multi_merkle_root( - &[ - Node::from_bytes( - execution_payload - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - execution_payload - .block_number - .hash_tree_root() - .map_err(|_| Error::InvalidRoot)?, - ], - &multi_proof_nodes, - &[ - GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), - GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), - ], - ); - - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let is_merkle_branch_valid = is_valid_merkle_branch( - &execution_payload_root, - execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - EXECUTION_PAYLOAD_INDEX as usize, - &Node::from_bytes( - update - .finalized_header - .clone() - .body_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - libc_println!("valid merkle branch for execution_payload_branch"); - if !is_merkle_branch_valid { - libc_println!("invalid merkle branch for execution_payload_branch"); - //Err(Error::InvalidMerkleBranch)?; - } - - if let Some(sync_committee_update) = update.sync_committee_update.clone() { - if update_attested_period == state_period - && sync_committee_update.next_sync_committee - != trusted_state.next_sync_committee.clone() - { - libc_println!("invalid update for sync committee update"); - //rr(Error::InvalidUpdate)? - } - - let next_sync_committee_branch = sync_committee_update - .next_sync_committee_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( - light_client_primitives::util::hash_tree_root( - sync_committee_update.next_sync_committee, - ) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - next_sync_committee_branch.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, - get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize, - &Node::from_bytes( - update - .attested_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - libc_println!( - "valid merkle branch for sync committee {}", - is_merkle_branch_valid - ); - if !is_merkle_branch_valid { - libc_println!("invalid merkle branch for sync committee"); - // Err(Error::InvalidMerkleBranch)?; - } - } - - // verify the ancestry proofs - for ancestor in update.ancestor_blocks { - match ancestor.ancestry_proof { - AncestryProof::BlockRoots { - block_roots_proof, - block_roots_branch, - } => { - let block_header_branch = block_roots_proof - .block_header_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let block_roots_root = calculate_merkle_root( - &Node::from_bytes( - hash_tree_root(ancestor.header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - &*block_header_branch, - &GeneralizedIndex(block_roots_proof.block_header_index as usize), - ); - - let block_roots_branch_node = block_roots_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let is_merkle_branch_valid = is_valid_merkle_branch( - &block_roots_root, - block_roots_branch_node.iter(), - BLOCK_ROOTS_INDEX.floor_log2() as usize, - BLOCK_ROOTS_INDEX as usize, - &Node::from_bytes( - update - .finalized_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - } - AncestryProof::HistoricalRoots { - block_roots_proof, - historical_batch_proof, - historical_roots_proof, - historical_roots_index, - historical_roots_branch, - } => { - let block_header_branch = block_roots_proof - .block_header_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let block_roots_root = calculate_merkle_root( - &Node::from_bytes( - hash_tree_root(ancestor.header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - &block_header_branch, - &GeneralizedIndex(block_roots_proof.block_header_index as usize), - ); - - let historical_batch_proof_nodes = historical_batch_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let historical_batch_root = calculate_merkle_root( - &block_roots_root, - &historical_batch_proof_nodes, - &GeneralizedIndex(HISTORICAL_BATCH_BLOCK_ROOTS_INDEX as usize), - ); - - let historical_roots_proof_nodes = historical_roots_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let historical_roots_root = calculate_merkle_root( - &historical_batch_root, - &historical_roots_proof_nodes, - &GeneralizedIndex(historical_roots_index as usize), - ); - - let historical_roots_branch_nodes = historical_roots_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &historical_roots_root, - historical_roots_branch_nodes.iter(), - HISTORICAL_ROOTS_INDEX.floor_log2() as usize, - get_subtree_index(HISTORICAL_ROOTS_INDEX) as usize, - &Node::from_bytes( - update - .finalized_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - } - }; - - // verify the associated execution paylaod header. - let execution_payload = ancestor.execution_payload; - let multi_proof = execution_payload - .multi_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let execution_payload_root = calculate_multi_merkle_root( - &[ - Node::from_bytes( - execution_payload - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - Node::from_bytes( - hash_tree_root(execution_payload.block_number) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ], - &multi_proof, - &[ - GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), - GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), - ], - ); - - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &execution_payload_root, - execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - EXECUTION_PAYLOAD_INDEX as usize, - &Node::from_bytes( - ancestor - .header - .body_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - } - - let new_light_client_state = - if let Some(sync_committee_update) = update.sync_committee_update { - LightClientState { - finalized_header: update.finalized_header, - current_sync_committee: trusted_state.next_sync_committee, - next_sync_committee: sync_committee_update.next_sync_committee, - } - } else { - LightClientState { - finalized_header: update.finalized_header, - ..trusted_state - } - }; - - Ok(new_light_client_state) - } -} diff --git a/light-client-primitives/Cargo.toml b/primitives/Cargo.toml similarity index 69% rename from light-client-primitives/Cargo.toml rename to primitives/Cargo.toml index 4e83181c9..a9f5cdf96 100644 --- a/light-client-primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,13 +1,12 @@ [package] -name = "light-client-primitives" +name = "sync-committee-primitives" version = "0.1.0" edition = "2021" authors = ["Polytope Labs"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -base2 = {version="0.2.2", default-features=false} +base2 = { version = "0.3.1", default-features=false} ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/light-client-primitives/src/lib.rs b/primitives/src/lib.rs similarity index 100% rename from light-client-primitives/src/lib.rs rename to primitives/src/lib.rs diff --git a/primitives/src/types.rs b/primitives/src/types.rs new file mode 100644 index 000000000..dc115b6f8 --- /dev/null +++ b/primitives/src/types.rs @@ -0,0 +1,125 @@ +use alloc::vec::Vec; +use ethereum_consensus::{ + bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, + domains::DomainType, + primitives::{Hash32, Slot}, +}; + +pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; +pub const FINALIZED_ROOT_INDEX: u64 = 105; +pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; +pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; +pub const EXECUTION_PAYLOAD_INDEX: u64 = 25; +pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; +pub const BLOCK_ROOTS_INDEX: u64 = 37; +pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; +pub const HISTORICAL_ROOTS_INDEX: u64 = 39; +pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); + +/// This holds the relevant data required to prove the state root in the execution payload. +#[derive(Debug, Clone)] +pub struct ExecutionPayloadProof { + /// The state root in the `ExecutionPayload` which represents the commitment to + /// the ethereum world state in the yellow paper. + pub state_root: Hash32, + /// the block number of the execution header. + pub block_number: u64, + /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. + pub multi_proof: Vec, + /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. + pub execution_payload_branch: Vec, +} + +/// Holds the neccessary proofs required to verify a header in the `block_roots` field +/// either in [`BeaconState`] or [`HistoricalBatch`]. +#[derive(Debug, Clone)] +pub struct BlockRootsProof { + /// Generalized index of the header in the `block_roots` list. + pub block_header_index: u64, + /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` + pub block_header_branch: Vec, +} + +/// The block header ancestry proof, this is an enum because the header may either exist in +/// `state.block_roots` or `state.historical_roots`. +#[derive(Debug, Clone)] +pub enum AncestryProof { + /// This variant defines the proof data for a beacon chain header in the `state.block_roots` + BlockRoots { + /// Proof for the header in `state.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] + block_roots_branch: Vec, + }, + /// This variant defines the neccessary proofs for a beacon chain header in the + /// `state.historical_roots`. + HistoricalRoots { + /// Proof for the header in `historical_batch.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the `historical_batch.block_roots`, needed to reconstruct + /// `hash_tree_root(historical_batch)` + historical_batch_proof: Vec, + /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` + historical_roots_proof: Vec, + /// The generalized index for the historical_batch in `state.historical_roots`. + historical_roots_index: u64, + /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in + /// [`BeaconState`] + historical_roots_branch: Vec, + }, +} + +/// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized +/// header. +#[derive(Debug, Clone)] +pub struct AncestorBlock { + /// The actual beacon chain header + pub header: BeaconBlockHeader, + /// Associated execution header proofs + pub execution_payload: ExecutionPayloadProof, + /// Ancestry proofs of the beacon chain header. + pub ancestry_proof: AncestryProof, +} + +/// Holds the latest sync committee as well as an ssz proof for it's existence +/// in a finalized header. +#[derive(Debug, Clone)] +pub struct SyncCommitteeUpdate { + // actual sync committee + pub next_sync_committee: SyncCommittee, + // sync committee, ssz merkle proof. + pub next_sync_committee_branch: Vec, +} + +/// Minimum state required by the light client to validate new sync committee attestations +#[derive(Debug, Clone)] +pub struct LightClientState { + /// The latest recorded finalized header + pub finalized_header: BeaconBlockHeader, + // Sync committees corresponding to the finalized header + pub current_sync_committee: SyncCommittee, + pub next_sync_committee: SyncCommittee, +} + +/// Data required to advance the state of the light client. +#[derive(Debug, Clone)] +pub struct LightClientUpdate { + /// the header that the sync committee signed + pub attested_header: BeaconBlockHeader, + /// the sync committee has potentially changed, here's an ssz proof for that. + pub sync_committee_update: Option>, + /// the actual header which was finalized by the ethereum attestation protocol. + pub finalized_header: BeaconBlockHeader, + /// execution payload of the finalized header + pub execution_payload: ExecutionPayloadProof, + /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 + /// epochs. + pub finality_branch: Vec, + /// signature & participation bits + pub sync_aggregate: SyncAggregate, + /// slot at which signature was produced + pub signature_slot: Slot, + /// ancestors of the finalized block to be verified, may be empty. + pub ancestor_blocks: Vec, +} diff --git a/light-client-primitives/src/util.rs b/primitives/src/util.rs similarity index 52% rename from light-client-primitives/src/util.rs rename to primitives/src/util.rs index 6685bf4f5..ab58d83be 100644 --- a/light-client-primitives/src/util.rs +++ b/primitives/src/util.rs @@ -1,46 +1,45 @@ use base2::Base2; -use ethereum_consensus::altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD; -use ethereum_consensus::configs::mainnet::{ - ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION, +use ethereum_consensus::{ + altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD, + configs::mainnet::{ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION}, + phase0::mainnet::SLOTS_PER_EPOCH, }; -use ethereum_consensus::phase0::mainnet::SLOTS_PER_EPOCH; -use ethereum_consensus::primitives::{Hash32, Root}; -use ssz_rs::{MerkleizationError, Node}; +use ssz_rs::Node; /// Calculate the subtree index from the ``generalized_index`` pub fn get_subtree_index(generalized_index: u64) -> u64 { - generalized_index % 2 ^ (generalized_index.floor_log2() as u64) + generalized_index % 2 ^ (generalized_index.floor_log2() as u64) } /// Return the sync committe period at the given ``epoch`` pub fn compute_sync_committee_period(epoch: u64) -> u64 { - epoch / EPOCHS_PER_SYNC_COMMITTEE_PERIOD + epoch / EPOCHS_PER_SYNC_COMMITTEE_PERIOD } /// Return the epoch number at ``slot``. pub fn compute_epoch_at_slot(slot: u64) -> u64 { - slot / SLOTS_PER_EPOCH + slot / SLOTS_PER_EPOCH } /// Return the fork version at the given ``epoch``. pub fn compute_fork_version(epoch: u64) -> [u8; 4] { - if epoch >= ALTAIR_FORK_EPOCH { - ALTAIR_FORK_VERSION - } else { - GENESIS_FORK_VERSION - } + if epoch >= ALTAIR_FORK_EPOCH { + ALTAIR_FORK_VERSION + } else { + GENESIS_FORK_VERSION + } } /// Return the sync committee period at ``slot`` pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { - compute_sync_committee_period(compute_epoch_at_slot(slot)) + compute_sync_committee_period(compute_epoch_at_slot(slot)) } /// method for hashing objects into a single root by utilizing a hash tree structure, as defined in /// the SSZ spec. pub fn hash_tree_root( - mut object: T, + mut object: T, ) -> Result { - let root = object.hash_tree_root()?; - Ok(root) + let root = object.hash_tree_root()?; + Ok(root) } diff --git a/sync-committee-prover/Cargo.toml b/prover/Cargo.toml similarity index 82% rename from sync-committee-prover/Cargo.toml rename to prover/Cargo.toml index 83216377d..513a81cca 100644 --- a/sync-committee-prover/Cargo.toml +++ b/prover/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -light-client-primitives = {path="../light-client-primitives", default-features = false } -light-client-verifier = {path="../light-client-verifier", default-features = false } +sync-committee-primitives = { path= "../primitives", default-features = false } +sync-committee-verifier = { path= "../verifier", default-features = false } ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} diff --git a/prover/src/error.rs b/prover/src/error.rs new file mode 100644 index 000000000..e6a6a5c49 --- /dev/null +++ b/prover/src/error.rs @@ -0,0 +1,5 @@ +#[derive(Debug)] +pub enum Error { + AggregateSignatureError, + EmptySignedBeaconBlock, +} diff --git a/prover/src/lib.rs b/prover/src/lib.rs new file mode 100644 index 000000000..219439c79 --- /dev/null +++ b/prover/src/lib.rs @@ -0,0 +1,346 @@ +mod error; +mod responses; +mod routes; +#[cfg(test)] +mod test; + +// todo: split up this file + +use ethereum_consensus::{ + altair::Validator, + bellatrix::{ + BeaconBlock, BeaconBlockHeader, BeaconState, Checkpoint, SignedBeaconBlock, SyncCommittee, + }, +}; +use reqwest::Client; + +use crate::{responses::sync_committee_response::NodeSyncCommittee, routes::*}; +use ethereum_consensus::{ + bellatrix::mainnet::{ + BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, + }, + crypto::eth_aggregate_public_keys, + phase0::mainnet::{ + EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, + HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, + SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, + }, + primitives::{Bytes32, Slot, ValidatorIndex}, +}; +use light_client_primitives::{ + types::{ + BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, + NEXT_SYNC_COMMITTEE_INDEX, + }, + util::get_subtree_index, +}; +use ssz_rs::{GeneralizedIndex, List, Node, Vector}; +use sync_committee_primitives::{ + types::{ + BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, + EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, + NEXT_SYNC_COMMITTEE_INDEX, + }, + util::get_subtree_index, +}; + +type BeaconBlockType = BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + +type SignedBeaconBlockType = SignedBeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + +pub type BeaconStateType = BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, +>; + +pub struct SyncCommitteeProver { + pub node_url: String, + pub client: Client, +} + +impl SyncCommitteeProver { + pub fn new(node_url: String) -> Self { + let client = Client::new(); + + SyncCommitteeProver { node_url, client } + } + + pub async fn fetch_finalized_checkpoint(&self) -> Result { + let full_url = self.generate_route(&finality_checkpoints("head")); + let response = self.client.get(full_url).send().await?; + + let response_data = + response.json::().await?; + Ok(response_data.data.finalized) + } + + pub async fn fetch_header(&self, block_id: &str) -> Result { + let path = header_route(block_id); + let full_url = self.generate_route(&path); + let response = self.client.get(full_url).send().await?; + let status = response.status().as_u16(); + + let response_data = + response.json::().await?; + + let beacon_block_header = response_data.data.header.message; + + Ok(beacon_block_header) + } + + pub async fn fetch_block( + &self, + block_id: &str, + ) -> Result< + BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + reqwest::Error, + > { + let path = block_route(block_id); + let full_url = self.generate_route(&path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response.json::().await?; + + let beacon_block = response_data.data.message; + + Ok(beacon_block) + } + + pub async fn fetch_sync_committee( + &self, + state_id: &str, + ) -> Result { + let path = sync_committee_route(state_id); + let full_url = self.generate_route(&path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response.json::().await?; + + let sync_committee = response_data.data; + + Ok(sync_committee) + } + + pub async fn fetch_validator( + &self, + state_id: &str, + validator_index: &str, + ) -> Result { + let path = validator_route(state_id, validator_index); + let full_url = self.generate_route(&path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response.json::().await?; + + let validator = response_data.data.validator; + + Ok(validator) + } + + pub async fn fetch_beacon_state( + &self, + state_id: &str, + ) -> Result { + let path = beacon_state_route(state_id); + let full_url = self.generate_route(&path); + + let response = self.client.get(full_url).send().await?; + + let response_data = response.json::().await?; + + let beacon_state = response_data.data; + + Ok(beacon_state) + } + + pub async fn fetch_processed_sync_committee( + &self, + state_id: &str, + ) -> Result, reqwest::Error> { + // fetches sync committee from Node + let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; + + let mut validators: List = Default::default(); + for mut validator_index in node_sync_committee.validators.clone() { + // fetches validator based on validator index + let validator = self.fetch_validator(state_id.clone(), &validator_index).await?; + validators.push(validator); + } + + let public_keys_vector = node_sync_committee + .validators + .into_iter() + .map(|i| { + let validator_index: ValidatorIndex = i.parse().unwrap(); + validators[validator_index].public_key.clone() + }) + .collect::>(); + + let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); + + let sync_committee = SyncCommittee:: { + public_keys: public_keys_vector, + aggregate_public_key, + }; + + Ok(sync_committee) + } + + async fn fetch_latest_finalized_block( + &self, + ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { + let block_header = self.fetch_header("finalized").await?; + let block = self.fetch_block("finalized").await?; + + Ok((block_header, block)) + } + + fn generate_route(&self, path: &str) -> String { + format!("{}{}", self.node_url.clone(), path) + } +} + +fn get_attestation_slots_for_finalized_header( + finalized_header: &BeaconBlockHeader, + slots_per_epoch: u64, +) -> Slot { + let finalized_header_slot = finalized_header.slot; + + // given that an epoch is 32 slots and blocks are finalized every 2 epochs + // so the attested slot for a finalized block is 64 slots away + let attested_slot = finalized_header_slot + (slots_per_epoch * 2); + + attested_slot +} + +fn prove_beacon_state_values( + data: BeaconStateType, + indices: &[usize], +) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(data, indices)?; + Ok(proof) +} + +fn prove_beacon_block_values( + data: BeaconBlockType, + indices: &[usize], +) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(data, indices)?; + Ok(proof) +} + +fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result { + let indices = [ + EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, + ]; + // generate multi proofs + let multi_proof = + ssz_rs::generate_proof(block.body.execution_payload.clone(), indices.as_slice())?; + + let execution_payload_index = [GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0]; + let execution_payload_branch = + ssz_rs::generate_proof(block.body.clone(), execution_payload_index.as_slice())?; + + Ok(ExecutionPayloadProof { + state_root: block.body.execution_payload.state_root, + block_number: block.body.execution_payload.block_number, + multi_proof: multi_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), + execution_payload_branch: execution_payload_branch + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), + }) +} + +fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { + let indices = vec![NEXT_SYNC_COMMITTEE_INDEX as usize]; + let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; + + Ok(proof) +} + +fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { + let indices = [FINALIZED_ROOT_INDEX as usize]; //vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; + let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; + + Ok(proof) +} + +// function that generates block roots proof +// block number and convert to get_subtree_index +// beacon state has a block roots vec, pass the block root to generate proof +fn prove_block_roots_proof( + state: BeaconStateType, + block_number: u64, +) -> anyhow::Result { + let indices = vec![get_subtree_index(block_number) as usize]; + let proof = ssz_rs::generate_proof(state.block_roots, indices.as_slice())?; + + Ok(BlockRootsProof { + block_header_index: block_number, + block_header_branch: proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), + }) +} + +// prove the block roots vec inside the beacon state which will be the block roots branch + +// when aggr sigs, create a new bit list diff --git a/sync-committee-prover/src/responses/beacon_block_header_response.rs b/prover/src/responses/beacon_block_header_response.rs similarity index 67% rename from sync-committee-prover/src/responses/beacon_block_header_response.rs rename to prover/src/responses/beacon_block_header_response.rs index 4ac4748ed..3d6d3a533 100644 --- a/sync-committee-prover/src/responses/beacon_block_header_response.rs +++ b/prover/src/responses/beacon_block_header_response.rs @@ -2,18 +2,18 @@ use ethereum_consensus::bellatrix::BeaconBlockHeader; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { - pub(crate) data: ResponseData, - execution_optimistic: bool, + pub(crate) data: ResponseData, + execution_optimistic: bool, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ResponseData { - root: String, - canonical: bool, - pub(crate) header: ResponseDataBeaconBlockHeaderMessage, + root: String, + canonical: bool, + pub(crate) header: ResponseDataBeaconBlockHeaderMessage, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ResponseDataBeaconBlockHeaderMessage { - pub message: BeaconBlockHeader, + pub message: BeaconBlockHeader, } diff --git a/prover/src/responses/beacon_block_response.rs b/prover/src/responses/beacon_block_response.rs new file mode 100644 index 000000000..d90317c7a --- /dev/null +++ b/prover/src/responses/beacon_block_response.rs @@ -0,0 +1,40 @@ +use ethereum_consensus::{ + bellatrix::{ + mainnet::{ + BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, + }, + BeaconBlock, BeaconBlockHeader, + }, + phase0::mainnet::{ + EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, + HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, + SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, + }, +}; + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + pub(crate) data: ResponseData, + version: String, + execution_optimistic: bool, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct ResponseData { + pub(crate) message: BeaconBlock< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, + pub signature: String, +} diff --git a/prover/src/responses/beacon_state_response.rs b/prover/src/responses/beacon_state_response.rs new file mode 100644 index 000000000..14b0b91ee --- /dev/null +++ b/prover/src/responses/beacon_state_response.rs @@ -0,0 +1,26 @@ +use ethereum_consensus::bellatrix::BeaconState; + +use ethereum_consensus::bellatrix::mainnet::{ + BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, + ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, + MAX_TRANSACTIONS_PER_PAYLOAD, MAX_VALIDATORS_PER_COMMITTEE, SLOTS_PER_HISTORICAL_ROOT, + SYNC_COMMITTEE_SIZE, VALIDATOR_REGISTRY_LIMIT, +}; +#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +pub struct Response { + version: String, + pub(crate) data: BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + >, +} diff --git a/sync-committee-prover/src/responses/finality_checkpoint_response.rs b/prover/src/responses/finality_checkpoint_response.rs similarity index 63% rename from sync-committee-prover/src/responses/finality_checkpoint_response.rs rename to prover/src/responses/finality_checkpoint_response.rs index f9e9a20eb..17c276be7 100644 --- a/sync-committee-prover/src/responses/finality_checkpoint_response.rs +++ b/prover/src/responses/finality_checkpoint_response.rs @@ -2,13 +2,13 @@ use ethereum_consensus::bellatrix::Checkpoint; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub(crate) struct Response { - execution_optimistic: bool, - pub data: ResponseData, + execution_optimistic: bool, + pub data: ResponseData, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ResponseData { - previous_justified: Checkpoint, - current_justified: Checkpoint, - pub finalized: Checkpoint, + previous_justified: Checkpoint, + current_justified: Checkpoint, + pub finalized: Checkpoint, } diff --git a/sync-committee-prover/src/responses/mod.rs b/prover/src/responses/mod.rs similarity index 85% rename from sync-committee-prover/src/responses/mod.rs rename to prover/src/responses/mod.rs index 1d63bda98..bb7714c6f 100644 --- a/sync-committee-prover/src/responses/mod.rs +++ b/prover/src/responses/mod.rs @@ -4,3 +4,5 @@ pub mod beacon_state_response; pub mod finality_checkpoint_response; pub mod sync_committee_response; pub mod validator_response; + +// todo: collapse into one file. diff --git a/sync-committee-prover/src/responses/sync_committee_response.rs b/prover/src/responses/sync_committee_response.rs similarity index 60% rename from sync-committee-prover/src/responses/sync_committee_response.rs rename to prover/src/responses/sync_committee_response.rs index 80bbcd7d8..7e0637eb5 100644 --- a/sync-committee-prover/src/responses/sync_committee_response.rs +++ b/prover/src/responses/sync_committee_response.rs @@ -1,11 +1,11 @@ #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { - pub(crate) data: NodeSyncCommittee, - execution_optimistic: bool, + pub(crate) data: NodeSyncCommittee, + execution_optimistic: bool, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct NodeSyncCommittee { - pub validators: Vec, - pub validator_aggregates: Vec>, + pub validators: Vec, + pub validator_aggregates: Vec>, } diff --git a/sync-committee-prover/src/responses/validator_response.rs b/prover/src/responses/validator_response.rs similarity index 60% rename from sync-committee-prover/src/responses/validator_response.rs rename to prover/src/responses/validator_response.rs index 4422a4b8f..6a37e0afd 100644 --- a/sync-committee-prover/src/responses/validator_response.rs +++ b/prover/src/responses/validator_response.rs @@ -2,14 +2,14 @@ use ethereum_consensus::bellatrix::Validator; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { - pub(crate) data: ValidatorData, - execution_optimistic: bool, + pub(crate) data: ValidatorData, + execution_optimistic: bool, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ValidatorData { - pub index: String, - pub balance: String, - pub status: String, - pub(crate) validator: Validator, + pub index: String, + pub balance: String, + pub status: String, + pub(crate) validator: Validator, } diff --git a/prover/src/routes.rs b/prover/src/routes.rs new file mode 100644 index 000000000..a6b7d37ed --- /dev/null +++ b/prover/src/routes.rs @@ -0,0 +1,21 @@ +pub fn header_route(block_id: &str) -> String { + format!("/eth/v1/beacon/headers/{block_id}") +} + +pub fn block_route(block_id: &str) -> String { + format!("/eth/v2/beacon/blocks/{block_id}") +} + +pub fn sync_committee_route(state_id: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/sync_committees") +} + +pub fn validator_route(state_id: &str, validator_index: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/validators/{validator_index}") +} +pub fn beacon_state_route(state_id: &str) -> String { + format!("/eth/v2/debug/beacon/states/{state_id}") +} +pub fn finality_checkpoints(state_id: &str) -> String { + format!("/eth/v1/beacon/states/{state_id}/finality_checkpoints") +} diff --git a/prover/src/test.rs b/prover/src/test.rs new file mode 100644 index 000000000..3854bd5f6 --- /dev/null +++ b/prover/src/test.rs @@ -0,0 +1,508 @@ +use super::*; +use base2::Base2; +use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; +use light_client_primitives::{ + types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, + util::compute_sync_committee_period_at_slot, +}; +use light_client_verifier::light_client::EthLightClient; +use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; +use std::{thread, time::Duration}; +use tokio::time; +use tokio_stream::{wrappers::IntervalStream, StreamExt}; + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_block_header_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let mut block_header = sync_committee_prover.fetch_header("1000").await; + while block_header.is_err() { + println!("I am running till i am ok. lol"); + block_header = sync_committee_prover.fetch_header("1000").await; + } + assert!(block_header.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_block_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block = sync_committee_prover.fetch_block("100").await; + assert!(block.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_sync_committee_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let block = sync_committee_prover.fetch_sync_committee("117").await; + assert!(block.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_validator_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let validator = sync_committee_prover.fetch_validator("2561", "48").await; + assert!(validator.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_processed_sync_committee_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let validator = sync_committee_prover.fetch_processed_sync_committee("2561").await; + assert!(validator.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_beacon_state_works() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; + assert!(beacon_state.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn state_root_and_block_header_root_matches() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let beacon_state = sync_committee_prover.fetch_beacon_state("100").await; + assert!(beacon_state.is_ok()); + + let block_header = sync_committee_prover.fetch_header("100").await; + assert!(block_header.is_ok()); + + let state = beacon_state.unwrap(); + let block_header = block_header.unwrap(); + let hash_tree_root = state.clone().hash_tree_root(); + + assert!(block_header.state_root == hash_tree_root.unwrap()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn fetch_finality_checkpoints_work() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; + assert!(finality_checkpoint.is_ok()); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_execution_payload_proof() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let block_id = "finalized"; + let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); + + let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); + + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + + // verify the associated execution header of the finalized beacon header. + let mut execution_payload = execution_payload_proof.clone(); + let multi_proof_vec = execution_payload.multi_proof; + let multi_proof_nodes = multi_proof_vec + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), + execution_payload.block_number.hash_tree_root().unwrap(), + ], + &multi_proof_nodes, + &[ + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + ], + ); + + println!("execution_payload_root {:?}", execution_payload_root); + + let execution_payload_hash_tree_root = + finalized_block.body.execution_payload.clone().hash_tree_root().unwrap(); + + println!("execution_payload_hash_tree_root {:?}", execution_payload_hash_tree_root); + + assert_eq!(execution_payload_root, execution_payload_hash_tree_root); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, + &Node::from_bytes(finalized_header.clone().body_root.as_ref().try_into().unwrap()), + ); + + assert_eq!(is_merkle_branch_valid, true); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_finality_proof() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let block_id = "finalized"; + let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); + + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); + + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); + + let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + } + + let attested_header = attested_header.unwrap(); + + let finality_branch_proof = finality_branch_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + + // verify the associated execution header of the finalized beacon header. + + // Verify that the `finality_branch` confirms `finalized_header` + // to match the finalized checkpoint root saved in the state of `attested_header`. + // Note that the genesis finalized checkpoint root is represented as a zero hash. + let finalized_root = &Node::from_bytes( + light_client_primitives::util::hash_tree_root(finalized_header.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ); + + let branch = finality_branch_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + println!("finalized_root {:?}", finalized_root.clone()); + + let finality_hash_tree_root = finalized_block.clone().hash_tree_root().unwrap(); + + assert_eq!(finalized_root, &finality_hash_tree_root); + + println!("finalized_root {:?}", finality_hash_tree_root); + let is_merkle_branch_valid = is_valid_merkle_branch( + finalized_root, + branch.iter(), + FINALIZED_ROOT_INDEX.floor_log2() as usize, + get_subtree_index(FINALIZED_ROOT_INDEX) as usize, + &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), + ); + + println!("is_merkle_branch_valid {:?}", is_merkle_branch_valid.clone()); + + assert!(is_merkle_branch_valid, "{}", true); +} + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_sync_committee_proof() { + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); + + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); + dbg!(&finality_checkpoint.root); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + dbg!(&block_id); + + let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + + let state = sync_committee_prover + .fetch_beacon_state(&block_header.slot.to_string()) + .await + .unwrap(); + + let block_id = "head"; + let mut finalized_block = sync_committee_prover.fetch_block(block_id).await; + + while finalized_block.is_err() { + println!("I am running finalized block till i am ok. lol {}", &block_id); + finalized_block = sync_committee_prover.fetch_block(block_id).await; + } + + let finalized_block = finalized_block.unwrap(); + + let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); + + let sync_committee_proof = prove_sync_committee_update(finalized_state.clone()).unwrap(); + + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + let mut sync_committee = sync_committee_prover + .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) + .await; + + while sync_committee.is_err() { + println!("I am fetching sync committee till i am ok. lol {}", &block_id); + sync_committee = sync_committee_prover + .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) + .await; + } + + let sync_committee = sync_committee.unwrap(); + + let calculated_finalized_root = calculate_multi_merkle_root( + &[Node::from_bytes( + light_client_primitives::util::hash_tree_root(sync_committee.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + )], + &sync_committee_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(), + &[GeneralizedIndex(NEXT_SYNC_COMMITTEE_INDEX as usize)], + ); + + let hash_tree_root = finalized_state.clone().hash_tree_root().unwrap(); + + println!("calculated_finalized_root {:?}", calculated_finalized_root); + println!("finalized_state_root {:?}", finalized_header.state_root); + println!("hash_tree_root {:?}", hash_tree_root); + + let next_sync_committee_branch = sync_committee_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + light_client_primitives::util::hash_tree_root(sync_committee.clone()) + .unwrap() + .as_ref() + .try_into() + .unwrap(), + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX as usize, + &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), + ); + + println!("valid merkle branch for sync committee {}", is_merkle_branch_valid); + assert!(is_merkle_branch_valid, "{}", true); +} + +// use tokio interval(should run every 13 minutes) +// every 13 minutes, fetch latest finalized block +// then prove the execution payload +// prove the finality branch + +// prove sync committee if there is a sync committee update +// to prove sync comnmittee update, calculate state_period and the update_attested_period +// ensure they are the same, and then prove sync committee + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_prover() { + // In test config an epoch is 6 slots and we expect finalization every two epochs, + // a slot is 12 seconds so that brings us to 144 seconds + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); + + let node_url: String = "http://127.0.0.1:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); + dbg!(&finality_checkpoint.root); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + dbg!(&block_id); + + let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + + let state = sync_committee_prover + .fetch_beacon_state(&block_header.slot.to_string()) + .await + .unwrap(); + + let mut client_state = LightClientState { + finalized_header: block_header.clone(), + current_sync_committee: state.current_sync_committee, + next_sync_committee: state.next_sync_committee, + }; + + while let Some(_ts) = stream.next().await { + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); + dbg!(&finality_checkpoint.root); + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + dbg!(&block_id); + let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); + + if finalized_block.slot <= client_state.finalized_header.slot { + println!("finalized_block slot is {}", &finalized_block.slot); + println!("finalized_header slot is {}", &client_state.finalized_header.slot); + continue + } + + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + + let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); + + let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .await + .unwrap(); + + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_header_slot.to_string().as_str()) + .await + .unwrap(); + + let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + let finality_branch_proof = finality_branch_proof + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect::>(); + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + // purposely for waiting + //println!("sleeping"); + thread::sleep(time::Duration::from_secs(5)); + + let mut attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + + while attested_header.is_err() { + println!("I am running till i am ok. lol {}", &block_id); + attested_header = sync_committee_prover + .fetch_header(attested_header_slot.to_string().as_str()) + .await; + } + + let attested_header = attested_header.unwrap(); + + let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); + + let sync_committee_update = if state_period == attested_header_slot { + let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); + + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect::>(); + + let sync_committee = sync_committee_prover + .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) + .await + .unwrap(); + + Some(SyncCommitteeUpdate { + next_sync_committee: sync_committee, + next_sync_committee_branch: sync_committee_proof, + }) + } else { + None + }; + + // construct light client + let light_client_update = LightClientUpdate { + attested_header, + sync_committee_update, + finalized_header, + execution_payload: execution_payload_proof, + finality_branch: finality_branch_proof, + sync_aggregate: finalized_block.body.sync_aggregate, + signature_slot: attested_header_slot, + ancestor_blocks: vec![], + }; + + client_state = EthLightClient::verify_sync_committee_attestation( + client_state.clone(), + light_client_update, + ) + .unwrap(); + println!( + "Sucessfully verified Ethereum block at slot {:?}", + client_state.finalized_header.slot + ); + } +} diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..441913f61 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,23 @@ +# Basic +hard_tabs = true +max_width = 100 +use_small_heuristics = "Max" +# Imports +imports_granularity = "Crate" +reorder_imports = true +# Consistency +newline_style = "Unix" +# Format comments +comment_width = 100 +wrap_comments = true +# Misc +chain_width = 80 +spaces_around_ranges = false +binop_separator = "Back" +reorder_impl_items = false +match_arm_leading_pipes = "Preserve" +match_arm_blocks = false +match_block_trailing_comma = true +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true diff --git a/sync-committee-prover/src/error.rs b/sync-committee-prover/src/error.rs deleted file mode 100644 index 9ec588852..000000000 --- a/sync-committee-prover/src/error.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug)] -pub enum Error { - AggregateSignatureError, - EmptySignedBeaconBlock, -} diff --git a/sync-committee-prover/src/lib.rs b/sync-committee-prover/src/lib.rs deleted file mode 100644 index add7b1cda..000000000 --- a/sync-committee-prover/src/lib.rs +++ /dev/null @@ -1,344 +0,0 @@ -mod error; -mod responses; -mod routes; -#[cfg(test)] -mod test; - -use ethereum_consensus::altair::Validator; -use ethereum_consensus::bellatrix::{ - BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, Checkpoint, SignedBeaconBlock, - SignedBeaconBlockHeader, SyncCommittee, -}; -use reqwest::{Client, StatusCode}; - -use crate::error::Error; -use crate::responses::sync_committee_response::NodeSyncCommittee; -use crate::routes::*; -use ethereum_consensus::bellatrix::mainnet::{ - BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, -}; -use ethereum_consensus::crypto::{aggregate, eth_aggregate_public_keys, PublicKey}; -use ethereum_consensus::phase0::mainnet::{ - EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, - HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, - SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, -}; -use ethereum_consensus::primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}; -use light_client_primitives::types::{ - BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, - EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, - NEXT_SYNC_COMMITTEE_INDEX, -}; -use light_client_primitives::util::get_subtree_index; -use ssz_rs::{ - get_generalized_index, Bitlist, GeneralizedIndex, List, Node, SszVariableOrIndex, Vector, -}; - -type BeaconBlockType = BeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, ->; - -type SignedBeaconBlockType = SignedBeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, ->; - -pub type BeaconStateType = BeaconState< - SLOTS_PER_HISTORICAL_ROOT, - HISTORICAL_ROOTS_LIMIT, - ETH1_DATA_VOTES_BOUND, - VALIDATOR_REGISTRY_LIMIT, - EPOCHS_PER_HISTORICAL_VECTOR, - EPOCHS_PER_SLASHINGS_VECTOR, - MAX_VALIDATORS_PER_COMMITTEE, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, ->; - -pub struct SyncCommitteeProver { - pub node_url: String, - pub client: Client, -} - -impl SyncCommitteeProver { - pub fn new(node_url: String) -> Self { - let client = reqwest::Client::new(); - - SyncCommitteeProver { node_url, client } - } - - pub async fn fetch_finalized_checkpoint(&self) -> Result { - let full_url = self.generate_route(&finality_checkpoints("head")); - let response = self.client.get(full_url).send().await?; - - let response_data = response - .json::() - .await?; - Ok(response_data.data.finalized) - } - - pub async fn fetch_header(&self, block_id: &str) -> Result { - let path = header_route(block_id); - let full_url = self.generate_route(&path); - let response = self.client.get(full_url).send().await?; - let status = response.status().as_u16(); - - let response_data = response - .json::() - .await?; - - let beacon_block_header = response_data.data.header.message; - - Ok(beacon_block_header) - } - pub async fn fetch_block( - &self, - block_id: &str, - ) -> Result< - BeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, - reqwest::Error, - > { - let path = block_route(block_id); - let full_url = self.generate_route(&path); - - let response = self.client.get(full_url).send().await?; - - let response_data = response - .json::() - .await?; - - let beacon_block = response_data.data.message; - - Ok(beacon_block) - } - pub async fn fetch_sync_committee( - &self, - state_id: &str, - ) -> Result { - let path = sync_committee_route(state_id); - let full_url = self.generate_route(&path); - - let response = self.client.get(full_url).send().await?; - - let response_data = response - .json::() - .await?; - - let sync_committee = response_data.data; - - Ok(sync_committee) - } - pub async fn fetch_validator( - &self, - state_id: &str, - validator_index: &str, - ) -> Result { - let path = validator_route(state_id, validator_index); - let full_url = self.generate_route(&path); - - let response = self.client.get(full_url).send().await?; - - let response_data = response - .json::() - .await?; - - let validator = response_data.data.validator; - - Ok(validator) - } - - pub async fn fetch_beacon_state( - &self, - state_id: &str, - ) -> Result { - let path = beacon_state_route(state_id); - let full_url = self.generate_route(&path); - - let response = self.client.get(full_url).send().await?; - - let response_data = response - .json::() - .await?; - - let beacon_state = response_data.data; - - Ok(beacon_state) - } - - pub async fn fetch_processed_sync_committee( - &self, - state_id: &str, - ) -> Result, reqwest::Error> { - // fetches sync committee from Node - let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; - - let mut validators: List = Default::default(); - for mut validator_index in node_sync_committee.validators.clone() { - // fetches validator based on validator index - let validator = self - .fetch_validator(state_id.clone(), &validator_index) - .await?; - validators.push(validator); - } - - let public_keys_vector = node_sync_committee - .validators - .into_iter() - .map(|i| { - let validator_index: ValidatorIndex = i.parse().unwrap(); - validators[validator_index].public_key.clone() - }) - .collect::>(); - - let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); - - let sync_committee = SyncCommittee:: { - public_keys: public_keys_vector, - aggregate_public_key, - }; - - Ok(sync_committee) - } - - async fn fetch_latest_finalized_block( - &self, - ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { - let block_header = self.fetch_header("finalized").await?; - let block = self.fetch_block("finalized").await?; - - Ok((block_header, block)) - } - - fn generate_route(&self, path: &str) -> String { - format!("{}{}", self.node_url.clone(), path) - } -} - -fn get_attestation_slots_for_finalized_header( - finalized_header: &BeaconBlockHeader, - slots_per_epoch: u64, -) -> Slot { - let finalized_header_slot = finalized_header.slot; - - // given that an epoch is 32 slots and blocks are finalized every 2 epochs - // so the attested slot for a finalized block is 64 slots away - let attested_slot = finalized_header_slot + (slots_per_epoch * 2); - - attested_slot -} - -fn prove_beacon_state_values( - data: BeaconStateType, - indices: &[usize], -) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(data, indices)?; - Ok(proof) -} - -fn prove_beacon_block_values( - data: BeaconBlockType, - indices: &[usize], -) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(data, indices)?; - Ok(proof) -} - -fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result { - let indices = [ - EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, - EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, - ]; - // generate multi proofs - let multi_proof = - ssz_rs::generate_proof(block.body.execution_payload.clone(), indices.as_slice())?; - - let execution_payload_index = [GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0]; - let execution_payload_branch = - ssz_rs::generate_proof(block.body.clone(), execution_payload_index.as_slice())?; - - Ok(ExecutionPayloadProof { - state_root: block.body.execution_payload.state_root, - block_number: block.body.execution_payload.block_number, - multi_proof: multi_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), - execution_payload_branch: execution_payload_branch - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), - }) -} - -fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { - let indices = vec![NEXT_SYNC_COMMITTEE_INDEX as usize]; - let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; - - Ok(proof) -} - -fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { - let indices = [FINALIZED_ROOT_INDEX as usize]; //vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; - let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; - - Ok(proof) -} - -// function that generates block roots proof -// block number and convert to get_subtree_index -// beacon state has a block roots vec, pass the block root to generate proof -fn prove_block_roots_proof( - state: BeaconStateType, - block_number: u64, -) -> anyhow::Result { - let indices = vec![get_subtree_index(block_number) as usize]; - let proof = ssz_rs::generate_proof(state.block_roots, indices.as_slice())?; - - Ok(BlockRootsProof { - block_header_index: block_number, - block_header_branch: proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), - }) -} - -// prove the block roots vec inside the beacon state which will be the block roots branch - -// when aggr sigs, create a new bit list diff --git a/sync-committee-prover/src/responses/beacon_block_response.rs b/sync-committee-prover/src/responses/beacon_block_response.rs deleted file mode 100644 index e4f1a19c6..000000000 --- a/sync-committee-prover/src/responses/beacon_block_response.rs +++ /dev/null @@ -1,36 +0,0 @@ -use ethereum_consensus::bellatrix::mainnet::{ - BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, -}; -use ethereum_consensus::bellatrix::{BeaconBlock, BeaconBlockHeader}; -use ethereum_consensus::phase0::mainnet::{ - EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, - HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, - SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, -}; - -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct Response { - pub(crate) data: ResponseData, - version: String, - execution_optimistic: bool, -} - -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct ResponseData { - pub(crate) message: BeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, - pub signature: String, -} diff --git a/sync-committee-prover/src/responses/beacon_state_response.rs b/sync-committee-prover/src/responses/beacon_state_response.rs deleted file mode 100644 index d9155750b..000000000 --- a/sync-committee-prover/src/responses/beacon_state_response.rs +++ /dev/null @@ -1,26 +0,0 @@ -use ethereum_consensus::bellatrix::BeaconState; - -use ethereum_consensus::bellatrix::mainnet::{ - BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, - ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, MAX_VALIDATORS_PER_COMMITTEE, SLOTS_PER_HISTORICAL_ROOT, - SYNC_COMMITTEE_SIZE, VALIDATOR_REGISTRY_LIMIT, -}; -#[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct Response { - version: String, - pub(crate) data: BeaconState< - SLOTS_PER_HISTORICAL_ROOT, - HISTORICAL_ROOTS_LIMIT, - ETH1_DATA_VOTES_BOUND, - VALIDATOR_REGISTRY_LIMIT, - EPOCHS_PER_HISTORICAL_VECTOR, - EPOCHS_PER_SLASHINGS_VECTOR, - MAX_VALIDATORS_PER_COMMITTEE, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, - >, -} diff --git a/sync-committee-prover/src/routes.rs b/sync-committee-prover/src/routes.rs deleted file mode 100644 index a7b398b28..000000000 --- a/sync-committee-prover/src/routes.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub fn header_route(block_id: &str) -> String { - format!("/eth/v1/beacon/headers/{block_id}") -} - -pub fn block_route(block_id: &str) -> String { - format!("/eth/v2/beacon/blocks/{block_id}") -} - -pub fn sync_committee_route(state_id: &str) -> String { - format!("/eth/v1/beacon/states/{state_id}/sync_committees") -} - -pub fn validator_route(state_id: &str, validator_index: &str) -> String { - format!("/eth/v1/beacon/states/{state_id}/validators/{validator_index}") -} -pub fn beacon_state_route(state_id: &str) -> String { - format!("/eth/v2/debug/beacon/states/{state_id}") -} -pub fn finality_checkpoints(state_id: &str) -> String { - format!("/eth/v1/beacon/states/{state_id}/finality_checkpoints") -} diff --git a/sync-committee-prover/src/test.rs b/sync-committee-prover/src/test.rs deleted file mode 100644 index 7e408823f..000000000 --- a/sync-committee-prover/src/test.rs +++ /dev/null @@ -1,560 +0,0 @@ -use super::*; -use base2::Base2; -use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; -use light_client_primitives::types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}; -use light_client_primitives::util::compute_sync_committee_period_at_slot; -use light_client_verifier::light_client::EthLightClient; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; -use std::thread; -use std::time::Duration; -use tokio::time; -use tokio_stream::wrappers::IntervalStream; -use tokio_stream::StreamExt; - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_block_header_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let mut block_header = sync_committee_prover.fetch_header("1000").await; - while block_header.is_err() { - println!("I am running till i am ok. lol"); - block_header = sync_committee_prover.fetch_header("1000").await; - } - assert!(block_header.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_block_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_block("100").await; - assert!(block.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_sync_committee_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_sync_committee("117").await; - assert!(block.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_validator_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let validator = sync_committee_prover.fetch_validator("2561", "48").await; - assert!(validator.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_processed_sync_committee_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let validator = sync_committee_prover - .fetch_processed_sync_committee("2561") - .await; - assert!(validator.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_beacon_state_works() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; - assert!(beacon_state.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn state_root_and_block_header_root_matches() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let beacon_state = sync_committee_prover.fetch_beacon_state("100").await; - assert!(beacon_state.is_ok()); - - let block_header = sync_committee_prover.fetch_header("100").await; - assert!(block_header.is_ok()); - - let state = beacon_state.unwrap(); - let block_header = block_header.unwrap(); - let hash_tree_root = state.clone().hash_tree_root(); - - assert!(block_header.state_root == hash_tree_root.unwrap()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_finality_checkpoints_work() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; - assert!(finality_checkpoint.is_ok()); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_execution_payload_proof() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let block_id = "finalized"; - let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); - - let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); - - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - - // verify the associated execution header of the finalized beacon header. - let mut execution_payload = execution_payload_proof.clone(); - let multi_proof_vec = execution_payload.multi_proof; - let multi_proof_nodes = multi_proof_vec - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let execution_payload_root = calculate_multi_merkle_root( - &[ - Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), - execution_payload.block_number.hash_tree_root().unwrap(), - ], - &multi_proof_nodes, - &[ - GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), - GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), - ], - ); - - println!("execution_payload_root {:?}", execution_payload_root); - - let execution_payload_hash_tree_root = finalized_block - .body - .execution_payload - .clone() - .hash_tree_root() - .unwrap(); - - println!( - "execution_payload_hash_tree_root {:?}", - execution_payload_hash_tree_root - ); - - assert_eq!(execution_payload_root, execution_payload_hash_tree_root); - - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let is_merkle_branch_valid = is_valid_merkle_branch( - &execution_payload_root, - execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, - &Node::from_bytes( - finalized_header - .clone() - .body_root - .as_ref() - .try_into() - .unwrap(), - ), - ); - - assert_eq!(is_merkle_branch_valid, true); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_finality_proof() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let block_id = "finalized"; - let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); - - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); - - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); - - let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); - - let mut attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } - - let attested_header = attested_header.unwrap(); - - let finality_branch_proof = finality_branch_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); - - // verify the associated execution header of the finalized beacon header. - - // Verify that the `finality_branch` confirms `finalized_header` - // to match the finalized checkpoint root saved in the state of `attested_header`. - // Note that the genesis finalized checkpoint root is represented as a zero hash. - let finalized_root = &Node::from_bytes( - light_client_primitives::util::hash_tree_root(finalized_header.clone()) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - ); - - let branch = finality_branch_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - println!("finalized_root {:?}", finalized_root.clone()); - - let finality_hash_tree_root = finalized_block.clone().hash_tree_root().unwrap(); - - assert_eq!(finalized_root, &finality_hash_tree_root); - - println!("finalized_root {:?}", finality_hash_tree_root); - let is_merkle_branch_valid = is_valid_merkle_branch( - finalized_root, - branch.iter(), - FINALIZED_ROOT_INDEX.floor_log2() as usize, - get_subtree_index(FINALIZED_ROOT_INDEX) as usize, - &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), - ); - - println!( - "is_merkle_branch_valid {:?}", - is_merkle_branch_valid.clone() - ); - - assert!(is_merkle_branch_valid, "{}", true); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_sync_committee_proof() { - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); - - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let finality_checkpoint = sync_committee_prover - .fetch_finalized_checkpoint() - .await - .unwrap(); - dbg!(&finality_checkpoint.root); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - - let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let state = sync_committee_prover - .fetch_beacon_state(&block_header.slot.to_string()) - .await - .unwrap(); - - let block_id = "head"; - let mut finalized_block = sync_committee_prover.fetch_block(block_id).await; - - while finalized_block.is_err() { - println!( - "I am running finalized block till i am ok. lol {}", - &block_id - ); - finalized_block = sync_committee_prover.fetch_block(block_id).await; - } - - let finalized_block = finalized_block.unwrap(); - - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); - - let sync_committee_proof = prove_sync_committee_update(finalized_state.clone()).unwrap(); - - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); - let mut sync_committee = sync_committee_prover - .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) - .await; - - while sync_committee.is_err() { - println!( - "I am fetching sync committee till i am ok. lol {}", - &block_id - ); - sync_committee = sync_committee_prover - .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) - .await; - } - - let sync_committee = sync_committee.unwrap(); - - let calculated_finalized_root = calculate_multi_merkle_root( - &[ - Node::from_bytes( - light_client_primitives::util::hash_tree_root( - sync_committee.clone(), - ) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - ), - ], - &sync_committee_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(), - &[ - GeneralizedIndex(NEXT_SYNC_COMMITTEE_INDEX as usize), - ], - ); - - let hash_tree_root = finalized_state - .clone() - .hash_tree_root() - .unwrap(); - - println!("calculated_finalized_root {:?}", calculated_finalized_root); - println!("finalized_state_root {:?}", finalized_header.state_root); - println!("hash_tree_root {:?}", hash_tree_root); - - - let next_sync_committee_branch = sync_committee_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( - light_client_primitives::util::hash_tree_root( - sync_committee.clone(), - ) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - ), - next_sync_committee_branch.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, - NEXT_SYNC_COMMITTEE_INDEX as usize, - &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), - ); - - println!( - "valid merkle branch for sync committee {}", - is_merkle_branch_valid - ); - assert!(is_merkle_branch_valid, "{}", true); -} - -// use tokio interval(should run every 13 minutes) -// every 13 minutes, fetch latest finalized block -// then prove the execution payload -// prove the finality branch - -// prove sync committee if there is a sync committee update -// to prove sync comnmittee update, calculate state_period and the update_attested_period -// ensure they are the same, and then prove sync committee - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_prover() { - // In test config an epoch is 6 slots and we expect finalization every two epochs, - // a slot is 12 seconds so that brings us to 144 seconds - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); - - let node_url: String = "http://127.0.0.1:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let finality_checkpoint = sync_committee_prover - .fetch_finalized_checkpoint() - .await - .unwrap(); - dbg!(&finality_checkpoint.root); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - - let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let state = sync_committee_prover - .fetch_beacon_state(&block_header.slot.to_string()) - .await - .unwrap(); - - let mut client_state = LightClientState { - finalized_header: block_header.clone(), - current_sync_committee: state.current_sync_committee, - next_sync_committee: state.next_sync_committee, - }; - - while let Some(_ts) = stream.next().await { - let finality_checkpoint = sync_committee_prover - .fetch_finalized_checkpoint() - .await - .unwrap(); - dbg!(&finality_checkpoint.root); - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); - - if finalized_block.slot <= client_state.finalized_header.slot { - println!("finalized_block slot is {}", &finalized_block.slot); - println!( - "finalized_header slot is {}", - &client_state.finalized_header.slot - ); - continue; - } - - let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); - - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); - - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); - - let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); - let finality_branch_proof = finality_branch_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); - - let mut attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } - - let attested_header = attested_header.unwrap(); - - let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); - - let sync_committee_update = if state_period == attested_header_slot { - let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); - - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect::>(); - - let sync_committee = sync_committee_prover - .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) - .await - .unwrap(); - - Some(SyncCommitteeUpdate { - next_sync_committee: sync_committee, - next_sync_committee_branch: sync_committee_proof, - }) - } else { - None - }; - - // construct light client - let light_client_update = LightClientUpdate { - attested_header, - sync_committee_update, - finalized_header, - execution_payload: execution_payload_proof, - finality_branch: finality_branch_proof, - sync_aggregate: finalized_block.body.sync_aggregate, - signature_slot: attested_header_slot, - ancestor_blocks: vec![], - }; - - client_state = EthLightClient::verify_sync_committee_attestation( - client_state.clone(), - light_client_update, - ) - .unwrap(); - println!( - "Sucessfully verified Ethereum block at slot {:?}", - client_state.finalized_header.slot - ); - } -} diff --git a/light-client-verifier/Cargo.toml b/verifier/Cargo.toml similarity index 59% rename from light-client-verifier/Cargo.toml rename to verifier/Cargo.toml index 5e18be9d1..4fa8e4f74 100644 --- a/light-client-verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -1,15 +1,13 @@ [package] -name = "light-client-verifier" +name = "sync-committee-verifier" version = "0.1.0" edition = "2021" authors = ["Polytope Labs"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -base2 = {version="0.2.2", default-features=false} -light-client-primitives = {path="../light-client-primitives", default-features = false } +base2 = { version="0.2.2", default-features = false } +sync-committee-primitives = { path= "../primitives", default-features = false } ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } -libc-print = {version=" 0.1.20"} +log = "0.4.17" \ No newline at end of file diff --git a/verifier/src/error.rs b/verifier/src/error.rs new file mode 100644 index 000000000..dcd6e74b5 --- /dev/null +++ b/verifier/src/error.rs @@ -0,0 +1,34 @@ +use core::fmt::{Display, Formatter}; + +#[derive(Debug)] +pub enum Error { + SyncCommitteeParticipantsTooLow, + InvalidUpdate, + DomainError, + FastAggregateError(ethereum_consensus::crypto::Error), + InvalidMerkleBranch, + InvalidRoot, + MerkleizationError, +} + +impl From for Error { + fn from(error: ethereum_consensus::crypto::Error) -> Self { + Error::FastAggregateError(error) + } +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self { + Error::SyncCommitteeParticipantsTooLow => { + write!(f, "Sync committee participants are too low") + }, + Error::InvalidUpdate => write!(f, "Invalid update"), + Error::DomainError => write!(f, "Couldn't get domain"), + Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), + Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), + Error::InvalidRoot => write!(f, "Invalid root"), + Error::MerkleizationError => write!(f, "Merkleization error"), + } + } +} diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs new file mode 100644 index 000000000..9c5f0e35f --- /dev/null +++ b/verifier/src/lib.rs @@ -0,0 +1,461 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(not(feature = "std"))] +extern crate alloc; + +pub mod error; + +use crate::error::Error; +use alloc::vec::Vec; +use base2::Base2; +use core::{borrow::Borrow, fmt::Display}; +use ethereum_consensus::{ + altair::{ + mainnet::SYNC_COMMITTEE_SIZE, FINALIZED_ROOT_INDEX_FLOOR_LOG_2, + NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, + }, + bellatrix::compute_domain, + primitives::Root, + signing::compute_signing_root, + state_transition::Context, +}; +use ssz_rs::{ + calculate_merkle_root, calculate_multi_merkle_root, prelude::is_valid_merkle_branch, + GeneralizedIndex, Merkleized, Node, +}; +use sync_committee_primitives::{ + types::{ + AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, GENESIS_VALIDATORS_ROOT, + HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, NEXT_SYNC_COMMITTEE_INDEX, + }, + util::{ + compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, + get_subtree_index, hash_tree_root, + }, +}; + +pub type LightClientState = sync_committee_primitives::types::LightClientState; +pub type LightClientUpdate = + sync_committee_primitives::types::LightClientUpdate; + +/// This function simply verifies a sync committee's attestation & it's finalized counterpart. +pub fn verify_sync_committee_attestation( + trusted_state: LightClientState, + update: LightClientUpdate, +) -> Result { + if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize && + update.sync_committee_update.is_some() && + update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() != + NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize + { + log::debug!("Invalid update "); + log::debug!("update finality branch length {} ", update.finality_branch.len()); + log::debug!("FINALIZED_ROOT_INDEX_FLOOR_LOG_2 {}", FINALIZED_ROOT_INDEX_FLOOR_LOG_2); + log::debug!( + "update next sync committee branch length {} ", + update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() + ); + log::debug!( + "NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 {}", + NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 + ); + //Err(Error::InvalidUpdate)? + } + + // Verify sync committee has super majority participants + let sync_committee_bits = update.sync_aggregate.sync_committee_bits; + let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; + if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { + log::debug!("SyncCommitteeParticipantsTooLow "); + log::debug!("sync_aggregate_participants {} ", { sync_aggregate_participants * 3 }); + log::debug!("sync_committee_bits {}", { sync_committee_bits.clone().len() * 2 }); + //Err(Error::SyncCommitteeParticipantsTooLow)? + } + + // Verify update does not skip a sync committee period + let is_valid_update = update.signature_slot > update.attested_header.slot && + update.attested_header.slot >= update.finalized_header.slot; + if !is_valid_update { + log::debug!("is_valid_update {} ", is_valid_update); + log::debug!( + "update.signature_slot {} update.attested_header.slot {}", + update.signature_slot, + update.attested_header.slot + ); + log::debug!( + "update.attested_header.slot {} update.finalized_header.slot {}", + update.attested_header.slot, + update.finalized_header.slot + ); + //Err(Error::InvalidUpdate)? + } + + let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); + let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); + if !(state_period..=state_period + 1).contains(&update_signature_period) { + log::debug!("invalid update"); + log::debug!("state_period is {}", state_period); + log::debug!("update_signature_period is {}", update_signature_period); + //Err(Error::InvalidUpdate)? + } + + // Verify update is relevant + let update_attested_period = compute_sync_committee_period_at_slot(update.attested_header.slot); + let update_has_next_sync_committee = + update.sync_committee_update.is_some() && update_attested_period == state_period; + + if !(update.attested_header.slot > trusted_state.finalized_header.slot || + update_has_next_sync_committee) + { + Err(Error::InvalidUpdate)? + } + + // Verify sync committee aggregate signature + let sync_committee = if update_signature_period == state_period { + trusted_state.current_sync_committee.clone() + } else { + trusted_state.next_sync_committee.clone() + }; + + let sync_committee_pubkeys = sync_committee.public_keys; + + let participant_pubkeys = sync_committee_bits + .iter() + .zip(sync_committee_pubkeys.iter()) + .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) + .collect::>(); + + let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); + //TODO: we probably need to construct context + let domain = compute_domain( + DOMAIN_SYNC_COMMITTEE, + Some(fork_version), + Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().map_err(|_| Error::InvalidRoot)?)), + &Context::default(), + ) + .map_err(|_| Error::InvalidUpdate)?; + + let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain); + + // todo: should be generic + ethereum_consensus::crypto::fast_aggregate_verify( + &*participant_pubkeys, + signing_root.map_err(|_| Error::InvalidRoot)?.as_bytes(), + &update.sync_aggregate.sync_committee_signature, + )?; + + // Verify that the `finality_branch` confirms `finalized_header` + // to match the finalized checkpoint root saved in the state of `attested_header`. + // Note that the genesis finalized checkpoint root is represented as a zero hash. + let finalized_root = &Node::from_bytes( + hash_tree_root(update.finalized_header.clone()) + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ); + + let branch = update + .finality_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + finalized_root, + branch.iter(), + FINALIZED_ROOT_INDEX.floor_log2() as usize, + FINALIZED_ROOT_INDEX as usize, + &Node::from_bytes( + update + .attested_header + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ); + + log::debug!("valid merkle branch for finalized_root {}", is_merkle_branch_valid); + if !is_merkle_branch_valid { + log::debug!("invalid merkle branch for finalized root"); + //Err(Error::InvalidMerkleBranch)?; + } + + // verify the associated execution header of the finalized beacon header. + let mut execution_payload = update.execution_payload; + let multi_proof_vec = execution_payload.multi_proof; + let multi_proof_nodes = multi_proof_vec + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes( + execution_payload + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + execution_payload + .block_number + .hash_tree_root() + .map_err(|_| Error::InvalidRoot)?, + ], + &multi_proof_nodes, + &[ + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + ], + ); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + EXECUTION_PAYLOAD_INDEX as usize, + &Node::from_bytes( + update + .finalized_header + .clone() + .body_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ); + + log::debug!("valid merkle branch for execution_payload_branch"); + if !is_merkle_branch_valid { + log::debug!("invalid merkle branch for execution_payload_branch"); + //Err(Error::InvalidMerkleBranch)?; + } + + if let Some(sync_committee_update) = update.sync_committee_update.clone() { + if update_attested_period == state_period && + sync_committee_update.next_sync_committee != + trusted_state.next_sync_committee.clone() + { + log::debug!("invalid update for sync committee update"); + //rr(Error::InvalidUpdate)? + } + + let next_sync_committee_branch = sync_committee_update + .next_sync_committee_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &Node::from_bytes( + hash_tree_root(sync_committee_update.next_sync_committee) + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + next_sync_committee_branch.iter(), + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize, + &Node::from_bytes( + update + .attested_header + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ); + + log::debug!("valid merkle branch for sync committee {}", is_merkle_branch_valid); + if !is_merkle_branch_valid { + log::debug!("invalid merkle branch for sync committee"); + // Err(Error::InvalidMerkleBranch)?; + } + } + + // verify the ancestry proofs + for ancestor in update.ancestor_blocks { + match ancestor.ancestry_proof { + AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => { + let block_header_branch = block_roots_proof + .block_header_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let block_roots_root = calculate_merkle_root( + &Node::from_bytes( + hash_tree_root(ancestor.header.clone()) + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + &*block_header_branch, + &GeneralizedIndex(block_roots_proof.block_header_index as usize), + ); + + let block_roots_branch_node = block_roots_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + + let is_merkle_branch_valid = is_valid_merkle_branch( + &block_roots_root, + block_roots_branch_node.iter(), + BLOCK_ROOTS_INDEX.floor_log2() as usize, + BLOCK_ROOTS_INDEX as usize, + &Node::from_bytes( + update + .finalized_header + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ); + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + }, + AncestryProof::HistoricalRoots { + block_roots_proof, + historical_batch_proof, + historical_roots_proof, + historical_roots_index, + historical_roots_branch, + } => { + let block_header_branch = block_roots_proof + .block_header_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let block_roots_root = calculate_merkle_root( + &Node::from_bytes( + hash_tree_root(ancestor.header.clone()) + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + &block_header_branch, + &GeneralizedIndex(block_roots_proof.block_header_index as usize), + ); + + let historical_batch_proof_nodes = historical_batch_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let historical_batch_root = calculate_merkle_root( + &block_roots_root, + &historical_batch_proof_nodes, + &GeneralizedIndex(HISTORICAL_BATCH_BLOCK_ROOTS_INDEX as usize), + ); + + let historical_roots_proof_nodes = historical_roots_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let historical_roots_root = calculate_merkle_root( + &historical_batch_root, + &historical_roots_proof_nodes, + &GeneralizedIndex(historical_roots_index as usize), + ); + + let historical_roots_branch_nodes = historical_roots_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &historical_roots_root, + historical_roots_branch_nodes.iter(), + HISTORICAL_ROOTS_INDEX.floor_log2() as usize, + get_subtree_index(HISTORICAL_ROOTS_INDEX) as usize, + &Node::from_bytes( + update + .finalized_header + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + }, + }; + + // verify the associated execution paylaod header. + let execution_payload = ancestor.execution_payload; + let multi_proof = execution_payload + .multi_proof + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let execution_payload_root = calculate_multi_merkle_root( + &[ + Node::from_bytes( + execution_payload + .state_root + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + Node::from_bytes( + hash_tree_root(execution_payload.block_number) + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), + ], + &multi_proof, + &[ + GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + ], + ); + + let execution_payload_branch = execution_payload + .execution_payload_branch + .iter() + .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) + .collect::>(); + let is_merkle_branch_valid = is_valid_merkle_branch( + &execution_payload_root, + execution_payload_branch.iter(), + EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + EXECUTION_PAYLOAD_INDEX as usize, + &Node::from_bytes( + ancestor.header.body_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, + ), + ); + + if !is_merkle_branch_valid { + Err(Error::InvalidMerkleBranch)?; + } + } + + let new_light_client_state = if let Some(sync_committee_update) = update.sync_committee_update { + LightClientState { + finalized_header: update.finalized_header, + current_sync_committee: trusted_state.next_sync_committee, + next_sync_committee: sync_committee_update.next_sync_committee, + } + } else { + LightClientState { finalized_header: update.finalized_header, ..trusted_state } + }; + + Ok(new_light_client_state) +} From 87efc030841ee54d2e6c64cc2d25b0e1096c161b Mon Sep 17 00:00:00 2001 From: David Salami Date: Tue, 21 Feb 2023 21:35:56 +0100 Subject: [PATCH 052/100] finalized header test --- prover/src/lib.rs | 2 +- prover/src/test.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 219439c79..6782cdcaf 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -290,7 +290,7 @@ fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result Date: Tue, 21 Feb 2023 22:23:11 +0100 Subject: [PATCH 053/100] test finality proof --- prover/src/lib.rs | 8 -------- prover/src/test.rs | 44 +++++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 6782cdcaf..47ac6e725 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -29,14 +29,6 @@ use ethereum_consensus::{ }, primitives::{Bytes32, Slot, ValidatorIndex}, }; -use light_client_primitives::{ - types::{ - BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, - EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, - NEXT_SYNC_COMMITTEE_INDEX, - }, - util::get_subtree_index, -}; use ssz_rs::{GeneralizedIndex, List, Node, Vector}; use sync_committee_primitives::{ types::{ diff --git a/prover/src/test.rs b/prover/src/test.rs index 3fc50f721..eaf8a5721 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -1,12 +1,12 @@ use super::*; use base2::Base2; use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; -use light_client_primitives::{ +use sync_committee_primitives::{ types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, util::compute_sync_committee_period_at_slot, }; -use light_client_verifier::light_client::EthLightClient; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; +//use sync_committee_verifier::light_client::EthLightClient; +use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized, get_generalized_index, SszVariableOrIndex}; use std::{thread, time::Duration}; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; @@ -104,6 +104,25 @@ async fn fetch_finality_checkpoints_work() { assert!(finality_checkpoint.is_ok()); } +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_finalized_header() { + let node_url: String = "http://localhost:3500".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + let mut state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); + + let generalized_index = get_generalized_index(&state, &[SszVariableOrIndex::Name("finalized_checkpoint")]); + dbg!(generalized_index); + let proof = ssz_rs::generate_proof(state.clone(), &vec![generalized_index]); + + + let leaves = vec![Node::from_bytes(state.finalized_checkpoint.hash_tree_root().unwrap().as_ref().try_into().unwrap())]; + let root = calculate_multi_merkle_root(&leaves, &proof.unwrap(), &[GeneralizedIndex(generalized_index)]); + assert_eq!(root, state.hash_tree_root().unwrap()); +} + +/* #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] @@ -252,6 +271,7 @@ async fn test_finality_proof() { assert!(is_merkle_branch_valid, "{}", true); } + #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] @@ -342,7 +362,7 @@ async fn test_sync_committee_proof() { .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( &Node::from_bytes( - light_client_primitives::util::hash_tree_root(sync_committee.clone()) + sync_committee_primitives::util::hash_tree_root(sync_committee.clone()) .unwrap() .as_ref() .try_into() @@ -358,20 +378,6 @@ async fn test_sync_committee_proof() { assert!(is_merkle_branch_valid, "{}", true); } -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_finalized_header() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); - let proof = ssz_rs::generate_proof(state, vec![FINALIZED_ROOT_INDEX]); - - let leaves = vec![Node::from_bytes(state.finalized_checkpoint.hash_tree_root().unwrap().as_ref().try_into().unwrap())]; - let root = calculate_multi_merkle_root(&leaves, &proof, vec![FINALIZED_ROOT_INDEX]); - assert_eq!(root, state.hash_tree_root()); -} - // use tokio interval(should run every 13 minutes) // every 13 minutes, fetch latest finalized block // then prove the execution payload @@ -521,4 +527,4 @@ async fn test_prover() { client_state.finalized_header.slot ); } -} +}*/ From 186f9e89b7572195e86fa5e4b716f8111f0c79f0 Mon Sep 17 00:00:00 2001 From: David Salami Date: Wed, 22 Feb 2023 14:10:42 +0100 Subject: [PATCH 054/100] update sync committee test --- Cargo.lock | 73 +++--- Cargo.toml | 6 + primitives/Cargo.toml | 4 +- primitives/src/types.rs | 25 +- prover/Cargo.toml | 4 +- prover/src/lib.rs | 58 +++-- prover/src/test.rs | 531 +++++++++++++++------------------------- verifier/Cargo.toml | 4 +- verifier/src/lib.rs | 129 ++++------ 9 files changed, 344 insertions(+), 490 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4980c81fe..cc1219cb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,9 +41,9 @@ source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee67 [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "arrayref" @@ -59,19 +59,20 @@ checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite", ] [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -374,7 +375,7 @@ dependencies = [ [[package]] name = "ethereum-consensus" version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#9862cab0797fe80c27f435b5b0313f32c24708da" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#8be43ea5768297f83acfc22651121154fb1a5874" dependencies = [ "async-stream", "bs58", @@ -399,9 +400,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -591,9 +592,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -625,9 +626,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.23" +version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" +checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ "bytes", "futures-channel", @@ -822,14 +823,14 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -937,9 +938,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1091,9 +1092,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -1305,9 +1306,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -1362,9 +1363,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -1381,9 +1382,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -1417,7 +1418,7 @@ dependencies = [ [[package]] name = "ssz-rs" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f85f088552ee45c4c6080eede3fb57d47bff92e3" dependencies = [ "as-any", "bitvec", @@ -1433,7 +1434,7 @@ dependencies = [ [[package]] name = "ssz-rs-derive" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=dami/seun-multi-proofs#24f04b8daefc110aff6dd8f20778f3da95a9cdf7" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f85f088552ee45c4c6080eede3fb57d47bff92e3" dependencies = [ "proc-macro2", "quote", @@ -1568,9 +1569,9 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" @@ -1605,9 +1606,9 @@ dependencies = [ [[package]] name = "tokio-native-tls" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", "tokio", @@ -1615,9 +1616,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", @@ -1626,9 +1627,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ "bytes", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index 37dfd2d6a..29417d48b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,9 @@ members = [ "primitives", "prover" ] + +[patch."https://github.com/ralexstokes/ethereum-consensus"] +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "dami/no-std-support" } + +[patch."https://github.com/ralexstokes/ssz-rs"] +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "seun/ssz-merkle-multi-proof-phase-1" } diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index a9f5cdf96..3638636cd 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,6 +7,6 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version = "0.3.1", default-features=false} -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } +ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features=false, features=["serde"] } hex-literal = { package = "hex-literal", version = "0.3.3" } diff --git a/primitives/src/types.rs b/primitives/src/types.rs index dc115b6f8..87d4ada6a 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -1,21 +1,25 @@ use alloc::vec::Vec; +use base2::Base2; use ethereum_consensus::{ bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, domains::DomainType, - primitives::{Hash32, Slot}, + primitives::{Epoch, Hash32, Slot}, }; pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; -pub const FINALIZED_ROOT_INDEX: u64 = 105; +pub const FINALIZED_ROOT_INDEX: u64 = 52; pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; -pub const EXECUTION_PAYLOAD_INDEX: u64 = 25; +pub const EXECUTION_PAYLOAD_INDEX: u64 = 56; pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); +// pub const NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2: usize = NEXT_SYNC_COMMITTEE_INDEX.floor_log2() +// as usize; pub const FINALIZED_ROOT_INDEX_FLOOR_LOG_2: usize = FINALIZED_ROOT_INDEX.floor_log2() +// as usize; /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] @@ -102,6 +106,16 @@ pub struct LightClientState { pub next_sync_committee: SyncCommittee, } +/// Minimum state required by the light client to validate new sync committee attestations +#[derive(Debug, Clone)] +pub struct FinalityProof { + /// Epoch that was finalized + pub finalized_epoch: Epoch, + /// the ssz merkle proof for the finalized checkpoint in the attested header, finalized headers + /// lag by 2 epochs. + pub finality_branch: Vec, +} + /// Data required to advance the state of the light client. #[derive(Debug, Clone)] pub struct LightClientUpdate { @@ -113,9 +127,8 @@ pub struct LightClientUpdate { pub finalized_header: BeaconBlockHeader, /// execution payload of the finalized header pub execution_payload: ExecutionPayloadProof, - /// the ssz merkle proof for this header in the attested header, finalized headers lag by 2 - /// epochs. - pub finality_branch: Vec, + /// Finalized header proof + pub finality_proof: FinalityProof, /// signature & participation bits pub sync_aggregate: SyncAggregate, /// slot at which signature was produced diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 513a81cca..f07ffedd3 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives", default-features = false } sync-committee-verifier = { path= "../verifier", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } +ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 47ac6e725..802a3f87a 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -27,14 +27,14 @@ use ethereum_consensus::{ MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }, - primitives::{Bytes32, Slot, ValidatorIndex}, + primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}, }; -use ssz_rs::{GeneralizedIndex, List, Node, Vector}; +use ssz_rs::{get_generalized_index, GeneralizedIndex, List, Node, SszVariableOrIndex, Vector}; use sync_committee_primitives::{ types::{ - BlockRootsProof, ExecutionPayloadProof, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, - EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, - NEXT_SYNC_COMMITTEE_INDEX, + BlockRootsProof, ExecutionPayloadProof, FinalityProof, + EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, util::get_subtree_index, }; @@ -218,12 +218,13 @@ impl SyncCommitteeProver { let validator_index: ValidatorIndex = i.parse().unwrap(); validators[validator_index].public_key.clone() }) - .collect::>(); + .collect::>(); let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); let sync_committee = SyncCommittee:: { - public_keys: public_keys_vector, + public_keys: Vector::::try_from(public_keys_vector) + .unwrap(), aggregate_public_key, }; @@ -273,45 +274,50 @@ fn prove_beacon_block_values( Ok(proof) } -fn prove_execution_payload(block: BeaconBlockType) -> anyhow::Result { +fn prove_execution_payload(beacon_state: BeaconStateType) -> anyhow::Result { let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, ]; // generate multi proofs - let multi_proof = - ssz_rs::generate_proof(block.body.execution_payload.clone(), indices.as_slice())?; - - let execution_payload_index = [EXECUTION_PAYLOAD_INDEX as usize]; - let execution_payload_branch = - ssz_rs::generate_proof(block.body.clone(), execution_payload_index.as_slice())?; + let multi_proof = ssz_rs::generate_proof( + beacon_state.latest_execution_payload_header.clone(), + indices.as_slice(), + )?; Ok(ExecutionPayloadProof { - state_root: block.body.execution_payload.state_root, - block_number: block.body.execution_payload.block_number, + state_root: beacon_state.latest_execution_payload_header.state_root.clone(), + block_number: beacon_state.latest_execution_payload_header.block_number, multi_proof: multi_proof .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect(), - execution_payload_branch: execution_payload_branch - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), + execution_payload_branch: ssz_rs::generate_proof( + beacon_state, + &[EXECUTION_PAYLOAD_INDEX as usize], + )? + .into_iter() + .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) + .collect(), }) } fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { - let indices = vec![NEXT_SYNC_COMMITTEE_INDEX as usize]; - let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; - + let proof = ssz_rs::generate_proof(state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } -fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { - let indices = [FINALIZED_ROOT_INDEX as usize]; //vec![get_subtree_index(FINALIZED_ROOT_INDEX) as usize]; +fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result { + let indices = [FINALIZED_ROOT_INDEX as usize]; let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; - Ok(proof) + Ok(FinalityProof { + finalized_epoch: state.finalized_checkpoint.epoch, + finality_branch: proof + .into_iter() + .map(|node| Hash32::try_from(node.as_ref()).expect("Node is always a 32 byte slice")) + .collect(), + }) } // function that generates block roots proof diff --git a/prover/src/test.rs b/prover/src/test.rs index eaf8a5721..ddd79bdb3 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -5,8 +5,11 @@ use sync_committee_primitives::{ types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, util::compute_sync_committee_period_at_slot, }; -//use sync_committee_verifier::light_client::EthLightClient; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized, get_generalized_index, SszVariableOrIndex}; + +use ssz_rs::{ + calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, + Merkleized, SszVariableOrIndex, +}; use std::{thread, time::Duration}; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; @@ -14,8 +17,9 @@ use tokio_stream::{wrappers::IntervalStream, StreamExt}; #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_block_header_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let mut block_header = sync_committee_prover.fetch_header("1000").await; while block_header.is_err() { @@ -28,8 +32,9 @@ async fn fetch_block_header_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_block_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let block = sync_committee_prover.fetch_block("100").await; assert!(block.is_ok()); @@ -38,8 +43,9 @@ async fn fetch_block_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_sync_committee_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let block = sync_committee_prover.fetch_sync_committee("117").await; assert!(block.is_ok()); @@ -48,8 +54,9 @@ async fn fetch_sync_committee_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_validator_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let validator = sync_committee_prover.fetch_validator("2561", "48").await; assert!(validator.is_ok()); @@ -58,8 +65,9 @@ async fn fetch_validator_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_processed_sync_committee_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let validator = sync_committee_prover.fetch_processed_sync_committee("2561").await; assert!(validator.is_ok()); @@ -68,8 +76,9 @@ async fn fetch_processed_sync_committee_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn fetch_beacon_state_works() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; assert!(beacon_state.is_ok()); @@ -78,8 +87,9 @@ async fn fetch_beacon_state_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] +#[ignore] async fn state_root_and_block_header_root_matches() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let beacon_state = sync_committee_prover.fetch_beacon_state("100").await; assert!(beacon_state.is_ok()); @@ -98,7 +108,7 @@ async fn state_root_and_block_header_root_matches() { #[allow(non_snake_case)] #[actix_rt::test] async fn fetch_finality_checkpoints_work() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; assert!(finality_checkpoint.is_ok()); @@ -108,34 +118,41 @@ async fn fetch_finality_checkpoints_work() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_finalized_header() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let mut state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); - - let generalized_index = get_generalized_index(&state, &[SszVariableOrIndex::Name("finalized_checkpoint")]); - dbg!(generalized_index); - let proof = ssz_rs::generate_proof(state.clone(), &vec![generalized_index]); + let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); + let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); - let leaves = vec![Node::from_bytes(state.finalized_checkpoint.hash_tree_root().unwrap().as_ref().try_into().unwrap())]; - let root = calculate_multi_merkle_root(&leaves, &proof.unwrap(), &[GeneralizedIndex(generalized_index)]); + let leaves = vec![Node::from_bytes( + state + .finalized_checkpoint + .hash_tree_root() + .unwrap() + .as_ref() + .try_into() + .unwrap(), + )]; + let root = calculate_multi_merkle_root( + &leaves, + &proof.unwrap(), + &[GeneralizedIndex(FINALIZED_ROOT_INDEX as usize)], + ); assert_eq!(root, state.hash_tree_root().unwrap()); } -/* #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] async fn test_execution_payload_proof() { - let node_url: String = "http://localhost:3500".to_string(); + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block_id = "finalized"; - let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); - - let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); + let finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); + let block_id = finalized_state.slot.to_string(); + let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); // verify the associated execution header of the finalized beacon header. let mut execution_payload = execution_payload_proof.clone(); @@ -156,12 +173,11 @@ async fn test_execution_payload_proof() { ], ); - println!("execution_payload_root {:?}", execution_payload_root); - - let execution_payload_hash_tree_root = - finalized_block.body.execution_payload.clone().hash_tree_root().unwrap(); - - println!("execution_payload_hash_tree_root {:?}", execution_payload_hash_tree_root); + let execution_payload_hash_tree_root = finalized_state + .latest_execution_payload_header + .clone() + .hash_tree_root() + .unwrap(); assert_eq!(execution_payload_root, execution_payload_hash_tree_root); @@ -176,143 +192,24 @@ async fn test_execution_payload_proof() { execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, - &Node::from_bytes(finalized_header.clone().body_root.as_ref().try_into().unwrap()), - ); - - - - assert_eq!(is_merkle_branch_valid, true); -} - -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_finality_proof() { - let node_url: String = "http://localhost:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let block_id = "finalized"; - let finalized_block = sync_committee_prover.fetch_block(block_id).await.unwrap(); - - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); - - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); - - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); - - let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); - - let mut attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } - - let attested_header = attested_header.unwrap(); - - let finality_branch_proof = finality_branch_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); - - // verify the associated execution header of the finalized beacon header. - - // Verify that the `finality_branch` confirms `finalized_header` - // to match the finalized checkpoint root saved in the state of `attested_header`. - // Note that the genesis finalized checkpoint root is represented as a zero hash. - let finalized_root = &Node::from_bytes( - light_client_primitives::util::hash_tree_root(finalized_header.clone()) - .unwrap() - .as_ref() - .try_into() - .unwrap(), + &Node::from_bytes(finalized_header.clone().state_root.as_ref().try_into().unwrap()), ); - let branch = finality_branch_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - println!("finalized_root {:?}", finalized_root.clone()); - - let finality_hash_tree_root = finalized_block.clone().hash_tree_root().unwrap(); - - assert_eq!(finalized_root, &finality_hash_tree_root); - - println!("finalized_root {:?}", finality_hash_tree_root); - let is_merkle_branch_valid = is_valid_merkle_branch( - finalized_root, - branch.iter(), - FINALIZED_ROOT_INDEX.floor_log2() as usize, - get_subtree_index(FINALIZED_ROOT_INDEX) as usize, - &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), - ); - - println!("is_merkle_branch_valid {:?}", is_merkle_branch_valid.clone()); - - assert!(is_merkle_branch_valid, "{}", true); + assert!(is_merkle_branch_valid); } - #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -async fn test_sync_committee_proof() { - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); - - let node_url: String = "http://localhost:3500".to_string(); +async fn test_sync_committee_update_proof() { + let node_url: String = "http://localhost:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); - let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); - dbg!(&finality_checkpoint.root); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - - let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let state = sync_committee_prover - .fetch_beacon_state(&block_header.slot.to_string()) - .await - .unwrap(); - - let block_id = "head"; - let mut finalized_block = sync_committee_prover.fetch_block(block_id).await; - - while finalized_block.is_err() { - println!("I am running finalized block till i am ok. lol {}", &block_id); - finalized_block = sync_committee_prover.fetch_block(block_id).await; - } - - let finalized_block = finalized_block.unwrap(); - - let finalized_header = sync_committee_prover.fetch_header(block_id).await.unwrap(); + let finalized_header = sync_committee_prover.fetch_header("head").await.unwrap(); + let block_id = finalized_header.slot.to_string(); let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) + .fetch_beacon_state(&finalized_header.slot.to_string()) .await .unwrap(); @@ -322,27 +219,10 @@ async fn test_sync_committee_proof() { .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect::>(); - let mut sync_committee = sync_committee_prover - .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) - .await; - - while sync_committee.is_err() { - println!("I am fetching sync committee till i am ok. lol {}", &block_id); - sync_committee = sync_committee_prover - .fetch_processed_sync_committee(finalized_header.slot.to_string().as_str()) - .await; - } - - let sync_committee = sync_committee.unwrap(); + let mut sync_committee = finalized_state.next_sync_committee; let calculated_finalized_root = calculate_multi_merkle_root( - &[Node::from_bytes( - light_client_primitives::util::hash_tree_root(sync_committee.clone()) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - )], + &[Node::from_bytes(sync_committee.hash_tree_root().unwrap().as_ref().try_into().unwrap())], &sync_committee_proof .iter() .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) @@ -350,32 +230,21 @@ async fn test_sync_committee_proof() { &[GeneralizedIndex(NEXT_SYNC_COMMITTEE_INDEX as usize)], ); - let hash_tree_root = finalized_state.clone().hash_tree_root().unwrap(); - - println!("calculated_finalized_root {:?}", calculated_finalized_root); - println!("finalized_state_root {:?}", finalized_header.state_root); - println!("hash_tree_root {:?}", hash_tree_root); + assert_eq!(calculated_finalized_root.as_bytes(), finalized_header.state_root.as_bytes()); let next_sync_committee_branch = sync_committee_proof .iter() .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( - sync_committee_primitives::util::hash_tree_root(sync_committee.clone()) - .unwrap() - .as_ref() - .try_into() - .unwrap(), - ), + &Node::from_bytes(sync_committee.hash_tree_root().unwrap().as_ref().try_into().unwrap()), next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), ); - println!("valid merkle branch for sync committee {}", is_merkle_branch_valid); - assert!(is_merkle_branch_valid, "{}", true); + assert!(is_merkle_branch_valid); } // use tokio interval(should run every 13 minutes) @@ -387,144 +256,144 @@ async fn test_sync_committee_proof() { // to prove sync comnmittee update, calculate state_period and the update_attested_period // ensure they are the same, and then prove sync committee -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_prover() { - // In test config an epoch is 6 slots and we expect finalization every two epochs, - // a slot is 12 seconds so that brings us to 144 seconds - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); - - let node_url: String = "http://127.0.0.1:3500".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - - let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); - dbg!(&finality_checkpoint.root); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - - let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let state = sync_committee_prover - .fetch_beacon_state(&block_header.slot.to_string()) - .await - .unwrap(); - - let mut client_state = LightClientState { - finalized_header: block_header.clone(), - current_sync_committee: state.current_sync_committee, - next_sync_committee: state.next_sync_committee, - }; - - while let Some(_ts) = stream.next().await { - let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); - dbg!(&finality_checkpoint.root); - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - dbg!(&block_id); - let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); - - if finalized_block.slot <= client_state.finalized_header.slot { - println!("finalized_block slot is {}", &finalized_block.slot); - println!("finalized_header slot is {}", &client_state.finalized_header.slot); - continue - } - - let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - - let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); - - let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_block.slot.to_string().as_str()) - .await - .unwrap(); - - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_header_slot.to_string().as_str()) - .await - .unwrap(); - - let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); - let finality_branch_proof = finality_branch_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - // purposely for waiting - //println!("sleeping"); - thread::sleep(time::Duration::from_secs(5)); - - let mut attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - - while attested_header.is_err() { - println!("I am running till i am ok. lol {}", &block_id); - attested_header = sync_committee_prover - .fetch_header(attested_header_slot.to_string().as_str()) - .await; - } - - let attested_header = attested_header.unwrap(); - - let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); - - let sync_committee_update = if state_period == attested_header_slot { - let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); - - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect::>(); - - let sync_committee = sync_committee_prover - .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) - .await - .unwrap(); - - Some(SyncCommitteeUpdate { - next_sync_committee: sync_committee, - next_sync_committee_branch: sync_committee_proof, - }) - } else { - None - }; - - // construct light client - let light_client_update = LightClientUpdate { - attested_header, - sync_committee_update, - finalized_header, - execution_payload: execution_payload_proof, - finality_branch: finality_branch_proof, - sync_aggregate: finalized_block.body.sync_aggregate, - signature_slot: attested_header_slot, - ancestor_blocks: vec![], - }; - - client_state = EthLightClient::verify_sync_committee_attestation( - client_state.clone(), - light_client_update, - ) - .unwrap(); - println!( - "Sucessfully verified Ethereum block at slot {:?}", - client_state.finalized_header.slot - ); - } -}*/ +// #[cfg(test)] +// #[allow(non_snake_case)] +// #[actix_rt::test] +// async fn test_prover() { +// // In test config an epoch is 6 slots and we expect finalization every two epochs, +// // a slot is 12 seconds so that brings us to 144 seconds +// let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); +// +// let node_url: String = "http://127.0.0.1:5052".to_string(); +// let sync_committee_prover = SyncCommitteeProver::new(node_url); +// +// let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); +// dbg!(&finality_checkpoint.root); +// +// let block_id = { +// let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); +// block_id.insert_str(0, "0x"); +// block_id +// }; +// +// dbg!(&block_id); +// +// let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); +// +// let state = sync_committee_prover +// .fetch_beacon_state(&block_header.slot.to_string()) +// .await +// .unwrap(); +// +// let mut client_state = LightClientState { +// finalized_header: block_header.clone(), +// current_sync_committee: state.current_sync_committee, +// next_sync_committee: state.next_sync_committee, +// }; +// +// while let Some(_ts) = stream.next().await { +// let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); +// dbg!(&finality_checkpoint.root); +// let block_id = { +// let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); +// block_id.insert_str(0, "0x"); +// block_id +// }; +// +// dbg!(&block_id); +// let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); +// +// if finalized_block.slot <= client_state.finalized_header.slot { +// println!("finalized_block slot is {}", &finalized_block.slot); +// println!("finalized_header slot is {}", &client_state.finalized_header.slot); +// continue +// } +// +// let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); +// +// let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); +// +// let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); +// let finalized_state = sync_committee_prover +// .fetch_beacon_state(finalized_block.slot.to_string().as_str()) +// .await +// .unwrap(); +// +// let attested_state = sync_committee_prover +// .fetch_beacon_state(attested_header_slot.to_string().as_str()) +// .await +// .unwrap(); +// +// let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); +// let finality_branch_proof = finality_branch_proof +// .into_iter() +// .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) +// .collect::>(); +// +// let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); +// +// // purposely for waiting +// //println!("sleeping"); +// thread::sleep(time::Duration::from_secs(5)); +// +// let mut attested_header = sync_committee_prover +// .fetch_header(attested_header_slot.to_string().as_str()) +// .await; +// +// while attested_header.is_err() { +// println!("I am running till i am ok. lol {}", &block_id); +// attested_header = sync_committee_prover +// .fetch_header(attested_header_slot.to_string().as_str()) +// .await; +// } +// +// let attested_header = attested_header.unwrap(); +// +// let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); +// +// let sync_committee_update = if state_period == attested_header_slot { +// let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); +// +// let sync_committee_proof = sync_committee_proof +// .into_iter() +// .map(|node| { +// Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") +// }) +// .collect::>(); +// +// let sync_committee = sync_committee_prover +// .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) +// .await +// .unwrap(); +// +// Some(SyncCommitteeUpdate { +// next_sync_committee: sync_committee, +// next_sync_committee_branch: sync_committee_proof, +// }) +// } else { +// None +// }; +// +// // construct light client +// let light_client_update = LightClientUpdate { +// attested_header, +// sync_committee_update, +// finalized_header, +// execution_payload: execution_payload_proof, +// finality_branch: finality_branch_proof, +// sync_aggregate: finalized_block.body.sync_aggregate, +// signature_slot: attested_header_slot, +// ancestor_blocks: vec![], +// }; +// +// client_state = EthLightClient::verify_sync_committee_attestation( +// client_state.clone(), +// light_client_update, +// ) +// .unwrap(); +// println!( +// "Sucessfully verified Ethereum block at slot {:?}", +// client_state.finalized_header.slot +// ); +// } +// } diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 4fa8e4f74..8b68a4014 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch="dami/no-std-support" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch="dami/seun-multi-proofs", default-features=false, features=["serde", "std"] } +ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features=false, features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = "0.4.17" \ No newline at end of file diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 9c5f0e35f..8bce18650 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -10,11 +10,7 @@ use alloc::vec::Vec; use base2::Base2; use core::{borrow::Borrow, fmt::Display}; use ethereum_consensus::{ - altair::{ - mainnet::SYNC_COMMITTEE_SIZE, FINALIZED_ROOT_INDEX_FLOOR_LOG_2, - NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2, - }, - bellatrix::compute_domain, + bellatrix::{compute_domain, mainnet::SYNC_COMMITTEE_SIZE, Checkpoint}, primitives::Root, signing::compute_signing_root, state_transition::Context, @@ -35,6 +31,8 @@ use sync_committee_primitives::{ get_subtree_index, hash_tree_root, }, }; +// use sync_committee_primitives::types::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, +// NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; pub type LightClientState = sync_committee_primitives::types::LightClientState; pub type LightClientUpdate = @@ -45,23 +43,22 @@ pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { - if update.finality_branch.len() != FINALIZED_ROOT_INDEX_FLOOR_LOG_2 as usize && + if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && update.sync_committee_update.is_some() && update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() != - NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 as usize + NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize { log::debug!("Invalid update "); - log::debug!("update finality branch length {} ", update.finality_branch.len()); - log::debug!("FINALIZED_ROOT_INDEX_FLOOR_LOG_2 {}", FINALIZED_ROOT_INDEX_FLOOR_LOG_2); log::debug!( - "update next sync committee branch length {} ", - update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() + "update finality branch length {} ", + update.finality_proof.finality_branch.len() ); log::debug!( - "NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 {}", - NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2 + "update next sync committee branch length {} ", + update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() ); - //Err(Error::InvalidUpdate)? + + Err(Error::InvalidUpdate)? } // Verify sync committee has super majority participants @@ -71,7 +68,7 @@ pub fn verify_sync_committee_attestation( log::debug!("SyncCommitteeParticipantsTooLow "); log::debug!("sync_aggregate_participants {} ", { sync_aggregate_participants * 3 }); log::debug!("sync_committee_bits {}", { sync_committee_bits.clone().len() * 2 }); - //Err(Error::SyncCommitteeParticipantsTooLow)? + Err(Error::SyncCommitteeParticipantsTooLow)? } // Verify update does not skip a sync committee period @@ -89,7 +86,7 @@ pub fn verify_sync_committee_attestation( update.attested_header.slot, update.finalized_header.slot ); - //Err(Error::InvalidUpdate)? + Err(Error::InvalidUpdate)? } let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); @@ -98,7 +95,7 @@ pub fn verify_sync_committee_attestation( log::debug!("invalid update"); log::debug!("state_period is {}", state_period); log::debug!("update_signature_period is {}", update_signature_period); - //Err(Error::InvalidUpdate)? + Err(Error::InvalidUpdate)? } // Verify update is relevant @@ -149,39 +146,34 @@ pub fn verify_sync_committee_attestation( // Verify that the `finality_branch` confirms `finalized_header` // to match the finalized checkpoint root saved in the state of `attested_header`. // Note that the genesis finalized checkpoint root is represented as a zero hash. - let finalized_root = &Node::from_bytes( - hash_tree_root(update.finalized_header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() + let mut finalized_checkpoint = Checkpoint { + epoch: update.finality_proof.finalized_epoch, + root: update + .finalized_header + .clone() + .hash_tree_root() .map_err(|_| Error::InvalidRoot)?, - ); + }; let branch = update + .finality_proof .finality_branch .iter() .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( - finalized_root, + &finalized_checkpoint.hash_tree_root().map_err(|_| Error::InvalidRoot)?, branch.iter(), FINALIZED_ROOT_INDEX.floor_log2() as usize, FINALIZED_ROOT_INDEX as usize, - &Node::from_bytes( - update - .attested_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &update.attested_header.state_root, ); log::debug!("valid merkle branch for finalized_root {}", is_merkle_branch_valid); if !is_merkle_branch_valid { log::debug!("invalid merkle branch for finalized root"); - //Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch)?; } // verify the associated execution header of the finalized beacon header. @@ -223,30 +215,22 @@ pub fn verify_sync_committee_attestation( execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, EXECUTION_PAYLOAD_INDEX as usize, - &Node::from_bytes( - update - .finalized_header - .clone() - .body_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &update.finalized_header.state_root, ); log::debug!("valid merkle branch for execution_payload_branch"); if !is_merkle_branch_valid { log::debug!("invalid merkle branch for execution_payload_branch"); - //Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch)?; } - if let Some(sync_committee_update) = update.sync_committee_update.clone() { + if let Some(mut sync_committee_update) = update.sync_committee_update.clone() { if update_attested_period == state_period && sync_committee_update.next_sync_committee != trusted_state.next_sync_committee.clone() { log::debug!("invalid update for sync committee update"); - //rr(Error::InvalidUpdate)? + Err(Error::InvalidUpdate)? } let next_sync_committee_branch = sync_committee_update @@ -255,35 +239,25 @@ pub fn verify_sync_committee_attestation( .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes( - hash_tree_root(sync_committee_update.next_sync_committee) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &sync_committee_update + .next_sync_committee + .hash_tree_root() + .map_err(|_| Error::MerkleizationError)?, next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize, - &Node::from_bytes( - update - .attested_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &update.attested_header.state_root, ); log::debug!("valid merkle branch for sync committee {}", is_merkle_branch_valid); if !is_merkle_branch_valid { log::debug!("invalid merkle branch for sync committee"); - // Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch)?; } } // verify the ancestry proofs - for ancestor in update.ancestor_blocks { + for mut ancestor in update.ancestor_blocks { match ancestor.ancestry_proof { AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => { let block_header_branch = block_roots_proof @@ -293,13 +267,7 @@ pub fn verify_sync_committee_attestation( .collect::>(); let block_roots_root = calculate_merkle_root( - &Node::from_bytes( - hash_tree_root(ancestor.header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &ancestor.header.hash_tree_root().map_err(|_| Error::MerkleizationError)?, &*block_header_branch, &GeneralizedIndex(block_roots_proof.block_header_index as usize), ); @@ -314,14 +282,7 @@ pub fn verify_sync_committee_attestation( block_roots_branch_node.iter(), BLOCK_ROOTS_INDEX.floor_log2() as usize, BLOCK_ROOTS_INDEX as usize, - &Node::from_bytes( - update - .finalized_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &update.finalized_header.state_root, ); if !is_merkle_branch_valid { Err(Error::InvalidMerkleBranch)?; @@ -340,13 +301,11 @@ pub fn verify_sync_committee_attestation( .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) .collect::>(); let block_roots_root = calculate_merkle_root( - &Node::from_bytes( - hash_tree_root(ancestor.header.clone()) - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + &ancestor + .header + .clone() + .hash_tree_root() + .map_err(|_| Error::MerkleizationError)?, &block_header_branch, &GeneralizedIndex(block_roots_proof.block_header_index as usize), ); @@ -438,7 +397,7 @@ pub fn verify_sync_committee_attestation( EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, EXECUTION_PAYLOAD_INDEX as usize, &Node::from_bytes( - ancestor.header.body_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, + ancestor.header.state_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, ), ); From 143543cf1ed810ed1b2b7c9dc4859b085ef42e5a Mon Sep 17 00:00:00 2001 From: David Salami Date: Wed, 22 Feb 2023 22:00:14 +0100 Subject: [PATCH 055/100] refactor integration test --- primitives/src/types.rs | 2 +- prover/src/lib.rs | 96 ++++--- .../responses/finality_checkpoint_response.rs | 8 +- prover/src/test.rs | 264 ++++++++---------- verifier/src/lib.rs | 2 - 5 files changed, 174 insertions(+), 198 deletions(-) diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 87d4ada6a..b292272c7 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -13,8 +13,8 @@ pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; pub const EXECUTION_PAYLOAD_INDEX: u64 = 56; pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; pub const BLOCK_ROOTS_INDEX: u64 = 37; -pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 0; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; +pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); // pub const NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2: usize = NEXT_SYNC_COMMITTEE_INDEX.floor_log2() diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 802a3f87a..74d7223aa 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -14,7 +14,13 @@ use ethereum_consensus::{ }; use reqwest::Client; -use crate::{responses::sync_committee_response::NodeSyncCommittee, routes::*}; +use crate::{ + responses::{ + finality_checkpoint_response::FinalityCheckpoint, + sync_committee_response::NodeSyncCommittee, + }, + routes::*, +}; use ethereum_consensus::{ bellatrix::mainnet::{ BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, @@ -24,19 +30,21 @@ use ethereum_consensus::{ phase0::mainnet::{ EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, + MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }, primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}, }; -use ssz_rs::{get_generalized_index, GeneralizedIndex, List, Node, SszVariableOrIndex, Vector}; +use ssz_rs::{ + get_generalized_index, GeneralizedIndex, List, Merkleized, Node, SszVariableOrIndex, Vector, +}; use sync_committee_primitives::{ types::{ - BlockRootsProof, ExecutionPayloadProof, FinalityProof, + AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, BLOCK_ROOTS_INDEX, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, - util::get_subtree_index, + util::{compute_epoch_at_slot, get_subtree_index}, }; type BeaconBlockType = BeaconBlock< @@ -94,13 +102,13 @@ impl SyncCommitteeProver { SyncCommitteeProver { node_url, client } } - pub async fn fetch_finalized_checkpoint(&self) -> Result { + pub async fn fetch_finalized_checkpoint(&self) -> Result { let full_url = self.generate_route(&finality_checkpoints("head")); let response = self.client.get(full_url).send().await?; let response_data = response.json::().await?; - Ok(response_data.data.finalized) + Ok(response_data.data) } pub async fn fetch_header(&self, block_id: &str) -> Result { @@ -258,22 +266,6 @@ fn get_attestation_slots_for_finalized_header( attested_slot } -fn prove_beacon_state_values( - data: BeaconStateType, - indices: &[usize], -) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(data, indices)?; - Ok(proof) -} - -fn prove_beacon_block_values( - data: BeaconBlockType, - indices: &[usize], -) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(data, indices)?; - Ok(proof) -} - fn prove_execution_payload(beacon_state: BeaconStateType) -> anyhow::Result { let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, @@ -320,25 +312,47 @@ fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result anyhow::Result { - let indices = vec![get_subtree_index(block_number) as usize]; - let proof = ssz_rs::generate_proof(state.block_roots, indices.as_slice())?; - - Ok(BlockRootsProof { - block_header_index: block_number, - block_header_branch: proof + mut header: BeaconBlockHeader, +) -> anyhow::Result { + // Check if block root should still be part of the block roots vector on the beacon state + let next_epoch = (compute_epoch_at_slot(header.slot) + 1) as usize; + + if next_epoch % (SLOTS_PER_HISTORICAL_ROOT / SLOTS_PER_EPOCH as usize) == 0 { + // todo: Historical root proofs + unimplemented!() + } else { + // Get index of block root in the block roots + let block_root = header.hash_tree_root().expect("hash tree root should be valid"); + let block_index = state + .block_roots + .as_ref() .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), - }) -} - -// prove the block roots vec inside the beacon state which will be the block roots branch + .position(|root| root == &block_root) + .expect("Block root should exist in block_roots"); + + let proof = ssz_rs::generate_proof(state.block_roots.clone(), &[block_index])?; + + let block_roots_proof = BlockRootsProof { + block_header_index: block_index as u64, + block_header_branch: proof + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect(), + }; -// when aggr sigs, create a new bit list + let block_roots_branch = ssz_rs::generate_proof(state, &[BLOCK_ROOTS_INDEX as usize])?; + Ok(AncestryProof::BlockRoots { + block_roots_proof, + block_roots_branch: block_roots_branch + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect(), + }) + } +} diff --git a/prover/src/responses/finality_checkpoint_response.rs b/prover/src/responses/finality_checkpoint_response.rs index 17c276be7..db251def7 100644 --- a/prover/src/responses/finality_checkpoint_response.rs +++ b/prover/src/responses/finality_checkpoint_response.rs @@ -3,12 +3,12 @@ use ethereum_consensus::bellatrix::Checkpoint; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub(crate) struct Response { execution_optimistic: bool, - pub data: ResponseData, + pub data: FinalityCheckpoint, } #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -pub struct ResponseData { - previous_justified: Checkpoint, - current_justified: Checkpoint, +pub struct FinalityCheckpoint { + pub previous_justified: Checkpoint, + pub current_justified: Checkpoint, pub finalized: Checkpoint, } diff --git a/prover/src/test.rs b/prover/src/test.rs index ddd79bdb3..30c3949e0 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -6,11 +6,13 @@ use sync_committee_primitives::{ util::compute_sync_committee_period_at_slot, }; +use ethereum_consensus::bellatrix::mainnet::HistoricalBatch; use ssz_rs::{ calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, Merkleized, SszVariableOrIndex, }; use std::{thread, time::Duration}; +use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; @@ -247,153 +249,115 @@ async fn test_sync_committee_update_proof() { assert!(is_merkle_branch_valid); } -// use tokio interval(should run every 13 minutes) -// every 13 minutes, fetch latest finalized block -// then prove the execution payload -// prove the finality branch - -// prove sync committee if there is a sync committee update -// to prove sync comnmittee update, calculate state_period and the update_attested_period -// ensure they are the same, and then prove sync committee - -// #[cfg(test)] -// #[allow(non_snake_case)] -// #[actix_rt::test] -// async fn test_prover() { -// // In test config an epoch is 6 slots and we expect finalization every two epochs, -// // a slot is 12 seconds so that brings us to 144 seconds -// let mut stream = IntervalStream::new(time::interval(Duration::from_secs(160))); -// -// let node_url: String = "http://127.0.0.1:5052".to_string(); -// let sync_committee_prover = SyncCommitteeProver::new(node_url); -// -// let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); -// dbg!(&finality_checkpoint.root); -// -// let block_id = { -// let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); -// block_id.insert_str(0, "0x"); -// block_id -// }; -// -// dbg!(&block_id); -// -// let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); -// -// let state = sync_committee_prover -// .fetch_beacon_state(&block_header.slot.to_string()) -// .await -// .unwrap(); -// -// let mut client_state = LightClientState { -// finalized_header: block_header.clone(), -// current_sync_committee: state.current_sync_committee, -// next_sync_committee: state.next_sync_committee, -// }; -// -// while let Some(_ts) = stream.next().await { -// let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); -// dbg!(&finality_checkpoint.root); -// let block_id = { -// let mut block_id = hex::encode(finality_checkpoint.root.as_bytes()); -// block_id.insert_str(0, "0x"); -// block_id -// }; -// -// dbg!(&block_id); -// let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); -// -// if finalized_block.slot <= client_state.finalized_header.slot { -// println!("finalized_block slot is {}", &finalized_block.slot); -// println!("finalized_header slot is {}", &client_state.finalized_header.slot); -// continue -// } -// -// let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); -// -// let execution_payload_proof = prove_execution_payload(finalized_block.clone()).unwrap(); -// -// let attested_header_slot = get_attestation_slots_for_finalized_header(&finalized_header, 6); -// let finalized_state = sync_committee_prover -// .fetch_beacon_state(finalized_block.slot.to_string().as_str()) -// .await -// .unwrap(); -// -// let attested_state = sync_committee_prover -// .fetch_beacon_state(attested_header_slot.to_string().as_str()) -// .await -// .unwrap(); -// -// let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); -// let finality_branch_proof = finality_branch_proof -// .into_iter() -// .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) -// .collect::>(); -// -// let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); -// -// // purposely for waiting -// //println!("sleeping"); -// thread::sleep(time::Duration::from_secs(5)); -// -// let mut attested_header = sync_committee_prover -// .fetch_header(attested_header_slot.to_string().as_str()) -// .await; -// -// while attested_header.is_err() { -// println!("I am running till i am ok. lol {}", &block_id); -// attested_header = sync_committee_prover -// .fetch_header(attested_header_slot.to_string().as_str()) -// .await; -// } -// -// let attested_header = attested_header.unwrap(); -// -// let update_attested_period = compute_sync_committee_period_at_slot(attested_header_slot); -// -// let sync_committee_update = if state_period == attested_header_slot { -// let sync_committee_proof = prove_sync_committee_update(attested_state).unwrap(); -// -// let sync_committee_proof = sync_committee_proof -// .into_iter() -// .map(|node| { -// Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") -// }) -// .collect::>(); -// -// let sync_committee = sync_committee_prover -// .fetch_processed_sync_committee(attested_header.slot.to_string().as_str()) -// .await -// .unwrap(); -// -// Some(SyncCommitteeUpdate { -// next_sync_committee: sync_committee, -// next_sync_committee_branch: sync_committee_proof, -// }) -// } else { -// None -// }; -// -// // construct light client -// let light_client_update = LightClientUpdate { -// attested_header, -// sync_committee_update, -// finalized_header, -// execution_payload: execution_payload_proof, -// finality_branch: finality_branch_proof, -// sync_aggregate: finalized_block.body.sync_aggregate, -// signature_slot: attested_header_slot, -// ancestor_blocks: vec![], -// }; -// -// client_state = EthLightClient::verify_sync_committee_attestation( -// client_state.clone(), -// light_client_update, -// ) -// .unwrap(); -// println!( -// "Sucessfully verified Ethereum block at slot {:?}", -// client_state.finalized_header.slot -// ); -// } -// } +// todo: cloning the beacon state might expensive in production or testnet, if we can modify +// generate_proof function take a reference for the object that would be better. +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_prover() { + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 64))); + + let node_url: String = "http://127.0.0.1:5052".to_string(); + let sync_committee_prover = SyncCommitteeProver::new(node_url); + + let block_id = "head"; + + let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + + let state = sync_committee_prover + .fetch_beacon_state(&block_header.slot.to_string()) + .await + .unwrap(); + + let mut client_state = LightClientState { + finalized_header: block_header.clone(), + current_sync_committee: state.current_sync_committee, + next_sync_committee: state.next_sync_committee, + }; + + while let Some(_ts) = stream.next().await { + let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); + if finality_checkpoint.finalized.root == Node::default() || + finality_checkpoint.finalized.epoch <= + compute_epoch_at_slot(client_state.finalized_header.slot) + { + continue + } + + println!("A new epoch has been finalized {}", finality_checkpoint.finalized.epoch); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.finalized.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + let finalized_state = sync_committee_prover + .fetch_beacon_state(finalized_header.slot.to_string().as_str()) + .await + .unwrap(); + let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); + + let attested_block_id = { + let mut block_id = hex::encode(finality_checkpoint.current_justified.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + let attested_block_header = + sync_committee_prover.fetch_header(&attested_block_id).await.unwrap(); + + let attested_state = sync_committee_prover + .fetch_beacon_state(attested_block_header.slot.to_string().as_str()) + .await + .unwrap(); + + let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + let update_attested_period = + compute_sync_committee_period_at_slot(attested_block_header.slot); + + let sync_committee_update = if state_period == attested_block_header.slot { + let sync_committee_proof = prove_sync_committee_update(attested_state.clone()).unwrap(); + + let sync_committee_proof = sync_committee_proof + .into_iter() + .map(|node| { + Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") + }) + .collect::>(); + + Some(SyncCommitteeUpdate { + next_sync_committee: attested_state.next_sync_committee, + next_sync_committee_branch: sync_committee_proof, + }) + } else { + None + }; + + let signature_slot = attested_block_header.slot; + // construct light client + let light_client_update = LightClientUpdate { + attested_header: attested_block_header, + sync_committee_update, + finalized_header, + execution_payload: execution_payload_proof, + finality_proof: finality_branch_proof, + sync_aggregate: finalized_block.body.sync_aggregate, + signature_slot, + // todo: Prove some ancestry blocks + ancestor_blocks: vec![], + }; + + client_state = + verify_sync_committee_attestation(client_state.clone(), light_client_update).unwrap(); + println!( + "Sucessfully verified Ethereum block at slot {:?}", + client_state.finalized_header.slot + ); + } +} diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 8bce18650..573fe609e 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -31,8 +31,6 @@ use sync_committee_primitives::{ get_subtree_index, hash_tree_root, }, }; -// use sync_committee_primitives::types::{FINALIZED_ROOT_INDEX_FLOOR_LOG_2, -// NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2}; pub type LightClientState = sync_committee_primitives::types::LightClientState; pub type LightClientUpdate = From 908ecbc2f93c0d6e2e1f8a4ae5ba99599070b594 Mon Sep 17 00:00:00 2001 From: David Salami Date: Thu, 23 Feb 2023 09:48:27 +0100 Subject: [PATCH 056/100] fix sync comittee aggregate participation bits count --- prover/src/lib.rs | 8 +++++--- prover/src/test.rs | 8 ++++---- verifier/src/lib.rs | 8 +++++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 74d7223aa..853da1ef1 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -115,7 +115,6 @@ impl SyncCommitteeProver { let path = header_route(block_id); let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; - let status = response.status().as_u16(); let response_data = response.json::().await?; @@ -317,9 +316,12 @@ fn prove_block_roots_proof( mut header: BeaconBlockHeader, ) -> anyhow::Result { // Check if block root should still be part of the block roots vector on the beacon state - let next_epoch = (compute_epoch_at_slot(header.slot) + 1) as usize; + let epoch_for_header = compute_epoch_at_slot(header.slot) as usize; + let epoch_for_state = compute_epoch_at_slot(state.slot) as usize; - if next_epoch % (SLOTS_PER_HISTORICAL_ROOT / SLOTS_PER_EPOCH as usize) == 0 { + if epoch_for_state.saturating_sub(epoch_for_header) >= + SLOTS_PER_HISTORICAL_ROOT / SLOTS_PER_EPOCH as usize + { // todo: Historical root proofs unimplemented!() } else { diff --git a/prover/src/test.rs b/prover/src/test.rs index 30c3949e0..81118a8b6 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -11,7 +11,7 @@ use ssz_rs::{ calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, Merkleized, SszVariableOrIndex, }; -use std::{thread, time::Duration}; +use std::time::Duration; use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; @@ -208,7 +208,6 @@ async fn test_sync_committee_update_proof() { let sync_committee_prover = SyncCommitteeProver::new(node_url); let finalized_header = sync_committee_prover.fetch_header("head").await.unwrap(); - let block_id = finalized_header.slot.to_string(); let finalized_state = sync_committee_prover .fetch_beacon_state(&finalized_header.slot.to_string()) @@ -255,7 +254,7 @@ async fn test_sync_committee_update_proof() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_prover() { - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 64))); + let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 12))); let node_url: String = "http://127.0.0.1:5052".to_string(); let sync_committee_prover = SyncCommitteeProver::new(node_url); @@ -281,6 +280,7 @@ async fn test_prover() { finality_checkpoint.finalized.epoch <= compute_epoch_at_slot(client_state.finalized_header.slot) { + println!("No new finalized checkpoint"); continue } @@ -321,7 +321,7 @@ async fn test_prover() { let update_attested_period = compute_sync_committee_period_at_slot(attested_block_header.slot); - let sync_committee_update = if state_period == attested_block_header.slot { + let sync_committee_update = if state_period == update_attested_period { let sync_committee_proof = prove_sync_committee_update(attested_state.clone()).unwrap(); let sync_committee_proof = sync_committee_proof diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 573fe609e..aac2d6930 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -43,7 +43,7 @@ pub fn verify_sync_committee_attestation( ) -> Result { if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && update.sync_committee_update.is_some() && - update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() != + update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize { log::debug!("Invalid update "); @@ -53,7 +53,7 @@ pub fn verify_sync_committee_attestation( ); log::debug!( "update next sync committee branch length {} ", - update.clone().sync_committee_update.unwrap().next_sync_committee_branch.len() + update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() ); Err(Error::InvalidUpdate)? @@ -61,7 +61,9 @@ pub fn verify_sync_committee_attestation( // Verify sync committee has super majority participants let sync_committee_bits = update.sync_aggregate.sync_committee_bits; - let sync_aggregate_participants: u64 = sync_committee_bits.iter().count() as u64; + let sync_aggregate_participants: u64 = + sync_committee_bits.iter().as_bitslice().count_ones() as u64; + if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { log::debug!("SyncCommitteeParticipantsTooLow "); log::debug!("sync_aggregate_participants {} ", { sync_aggregate_participants * 3 }); From 22e0b78c4bccc3c945bc4feb5d2782b50f740648 Mon Sep 17 00:00:00 2001 From: David Salami Date: Fri, 24 Feb 2023 00:42:58 +0100 Subject: [PATCH 057/100] fetching attested header correctly, signature slot left --- Cargo.lock | 137 +++++++++++++- primitives/Cargo.toml | 15 +- primitives/src/lib.rs | 1 - primitives/src/types.rs | 19 +- primitives/src/util.rs | 24 +-- prover/Cargo.toml | 7 +- prover/src/lib.rs | 34 +--- prover/src/responses/beacon_block_response.rs | 19 +- prover/src/test.rs | 176 ++++++++++++------ verifier/Cargo.toml | 15 +- verifier/src/lib.rs | 69 ++++--- 11 files changed, 353 insertions(+), 163 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc1219cb1..865fabfcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "amcl" version = "0.3.0" @@ -363,6 +372,40 @@ dependencies = [ "zeroize", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "error-chain" version = "0.12.4" @@ -569,6 +612,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -624,6 +673,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.24" @@ -717,12 +772,34 @@ dependencies = [ "num-traits", ] +[[package]] +name = "io-lifetimes" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "ipnet" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +[[package]] +name = "is-terminal" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -780,6 +857,12 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.4.9" @@ -811,6 +894,8 @@ version = "1.5.1" source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" dependencies = [ "amcl", + "hex", + "lazy_static", "rand", "zeroize", ] @@ -932,7 +1017,7 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -1153,6 +1238,23 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + [[package]] name = "remove_dir_all" version = "0.5.3" @@ -1226,6 +1328,20 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustix" +version = "0.36.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + [[package]] name = "ryu" version = "1.0.12" @@ -1482,6 +1598,7 @@ dependencies = [ "anyhow", "async-stream", "base2 0.2.2", + "env_logger", "ethereum-consensus", "hex", "reqwest", @@ -1538,6 +1655,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.38" @@ -1850,6 +1976,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 3638636cd..e9242033c 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -6,7 +6,14 @@ authors = ["Polytope Labs"] [dependencies] -base2 = { version = "0.3.1", default-features=false} -ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features=false, features=["serde"] } -hex-literal = { package = "hex-literal", version = "0.3.3" } +base2 = { version = "0.3.1", default-features = false} +ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2", default-features = false } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features = false, features=["serde"] } +hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } + +[features] +default = ["std"] +std = [ + "ssz-rs/std" +] +testing = [] \ No newline at end of file diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index d28e53bb2..7ff490608 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; pub mod types; diff --git a/primitives/src/types.rs b/primitives/src/types.rs index b292272c7..68484e68c 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -15,11 +15,12 @@ pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; +#[cfg(not(feature = "testing"))] pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); -// pub const NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2: usize = NEXT_SYNC_COMMITTEE_INDEX.floor_log2() -// as usize; pub const FINALIZED_ROOT_INDEX_FLOOR_LOG_2: usize = FINALIZED_ROOT_INDEX.floor_log2() -// as usize; +#[cfg(feature = "testing")] +pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("6034f557b4560fc549ac0e2c63269deb07bfac7bf2bbd0b8b7d4d321240bffd9"); /// This holds the relevant data required to prove the state root in the execution payload. #[derive(Debug, Clone)] @@ -106,16 +107,6 @@ pub struct LightClientState { pub next_sync_committee: SyncCommittee, } -/// Minimum state required by the light client to validate new sync committee attestations -#[derive(Debug, Clone)] -pub struct FinalityProof { - /// Epoch that was finalized - pub finalized_epoch: Epoch, - /// the ssz merkle proof for the finalized checkpoint in the attested header, finalized headers - /// lag by 2 epochs. - pub finality_branch: Vec, -} - /// Data required to advance the state of the light client. #[derive(Debug, Clone)] pub struct LightClientUpdate { @@ -128,7 +119,7 @@ pub struct LightClientUpdate { /// execution payload of the finalized header pub execution_payload: ExecutionPayloadProof, /// Finalized header proof - pub finality_proof: FinalityProof, + pub finality_branch: Vec, /// signature & participation bits pub sync_aggregate: SyncAggregate, /// slot at which signature was produced diff --git a/primitives/src/util.rs b/primitives/src/util.rs index ab58d83be..e090e33b2 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -1,7 +1,10 @@ use base2::Base2; use ethereum_consensus::{ altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD, - configs::mainnet::{ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, GENESIS_FORK_VERSION}, + configs::mainnet::{ + ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, BELLATRIX_FORK_EPOCH, BELLATRIX_FORK_VERSION, + GENESIS_FORK_VERSION, + }, phase0::mainnet::SLOTS_PER_EPOCH, }; use ssz_rs::Node; @@ -21,25 +24,24 @@ pub fn compute_epoch_at_slot(slot: u64) -> u64 { slot / SLOTS_PER_EPOCH } +#[cfg(not(feature = "testing"))] /// Return the fork version at the given ``epoch``. pub fn compute_fork_version(epoch: u64) -> [u8; 4] { - if epoch >= ALTAIR_FORK_EPOCH { + if epoch >= BELLATRIX_FORK_EPOCH { + BELLATRIX_FORK_VERSION + } else if epoch >= ALTAIR_FORK_EPOCH { ALTAIR_FORK_VERSION } else { GENESIS_FORK_VERSION } } +#[cfg(feature = "testing")] +pub fn compute_fork_version(epoch: u64) -> [u8; 4] { + BELLATRIX_FORK_VERSION +} + /// Return the sync committee period at ``slot`` pub fn compute_sync_committee_period_at_slot(slot: u64) -> u64 { compute_sync_committee_period(compute_epoch_at_slot(slot)) } - -/// method for hashing objects into a single root by utilizing a hash tree structure, as defined in -/// the SSZ spec. -pub fn hash_tree_root( - mut object: T, -) -> Result { - let root = object.hash_tree_root()?; - Ok(root) -} diff --git a/prover/Cargo.toml b/prover/Cargo.toml index f07ffedd3..8db82b6b2 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sync-committee-primitives = { path= "../primitives", default-features = false } -sync-committee-verifier = { path= "../verifier", default-features = false } +sync-committee-primitives = { path= "../primitives" } +sync-committee-verifier = { path= "../verifier" } ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", features=["serde", "std"] } reqwest = {version="0.11.14", features=["json"]} @@ -19,8 +19,11 @@ tokio = { version = "1.18.2", features = ["full"]} tokio-stream = { version = "0.1.8" } async-stream = { version = "0.3.3"} base2 = {version="0.2.2", default-features=false} +env_logger = "0.10.0" [dev-dependencies] hex = "0.4.3" +sync-committee-primitives = { path= "../primitives", features = ["testing"] } +sync-committee-verifier = { path= "../verifier", features = ["testing"] } diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 853da1ef1..14e395445 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -8,9 +8,7 @@ mod test; use ethereum_consensus::{ altair::Validator, - bellatrix::{ - BeaconBlock, BeaconBlockHeader, BeaconState, Checkpoint, SignedBeaconBlock, SyncCommittee, - }, + bellatrix::{BeaconBlock, BeaconBlockHeader, BeaconState, SignedBeaconBlock, SyncCommittee}, }; use reqwest::Client; @@ -35,16 +33,14 @@ use ethereum_consensus::{ }, primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}, }; -use ssz_rs::{ - get_generalized_index, GeneralizedIndex, List, Merkleized, Node, SszVariableOrIndex, Vector, -}; +use ssz_rs::{get_generalized_index, GeneralizedIndex, List, Merkleized, Node, Vector}; use sync_committee_primitives::{ types::{ - AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, BLOCK_ROOTS_INDEX, + AncestryProof, BlockRootsProof, ExecutionPayloadProof, BLOCK_ROOTS_INDEX, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, - util::{compute_epoch_at_slot, get_subtree_index}, + util::compute_epoch_at_slot, }; type BeaconBlockType = BeaconBlock< @@ -238,15 +234,6 @@ impl SyncCommitteeProver { Ok(sync_committee) } - async fn fetch_latest_finalized_block( - &self, - ) -> Result<(BeaconBlockHeader, BeaconBlockType), reqwest::Error> { - let block_header = self.fetch_header("finalized").await?; - let block = self.fetch_block("finalized").await?; - - Ok((block_header, block)) - } - fn generate_route(&self, path: &str) -> String { format!("{}{}", self.node_url.clone(), path) } @@ -298,17 +285,14 @@ fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result anyhow::Result { +fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; - Ok(FinalityProof { - finalized_epoch: state.finalized_checkpoint.epoch, - finality_branch: proof - .into_iter() - .map(|node| Hash32::try_from(node.as_ref()).expect("Node is always a 32 byte slice")) - .collect(), - }) + Ok(proof + .into_iter() + .map(|node| Hash32::try_from(node.as_ref()).expect("Node is always a 32 byte slice")) + .collect()) } fn prove_block_roots_proof( diff --git a/prover/src/responses/beacon_block_response.rs b/prover/src/responses/beacon_block_response.rs index d90317c7a..62839e3c4 100644 --- a/prover/src/responses/beacon_block_response.rs +++ b/prover/src/responses/beacon_block_response.rs @@ -1,17 +1,10 @@ -use ethereum_consensus::{ - bellatrix::{ - mainnet::{ - BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, - }, - BeaconBlock, BeaconBlockHeader, - }, - phase0::mainnet::{ - EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, - HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, - SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, +use ethereum_consensus::bellatrix::{ + mainnet::{ + BYTES_PER_LOGS_BLOOM, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_BYTES_PER_TRANSACTION, + MAX_DEPOSITS, MAX_EXTRA_DATA_BYTES, MAX_PROPOSER_SLASHINGS, MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SYNC_COMMITTEE_SIZE, }, + BeaconBlock, }; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] diff --git a/prover/src/test.rs b/prover/src/test.rs index 81118a8b6..687a62810 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -1,33 +1,33 @@ use super::*; use base2::Base2; -use ethereum_consensus::altair::NEXT_SYNC_COMMITTEE_INDEX_FLOOR_LOG_2; use sync_committee_primitives::{ types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, util::compute_sync_committee_period_at_slot, }; -use ethereum_consensus::bellatrix::mainnet::HistoricalBatch; -use ssz_rs::{ - calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, - Merkleized, SszVariableOrIndex, +use ethereum_consensus::{ + bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, + state_transition::Context, }; +use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; use std::time::Duration; +use sync_committee_primitives::{ + types::{DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, + util::compute_fork_version, +}; use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; +const NODE_URL: &'static str = "http://localhost:5052"; + #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] #[ignore] async fn fetch_block_header_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let mut block_header = sync_committee_prover.fetch_header("1000").await; - while block_header.is_err() { - println!("I am running till i am ok. lol"); - block_header = sync_committee_prover.fetch_header("1000").await; - } + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let block_header = sync_committee_prover.fetch_header("head").await; assert!(block_header.is_ok()); } @@ -36,9 +36,8 @@ async fn fetch_block_header_works() { #[actix_rt::test] #[ignore] async fn fetch_block_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_block("100").await; + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let block = sync_committee_prover.fetch_block("head").await; assert!(block.is_ok()); } @@ -47,9 +46,8 @@ async fn fetch_block_works() { #[actix_rt::test] #[ignore] async fn fetch_sync_committee_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let block = sync_committee_prover.fetch_sync_committee("117").await; + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let block = sync_committee_prover.fetch_sync_committee("head").await; assert!(block.is_ok()); } @@ -58,9 +56,8 @@ async fn fetch_sync_committee_works() { #[actix_rt::test] #[ignore] async fn fetch_validator_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let validator = sync_committee_prover.fetch_validator("2561", "48").await; + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let validator = sync_committee_prover.fetch_validator("head", "48").await; assert!(validator.is_ok()); } @@ -69,9 +66,8 @@ async fn fetch_validator_works() { #[actix_rt::test] #[ignore] async fn fetch_processed_sync_committee_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let validator = sync_committee_prover.fetch_processed_sync_committee("2561").await; + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let validator = sync_committee_prover.fetch_processed_sync_committee("head").await; assert!(validator.is_ok()); } @@ -80,8 +76,7 @@ async fn fetch_processed_sync_committee_works() { #[actix_rt::test] #[ignore] async fn fetch_beacon_state_works() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; assert!(beacon_state.is_ok()); } @@ -91,17 +86,14 @@ async fn fetch_beacon_state_works() { #[actix_rt::test] #[ignore] async fn state_root_and_block_header_root_matches() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); - let beacon_state = sync_committee_prover.fetch_beacon_state("100").await; - assert!(beacon_state.is_ok()); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let mut beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let block_header = sync_committee_prover.fetch_header("100").await; + let block_header = sync_committee_prover.fetch_header(&beacon_state.slot.to_string()).await; assert!(block_header.is_ok()); - let state = beacon_state.unwrap(); let block_header = block_header.unwrap(); - let hash_tree_root = state.clone().hash_tree_root(); + let hash_tree_root = beacon_state.hash_tree_root(); assert!(block_header.state_root == hash_tree_root.unwrap()); } @@ -110,8 +102,7 @@ async fn state_root_and_block_header_root_matches() { #[allow(non_snake_case)] #[actix_rt::test] async fn fetch_finality_checkpoints_work() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; assert!(finality_checkpoint.is_ok()); } @@ -120,8 +111,7 @@ async fn fetch_finality_checkpoints_work() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_finalized_header() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); @@ -147,8 +137,7 @@ async fn test_finalized_header() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_execution_payload_proof() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_id = finalized_state.slot.to_string(); @@ -204,8 +193,7 @@ async fn test_execution_payload_proof() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_sync_committee_update_proof() { - let node_url: String = "http://localhost:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let finalized_header = sync_committee_prover.fetch_header("head").await.unwrap(); @@ -254,10 +242,10 @@ async fn test_sync_committee_update_proof() { #[allow(non_snake_case)] #[actix_rt::test] async fn test_prover() { + env_logger::init(); let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 12))); - let node_url: String = "http://127.0.0.1:5052".to_string(); - let sync_committee_prover = SyncCommitteeProver::new(node_url); + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let block_id = "head"; @@ -274,6 +262,7 @@ async fn test_prover() { next_sync_committee: state.next_sync_committee, }; + let mut count = 0; while let Some(_ts) = stream.next().await { let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); if finality_checkpoint.finalized.root == Node::default() || @@ -300,21 +289,36 @@ async fn test_prover() { .unwrap(); let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let attested_block_id = { - let mut block_id = hex::encode(finality_checkpoint.current_justified.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id + let attested_epoch = finality_checkpoint.finalized.epoch + 2; + // Get available block from attested epoch + + let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; + let attested_block_header = loop { + if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH) == attested_slot { + panic!("Could not find any block from the attested epoch") + } + + if let Ok(header) = + sync_committee_prover.fetch_header(attested_slot.to_string().as_str()).await + { + break header + } + attested_slot += 1 }; - let attested_block_header = - sync_committee_prover.fetch_header(&attested_block_id).await.unwrap(); - let attested_state = sync_committee_prover .fetch_beacon_state(attested_block_header.slot.to_string().as_str()) .await .unwrap(); - let finality_branch_proof = prove_finalized_header(attested_state.clone()).unwrap(); + println!("{:?}", attested_state.finalized_checkpoint); + println!( + "{:?}, {:?}", + compute_epoch_at_slot(finalized_header.slot), + finalized_header.clone().hash_tree_root().unwrap() + ); + + let finality_branch = prove_finalized_header(attested_state.clone()).unwrap(); let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); @@ -339,15 +343,19 @@ async fn test_prover() { None }; - let signature_slot = attested_block_header.slot; + let signature_slot = attested_block_header.slot + 1; + let signature_block = sync_committee_prover + .fetch_block(signature_slot.to_string().as_str()) + .await + .unwrap(); // construct light client let light_client_update = LightClientUpdate { attested_header: attested_block_header, sync_committee_update, finalized_header, execution_payload: execution_payload_proof, - finality_proof: finality_branch_proof, - sync_aggregate: finalized_block.body.sync_aggregate, + finality_branch, + sync_aggregate: signature_block.body.sync_aggregate, signature_slot, // todo: Prove some ancestry blocks ancestor_blocks: vec![], @@ -359,5 +367,65 @@ async fn test_prover() { "Sucessfully verified Ethereum block at slot {:?}", client_state.finalized_header.slot ); + + count += 1; + if count == 100 { + break + } } } + +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_sync_committee_signature_verification() { + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let block = loop { + let block = sync_committee_prover.fetch_block("head").await.unwrap(); + if block.slot < 16 { + std::thread::sleep(Duration::from_secs(48)); + continue + } + break block + }; + let sync_committee = sync_committee_prover + .fetch_processed_sync_committee(block.slot.to_string().as_str()) + .await + .unwrap(); + + let mut attested_header = sync_committee_prover + .fetch_header((block.slot - 1).to_string().as_str()) + .await + .unwrap(); + + let sync_committee_pubkeys = sync_committee.public_keys; + + let participant_pubkeys = block + .body + .sync_aggregate + .sync_committee_bits + .iter() + .zip(sync_committee_pubkeys.iter()) + .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) + .collect::>(); + + let fork_version = compute_fork_version(compute_epoch_at_slot(block.slot)); + + let context = Context::for_mainnet(); + let domain = compute_domain( + DOMAIN_SYNC_COMMITTEE, + Some(fork_version), + Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().unwrap())), + &context, + ) + .unwrap(); + + let signing_root = compute_signing_root(&mut attested_header, domain); + + ethereum_consensus::crypto::fast_aggregate_verify( + &*participant_pubkeys, + signing_root.unwrap().as_bytes(), + &block.body.sync_aggregate.sync_committee_signature, + ) + .unwrap(); +} diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 8b68a4014..3e65a2b1a 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -7,7 +7,16 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features=false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2", default-features = false } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features = false, features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } -log = "0.4.17" \ No newline at end of file +log = { version = "0.4.17", default-features = false } + +[features] +default = ["std"] +std = [ + "ssz-rs/std", + "milagro_bls/std", + "log/std" +] +testing = ["sync-committee-primitives/testing"] \ No newline at end of file diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index aac2d6930..2d13079ad 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; pub mod error; @@ -15,6 +14,7 @@ use ethereum_consensus::{ signing::compute_signing_root, state_transition::Context, }; + use ssz_rs::{ calculate_merkle_root, calculate_multi_merkle_root, prelude::is_valid_merkle_branch, GeneralizedIndex, Merkleized, Node, @@ -28,10 +28,13 @@ use sync_committee_primitives::{ }, util::{ compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, - get_subtree_index, hash_tree_root, + get_subtree_index, }, }; +#[cfg(not(feature = "std"))] +use log::debug as println; + pub type LightClientState = sync_committee_primitives::types::LightClientState; pub type LightClientUpdate = sync_committee_primitives::types::LightClientUpdate; @@ -41,17 +44,13 @@ pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { - if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && + if update.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && update.sync_committee_update.is_some() && update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize { - log::debug!("Invalid update "); - log::debug!( - "update finality branch length {} ", - update.finality_proof.finality_branch.len() - ); - log::debug!( + println!("update finality branch length {} ", update.finality_branch.len()); + println!( "update next sync committee branch length {} ", update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() ); @@ -64,10 +63,10 @@ pub fn verify_sync_committee_attestation( let sync_aggregate_participants: u64 = sync_committee_bits.iter().as_bitslice().count_ones() as u64; - if sync_aggregate_participants * 3 >= sync_committee_bits.clone().len() as u64 * 2 { - log::debug!("SyncCommitteeParticipantsTooLow "); - log::debug!("sync_aggregate_participants {} ", { sync_aggregate_participants * 3 }); - log::debug!("sync_committee_bits {}", { sync_committee_bits.clone().len() * 2 }); + if sync_aggregate_participants < (2 * sync_committee_bits.len() as u64) / 3 { + println!("SyncCommitteeParticipantsTooLow "); + println!("sync_aggregate_participants {} ", { sync_aggregate_participants }); + println!("sync_committee_bits {}", { sync_committee_bits.len() * 2 }); Err(Error::SyncCommitteeParticipantsTooLow)? } @@ -75,16 +74,14 @@ pub fn verify_sync_committee_attestation( let is_valid_update = update.signature_slot > update.attested_header.slot && update.attested_header.slot >= update.finalized_header.slot; if !is_valid_update { - log::debug!("is_valid_update {} ", is_valid_update); - log::debug!( + println!("is_valid_update {} ", is_valid_update); + println!( "update.signature_slot {} update.attested_header.slot {}", - update.signature_slot, - update.attested_header.slot + update.signature_slot, update.attested_header.slot ); - log::debug!( + println!( "update.attested_header.slot {} update.finalized_header.slot {}", - update.attested_header.slot, - update.finalized_header.slot + update.attested_header.slot, update.finalized_header.slot ); Err(Error::InvalidUpdate)? } @@ -92,9 +89,9 @@ pub fn verify_sync_committee_attestation( let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); if !(state_period..=state_period + 1).contains(&update_signature_period) { - log::debug!("invalid update"); - log::debug!("state_period is {}", state_period); - log::debug!("update_signature_period is {}", update_signature_period); + println!("invalid update"); + println!("state_period is {}", state_period); + println!("update_signature_period is {}", update_signature_period); Err(Error::InvalidUpdate)? } @@ -125,12 +122,13 @@ pub fn verify_sync_committee_attestation( .collect::>(); let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); - //TODO: we probably need to construct context + + let context = Context::for_mainnet(); let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().map_err(|_| Error::InvalidRoot)?)), - &Context::default(), + &context, ) .map_err(|_| Error::InvalidUpdate)?; @@ -147,7 +145,7 @@ pub fn verify_sync_committee_attestation( // to match the finalized checkpoint root saved in the state of `attested_header`. // Note that the genesis finalized checkpoint root is represented as a zero hash. let mut finalized_checkpoint = Checkpoint { - epoch: update.finality_proof.finalized_epoch, + epoch: compute_epoch_at_slot(update.finalized_header.slot), root: update .finalized_header .clone() @@ -156,7 +154,6 @@ pub fn verify_sync_committee_attestation( }; let branch = update - .finality_proof .finality_branch .iter() .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) @@ -170,9 +167,8 @@ pub fn verify_sync_committee_attestation( &update.attested_header.state_root, ); - log::debug!("valid merkle branch for finalized_root {}", is_merkle_branch_valid); if !is_merkle_branch_valid { - log::debug!("invalid merkle branch for finalized root"); + println!("invalid merkle branch for finalized block"); Err(Error::InvalidMerkleBranch)?; } @@ -218,9 +214,9 @@ pub fn verify_sync_committee_attestation( &update.finalized_header.state_root, ); - log::debug!("valid merkle branch for execution_payload_branch"); + println!("valid merkle branch for execution_payload_branch"); if !is_merkle_branch_valid { - log::debug!("invalid merkle branch for execution_payload_branch"); + println!("invalid merkle branch for execution_payload_branch"); Err(Error::InvalidMerkleBranch)?; } @@ -229,7 +225,7 @@ pub fn verify_sync_committee_attestation( sync_committee_update.next_sync_committee != trusted_state.next_sync_committee.clone() { - log::debug!("invalid update for sync committee update"); + println!("invalid update for sync committee update"); Err(Error::InvalidUpdate)? } @@ -249,9 +245,9 @@ pub fn verify_sync_committee_attestation( &update.attested_header.state_root, ); - log::debug!("valid merkle branch for sync committee {}", is_merkle_branch_valid); + println!("valid merkle branch for sync committee {}", is_merkle_branch_valid); if !is_merkle_branch_valid { - log::debug!("invalid merkle branch for sync committee"); + println!("invalid merkle branch for sync committee"); Err(Error::InvalidMerkleBranch)?; } } @@ -372,7 +368,10 @@ pub fn verify_sync_committee_attestation( .map_err(|_| Error::InvalidRoot)?, ), Node::from_bytes( - hash_tree_root(execution_payload.block_number) + execution_payload + .block_number + .clone() + .hash_tree_root() .map_err(|_| Error::MerkleizationError)? .as_ref() .try_into() From 1c4d0ee5c6dd003e90fedf643258b3a5836345e8 Mon Sep 17 00:00:00 2001 From: David Salami Date: Fri, 24 Feb 2023 11:55:21 +0100 Subject: [PATCH 058/100] stuff works now --- prover/src/test.rs | 63 +++++++++++++++++++++++++++++++++++---------- verifier/src/lib.rs | 33 +++--------------------- 2 files changed, 52 insertions(+), 44 deletions(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index 687a62810..2c44f949b 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -6,7 +6,7 @@ use sync_committee_primitives::{ }; use ethereum_consensus::{ - bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, + altair::Checkpoint, bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, state_transition::Context, }; use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; @@ -19,6 +19,11 @@ use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; +// **NOTE** To run these tests make sure the latest fork version on your devnet is the +// BELLATRIX_FORK_VERSION as defined in the mainnet config Also modify +// `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing feature +// flag to match the one that is present in the devnet you are running the tests with + const NODE_URL: &'static str = "http://localhost:5052"; #[cfg(test)] @@ -269,7 +274,6 @@ async fn test_prover() { finality_checkpoint.finalized.epoch <= compute_epoch_at_slot(client_state.finalized_header.slot) { - println!("No new finalized checkpoint"); continue } @@ -281,7 +285,6 @@ async fn test_prover() { block_id }; - let finalized_block = sync_committee_prover.fetch_block(&block_id).await.unwrap(); let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); let finalized_state = sync_committee_prover .fetch_beacon_state(finalized_header.slot.to_string().as_str()) @@ -290,18 +293,46 @@ async fn test_prover() { let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); let attested_epoch = finality_checkpoint.finalized.epoch + 2; - // Get available block from attested epoch + // Get attested header and the signature slot let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; - let attested_block_header = loop { - if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH) == attested_slot { + let (attested_block_header, signature_block) = loop { + if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == + attested_slot + { panic!("Could not find any block from the attested epoch") } if let Ok(header) = sync_committee_prover.fetch_header(attested_slot.to_string().as_str()).await { - break header + let mut signature_slot = header.slot + 1; + let signature_block = loop { + if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == + signature_slot + { + panic!("Could not find any block after the attested header from the attested epoch") + } + if let Ok(signature_block) = + sync_committee_prover.fetch_block(signature_slot.to_string().as_str()).await + { + break signature_block + } + signature_slot += 1; + }; + // If the next block does not have sufficient sync committee participants + if signature_block + .body + .sync_aggregate + .sync_committee_bits + .as_bitslice() + .count_ones() < 2 / 3 * (SYNC_COMMITTEE_SIZE) + { + attested_slot = signature_slot + 1; + println!("Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); + continue + } + break (header, signature_block) } attested_slot += 1 }; @@ -311,11 +342,20 @@ async fn test_prover() { .await .unwrap(); + let finalized_hash_tree_root = finalized_header.clone().hash_tree_root().unwrap(); println!("{:?}", attested_state.finalized_checkpoint); println!( "{:?}, {:?}", compute_epoch_at_slot(finalized_header.slot), - finalized_header.clone().hash_tree_root().unwrap() + finalized_hash_tree_root + ); + + assert_eq!( + Checkpoint { + epoch: compute_epoch_at_slot(finalized_header.slot), + root: finalized_hash_tree_root, + }, + attested_state.finalized_checkpoint, ); let finality_branch = prove_finalized_header(attested_state.clone()).unwrap(); @@ -343,11 +383,6 @@ async fn test_prover() { None }; - let signature_slot = attested_block_header.slot + 1; - let signature_block = sync_committee_prover - .fetch_block(signature_slot.to_string().as_str()) - .await - .unwrap(); // construct light client let light_client_update = LightClientUpdate { attested_header: attested_block_header, @@ -356,7 +391,7 @@ async fn test_prover() { execution_payload: execution_payload_proof, finality_branch, sync_aggregate: signature_block.body.sync_aggregate, - signature_slot, + signature_slot: signature_block.slot, // todo: Prove some ancestry blocks ancestor_blocks: vec![], }; diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 2d13079ad..701b3174e 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -26,15 +26,9 @@ use sync_committee_primitives::{ EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, - util::{ - compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot, - get_subtree_index, - }, + util::{compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot}, }; -#[cfg(not(feature = "std"))] -use log::debug as println; - pub type LightClientState = sync_committee_primitives::types::LightClientState; pub type LightClientUpdate = sync_committee_primitives::types::LightClientUpdate; @@ -64,9 +58,6 @@ pub fn verify_sync_committee_attestation( sync_committee_bits.iter().as_bitslice().count_ones() as u64; if sync_aggregate_participants < (2 * sync_committee_bits.len() as u64) / 3 { - println!("SyncCommitteeParticipantsTooLow "); - println!("sync_aggregate_participants {} ", { sync_aggregate_participants }); - println!("sync_committee_bits {}", { sync_committee_bits.len() * 2 }); Err(Error::SyncCommitteeParticipantsTooLow)? } @@ -74,24 +65,12 @@ pub fn verify_sync_committee_attestation( let is_valid_update = update.signature_slot > update.attested_header.slot && update.attested_header.slot >= update.finalized_header.slot; if !is_valid_update { - println!("is_valid_update {} ", is_valid_update); - println!( - "update.signature_slot {} update.attested_header.slot {}", - update.signature_slot, update.attested_header.slot - ); - println!( - "update.attested_header.slot {} update.finalized_header.slot {}", - update.attested_header.slot, update.finalized_header.slot - ); Err(Error::InvalidUpdate)? } let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); if !(state_period..=state_period + 1).contains(&update_signature_period) { - println!("invalid update"); - println!("state_period is {}", state_period); - println!("update_signature_period is {}", update_signature_period); Err(Error::InvalidUpdate)? } @@ -168,7 +147,6 @@ pub fn verify_sync_committee_attestation( ); if !is_merkle_branch_valid { - println!("invalid merkle branch for finalized block"); Err(Error::InvalidMerkleBranch)?; } @@ -214,9 +192,7 @@ pub fn verify_sync_committee_attestation( &update.finalized_header.state_root, ); - println!("valid merkle branch for execution_payload_branch"); if !is_merkle_branch_valid { - println!("invalid merkle branch for execution_payload_branch"); Err(Error::InvalidMerkleBranch)?; } @@ -225,7 +201,6 @@ pub fn verify_sync_committee_attestation( sync_committee_update.next_sync_committee != trusted_state.next_sync_committee.clone() { - println!("invalid update for sync committee update"); Err(Error::InvalidUpdate)? } @@ -241,13 +216,11 @@ pub fn verify_sync_committee_attestation( .map_err(|_| Error::MerkleizationError)?, next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, - get_subtree_index(NEXT_SYNC_COMMITTEE_INDEX) as usize, + NEXT_SYNC_COMMITTEE_INDEX as usize, &update.attested_header.state_root, ); - println!("valid merkle branch for sync committee {}", is_merkle_branch_valid); if !is_merkle_branch_valid { - println!("invalid merkle branch for sync committee"); Err(Error::InvalidMerkleBranch)?; } } @@ -334,7 +307,7 @@ pub fn verify_sync_committee_attestation( &historical_roots_root, historical_roots_branch_nodes.iter(), HISTORICAL_ROOTS_INDEX.floor_log2() as usize, - get_subtree_index(HISTORICAL_ROOTS_INDEX) as usize, + HISTORICAL_ROOTS_INDEX as usize, &Node::from_bytes( update .finalized_header From 06af491dc5986fb3d609cd27a5e941bcc70c39c5 Mon Sep 17 00:00:00 2001 From: David Salami Date: Fri, 24 Feb 2023 11:56:14 +0100 Subject: [PATCH 059/100] nit --- verifier/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 701b3174e..135faff1e 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -43,12 +43,6 @@ pub fn verify_sync_committee_attestation( update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize { - println!("update finality branch length {} ", update.finality_branch.len()); - println!( - "update next sync committee branch length {} ", - update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() - ); - Err(Error::InvalidUpdate)? } From 7383621aa0e92e0698926786ee1bc5854cb3defc Mon Sep 17 00:00:00 2001 From: David Salami Date: Fri, 24 Feb 2023 18:06:43 +0100 Subject: [PATCH 060/100] some fixes --- prover/src/test.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index 2c44f949b..77855d542 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -19,10 +19,12 @@ use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; -// **NOTE** To run these tests make sure the latest fork version on your devnet is the -// BELLATRIX_FORK_VERSION as defined in the mainnet config Also modify -// `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing feature -// flag to match the one that is present in the devnet you are running the tests with +// **NOTE** +// 1. To run these tests make sure the latest fork version on your devnet is the +// BELLATRIX_FORK_VERSION as defined in the mainnet config +// 2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing +// feature flag to match the one that is present in the devnet you are running the tests with +// 3. Make sure the SLOTS_PER_EPOCH is set to 32 in your beacon node. const NODE_URL: &'static str = "http://localhost:5052"; @@ -307,11 +309,18 @@ async fn test_prover() { sync_committee_prover.fetch_header(attested_slot.to_string().as_str()).await { let mut signature_slot = header.slot + 1; + let mut loop_count = 0; let signature_block = loop { + if loop_count == 3 { + panic!("Could not find valid signature block for attested slot {} after three loops", attested_slot); + } if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == signature_slot { - panic!("Could not find any block after the attested header from the attested epoch") + println!("Waiting for signature block for attested header"); + std::thread::sleep(Duration::from_secs(24)); + signature_slot = header.slot + 1; + loop_count += 1; } if let Ok(signature_block) = sync_committee_prover.fetch_block(signature_slot.to_string().as_str()).await @@ -343,11 +352,12 @@ async fn test_prover() { .unwrap(); let finalized_hash_tree_root = finalized_header.clone().hash_tree_root().unwrap(); - println!("{:?}", attested_state.finalized_checkpoint); + println!("{:?}, {}", attested_state.finalized_checkpoint, attested_state.slot); println!( - "{:?}, {:?}", + "{:?}, {:?}, {}", compute_epoch_at_slot(finalized_header.slot), - finalized_hash_tree_root + finalized_hash_tree_root, + finalized_header.slot ); assert_eq!( From 66b307da390a7aba818306e1bec6f50464891e9f Mon Sep 17 00:00:00 2001 From: David Salami Date: Sat, 25 Feb 2023 17:19:07 +0100 Subject: [PATCH 061/100] hopefully stabilize tests --- primitives/src/types.rs | 11 +++++- prover/src/test.rs | 79 +++++++++++++++++++++++++---------------- verifier/src/lib.rs | 5 +-- 3 files changed, 61 insertions(+), 34 deletions(-) diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 68484e68c..e565e4bbc 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -107,6 +107,15 @@ pub struct LightClientState { pub next_sync_committee: SyncCommittee, } +/// Finalized header proof +#[derive(Debug, Clone)] +pub struct FinalityProof { + /// The latest finalized epoch + pub epoch: u64, + /// Finalized header proof + pub finality_branch: Vec, +} + /// Data required to advance the state of the light client. #[derive(Debug, Clone)] pub struct LightClientUpdate { @@ -119,7 +128,7 @@ pub struct LightClientUpdate { /// execution payload of the finalized header pub execution_payload: ExecutionPayloadProof, /// Finalized header proof - pub finality_branch: Vec, + pub finality_proof: FinalityProof, /// signature & participation bits pub sync_aggregate: SyncAggregate, /// slot at which signature was produced diff --git a/prover/src/test.rs b/prover/src/test.rs index 77855d542..263d21aef 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -12,7 +12,7 @@ use ethereum_consensus::{ use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; use std::time::Duration; use sync_committee_primitives::{ - types::{DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, + types::{FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, util::compute_fork_version, }; use sync_committee_verifier::verify_sync_committee_attestation; @@ -294,15 +294,31 @@ async fn test_prover() { .unwrap(); let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let attested_epoch = finality_checkpoint.finalized.epoch + 2; + let mut attested_epoch = finality_checkpoint.finalized.epoch + 2; // Get attested header and the signature slot let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; + // Due to the fact that all slots in an epoch can be missed we are going to try and fetch + // the attested block from four possible epochs. + let mut attested_epoch_loop_count = 0; let (attested_block_header, signature_block) = loop { + if attested_epoch_loop_count == 4 { + panic!("Could not fetch any block from the attested epoch after going through four epochs, your Eth devnet is fucked") + } + // If we have maxed out the slots in the current epoch and still didn't find any block, + // we move to the next epoch if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == attested_slot { - panic!("Could not find any block from the attested epoch") + // No block was found in attested epoch we move to the next possible attested epoch + println!( + "No slots found in epoch {attested_epoch} Moving to the next possible epoch {}", + attested_epoch + 1 + ); + std::thread::sleep(Duration::from_secs(24)); + attested_epoch += 1; + attested_slot = attested_epoch * SLOTS_PER_EPOCH; + attested_epoch_loop_count += 1; } if let Ok(header) = @@ -311,8 +327,8 @@ async fn test_prover() { let mut signature_slot = header.slot + 1; let mut loop_count = 0; let signature_block = loop { - if loop_count == 3 { - panic!("Could not find valid signature block for attested slot {} after three loops", attested_slot); + if loop_count == 2 { + break None } if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == signature_slot @@ -325,23 +341,32 @@ async fn test_prover() { if let Ok(signature_block) = sync_committee_prover.fetch_block(signature_slot.to_string().as_str()).await { - break signature_block + break Some(signature_block) } signature_slot += 1; }; // If the next block does not have sufficient sync committee participants - if signature_block - .body - .sync_aggregate - .sync_committee_bits - .as_bitslice() - .count_ones() < 2 / 3 * (SYNC_COMMITTEE_SIZE) - { - attested_slot = signature_slot + 1; - println!("Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); + if let Some(signature_block) = signature_block { + if signature_block + .body + .sync_aggregate + .sync_committee_bits + .as_bitslice() + .count_ones() < (2 * (SYNC_COMMITTEE_SIZE)) / 3 + { + attested_slot += 1; + println!("Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); + continue + } + break (header, signature_block) + } else { + println!("No signature block found in {attested_epoch} Moving to the next possible epoch {}", attested_epoch + 1); + std::thread::sleep(Duration::from_secs(24)); + attested_epoch += 1; + attested_slot = attested_epoch * SLOTS_PER_EPOCH; + attested_epoch_loop_count += 1; continue } - break (header, signature_block) } attested_slot += 1 }; @@ -353,22 +378,14 @@ async fn test_prover() { let finalized_hash_tree_root = finalized_header.clone().hash_tree_root().unwrap(); println!("{:?}, {}", attested_state.finalized_checkpoint, attested_state.slot); - println!( - "{:?}, {:?}, {}", - compute_epoch_at_slot(finalized_header.slot), - finalized_hash_tree_root, - finalized_header.slot - ); + println!("{:?}, {}", finalized_hash_tree_root, finalized_header.slot); - assert_eq!( - Checkpoint { - epoch: compute_epoch_at_slot(finalized_header.slot), - root: finalized_hash_tree_root, - }, - attested_state.finalized_checkpoint, - ); + assert_eq!(finalized_hash_tree_root, attested_state.finalized_checkpoint.root); - let finality_branch = prove_finalized_header(attested_state.clone()).unwrap(); + let finality_proof = FinalityProof { + epoch: finality_checkpoint.finalized.epoch, + finality_branch: prove_finalized_header(attested_state.clone()).unwrap(), + }; let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); @@ -399,7 +416,7 @@ async fn test_prover() { sync_committee_update, finalized_header, execution_payload: execution_payload_proof, - finality_branch, + finality_proof, sync_aggregate: signature_block.body.sync_aggregate, signature_slot: signature_block.slot, // todo: Prove some ancestry blocks diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 135faff1e..e88e8a0bf 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -38,7 +38,7 @@ pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { - if update.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && + if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && update.sync_committee_update.is_some() && update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize @@ -118,7 +118,7 @@ pub fn verify_sync_committee_attestation( // to match the finalized checkpoint root saved in the state of `attested_header`. // Note that the genesis finalized checkpoint root is represented as a zero hash. let mut finalized_checkpoint = Checkpoint { - epoch: compute_epoch_at_slot(update.finalized_header.slot), + epoch: update.finality_proof.epoch, root: update .finalized_header .clone() @@ -127,6 +127,7 @@ pub fn verify_sync_committee_attestation( }; let branch = update + .finality_proof .finality_branch .iter() .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) From 72faf630735af0187985283067df234925a854e5 Mon Sep 17 00:00:00 2001 From: David Salami Date: Sun, 26 Feb 2023 08:10:27 +0100 Subject: [PATCH 062/100] tests are stable, add readme --- README.md | 7 +++++++ primitives/src/types.rs | 2 ++ prover/src/test.rs | 13 ++++--------- verifier/src/lib.rs | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index eb9389959..ffe672b74 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # ethereum-beacon-light-client Implementation of the Ethereum beacon chain light client in Rust + +# Running the prover tests +**NOTE** +1. To run these tests make sure the latest fork version on your devnet is the BELLATRIX_FORK_VERSION as defined in the mainnet config +2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing + feature flag to match the one that is present in the devnet you are running the tests with +3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. \ No newline at end of file diff --git a/primitives/src/types.rs b/primitives/src/types.rs index e565e4bbc..2d29c7db0 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -102,6 +102,8 @@ pub struct SyncCommitteeUpdate { pub struct LightClientState { /// The latest recorded finalized header pub finalized_header: BeaconBlockHeader, + /// Latest finalized epoch + pub latest_finalized_epoch: u64, // Sync committees corresponding to the finalized header pub current_sync_committee: SyncCommittee, pub next_sync_committee: SyncCommittee, diff --git a/prover/src/test.rs b/prover/src/test.rs index 263d21aef..6765028b0 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -19,13 +19,6 @@ use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; -// **NOTE** -// 1. To run these tests make sure the latest fork version on your devnet is the -// BELLATRIX_FORK_VERSION as defined in the mainnet config -// 2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing -// feature flag to match the one that is present in the devnet you are running the tests with -// 3. Make sure the SLOTS_PER_EPOCH is set to 32 in your beacon node. - const NODE_URL: &'static str = "http://localhost:5052"; #[cfg(test)] @@ -265,6 +258,7 @@ async fn test_prover() { let mut client_state = LightClientState { finalized_header: block_header.clone(), + latest_finalized_epoch: 0, current_sync_committee: state.current_sync_committee, next_sync_committee: state.next_sync_committee, }; @@ -273,8 +267,9 @@ async fn test_prover() { while let Some(_ts) = stream.next().await { let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); if finality_checkpoint.finalized.root == Node::default() || - finality_checkpoint.finalized.epoch <= - compute_epoch_at_slot(client_state.finalized_header.slot) + finality_checkpoint.finalized.epoch <= client_state.latest_finalized_epoch || + finality_checkpoint.finalized.root == + client_state.finalized_header.clone().hash_tree_root().unwrap() { continue } diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index e88e8a0bf..928f92406 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -376,6 +376,7 @@ pub fn verify_sync_committee_attestation( let new_light_client_state = if let Some(sync_committee_update) = update.sync_committee_update { LightClientState { finalized_header: update.finalized_header, + latest_finalized_epoch: update.finality_proof.epoch, current_sync_committee: trusted_state.next_sync_committee, next_sync_committee: sync_committee_update.next_sync_committee, } From 2a0a89421cd4c75aee414258e769b5bef6d20b40 Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 27 Feb 2023 10:34:39 +0100 Subject: [PATCH 063/100] chore: remove unused imports --- Cargo.lock | 66 +++++++++++++++++++++++++---------------- primitives/src/lib.rs | 3 +- primitives/src/types.rs | 3 +- primitives/src/util.rs | 1 - prover/Cargo.toml | 2 +- prover/src/lib.rs | 63 +++++++++------------------------------ verifier/src/error.rs | 2 +- verifier/src/lib.rs | 4 +-- 8 files changed, 62 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 865fabfcf..127a36bf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,9 +132,9 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bitflags" @@ -210,9 +210,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "core-foundation" @@ -418,7 +418,7 @@ dependencies = [ [[package]] name = "ethereum-consensus" version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#8be43ea5768297f83acfc22651121154fb1a5874" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#bd19d7c3e7a44810a7f57b5fd00ea55a816222f1" dependencies = [ "async-stream", "bs58", @@ -434,9 +434,9 @@ dependencies = [ "rand", "serde", "serde_json", + "serde_yaml", "sha2 0.9.9", "ssz-rs", - "thiserror", "tokio", "tokio-stream", ] @@ -790,9 +790,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" [[package]] name = "is-terminal" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -857,6 +857,12 @@ version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -933,7 +939,6 @@ dependencies = [ "serde", "static_assertions", "unsigned-varint", - "url", ] [[package]] @@ -1255,15 +1260,6 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "reqwest" version = "0.11.14" @@ -1443,6 +1439,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap", + "ryu", + "serde", + "yaml-rust", +] + [[package]] name = "sha2" version = "0.9.9" @@ -1571,9 +1579,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1643,16 +1651,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix", + "windows-sys 0.42.0", ] [[package]] @@ -2090,6 +2097,15 @@ dependencies = [ "tap", ] +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "zeroize" version = "1.5.7" diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 7ff490608..10f9e5962 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] - +#[deny(unused_imports)] +#[deny(unused_variables)] extern crate alloc; pub mod types; diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 2d29c7db0..699d5ea48 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -1,9 +1,8 @@ use alloc::vec::Vec; -use base2::Base2; use ethereum_consensus::{ bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, domains::DomainType, - primitives::{Epoch, Hash32, Slot}, + primitives::{Hash32, Slot}, }; pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; diff --git a/primitives/src/util.rs b/primitives/src/util.rs index e090e33b2..9a285734f 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -7,7 +7,6 @@ use ethereum_consensus::{ }, phase0::mainnet::SLOTS_PER_EPOCH, }; -use ssz_rs::Node; /// Calculate the subtree index from the ``generalized_index`` pub fn get_subtree_index(generalized_index: u64) -> u64 { diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 8db82b6b2..133a46c67 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", features=["serde", "std"] } +ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", features=["serde"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 14e395445..c8a2495ba 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -1,14 +1,14 @@ +#[deny(unused_imports)] +#[deny(unused_variables)] mod error; mod responses; mod routes; #[cfg(test)] mod test; -// todo: split up this file - use ethereum_consensus::{ altair::Validator, - bellatrix::{BeaconBlock, BeaconBlockHeader, BeaconState, SignedBeaconBlock, SyncCommittee}, + bellatrix::{BeaconBlock, BeaconBlockHeader, BeaconState, SyncCommittee}, }; use reqwest::Client; @@ -31,9 +31,9 @@ use ethereum_consensus::{ MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, }, - primitives::{BlsPublicKey, Bytes32, Hash32, Slot, ValidatorIndex}, + primitives::{BlsPublicKey, Bytes32, Hash32, ValidatorIndex}, }; -use ssz_rs::{get_generalized_index, GeneralizedIndex, List, Merkleized, Node, Vector}; +use ssz_rs::{List, Merkleized, Node, Vector}; use sync_committee_primitives::{ types::{ AncestryProof, BlockRootsProof, ExecutionPayloadProof, BLOCK_ROOTS_INDEX, @@ -43,34 +43,6 @@ use sync_committee_primitives::{ util::compute_epoch_at_slot, }; -type BeaconBlockType = BeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, ->; - -type SignedBeaconBlockType = SignedBeaconBlock< - MAX_PROPOSER_SLASHINGS, - MAX_VALIDATORS_PER_COMMITTEE, - MAX_ATTESTER_SLASHINGS, - MAX_ATTESTATIONS, - MAX_DEPOSITS, - MAX_VOLUNTARY_EXITS, - SYNC_COMMITTEE_SIZE, - BYTES_PER_LOGS_BLOOM, - MAX_EXTRA_DATA_BYTES, - MAX_BYTES_PER_TRANSACTION, - MAX_TRANSACTIONS_PER_PAYLOAD, ->; - pub type BeaconStateType = BeaconState< SLOTS_PER_HISTORICAL_ROOT, HISTORICAL_ROOTS_LIMIT, @@ -208,7 +180,7 @@ impl SyncCommitteeProver { let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; let mut validators: List = Default::default(); - for mut validator_index in node_sync_committee.validators.clone() { + for validator_index in node_sync_committee.validators.clone() { // fetches validator based on validator index let validator = self.fetch_validator(state_id.clone(), &validator_index).await?; validators.push(validator); @@ -239,20 +211,13 @@ impl SyncCommitteeProver { } } -fn get_attestation_slots_for_finalized_header( - finalized_header: &BeaconBlockHeader, - slots_per_epoch: u64, -) -> Slot { - let finalized_header_slot = finalized_header.slot; - - // given that an epoch is 32 slots and blocks are finalized every 2 epochs - // so the attested slot for a finalized block is 64 slots away - let attested_slot = finalized_header_slot + (slots_per_epoch * 2); - - attested_slot +pub fn get_attested_epoch(finalized_epoch: u64) -> u64 { + finalized_epoch + 2 } -fn prove_execution_payload(beacon_state: BeaconStateType) -> anyhow::Result { +pub fn prove_execution_payload( + beacon_state: BeaconStateType, +) -> anyhow::Result { let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, @@ -280,12 +245,12 @@ fn prove_execution_payload(beacon_state: BeaconStateType) -> anyhow::Result anyhow::Result> { +pub fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { let proof = ssz_rs::generate_proof(state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } -fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { +pub fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; @@ -295,7 +260,7 @@ fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> .collect()) } -fn prove_block_roots_proof( +pub fn prove_block_roots_proof( state: BeaconStateType, mut header: BeaconBlockHeader, ) -> anyhow::Result { diff --git a/verifier/src/error.rs b/verifier/src/error.rs index dcd6e74b5..4fd88fabc 100644 --- a/verifier/src/error.rs +++ b/verifier/src/error.rs @@ -25,7 +25,7 @@ impl Display for Error { }, Error::InvalidUpdate => write!(f, "Invalid update"), Error::DomainError => write!(f, "Couldn't get domain"), - Error::FastAggregateError(err) => write!(f, "Fast aggregate error"), + Error::FastAggregateError(err) => write!(f, "Fast aggregate error {:?}", err), Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), Error::InvalidRoot => write!(f, "Invalid root"), Error::MerkleizationError => write!(f, "Merkleization error"), diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 928f92406..833715e81 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -1,5 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] - +#[deny(unused_imports)] +#[deny(unused_variables)] extern crate alloc; pub mod error; @@ -7,7 +8,6 @@ pub mod error; use crate::error::Error; use alloc::vec::Vec; use base2::Base2; -use core::{borrow::Borrow, fmt::Display}; use ethereum_consensus::{ bellatrix::{compute_domain, mainnet::SYNC_COMMITTEE_SIZE, Checkpoint}, primitives::Root, From 4cf2003868d1df85072e430de8e7bc9d394996a0 Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 27 Feb 2023 12:09:19 +0100 Subject: [PATCH 064/100] add a todo for ancestry blocks --- prover/src/test.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index 6765028b0..2bce45093 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -12,7 +12,7 @@ use ethereum_consensus::{ use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; use std::time::Duration; use sync_committee_primitives::{ - types::{FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, + types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, util::compute_fork_version, }; use sync_committee_verifier::verify_sync_committee_attestation; @@ -405,6 +405,33 @@ async fn test_prover() { None }; + // todo: Reenable when proofs are implemented for Lists adn Vectors + // let mut i = finalized_header.slot - 1; + // let mut ancestor_blocks = vec![]; + // while ancestor_blocks.len() < 5 { + // if (finalized_header.slot - i) > 100 { + // break + // } + // if let Ok(ancestor_header) = + // sync_committee_prover.fetch_header(i.to_string().as_str()).await + // { + // let ancestry_proof = + // prove_block_roots_proof(finalized_state.clone(), ancestor_header.clone()) + // .unwrap(); + // let header_state = + // sync_committee_prover.fetch_beacon_state(i.to_string().as_str()).await.unwrap(); + // let execution_payload_proof = prove_execution_payload(header_state).unwrap(); + // ancestor_blocks.push(AncestorBlock { + // header: ancestor_header, + // execution_payload: execution_payload_proof, + // ancestry_proof, + // }) + // } + // i -= 1; + // } + // + // println!("Ancestor block count {}", ancestor_blocks.len()); + // construct light client let light_client_update = LightClientUpdate { attested_header: attested_block_header, @@ -414,7 +441,6 @@ async fn test_prover() { finality_proof, sync_aggregate: signature_block.body.sync_aggregate, signature_slot: signature_block.slot, - // todo: Prove some ancestry blocks ancestor_blocks: vec![], }; From a6ec7bb7a8155020ed188522d543023c054e3e30 Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 27 Feb 2023 12:13:44 +0100 Subject: [PATCH 065/100] chore --- primitives/src/lib.rs | 4 ++-- prover/src/lib.rs | 4 ++-- prover/src/test.rs | 2 +- verifier/src/lib.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 10f9e5962..23d346f32 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[deny(unused_imports)] -#[deny(unused_variables)] +#[warn(unused_imports)] +#[warn(unused_variables)] extern crate alloc; pub mod types; diff --git a/prover/src/lib.rs b/prover/src/lib.rs index c8a2495ba..28848958a 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -1,5 +1,5 @@ -#[deny(unused_imports)] -#[deny(unused_variables)] +#[warn(unused_imports)] +#[warn(unused_variables)] mod error; mod responses; mod routes; diff --git a/prover/src/test.rs b/prover/src/test.rs index 2bce45093..3b94e8014 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -405,7 +405,7 @@ async fn test_prover() { None }; - // todo: Reenable when proofs are implemented for Lists adn Vectors + // todo: Enable when proofs are implemented for Lists adn Vectors // let mut i = finalized_header.slot - 1; // let mut ancestor_blocks = vec![]; // while ancestor_blocks.len() < 5 { diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 833715e81..ac6a6df14 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -1,6 +1,6 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[deny(unused_imports)] -#[deny(unused_variables)] +#[warn(unused_imports)] +#[warn(unused_variables)] extern crate alloc; pub mod error; From 5cd1028743121688019cc4d35109bf9af2536b8c Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 27 Feb 2023 12:15:44 +0100 Subject: [PATCH 066/100] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ffe672b74..5e3496e7a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ethereum-beacon-light-client -Implementation of the Ethereum beacon chain light client in Rust +# Ethereum beacon light client verifier +Implementation of the Ethereum beacon light client verifier in Rust # Running the prover tests **NOTE** From d20c277745ccc64fd7d2f4008b366ffca50ec6f5 Mon Sep 17 00:00:00 2001 From: David Salami Date: Thu, 2 Mar 2023 10:23:38 +0100 Subject: [PATCH 067/100] add some needed derives to types --- primitives/src/types.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 699d5ea48..3038dacdd 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -22,7 +22,7 @@ pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("6034f557b4560fc549ac0e2c63269deb07bfac7bf2bbd0b8b7d4d321240bffd9"); /// This holds the relevant data required to prove the state root in the execution payload. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct ExecutionPayloadProof { /// The state root in the `ExecutionPayload` which represents the commitment to /// the ethereum world state in the yellow paper. @@ -37,7 +37,7 @@ pub struct ExecutionPayloadProof { /// Holds the neccessary proofs required to verify a header in the `block_roots` field /// either in [`BeaconState`] or [`HistoricalBatch`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct BlockRootsProof { /// Generalized index of the header in the `block_roots` list. pub block_header_index: u64, @@ -47,7 +47,7 @@ pub struct BlockRootsProof { /// The block header ancestry proof, this is an enum because the header may either exist in /// `state.block_roots` or `state.historical_roots`. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum AncestryProof { /// This variant defines the proof data for a beacon chain header in the `state.block_roots` BlockRoots { @@ -76,7 +76,7 @@ pub enum AncestryProof { /// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized /// header. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AncestorBlock { /// The actual beacon chain header pub header: BeaconBlockHeader, @@ -88,7 +88,7 @@ pub struct AncestorBlock { /// Holds the latest sync committee as well as an ssz proof for it's existence /// in a finalized header. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct SyncCommitteeUpdate { // actual sync committee pub next_sync_committee: SyncCommittee, @@ -97,7 +97,7 @@ pub struct SyncCommitteeUpdate { } /// Minimum state required by the light client to validate new sync committee attestations -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct LightClientState { /// The latest recorded finalized header pub finalized_header: BeaconBlockHeader, @@ -109,7 +109,7 @@ pub struct LightClientState { } /// Finalized header proof -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct FinalityProof { /// The latest finalized epoch pub epoch: u64, @@ -118,7 +118,7 @@ pub struct FinalityProof { } /// Data required to advance the state of the light client. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub struct LightClientUpdate { /// the header that the sync committee signed pub attested_header: BeaconBlockHeader, From d1b9df6cfb3505cef1dfdd00ff052ffb1ad7fe22 Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 6 Mar 2023 16:10:50 +0100 Subject: [PATCH 068/100] enable ancestry proofd --- Cargo.lock | 46 +++++++++++++++++------------------ primitives/src/util.rs | 2 +- prover/src/lib.rs | 20 ++++++++-------- prover/src/test.rs | 54 +++++++++++++++++++++--------------------- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 127a36bf5..0d9d87dcb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,9 +571,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -811,9 +811,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" @@ -1326,9 +1326,9 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.36.8" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ "bitflags", "errno", @@ -1340,9 +1340,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "schannel" @@ -1418,9 +1418,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "itoa", "ryu", @@ -1521,9 +1521,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "ssz-rs" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f85f088552ee45c4c6080eede3fb57d47bff92e3" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f25813944f80ba7c572a00900c6de316eb8a50c8" dependencies = [ "as-any", "bitvec", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "ssz-rs-derive" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f85f088552ee45c4c6080eede3fb57d47bff92e3" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f25813944f80ba7c572a00900c6de316eb8a50c8" dependencies = [ "proc-macro2", "quote", @@ -1673,18 +1673,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", @@ -1708,9 +1708,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -1723,7 +1723,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1827,9 +1827,9 @@ checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" diff --git a/primitives/src/util.rs b/primitives/src/util.rs index 9a285734f..8be6d1474 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -36,7 +36,7 @@ pub fn compute_fork_version(epoch: u64) -> [u8; 4] { } #[cfg(feature = "testing")] -pub fn compute_fork_version(epoch: u64) -> [u8; 4] { +pub fn compute_fork_version(_epoch: u64) -> [u8; 4] { BELLATRIX_FORK_VERSION } diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 28848958a..5b3b75cd3 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -216,7 +216,7 @@ pub fn get_attested_epoch(finalized_epoch: u64) -> u64 { } pub fn prove_execution_payload( - beacon_state: BeaconStateType, + mut beacon_state: BeaconStateType, ) -> anyhow::Result { let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, @@ -224,7 +224,7 @@ pub fn prove_execution_payload( ]; // generate multi proofs let multi_proof = ssz_rs::generate_proof( - beacon_state.latest_execution_payload_header.clone(), + &mut beacon_state.latest_execution_payload_header, indices.as_slice(), )?; @@ -236,7 +236,7 @@ pub fn prove_execution_payload( .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect(), execution_payload_branch: ssz_rs::generate_proof( - beacon_state, + &mut beacon_state, &[EXECUTION_PAYLOAD_INDEX as usize], )? .into_iter() @@ -245,14 +245,14 @@ pub fn prove_execution_payload( }) } -pub fn prove_sync_committee_update(state: BeaconStateType) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; +pub fn prove_sync_committee_update(mut state: BeaconStateType) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(&mut state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } -pub fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result> { +pub fn prove_finalized_header(mut state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; - let proof = ssz_rs::generate_proof(state.clone(), indices.as_slice())?; + let proof = ssz_rs::generate_proof(&mut state, indices.as_slice())?; Ok(proof .into_iter() @@ -261,7 +261,7 @@ pub fn prove_finalized_header(state: BeaconStateType) -> anyhow::Result anyhow::Result { // Check if block root should still be part of the block roots vector on the beacon state @@ -283,7 +283,7 @@ pub fn prove_block_roots_proof( .position(|root| root == &block_root) .expect("Block root should exist in block_roots"); - let proof = ssz_rs::generate_proof(state.block_roots.clone(), &[block_index])?; + let proof = ssz_rs::generate_proof(&mut state.block_roots, &[block_index])?; let block_roots_proof = BlockRootsProof { block_header_index: block_index as u64, @@ -295,7 +295,7 @@ pub fn prove_block_roots_proof( .collect(), }; - let block_roots_branch = ssz_rs::generate_proof(state, &[BLOCK_ROOTS_INDEX as usize])?; + let block_roots_branch = ssz_rs::generate_proof(&mut state, &[BLOCK_ROOTS_INDEX as usize])?; Ok(AncestryProof::BlockRoots { block_roots_proof, block_roots_branch: block_roots_branch diff --git a/prover/src/test.rs b/prover/src/test.rs index 3b94e8014..deaa5591e 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -114,7 +114,7 @@ async fn test_finalized_header() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); + let proof = ssz_rs::generate_proof(&mut state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); let leaves = vec![Node::from_bytes( state @@ -405,32 +405,32 @@ async fn test_prover() { None }; - // todo: Enable when proofs are implemented for Lists adn Vectors - // let mut i = finalized_header.slot - 1; - // let mut ancestor_blocks = vec![]; - // while ancestor_blocks.len() < 5 { - // if (finalized_header.slot - i) > 100 { - // break - // } - // if let Ok(ancestor_header) = - // sync_committee_prover.fetch_header(i.to_string().as_str()).await - // { - // let ancestry_proof = - // prove_block_roots_proof(finalized_state.clone(), ancestor_header.clone()) - // .unwrap(); - // let header_state = - // sync_committee_prover.fetch_beacon_state(i.to_string().as_str()).await.unwrap(); - // let execution_payload_proof = prove_execution_payload(header_state).unwrap(); - // ancestor_blocks.push(AncestorBlock { - // header: ancestor_header, - // execution_payload: execution_payload_proof, - // ancestry_proof, - // }) - // } - // i -= 1; - // } - // - // println!("Ancestor block count {}", ancestor_blocks.len()); + let mut i = finalized_header.slot - 1; + let mut ancestor_blocks = vec![]; + while ancestor_blocks.len() < 5 { + if (finalized_header.slot - i) > 100 { + break + } + if let Ok(ancestor_header) = + sync_committee_prover.fetch_header(i.to_string().as_str()).await + { + let ancestry_proof = + prove_block_roots_proof(finalized_state.clone(), ancestor_header.clone()) + .unwrap(); + let header_state = + sync_committee_prover.fetch_beacon_state(i.to_string().as_str()).await.unwrap(); + let execution_payload_proof = prove_execution_payload(header_state).unwrap(); + ancestor_blocks.push(AncestorBlock { + header: ancestor_header, + execution_payload: execution_payload_proof, + ancestry_proof, + }) + } + i -= 1; + } + + println!("\nAncestor blocks count: \n {:?} \n", ancestor_blocks.len()); + println!("\nAncestor blocks count: \n {:#?} \n", ancestor_blocks); // construct light client let light_client_update = LightClientUpdate { From 49000faba3db6de103292d240dbf4a6cbf01d5d8 Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 6 Mar 2023 16:11:52 +0100 Subject: [PATCH 069/100] nit --- prover/src/test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index deaa5591e..f8981455f 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -430,7 +430,6 @@ async fn test_prover() { } println!("\nAncestor blocks count: \n {:?} \n", ancestor_blocks.len()); - println!("\nAncestor blocks count: \n {:#?} \n", ancestor_blocks); // construct light client let light_client_update = LightClientUpdate { From 2b292cf6d5e367629ec7ab78df112178cd4fdb2d Mon Sep 17 00:00:00 2001 From: David Salami Date: Mon, 6 Mar 2023 16:12:27 +0100 Subject: [PATCH 070/100] chore --- prover/src/test.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index f8981455f..5d6367b3c 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -236,8 +236,6 @@ async fn test_sync_committee_update_proof() { assert!(is_merkle_branch_valid); } -// todo: cloning the beacon state might expensive in production or testnet, if we can modify -// generate_proof function take a reference for the object that would be better. #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] From cea56dd2021b42c7a03c407b1930d68ef44dc5ab Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 7 Mar 2023 23:38:05 +0100 Subject: [PATCH 071/100] readme --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5e3496e7a..356b1cb22 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,52 @@ -# Ethereum beacon light client verifier -Implementation of the Ethereum beacon light client verifier in Rust +#

Sync-committee-rs ⚙️

+ +

+ Ethereum Beacon Chain Light Client SDK in Rust +
+ ⚠️ Beta Software ⚠️ +

+ +
+ +The sync-committee-rs is the implementation of the Ethereum beacon light client verifier in Rust. This follows the specifications +initially defined by Seun Lanlege [here](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) + + +This library consists of +- ✅ The primitives. +- ✅ The prover. +- ✅ The verifier + + +## The primitives +Consists of the types and structs as defined and described in the spec mentioned earlier. It also consists of the utility functions +to be used in the verifier and prover. + +## The prover +Consists of the various proof generations for the ethereum beacon chain structs/types such as: + +- Execution payload +- Finalized header +- Block roots +- Sync committee update + +The prover also defines the function for fetching various ethereum types from the beacon chain node which can be used to generate proofs. + + +## The verifier +This consist of the major function for verifying sync committee attestation. It also defines the different error that can occur while verifying. + + +# Major Depedencies +The major dependencies for this SDK/Library are: + +- [ssz-rs](https://github.com/ralexstokes/ssz-rs) +- [ethereum-consensus](https://github.com/ralexstokes/ethereum-consensus) + # Running the prover tests **NOTE** 1. To run these tests make sure the latest fork version on your devnet is the BELLATRIX_FORK_VERSION as defined in the mainnet config 2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing feature flag to match the one that is present in the devnet you are running the tests with -3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. \ No newline at end of file +3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. From a18ca5ab8faa310f4ab8fc94c23d0a38125bd637 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 11 Mar 2023 15:56:28 +0100 Subject: [PATCH 072/100] explain prover functions --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 356b1cb22..b99535924 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,16 @@ Consists of the various proof generations for the ethereum beacon chain structs/ - Block roots - Sync committee update -The prover also defines the function for fetching various ethereum types from the beacon chain node which can be used to generate proofs. - +The prover also defines the function for fetching various ethereum types from the beacon chain node using the `SyncCommitteeProver` which can be used to generate proofs. +The various function it defines are: + +- fetch_finalized_checkpoint: Fetches the finalized checkpoint for the `head` via this endpoint `eth/v1/beacon/states/{state_id}/finality_checkpoints` +- fetch_header: Fetches the header via the endpoint `/eth/v1/beacon/headers/{block_id}` +- fetch_block: Fetches the Beacon block via the endpoint `/eth/v2/beacon/blocks/{block_id}` +- fetch_sync_committee: Fetches the sync_committee via the endpoint `/eth/v1/beacon/states/{state_id}/sync_committees` +- fetch_validator: Fetches the node validator for a particular state via the endpoint `/eth/v1/beacon/states/{state_id}/validators/{validator_index}` +- fetch_beacon_state: Fetches the Beacon state via the endpoint `/eth/v2/debug/beacon/states/{state_id}` +- fetch_processed_sync_committee: Constructs the actual `SyncCommittee` after aggregating the validator `public_keys` ## The verifier This consist of the major function for verifying sync committee attestation. It also defines the different error that can occur while verifying. From 3aedb6d3d3f92d9607737797a0726b6e14261552 Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 11 Mar 2023 16:22:12 +0100 Subject: [PATCH 073/100] explain verifier function --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index b99535924..c5858fed5 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,23 @@ The various function it defines are: ## The verifier This consist of the major function for verifying sync committee attestation. It also defines the different error that can occur while verifying. +This contains the `verify_sync_committee_attestation` function. The purpose of this function is to verify that a sync committee attestation, represented by the update argument, +is valid with respect to the current trusted state, represented by the trusted_state argument. +If the attestation is valid, the function returns the updated trusted state; otherwise, it returns an error. + +Detailed explanation of the `verify_sync_committee_attestation` goes as follows: + +- It checks whether the update contains the correct number of finality and sync committee branches. If not, it returns an error. +- It verifies whether the number of participants in the sync committee aggregate signature is greater than or equal to two-thirds of the total number of participants. If not, it returns an error. +- It verifies whether the update skips a sync committee period or not. If it does, it returns an error. +- It checks whether the update is relevant by checking whether it attests to a later slot than the trusted_state or contains the next sync committee. If not, it returns an error. +- It verifies the sync committee aggregate signature by checking that it is valid for the given sync committee participants and domain. If not, it returns an error. +- It verifies the finality_branch of the update by checking whether it confirms the finalized_header that matches the finalized checkpoint root saved in the trusted_state. If not, it returns an error. +- It verifies the ancestry proofs of a sync committee attestation update. It iterates over the ancestor blocks in the update and for each block, checks if its ancestry proof is either a BlockRoots proof or a HistoricalRoots proof. It then calculates the merkle roots and checks if the merkle branches are valid using the is_valid_merkle_branch function. +If any of the merkle branches are invalid, the function returns an error. +- It verifies the associated execution header of the finalized beacon header. +- If all the above checks pass, the function returns a new LightClientState object with the updated trusted_state. + # Major Depedencies The major dependencies for this SDK/Library are: From 49d9d32a784fc003c4078db8b8d15b472feac63b Mon Sep 17 00:00:00 2001 From: Damilare Date: Sat, 11 Mar 2023 16:41:35 +0100 Subject: [PATCH 074/100] include the primitive types --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index c5858fed5..a179ad62e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,17 @@ This library consists of Consists of the types and structs as defined and described in the spec mentioned earlier. It also consists of the utility functions to be used in the verifier and prover. +The verious type primitives defined are: + +- [`ExecutionPayloadProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L26) +- [`BlockRootsProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L40) +- [`AncestryProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L51) +- [`AncestorBlock`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L80) +- [`SyncCommitteeUpdate`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L92) +- [`LightClientState`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L101) +- [`FinalityProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L113) +- [`LightClientUpdate`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L122) + ## The prover Consists of the various proof generations for the ethereum beacon chain structs/types such as: From a46ca34a34a303dbb709efb3f5a26a9b8ea2581f Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 13 Mar 2023 10:39:59 +0100 Subject: [PATCH 075/100] fix readme --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a179ad62e..c845ddf24 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@
The sync-committee-rs is the implementation of the Ethereum beacon light client verifier in Rust. This follows the specifications -initially defined by Seun Lanlege [here](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) +initially defined [here](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) This library consists of @@ -67,10 +67,9 @@ Detailed explanation of the `verify_sync_committee_attestation` goes as follows: - It checks whether the update is relevant by checking whether it attests to a later slot than the trusted_state or contains the next sync committee. If not, it returns an error. - It verifies the sync committee aggregate signature by checking that it is valid for the given sync committee participants and domain. If not, it returns an error. - It verifies the finality_branch of the update by checking whether it confirms the finalized_header that matches the finalized checkpoint root saved in the trusted_state. If not, it returns an error. -- It verifies the ancestry proofs of a sync committee attestation update. It iterates over the ancestor blocks in the update and for each block, checks if its ancestry proof is either a BlockRoots proof or a HistoricalRoots proof. It then calculates the merkle roots and checks if the merkle branches are valid using the is_valid_merkle_branch function. -If any of the merkle branches are invalid, the function returns an error. -- It verifies the associated execution header of the finalized beacon header. -- If all the above checks pass, the function returns a new LightClientState object with the updated trusted_state. +- It optionally verifies ancestry proofs if they are present. +- It verifies the associated execution payload of the finalized beacon header. +- If all the checks pass, the function returns a new LightClientState. # Major Depedencies @@ -86,3 +85,7 @@ The major dependencies for this SDK/Library are: 2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing feature flag to match the one that is present in the devnet you are running the tests with 3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. + + +## License +This library is licensed under the [Apache 2.0 License](./LICENSE), Copyright (c) 2023 Polytope Labs. From c32e09a931f010282d59676fe6ee56e5b3e77677 Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 13 Mar 2023 11:50:52 +0100 Subject: [PATCH 076/100] generalized index generation test --- README.md | 2 +- prover/src/test.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e3496e7a..ded874467 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ Implementation of the Ethereum beacon light client verifier in Rust 1. To run these tests make sure the latest fork version on your devnet is the BELLATRIX_FORK_VERSION as defined in the mainnet config 2. Modify `sync_committee_primitives::types::GENESIS_ROOT_VALIDATORS` defined under the testing feature flag to match the one that is present in the devnet you are running the tests with -3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. \ No newline at end of file +3. Make sure the SLOTS_PER_EPOCH is set to 32 in your devnet. diff --git a/prover/src/test.rs b/prover/src/test.rs index 5d6367b3c..4c0e23e2f 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -9,7 +9,7 @@ use ethereum_consensus::{ altair::Checkpoint, bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, state_transition::Context, }; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; +use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized, get_generalized_index, SszVariableOrIndex}; use std::time::Duration; use sync_committee_primitives::{ types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, @@ -133,6 +133,23 @@ async fn test_finalized_header() { assert_eq!(root, state.hash_tree_root().unwrap()); } +#[cfg(test)] +#[allow(non_snake_case)] +#[actix_rt::test] +async fn test_execution_payload_header_timestamp() { + let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let mut state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); + + let generalized_index = get_generalized_index(&state.latest_execution_payload_header.timestamp, &[SszVariableOrIndex::Name("finalized_checkpoint")]); + dbg!(generalized_index); + let proof = ssz_rs::generate_proof(state.latest_execution_payload_header.timestamp.clone(), &vec![generalized_index]); + + + //let leaves = vec![Node::from_bytes(state.finalized_checkpoint.hash_tree_root().unwrap().as_ref().try_into().unwrap())]; + //let root = calculate_multi_merkle_root(&leaves, &proof.unwrap(), &[GeneralizedIndex(generalized_index)]); + //assert_eq!(root, state.hash_tree_root().unwrap()); +} + #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] From a47a3c7caf02e709c5cda38e451f392e140d73f0 Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 13 Mar 2023 11:53:18 +0100 Subject: [PATCH 077/100] remove unwanted explanations --- README.md | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/README.md b/README.md index c845ddf24..8251adc6a 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,7 @@ This library consists of ## The primitives Consists of the types and structs as defined and described in the spec mentioned earlier. It also consists of the utility functions -to be used in the verifier and prover. - -The verious type primitives defined are: - -- [`ExecutionPayloadProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L26) -- [`BlockRootsProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L40) -- [`AncestryProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L51) -- [`AncestorBlock`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L80) -- [`SyncCommitteeUpdate`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L92) -- [`LightClientState`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L101) -- [`FinalityProof`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L113) -- [`LightClientUpdate`](https://github.com/polytope-labs/sync-committee-rs/blob/main/primitives/src/types.rs#L122) +to be used in the verifier and prover, which also defined in the [spec](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) ## The prover Consists of the various proof generations for the ethereum beacon chain structs/types such as: @@ -41,17 +30,6 @@ Consists of the various proof generations for the ethereum beacon chain structs/ - Block roots - Sync committee update -The prover also defines the function for fetching various ethereum types from the beacon chain node using the `SyncCommitteeProver` which can be used to generate proofs. -The various function it defines are: - -- fetch_finalized_checkpoint: Fetches the finalized checkpoint for the `head` via this endpoint `eth/v1/beacon/states/{state_id}/finality_checkpoints` -- fetch_header: Fetches the header via the endpoint `/eth/v1/beacon/headers/{block_id}` -- fetch_block: Fetches the Beacon block via the endpoint `/eth/v2/beacon/blocks/{block_id}` -- fetch_sync_committee: Fetches the sync_committee via the endpoint `/eth/v1/beacon/states/{state_id}/sync_committees` -- fetch_validator: Fetches the node validator for a particular state via the endpoint `/eth/v1/beacon/states/{state_id}/validators/{validator_index}` -- fetch_beacon_state: Fetches the Beacon state via the endpoint `/eth/v2/debug/beacon/states/{state_id}` -- fetch_processed_sync_committee: Constructs the actual `SyncCommittee` after aggregating the validator `public_keys` - ## The verifier This consist of the major function for verifying sync committee attestation. It also defines the different error that can occur while verifying. From bf0ad437cab3078adb98e0bb8c08c4ddbcd3703b Mon Sep 17 00:00:00 2001 From: Damilare Date: Mon, 13 Mar 2023 12:38:07 +0100 Subject: [PATCH 078/100] add apache license --- LICENSE | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..e83dc12de --- /dev/null +++ b/LICENSE @@ -0,0 +1,51 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of this License; and +You must cause any modified files to carry prominent notices stating that You changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS From e334c3f77b9553dba4908d8bf71f697247be3c47 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Mon, 13 Mar 2023 15:51:48 +0100 Subject: [PATCH 079/100] updates --- README.md | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8251adc6a..6a8c328a5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#

Sync-committee-rs ⚙️

+#

sync-committee-rs ⚙️

Ethereum Beacon Chain Light Client SDK in Rust @@ -8,8 +8,7 @@
-The sync-committee-rs is the implementation of the Ethereum beacon light client verifier in Rust. This follows the specifications -initially defined [here](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) +The sync-committee-rs is the implementation of the Ethereum beacon light client verifier in Rust. This is based on the research done here: https://research.polytope.technology/ethereum-light-client This library consists of @@ -20,7 +19,7 @@ This library consists of ## The primitives Consists of the types and structs as defined and described in the spec mentioned earlier. It also consists of the utility functions -to be used in the verifier and prover, which also defined in the [spec](https://polytopelabs.notion.site/ICS-15-ethereum-beacon-chain-light-client-specification-for-IBC-9c28567b02424585b4deceeb21b9beaf) +to be used in the verifier and prover. ## The prover Consists of the various proof generations for the ethereum beacon chain structs/types such as: @@ -31,23 +30,7 @@ Consists of the various proof generations for the ethereum beacon chain structs/ - Sync committee update ## The verifier -This consist of the major function for verifying sync committee attestation. It also defines the different error that can occur while verifying. - -This contains the `verify_sync_committee_attestation` function. The purpose of this function is to verify that a sync committee attestation, represented by the update argument, -is valid with respect to the current trusted state, represented by the trusted_state argument. -If the attestation is valid, the function returns the updated trusted state; otherwise, it returns an error. - -Detailed explanation of the `verify_sync_committee_attestation` goes as follows: - -- It checks whether the update contains the correct number of finality and sync committee branches. If not, it returns an error. -- It verifies whether the number of participants in the sync committee aggregate signature is greater than or equal to two-thirds of the total number of participants. If not, it returns an error. -- It verifies whether the update skips a sync committee period or not. If it does, it returns an error. -- It checks whether the update is relevant by checking whether it attests to a later slot than the trusted_state or contains the next sync committee. If not, it returns an error. -- It verifies the sync committee aggregate signature by checking that it is valid for the given sync committee participants and domain. If not, it returns an error. -- It verifies the finality_branch of the update by checking whether it confirms the finalized_header that matches the finalized checkpoint root saved in the trusted_state. If not, it returns an error. -- It optionally verifies ancestry proofs if they are present. -- It verifies the associated execution payload of the finalized beacon header. -- If all the checks pass, the function returns a new LightClientState. +This exports a single function for verifying ethereum's sync committee attestation. # Major Depedencies From fe3968dc671e7b57c0788d08ce94ca6c6941c145 Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Mon, 13 Mar 2023 15:53:02 +0100 Subject: [PATCH 080/100] updates --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6a8c328a5..91c984208 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@
-The sync-committee-rs is the implementation of the Ethereum beacon light client verifier in Rust. This is based on the research done here: https://research.polytope.technology/ethereum-light-client +The sync-committee-rs is the implementation of the Ethereum beacon light client prover & verifier in Rust. This is based on the research done here: https://research.polytope.technology/ethereum-light-client This library consists of @@ -17,11 +17,11 @@ This library consists of - ✅ The verifier -## The primitives +## primitives Consists of the types and structs as defined and described in the spec mentioned earlier. It also consists of the utility functions to be used in the verifier and prover. -## The prover +## prover Consists of the various proof generations for the ethereum beacon chain structs/types such as: - Execution payload @@ -29,7 +29,7 @@ Consists of the various proof generations for the ethereum beacon chain structs/ - Block roots - Sync committee update -## The verifier +## verifier This exports a single function for verifying ethereum's sync committee attestation. From fb47fb50b2504701f7b7ced5b05f8e5f29dcd412 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 14 Mar 2023 00:31:26 +0100 Subject: [PATCH 081/100] include execution payload timestamp in execution payload proof --- Cargo.lock | 2113 --------------------------------------- Cargo.toml | 6 - primitives/Cargo.toml | 6 +- primitives/src/types.rs | 3 + prover/Cargo.toml | 4 +- prover/src/lib.rs | 18 +- prover/src/test.rs | 48 +- verifier/Cargo.toml | 6 +- verifier/src/lib.rs | 6 +- 9 files changed, 64 insertions(+), 2146 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 0d9d87dcb..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,2113 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "actix-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" -dependencies = [ - "actix-macros", - "futures-core", - "tokio", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "amcl" -version = "0.3.0" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" - -[[package]] -name = "anyhow" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "as-any" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" - -[[package]] -name = "async-stream" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base2" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" -dependencies = [ - "int 0.2.11", -] - -[[package]] -name = "base2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" -dependencies = [ - "int 0.3.0", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "bumpalo" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const-oid" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "core2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" -dependencies = [ - "memchr", -] - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "data-encoding" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer 0.10.3", - "crypto-common", - "subtle", -] - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", -] - -[[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct", - "crypto-bigint", - "der", - "digest 0.10.6", - "ff", - "generic-array", - "group", - "pkcs8", - "rand_core", - "sec1", - "subtle", - "zeroize", -] - -[[package]] -name = "encoding_rs" -version = "0.8.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "enr" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" -dependencies = [ - "base64 0.13.1", - "bs58", - "bytes", - "hex", - "k256", - "log", - "rand", - "rlp", - "serde", - "sha3", - "zeroize", -] - -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "version_check", -] - -[[package]] -name = "ethereum-consensus" -version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=dami/no-std-support#bd19d7c3e7a44810a7f57b5fd00ea55a816222f1" -dependencies = [ - "async-stream", - "bs58", - "enr", - "error-chain", - "getrandom", - "hashbrown 0.13.2", - "hex", - "integer-sqrt", - "milagro_bls", - "multiaddr", - "multihash", - "rand", - "serde", - "serde_json", - "serde_yaml", - "sha2 0.9.9", - "ssz-rs", - "tokio", - "tokio-stream", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures-channel" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" - -[[package]] -name = "futures-sink" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" - -[[package]] -name = "futures-task" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" - -[[package]] -name = "futures-util" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" -dependencies = [ - "futures-core", - "futures-task", - "pin-project-lite", - "pin-utils", -] - -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff", - "rand_core", - "subtle", -] - -[[package]] -name = "h2" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.6", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "0.14.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "idna" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "int" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" -dependencies = [ - "num-traits", -] - -[[package]] -name = "int" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" -dependencies = [ - "num-traits", -] - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" -dependencies = [ - "libc", - "windows-sys 0.45.0", -] - -[[package]] -name = "ipnet" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" - -[[package]] -name = "is-terminal" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" -dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix", - "windows-sys 0.45.0", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" - -[[package]] -name = "js-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "keccak" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "milagro_bls" -version = "1.5.1" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" -dependencies = [ - "amcl", - "hex", - "lazy_static", - "rand", - "zeroize", -] - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mio" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.45.0", -] - -[[package]] -name = "multiaddr" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" -dependencies = [ - "arrayref", - "bs58", - "byteorder", - "data-encoding", - "multihash", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", -] - -[[package]] -name = "multihash" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" -dependencies = [ - "core2", - "digest 0.10.6", - "multihash-derive", - "sha2 0.10.6", - "unsigned-varint", -] - -[[package]] -name = "multihash-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn", - "synstructure", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys 0.45.0", -] - -[[package]] -name = "percent-encoding" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" - -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der", - "spki", -] - -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro2" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags", -] - -[[package]] -name = "regex" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" - -[[package]] -name = "reqwest" -version = "0.11.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" -dependencies = [ - "base64 0.21.0", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", -] - -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rustc-hex", -] - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustix" -version = "0.36.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.45.0", -] - -[[package]] -name = "ryu" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" - -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys 0.42.0", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "security-framework" -version = "2.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.6", -] - -[[package]] -name = "sha3" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" -dependencies = [ - "digest 0.10.6", - "keccak", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.6", - "rand_core", -] - -[[package]] -name = "slab" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der", -] - -[[package]] -name = "ssz-rs" -version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f25813944f80ba7c572a00900c6de316eb8a50c8" -dependencies = [ - "as-any", - "bitvec", - "hex", - "itertools", - "num-bigint", - "serde", - "sha2 0.9.9", - "ssz-rs-derive", - "thiserror", -] - -[[package]] -name = "ssz-rs-derive" -version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=seun/ssz-merkle-multi-proof-phase-1#f25813944f80ba7c572a00900c6de316eb8a50c8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync-committee-primitives" -version = "0.1.0" -dependencies = [ - "base2 0.3.1", - "ethereum-consensus", - "hex-literal", - "ssz-rs", -] - -[[package]] -name = "sync-committee-prover" -version = "0.1.0" -dependencies = [ - "actix-rt", - "anyhow", - "async-stream", - "base2 0.2.2", - "env_logger", - "ethereum-consensus", - "hex", - "reqwest", - "serde", - "serde_json", - "ssz-rs", - "sync-committee-primitives", - "sync-committee-verifier", - "tokio", - "tokio-stream", -] - -[[package]] -name = "sync-committee-verifier" -version = "0.1.0" -dependencies = [ - "base2 0.2.2", - "ethereum-consensus", - "log", - "milagro_bls", - "ssz-rs", - "sync-committee-primitives", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "unicode-xid", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempfile" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys 0.42.0", -] - -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "thiserror" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" -dependencies = [ - "autocfg", - "bytes", - "libc", - "memchr", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.45.0", -] - -[[package]] -name = "tokio-macros" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - -[[package]] -name = "unicode-bidi" -version = "0.3.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" - -[[package]] -name = "unicode-ident" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "unsigned-varint" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" - -[[package]] -name = "url" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "web-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "zeroize" -version = "1.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/Cargo.toml b/Cargo.toml index 29417d48b..37dfd2d6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,9 +5,3 @@ members = [ "primitives", "prover" ] - -[patch."https://github.com/ralexstokes/ethereum-consensus"] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "dami/no-std-support" } - -[patch."https://github.com/ralexstokes/ssz-rs"] -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "seun/ssz-merkle-multi-proof-phase-1" } diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index e9242033c..8a3e39be1 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version = "0.3.1", default-features = false} -ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2", default-features = false } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } [features] @@ -16,4 +16,4 @@ default = ["std"] std = [ "ssz-rs/std" ] -testing = [] \ No newline at end of file +testing = [] diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 3038dacdd..643a9de52 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -14,6 +14,7 @@ pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; +pub const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 25; #[cfg(not(feature = "testing"))] pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); @@ -33,6 +34,8 @@ pub struct ExecutionPayloadProof { pub multi_proof: Vec, /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. pub execution_payload_branch: Vec, + /// timestamp + pub timestamp: u64, } /// Holds the neccessary proofs required to verify a header in the `block_roots` field diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 133a46c67..24de19cdd 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } -ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2" } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", features=["serde"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 5b3b75cd3..0adc7ddcf 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -38,7 +38,8 @@ use sync_committee_primitives::{ types::{ AncestryProof, BlockRootsProof, ExecutionPayloadProof, BLOCK_ROOTS_INDEX, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, + FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, util::compute_epoch_at_slot, }; @@ -221,22 +222,24 @@ pub fn prove_execution_payload( let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize, + EXECUTION_PAYLOAD_TIMESTAMP_INDEX as usize, ]; // generate multi proofs let multi_proof = ssz_rs::generate_proof( - &mut beacon_state.latest_execution_payload_header, + beacon_state.latest_execution_payload_header.clone(), indices.as_slice(), )?; Ok(ExecutionPayloadProof { state_root: beacon_state.latest_execution_payload_header.state_root.clone(), block_number: beacon_state.latest_execution_payload_header.block_number, + timestamp: beacon_state.latest_execution_payload_header.timestamp, multi_proof: multi_proof .into_iter() .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect(), execution_payload_branch: ssz_rs::generate_proof( - &mut beacon_state, + beacon_state.clone(), &[EXECUTION_PAYLOAD_INDEX as usize], )? .into_iter() @@ -246,13 +249,13 @@ pub fn prove_execution_payload( } pub fn prove_sync_committee_update(mut state: BeaconStateType) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(&mut state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; + let proof = ssz_rs::generate_proof(state.clone(), &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } pub fn prove_finalized_header(mut state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; - let proof = ssz_rs::generate_proof(&mut state, indices.as_slice())?; + let proof = ssz_rs::generate_proof(state, indices.as_slice())?; Ok(proof .into_iter() @@ -283,7 +286,7 @@ pub fn prove_block_roots_proof( .position(|root| root == &block_root) .expect("Block root should exist in block_roots"); - let proof = ssz_rs::generate_proof(&mut state.block_roots, &[block_index])?; + let proof = ssz_rs::generate_proof(state.block_roots.clone(), &[block_index])?; let block_roots_proof = BlockRootsProof { block_header_index: block_index as u64, @@ -295,7 +298,8 @@ pub fn prove_block_roots_proof( .collect(), }; - let block_roots_branch = ssz_rs::generate_proof(&mut state, &[BLOCK_ROOTS_INDEX as usize])?; + let block_roots_branch = + ssz_rs::generate_proof(state.clone(), &[BLOCK_ROOTS_INDEX as usize])?; Ok(AncestryProof::BlockRoots { block_roots_proof, block_roots_branch: block_roots_branch diff --git a/prover/src/test.rs b/prover/src/test.rs index 4c0e23e2f..18b0db3a0 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -9,7 +9,10 @@ use ethereum_consensus::{ altair::Checkpoint, bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, state_transition::Context, }; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized, get_generalized_index, SszVariableOrIndex}; +use ssz_rs::{ + calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, + Merkleized, SszVariableOrIndex, +}; use std::time::Duration; use sync_committee_primitives::{ types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, @@ -19,7 +22,7 @@ use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; -const NODE_URL: &'static str = "http://localhost:5052"; +const NODE_URL: &'static str = "http://localhost:3500"; #[cfg(test)] #[allow(non_snake_case)] @@ -114,7 +117,7 @@ async fn test_finalized_header() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let proof = ssz_rs::generate_proof(&mut state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); + let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); let leaves = vec![Node::from_bytes( state @@ -140,14 +143,32 @@ async fn test_execution_payload_header_timestamp() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); - let generalized_index = get_generalized_index(&state.latest_execution_payload_header.timestamp, &[SszVariableOrIndex::Name("finalized_checkpoint")]); + let generalized_index = get_generalized_index( + &state.latest_execution_payload_header, + &[SszVariableOrIndex::Name("timestamp")], + ); dbg!(generalized_index); - let proof = ssz_rs::generate_proof(state.latest_execution_payload_header.timestamp.clone(), &vec![generalized_index]); - + let proof = ssz_rs::generate_proof( + state.latest_execution_payload_header.clone(), + &vec![generalized_index], + ); - //let leaves = vec![Node::from_bytes(state.finalized_checkpoint.hash_tree_root().unwrap().as_ref().try_into().unwrap())]; - //let root = calculate_multi_merkle_root(&leaves, &proof.unwrap(), &[GeneralizedIndex(generalized_index)]); - //assert_eq!(root, state.hash_tree_root().unwrap()); + let leaves = vec![Node::from_bytes( + state + .latest_execution_payload_header + .timestamp + .hash_tree_root() + .unwrap() + .as_ref() + .try_into() + .unwrap(), + )]; + let root = calculate_multi_merkle_root( + &leaves, + &proof.unwrap(), + &[GeneralizedIndex(generalized_index)], + ); + assert_eq!(root, state.latest_execution_payload_header.hash_tree_root().unwrap()); } #[cfg(test)] @@ -160,8 +181,13 @@ async fn test_execution_payload_proof() { let block_id = finalized_state.slot.to_string(); let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + let mut finalized_header = sync_committee_prover.fetch_header(&block_id).await; + + while finalized_header.is_err() { + finalized_header = sync_committee_prover.fetch_header(&block_id).await; + } + let finalized_header = finalized_header.unwrap(); // verify the associated execution header of the finalized beacon header. let mut execution_payload = execution_payload_proof.clone(); let multi_proof_vec = execution_payload.multi_proof; @@ -173,11 +199,13 @@ async fn test_execution_payload_proof() { &[ Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), execution_payload.block_number.hash_tree_root().unwrap(), + execution_payload.timestamp.hash_tree_root().unwrap(), ], &multi_proof_nodes, &[ GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_TIMESTAMP_INDEX as usize), ], ); diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 3e65a2b1a..df6374fbb 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "ef89b4a4ef97cdd53a66ddb52e554667aca0beb2", default-features = false } -ssz-rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "688a82389f60ed68c10404417c1f7f442ba748a1", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = { version = "0.4.17", default-features = false } @@ -19,4 +19,4 @@ std = [ "milagro_bls/std", "log/std" ] -testing = ["sync-committee-primitives/testing"] \ No newline at end of file +testing = ["sync-committee-primitives/testing"] diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index ac6a6df14..22e7291b0 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -23,8 +23,9 @@ use sync_committee_primitives::{ types::{ AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, FINALIZED_ROOT_INDEX, GENESIS_VALIDATORS_ROOT, - HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, NEXT_SYNC_COMMITTEE_INDEX, + EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, + FINALIZED_ROOT_INDEX, GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, + HISTORICAL_ROOTS_INDEX, NEXT_SYNC_COMMITTEE_INDEX, }, util::{compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot}, }; @@ -170,6 +171,7 @@ pub fn verify_sync_committee_attestation( &[ GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_TIMESTAMP_INDEX as usize), ], ); From 1cd8a43ea9b6c12aac956ad0acd6e59f0fc77b5b Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 14 Mar 2023 00:50:50 +0100 Subject: [PATCH 082/100] revert node url --- prover/src/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index 18b0db3a0..97eb247a4 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -22,7 +22,7 @@ use sync_committee_verifier::verify_sync_committee_attestation; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; -const NODE_URL: &'static str = "http://localhost:3500"; +const NODE_URL: &'static str = "http://localhost:5052"; #[cfg(test)] #[allow(non_snake_case)] From ea73f3880f3cf4e1be5891e01ca2c70981235ee2 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 14 Mar 2023 10:12:09 +0100 Subject: [PATCH 083/100] use latest commit revision --- primitives/Cargo.toml | 4 ++-- prover/Cargo.toml | 4 ++-- prover/src/lib.rs | 13 ++++++------- prover/src/test.rs | 11 +++-------- verifier/Cargo.toml | 4 ++-- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 8a3e39be1..fe2536ece 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version = "0.3.1", default-features = false} -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false, features=["serde"] } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } [features] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 24de19cdd..e1e8a0354 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", features=["serde"] } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 0adc7ddcf..b1ec1c001 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -226,7 +226,7 @@ pub fn prove_execution_payload( ]; // generate multi proofs let multi_proof = ssz_rs::generate_proof( - beacon_state.latest_execution_payload_header.clone(), + &mut beacon_state.latest_execution_payload_header, indices.as_slice(), )?; @@ -239,7 +239,7 @@ pub fn prove_execution_payload( .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect(), execution_payload_branch: ssz_rs::generate_proof( - beacon_state.clone(), + &mut beacon_state, &[EXECUTION_PAYLOAD_INDEX as usize], )? .into_iter() @@ -249,13 +249,13 @@ pub fn prove_execution_payload( } pub fn prove_sync_committee_update(mut state: BeaconStateType) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(state.clone(), &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; + let proof = ssz_rs::generate_proof(&mut state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } pub fn prove_finalized_header(mut state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; - let proof = ssz_rs::generate_proof(state, indices.as_slice())?; + let proof = ssz_rs::generate_proof(&mut state, indices.as_slice())?; Ok(proof .into_iter() @@ -286,7 +286,7 @@ pub fn prove_block_roots_proof( .position(|root| root == &block_root) .expect("Block root should exist in block_roots"); - let proof = ssz_rs::generate_proof(state.block_roots.clone(), &[block_index])?; + let proof = ssz_rs::generate_proof(&mut state.block_roots, &[block_index])?; let block_roots_proof = BlockRootsProof { block_header_index: block_index as u64, @@ -298,8 +298,7 @@ pub fn prove_block_roots_proof( .collect(), }; - let block_roots_branch = - ssz_rs::generate_proof(state.clone(), &[BLOCK_ROOTS_INDEX as usize])?; + let block_roots_branch = ssz_rs::generate_proof(&mut state, &[BLOCK_ROOTS_INDEX as usize])?; Ok(AncestryProof::BlockRoots { block_roots_proof, block_roots_branch: block_roots_branch diff --git a/prover/src/test.rs b/prover/src/test.rs index 97eb247a4..fa6e9ba7a 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -117,7 +117,7 @@ async fn test_finalized_header() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); + let proof = ssz_rs::generate_proof(&mut state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); let leaves = vec![Node::from_bytes( state @@ -149,7 +149,7 @@ async fn test_execution_payload_header_timestamp() { ); dbg!(generalized_index); let proof = ssz_rs::generate_proof( - state.latest_execution_payload_header.clone(), + &mut state.latest_execution_payload_header, &vec![generalized_index], ); @@ -181,13 +181,8 @@ async fn test_execution_payload_proof() { let block_id = finalized_state.slot.to_string(); let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let mut finalized_header = sync_committee_prover.fetch_header(&block_id).await; + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - while finalized_header.is_err() { - finalized_header = sync_committee_prover.fetch_header(&block_id).await; - } - - let finalized_header = finalized_header.unwrap(); // verify the associated execution header of the finalized beacon header. let mut execution_payload = execution_payload_proof.clone(); let multi_proof_vec = execution_payload.multi_proof; diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index df6374fbb..b09fc500c 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false, features=["serde"] } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = { version = "0.4.17", default-features = false } From ef97947a2d18078f4bff624a39f104fd5ca9c4cd Mon Sep 17 00:00:00 2001 From: David Salami Date: Tue, 14 Mar 2023 10:16:57 +0100 Subject: [PATCH 084/100] some fixes --- Cargo.lock | 2113 +++++++++++++++++++++++++++++++++++++++++ primitives/Cargo.toml | 4 +- prover/Cargo.toml | 4 +- prover/src/lib.rs | 13 +- prover/src/test.rs | 39 +- verifier/Cargo.toml | 4 +- 6 files changed, 2127 insertions(+), 50 deletions(-) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..3fee84a14 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2113 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "anyhow" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + +[[package]] +name = "async-stream" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int 0.2.11", +] + +[[package]] +name = "base2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" +dependencies = [ + "int 0.3.0", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64 0.13.1", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?rev=d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f#d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown 0.13.2", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "serde_yaml", + "sha2 0.9.9", + "ssz-rs", + "tokio", + "tokio-stream", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" + +[[package]] +name = "futures-sink" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" + +[[package]] +name = "futures-task" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" + +[[package]] +name = "futures-util" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "int" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "is-terminal" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "hex", + "lazy_static", + "rand", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.45.0", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "reqwest" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap", + "ryu", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +dependencies = [ + "as-any", + "bitvec", + "hex", + "itertools", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-committee-primitives" +version = "0.1.0" +dependencies = [ + "base2 0.3.1", + "ethereum-consensus", + "hex-literal", + "ssz-rs", +] + +[[package]] +name = "sync-committee-prover" +version = "0.1.0" +dependencies = [ + "actix-rt", + "anyhow", + "async-stream", + "base2 0.2.2", + "env_logger", + "ethereum-consensus", + "hex", + "reqwest", + "serde", + "serde_json", + "ssz-rs", + "sync-committee-primitives", + "sync-committee-verifier", + "tokio", + "tokio-stream", +] + +[[package]] +name = "sync-committee-verifier" +version = "0.1.0" +dependencies = [ + "base2 0.2.2", + "ethereum-consensus", + "log", + "milagro_bls", + "ssz-rs", + "sync-committee-primitives", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.42.0", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 8a3e39be1..a6db5811b 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version = "0.3.1", default-features = false} -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } [features] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 24de19cdd..d6546c55d 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7" } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 0adc7ddcf..b1ec1c001 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -226,7 +226,7 @@ pub fn prove_execution_payload( ]; // generate multi proofs let multi_proof = ssz_rs::generate_proof( - beacon_state.latest_execution_payload_header.clone(), + &mut beacon_state.latest_execution_payload_header, indices.as_slice(), )?; @@ -239,7 +239,7 @@ pub fn prove_execution_payload( .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) .collect(), execution_payload_branch: ssz_rs::generate_proof( - beacon_state.clone(), + &mut beacon_state, &[EXECUTION_PAYLOAD_INDEX as usize], )? .into_iter() @@ -249,13 +249,13 @@ pub fn prove_execution_payload( } pub fn prove_sync_committee_update(mut state: BeaconStateType) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(state.clone(), &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; + let proof = ssz_rs::generate_proof(&mut state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } pub fn prove_finalized_header(mut state: BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; - let proof = ssz_rs::generate_proof(state, indices.as_slice())?; + let proof = ssz_rs::generate_proof(&mut state, indices.as_slice())?; Ok(proof .into_iter() @@ -286,7 +286,7 @@ pub fn prove_block_roots_proof( .position(|root| root == &block_root) .expect("Block root should exist in block_roots"); - let proof = ssz_rs::generate_proof(state.block_roots.clone(), &[block_index])?; + let proof = ssz_rs::generate_proof(&mut state.block_roots, &[block_index])?; let block_roots_proof = BlockRootsProof { block_header_index: block_index as u64, @@ -298,8 +298,7 @@ pub fn prove_block_roots_proof( .collect(), }; - let block_roots_branch = - ssz_rs::generate_proof(state.clone(), &[BLOCK_ROOTS_INDEX as usize])?; + let block_roots_branch = ssz_rs::generate_proof(&mut state, &[BLOCK_ROOTS_INDEX as usize])?; Ok(AncestryProof::BlockRoots { block_roots_proof, block_roots_branch: block_roots_branch diff --git a/prover/src/test.rs b/prover/src/test.rs index 97eb247a4..679d54042 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -117,7 +117,7 @@ async fn test_finalized_header() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let proof = ssz_rs::generate_proof(state.clone(), &vec![FINALIZED_ROOT_INDEX as usize]); + let proof = ssz_rs::generate_proof(&mut state, &vec![FINALIZED_ROOT_INDEX as usize]); let leaves = vec![Node::from_bytes( state @@ -136,41 +136,6 @@ async fn test_finalized_header() { assert_eq!(root, state.hash_tree_root().unwrap()); } -#[cfg(test)] -#[allow(non_snake_case)] -#[actix_rt::test] -async fn test_execution_payload_header_timestamp() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); - let mut state = sync_committee_prover.fetch_beacon_state("finalized").await.unwrap(); - - let generalized_index = get_generalized_index( - &state.latest_execution_payload_header, - &[SszVariableOrIndex::Name("timestamp")], - ); - dbg!(generalized_index); - let proof = ssz_rs::generate_proof( - state.latest_execution_payload_header.clone(), - &vec![generalized_index], - ); - - let leaves = vec![Node::from_bytes( - state - .latest_execution_payload_header - .timestamp - .hash_tree_root() - .unwrap() - .as_ref() - .try_into() - .unwrap(), - )]; - let root = calculate_multi_merkle_root( - &leaves, - &proof.unwrap(), - &[GeneralizedIndex(generalized_index)], - ); - assert_eq!(root, state.latest_execution_payload_header.hash_tree_root().unwrap()); -} - #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] @@ -494,7 +459,7 @@ async fn test_prover() { ); count += 1; - if count == 100 { + if count == 10 { break } } diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index df6374fbb..357c12a77 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Polytope Labs"] [dependencies] base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "c26206f18fcecbd69ca5d505ae4211a7bc756ad0", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "a78a600c7751527b74e038094ead04b697caa4a5", default-features = false, features=["serde"] } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = { version = "0.4.17", default-features = false } From 18c5687e6a2168d0e88e05ff7253b0e0b0d474d5 Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 14 Mar 2023 10:17:16 +0100 Subject: [PATCH 085/100] include cargo lock --- Cargo.lock | 2113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2113 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..3fee84a14 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2113 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "amcl" +version = "0.3.0" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" + +[[package]] +name = "anyhow" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "as-any" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" + +[[package]] +name = "async-stream" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base2" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +dependencies = [ + "int 0.2.11", +] + +[[package]] +name = "base2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" +dependencies = [ + "int 0.3.0", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "digest 0.10.6", + "ff", + "generic-array", + "group", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +dependencies = [ + "base64 0.13.1", + "bs58", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "sha3", + "zeroize", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + +[[package]] +name = "ethereum-consensus" +version = "0.1.1" +source = "git+https://github.com/polytope-labs/ethereum-consensus?rev=d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f#d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" +dependencies = [ + "async-stream", + "bs58", + "enr", + "error-chain", + "getrandom", + "hashbrown 0.13.2", + "hex", + "integer-sqrt", + "milagro_bls", + "multiaddr", + "multihash", + "rand", + "serde", + "serde_json", + "serde_yaml", + "sha2 0.9.9", + "ssz-rs", + "tokio", + "tokio-stream", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-channel" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" + +[[package]] +name = "futures-sink" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" + +[[package]] +name = "futures-task" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" + +[[package]] +name = "futures-util" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "int" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +dependencies = [ + "num-traits", +] + +[[package]] +name = "int" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "ipnet" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" + +[[package]] +name = "is-terminal" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.10.6", +] + +[[package]] +name = "keccak" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "milagro_bls" +version = "1.5.1" +source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +dependencies = [ + "amcl", + "hex", + "lazy_static", + "rand", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.45.0", +] + +[[package]] +name = "multiaddr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" +dependencies = [ + "arrayref", + "bs58", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "core2", + "digest 0.10.6", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "reqwest" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint", + "hmac", + "zeroize", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rustc-hex", +] + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustix" +version = "0.36.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap", + "ryu", + "serde", + "yaml-rust", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + +[[package]] +name = "sha3" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +dependencies = [ + "digest 0.10.6", + "keccak", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.6", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "ssz-rs" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +dependencies = [ + "as-any", + "bitvec", + "hex", + "itertools", + "num-bigint", + "serde", + "sha2 0.9.9", + "ssz-rs-derive", + "thiserror", +] + +[[package]] +name = "ssz-rs-derive" +version = "0.8.0" +source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync-committee-primitives" +version = "0.1.0" +dependencies = [ + "base2 0.3.1", + "ethereum-consensus", + "hex-literal", + "ssz-rs", +] + +[[package]] +name = "sync-committee-prover" +version = "0.1.0" +dependencies = [ + "actix-rt", + "anyhow", + "async-stream", + "base2 0.2.2", + "env_logger", + "ethereum-consensus", + "hex", + "reqwest", + "serde", + "serde_json", + "ssz-rs", + "sync-committee-primitives", + "sync-committee-verifier", + "tokio", + "tokio-stream", +] + +[[package]] +name = "sync-committee-verifier" +version = "0.1.0" +dependencies = [ + "base2 0.2.2", + "ethereum-consensus", + "log", + "milagro_bls", + "ssz-rs", + "sync-committee-primitives", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.42.0", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "unsigned-varint" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "zeroize" +version = "1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" From 06bbd120ef1dee3bd372202c743cca00ed8455a1 Mon Sep 17 00:00:00 2001 From: David Salami Date: Tue, 14 Mar 2023 10:44:47 +0100 Subject: [PATCH 086/100] fix tests --- verifier/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 22e7291b0..fff66eb0a 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -166,6 +166,7 @@ pub fn verify_sync_committee_attestation( .block_number .hash_tree_root() .map_err(|_| Error::InvalidRoot)?, + execution_payload.timestamp.hash_tree_root().map_err(|_| Error::InvalidRoot)?, ], &multi_proof_nodes, &[ @@ -347,11 +348,22 @@ pub fn verify_sync_committee_attestation( .try_into() .map_err(|_| Error::InvalidRoot)?, ), + Node::from_bytes( + execution_payload + .timestamp + .clone() + .hash_tree_root() + .map_err(|_| Error::MerkleizationError)? + .as_ref() + .try_into() + .map_err(|_| Error::InvalidRoot)?, + ), ], &multi_proof, &[ GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), + GeneralizedIndex(EXECUTION_PAYLOAD_TIMESTAMP_INDEX as usize), ], ); From 4a0fb4989fc46cdf0f26aede30301f2cba66b21b Mon Sep 17 00:00:00 2001 From: Damilare Date: Tue, 14 Mar 2023 12:06:04 +0100 Subject: [PATCH 087/100] remove while loop --- prover/src/test.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/prover/src/test.rs b/prover/src/test.rs index 679d54042..f234f468f 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -146,13 +146,8 @@ async fn test_execution_payload_proof() { let block_id = finalized_state.slot.to_string(); let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - let mut finalized_header = sync_committee_prover.fetch_header(&block_id).await; + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - while finalized_header.is_err() { - finalized_header = sync_committee_prover.fetch_header(&block_id).await; - } - - let finalized_header = finalized_header.unwrap(); // verify the associated execution header of the finalized beacon header. let mut execution_payload = execution_payload_proof.clone(); let multi_proof_vec = execution_payload.multi_proof; From a326f56595fe51a8756cc6d7021a89564b8dc61f Mon Sep 17 00:00:00 2001 From: Femi Bankole Date: Thu, 16 Mar 2023 14:40:41 +0100 Subject: [PATCH 088/100] CI for Testing (#16) --- .github/workflows/test.yml | 169 +++++++++++++++++++++++++++ prover/src/error.rs | 5 - prover/src/lib.rs | 1 - prover/src/test.rs | 18 +-- scripts/wait_for_tcp_port_opening.sh | 12 ++ 5 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 prover/src/error.rs create mode 100755 scripts/wait_for_tcp_port_opening.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..1ad55a846 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,169 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@main + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Run cargo check + run: cargo check + + test: + name: Test Suite + runs-on: ubuntu-latest + # defaults: + # run: + # shell: bash + env: + TUID: 123 + steps: + - name: set UID env + run: | + echo $UID + echo "TUID=$UID" >> $GITHUB_ENV + + - name: Checkout sources + uses: actions/checkout@master + + - name: Clone eth-testnet-runner repository + run: | + git clone https://github.com/ralexstokes/eth-testnet-runner.git + cd eth-testnet-runner + git checkout 5f43097a03f8ff37217c843407bf7729617f2dff + + - name: Install rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - name: Install protoc + run: | + sudo apt update + sudo apt install protobuf-compiler + + - name: Fetch geth binary + run: | + cd eth-testnet-runner + mkdir bin + wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.11.3-5ed08c47.tar.gz -O ./geth-linux-amd64-1.11.3-5ed08c47.tar.gz + tar -xvf geth-linux-amd64-1.11.3-5ed08c47.tar.gz + cd geth-linux-amd64-1.11.3-5ed08c47 + cp geth ../bin + + - name: Build lighthouse from source + run: | + cd eth-testnet-runner + git clone https://github.com/sigp/lighthouse.git + cd lighthouse + git checkout 38514c07f222ff7783834c48cf5c0a6ee7f346d0 + cargo build -p lighthouse --release + mv target/release/lighthouse ../bin + + - name: Install go + uses: actions/setup-go@v3 + with: + go-version: "stable" + + - name: check go version + run: go version + + - name: Clone eth2-val-tools repository + run: | + git clone https://github.com/protolambda/eth2-val-tools.git + cd eth2-val-tools + git checkout 4bf01453537ad1a9323c7cd99afc4f8ba2a420b1 + + - name: build eth2-val-tools and move binary to eth-testnet-runner bin folder + run: | + cd eth2-val-tools + go build + cp eth2-val-tools ../eth-testnet-runner/bin + + # Make $UID available to the justfile + - name: set UID env variable as a local justfile variable + run: | + cd eth-testnet-runner + sed -i 's/$UID/{{UID}}/' justfile + sed -i 's/^NOW := `date +%s`/NOW := `date +%s`\nUID := "${{ env.TUID }}"/' justfile + + - name: install just + run: | + cargo install just + + - name: modify testnet config values + run: | + cd eth-testnet-runner/testnet-config + sed -i 's/GENESIS_FORK_VERSION=.*/GENESIS_FORK_VERSION="0x00000000"/' values.env + sed -i 's/ALTAIR_FORK_VERSION=.*/ALTAIR_FORK_VERSION="0x01000000"/' values.env + sed -i 's/BELLATRIX_FORK_VERSION=.*/BELLATRIX_FORK_VERSION="0x02000000"/' values.env + sed -i 's/CAPELLA_FORK_VERSION=.*/CAPELLA_FORK_VERSION="0x03000000"/' values.env + sed -i 's/EIP4844_FORK_VERSION=.*/EIP4844_FORK_VERSION="0x04000000"/' values.env + + - name: remove tty flag from docker command in create-config recipe + run: | + cd eth-testnet-runner + sed -i 's/-it/-i/' justfile + + - name: run create-config + run: | + cd eth-testnet-runner + just create-config & ../scripts/wait_for_tcp_port_opening.sh localhost 8000 + + - name: set shanghaiTime + run: | + cd eth-testnet-runner/config-data/custom_config_data + sed -i 's/"shanghaiTime":.*/"shanghaiTime": 167119236847838392/' genesis.json + + - name: Set MIN_GENESIS_TIME + run: | + cd eth-testnet-runner/config-data/custom_config_data/ + sed -i 's/^MIN_GENESIS_TIME:.*/MIN_GENESIS_TIME: 1678876062/' config.yaml + + - name: run generate-keys + run: | + cd eth-testnet-runner + just generate-keys + + - name: run init-geth + run: | + cd eth-testnet-runner + just init-geth + + - name: run run-el + run: | + cd eth-testnet-runner + just run-el & ../scripts/wait_for_tcp_port_opening.sh localhost 8545 + + - name: run run-cl + run: | + cd eth-testnet-runner + just run-cl & ../scripts/wait_for_tcp_port_opening.sh localhost 5052 + + - name: run run-validator + run: | + cd eth-testnet-runner + just run-validator & ../scripts/wait_for_tcp_port_opening.sh localhost 5062 + + - name: Run all tests + run: | + cargo test -p sync-committee-prover -- --nocapture diff --git a/prover/src/error.rs b/prover/src/error.rs deleted file mode 100644 index e6a6a5c49..000000000 --- a/prover/src/error.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug)] -pub enum Error { - AggregateSignatureError, - EmptySignedBeaconBlock, -} diff --git a/prover/src/lib.rs b/prover/src/lib.rs index b1ec1c001..863550ff7 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -1,6 +1,5 @@ #[warn(unused_imports)] #[warn(unused_variables)] -mod error; mod responses; mod routes; #[cfg(test)] diff --git a/prover/src/test.rs b/prover/src/test.rs index f234f468f..3618cb63e 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -6,13 +6,10 @@ use sync_committee_primitives::{ }; use ethereum_consensus::{ - altair::Checkpoint, bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, + bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, state_transition::Context, }; -use ssz_rs::{ - calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, - Merkleized, SszVariableOrIndex, -}; +use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; use std::time::Duration; use sync_committee_primitives::{ types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, @@ -27,7 +24,6 @@ const NODE_URL: &'static str = "http://localhost:5052"; #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn fetch_block_header_works() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let block_header = sync_committee_prover.fetch_header("head").await; @@ -37,7 +33,6 @@ async fn fetch_block_header_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn fetch_block_works() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let block = sync_committee_prover.fetch_block("head").await; @@ -47,7 +42,6 @@ async fn fetch_block_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn fetch_sync_committee_works() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let block = sync_committee_prover.fetch_sync_committee("head").await; @@ -57,7 +51,6 @@ async fn fetch_sync_committee_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn fetch_validator_works() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let validator = sync_committee_prover.fetch_validator("head", "48").await; @@ -77,17 +70,15 @@ async fn fetch_processed_sync_committee_works() { #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn fetch_beacon_state_works() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); - let beacon_state = sync_committee_prover.fetch_beacon_state("genesis").await; + let beacon_state = sync_committee_prover.fetch_beacon_state("head").await; assert!(beacon_state.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] #[actix_rt::test] -#[ignore] async fn state_root_and_block_header_root_matches() { let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); let mut beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); @@ -454,7 +445,8 @@ async fn test_prover() { ); count += 1; - if count == 10 { + // For CI purposes we test finalization of three epochs + if count == 3 { break } } diff --git a/scripts/wait_for_tcp_port_opening.sh b/scripts/wait_for_tcp_port_opening.sh new file mode 100755 index 000000000..d9e61a31e --- /dev/null +++ b/scripts/wait_for_tcp_port_opening.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +HOST=$1 +PORT=$2 + +echo "Trying to connect to ${HOST}:${PORT}..." + +while ! nc -z $HOST $PORT; do + sleep 0.5 +done + +echo "${HOST}:${PORT} is ready for requests." \ No newline at end of file From 592d28abde91ad81713df428e55f3e95ad157ea4 Mon Sep 17 00:00:00 2001 From: dharjeezy Date: Tue, 21 Mar 2023 11:24:23 +0100 Subject: [PATCH 089/100] Implement Scale Encode and Decode Traits for Light Client (#20) --- Cargo.lock | 142 +++++++--- primitives/Cargo.toml | 6 +- primitives/src/derived_types.rs | 488 ++++++++++++++++++++++++++++++++ primitives/src/error.rs | 24 ++ primitives/src/helpers.rs | 162 +++++++++++ primitives/src/lib.rs | 4 + 6 files changed, 785 insertions(+), 41 deletions(-) create mode 100644 primitives/src/derived_types.rs create mode 100644 primitives/src/error.rs create mode 100644 primitives/src/helpers.rs diff --git a/Cargo.lock b/Cargo.lock index 3fee84a14..2a58f1bf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -50,15 +50,21 @@ source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee67 [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "as-any" @@ -85,7 +91,7 @@ checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -184,6 +190,12 @@ version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + [[package]] name = "byteorder" version = "1.4.3" @@ -726,6 +738,17 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "indexmap" version = "1.9.2" @@ -774,10 +797,11 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ + "hermit-abi 0.3.1", "libc", "windows-sys 0.45.0", ] @@ -790,9 +814,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", @@ -908,9 +932,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" @@ -964,7 +988,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -1040,9 +1064,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.45" +version = "0.10.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" +checksum = "d8b277f87dacc05a6b709965d1cbafac4649d6ce9f3ce9ceb88508b5666dfec9" dependencies = [ "bitflags", "cfg-if", @@ -1061,7 +1085,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1072,9 +1096,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" dependencies = [ "autocfg", "cc", @@ -1083,6 +1107,32 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "parity-scale-codec" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1165,7 +1215,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1262,9 +1312,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "reqwest" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" +checksum = "0ba30cc2c0cd02af1222ed216ba659cdb2f879dfe3181852fe7c50b1d0005949" dependencies = [ "base64 0.21.0", "bytes", @@ -1326,9 +1376,9 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ "bitflags", "errno", @@ -1398,22 +1448,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.156" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.156" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.4", ] [[package]] @@ -1562,7 +1612,7 @@ source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1588,6 +1638,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c622ae390c9302e214c31013517c2061ecb2699935882c60a9b37f82f8625ae" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sync-committee-primitives" version = "0.1.0" @@ -1595,6 +1656,7 @@ dependencies = [ "base2 0.3.1", "ethereum-consensus", "hex-literal", + "parity-scale-codec", "ssz-rs", ] @@ -1639,7 +1701,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -1673,22 +1735,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.4", ] [[package]] @@ -1734,7 +1796,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1821,9 +1883,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-bidi" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -1912,7 +1974,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1946,7 +2008,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index a6db5811b..cef917f0a 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -10,10 +10,14 @@ base2 = { version = "0.3.1", default-features = false} ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ + "derive" +] } [features] default = ["std"] std = [ - "ssz-rs/std" + "ssz-rs/std", + 'codec/std' ] testing = [] diff --git a/primitives/src/derived_types.rs b/primitives/src/derived_types.rs new file mode 100644 index 000000000..3610e22d2 --- /dev/null +++ b/primitives/src/derived_types.rs @@ -0,0 +1,488 @@ +use crate::{ + error::Error, + helpers::{ + to_codec_light_client_state, to_codec_light_client_update, to_no_codec_beacon_header, + to_no_codec_light_client_state, to_no_codec_light_client_update, + to_no_codec_sync_committee, + }, + types, +}; +use alloc::vec::Vec; +use codec::{Decode, Encode}; +use ethereum_consensus::{bellatrix, primitives::Hash32}; + +/// Minimum state required by the light client to validate new sync committee attestations +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] +pub struct LightClientState { + /// The latest recorded finalized header + pub finalized_header: BeaconBlockHeader, + /// Latest finalized epoch + pub latest_finalized_epoch: u64, + // Sync committees corresponding to the finalized header + pub current_sync_committee: SyncCommittee, + pub next_sync_committee: SyncCommittee, +} + +impl TryFrom> + for LightClientState +{ + type Error = Error; + fn try_from(state: types::LightClientState) -> Result { + to_codec_light_client_state(state) + } +} + +impl TryFrom + for types::LightClientState +{ + type Error = Error; + fn try_from(state: LightClientState) -> Result { + to_no_codec_light_client_state(state) + } +} + +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] +pub struct BeaconBlockHeader { + pub slot: u64, + pub proposer_index: u64, + pub parent_root: [u8; 32], + pub state_root: [u8; 32], + pub body_root: [u8; 32], +} + +impl TryFrom for BeaconBlockHeader { + type Error = Error; + + fn try_from(beacon_block_header: bellatrix::BeaconBlockHeader) -> Result { + Ok(BeaconBlockHeader { + slot: beacon_block_header.slot, + proposer_index: beacon_block_header.proposer_index as u64, + parent_root: beacon_block_header + .parent_root + .as_bytes() + .try_into() + .map_err(|_| Error::InvalidNodeBytes)?, + state_root: beacon_block_header + .state_root + .as_bytes() + .try_into() + .map_err(|_| Error::InvalidNodeBytes)?, + body_root: beacon_block_header + .body_root + .as_bytes() + .try_into() + .map_err(|_| Error::InvalidNodeBytes)?, + }) + } +} + +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] +pub struct SyncCommittee { + pub public_keys: Vec>, + pub aggregate_public_key: Vec, +} + +impl TryFrom> + for SyncCommittee +{ + type Error = Error; + + fn try_from( + sync_committee: bellatrix::SyncCommittee, + ) -> Result { + Ok(SyncCommittee { + public_keys: sync_committee + .public_keys + .iter() + .map(|public_key| public_key.to_vec()) + .collect(), + aggregate_public_key: sync_committee.aggregate_public_key.to_vec(), + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] +pub struct LightClientUpdate { + /// the header that the sync committee signed + pub attested_header: BeaconBlockHeader, + /// the sync committee has potentially changed, here's an ssz proof for that. + pub sync_committee_update: Option, + /// the actual header which was finalized by the ethereum attestation protocol. + pub finalized_header: BeaconBlockHeader, + /// execution payload of the finalized header + pub execution_payload: ExecutionPayloadProof, + /// Finalized header proof + pub finality_proof: FinalityProof, + /// signature & participation bits + pub sync_aggregate: SyncAggregate, + /// slot at which signature was produced + pub signature_slot: u64, + /// ancestors of the finalized block to be verified, may be empty. + pub ancestor_blocks: Vec, +} + +impl TryFrom> + for LightClientUpdate +{ + type Error = Error; + fn try_from( + update: types::LightClientUpdate, + ) -> Result { + to_codec_light_client_update(update) + } +} + +impl TryFrom + for types::LightClientUpdate +{ + type Error = Error; + fn try_from(derived_update: LightClientUpdate) -> Result { + to_no_codec_light_client_update(derived_update) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] +pub struct SyncCommitteeUpdate { + // actual sync committee + pub next_sync_committee: SyncCommittee, + // sync committee, ssz merkle proof. + pub next_sync_committee_branch: Vec>, +} + +impl TryFrom> + for SyncCommitteeUpdate +{ + type Error = Error; + + fn try_from( + sync_committee_update: types::SyncCommitteeUpdate, + ) -> Result { + Ok(SyncCommitteeUpdate { + next_sync_committee: sync_committee_update.next_sync_committee.try_into()?, + next_sync_committee_branch: sync_committee_update + .next_sync_committee_branch + .iter() + .map(|hash| hash.to_vec()) + .collect(), + }) + } +} + +impl TryFrom + for types::SyncCommitteeUpdate +{ + type Error = Error; + + fn try_from(sync_committee_update: SyncCommitteeUpdate) -> Result { + let next_sync_committee = + to_no_codec_sync_committee(sync_committee_update.next_sync_committee)?; + Ok(types::SyncCommitteeUpdate { + next_sync_committee, + next_sync_committee_branch: sync_committee_update + .next_sync_committee_branch + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, Error>>()?, + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] +pub struct ExecutionPayloadProof { + /// The state root in the `ExecutionPayload` which represents the commitment to + /// the ethereum world state in the yellow paper. + pub state_root: Vec, + /// the block number of the execution header. + pub block_number: u64, + /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. + pub multi_proof: Vec>, + /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. + pub execution_payload_branch: Vec>, + /// timestamp + pub timestamp: u64, +} + +impl TryFrom for ExecutionPayloadProof { + type Error = Error; + fn try_from( + execution_payload_proof: types::ExecutionPayloadProof, + ) -> Result { + Ok(ExecutionPayloadProof { + state_root: execution_payload_proof.state_root.to_vec(), + block_number: execution_payload_proof.block_number, + multi_proof: execution_payload_proof + .multi_proof + .iter() + .map(|proof| proof.to_vec()) + .collect(), + execution_payload_branch: execution_payload_proof + .execution_payload_branch + .iter() + .map(|branch| branch.to_vec()) + .collect(), + timestamp: execution_payload_proof.timestamp, + }) + } +} + +impl TryFrom for types::ExecutionPayloadProof { + type Error = Error; + fn try_from( + derived_execution_payload_proof: ExecutionPayloadProof, + ) -> Result { + let multi_proof = derived_execution_payload_proof + .multi_proof + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?; + + let execution_payload_branch = derived_execution_payload_proof + .execution_payload_branch + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?; + + Ok(types::ExecutionPayloadProof { + state_root: Hash32::try_from(derived_execution_payload_proof.state_root.as_slice()) + .map_err(|_| Error::InvalidRoot)?, + block_number: derived_execution_payload_proof.block_number, + multi_proof, + execution_payload_branch, + timestamp: derived_execution_payload_proof.timestamp, + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] +pub struct FinalityProof { + /// The latest finalized epoch + pub epoch: u64, + /// Finalized header proof + pub finality_branch: Vec>, +} + +impl TryFrom for FinalityProof { + type Error = Error; + fn try_from(finality_proof: types::FinalityProof) -> Result { + Ok(FinalityProof { + epoch: finality_proof.epoch, + finality_branch: finality_proof + .finality_branch + .iter() + .map(|branch| branch.to_vec()) + .collect(), + }) + } +} + +impl TryFrom for types::FinalityProof { + type Error = Error; + fn try_from(derived_finality_proof: FinalityProof) -> Result { + Ok(types::FinalityProof { + epoch: derived_finality_proof.epoch, + finality_branch: derived_finality_proof + .finality_branch + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?, + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] +pub struct SyncAggregate { + pub sync_committee_bits: Vec, + pub sync_committee_signature: Vec, +} + +impl TryFrom> + for SyncAggregate +{ + type Error = Error; + fn try_from( + sync_aggregate: bellatrix::SyncAggregate, + ) -> Result { + Ok(SyncAggregate { + sync_committee_bits: sync_aggregate.sync_committee_bits.clone().to_bitvec().into_vec(), + sync_committee_signature: sync_aggregate.sync_committee_signature.clone().to_vec(), + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] +pub struct AncestorBlock { + /// The actual beacon chain header + pub header: BeaconBlockHeader, + /// Associated execution header proofs + pub execution_payload: ExecutionPayloadProof, + /// Ancestry proofs of the beacon chain header. + pub ancestry_proof: AncestryProof, +} + +impl TryFrom for AncestorBlock { + type Error = Error; + fn try_from(ancestor_block: types::AncestorBlock) -> Result { + Ok(AncestorBlock { + header: ancestor_block.header.try_into()?, + execution_payload: ancestor_block.execution_payload.try_into()?, + ancestry_proof: ancestor_block.ancestry_proof.try_into()?, + }) + } +} + +impl TryFrom for types::AncestorBlock { + type Error = Error; + fn try_from(derived_ancestor_block: AncestorBlock) -> Result { + let beacon_block_header = to_no_codec_beacon_header(derived_ancestor_block.header)?; + Ok(types::AncestorBlock { + header: beacon_block_header, + execution_payload: derived_ancestor_block.execution_payload.try_into()?, + ancestry_proof: derived_ancestor_block.ancestry_proof.try_into()?, + }) + } +} + +/// Holds the neccessary proofs required to verify a header in the `block_roots` field +/// either in [`BeaconState`] or [`HistoricalBatch`]. +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] +pub struct BlockRootsProof { + /// Generalized index of the header in the `block_roots` list. + pub block_header_index: u64, + /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` + pub block_header_branch: Vec>, +} + +impl TryFrom for BlockRootsProof { + type Error = Error; + fn try_from(beacon_block_header: types::BlockRootsProof) -> Result { + Ok(BlockRootsProof { + block_header_index: beacon_block_header.block_header_index, + block_header_branch: beacon_block_header + .block_header_branch + .iter() + .map(|hash| hash.to_vec()) + .collect(), + }) + } +} + +impl TryFrom for types::BlockRootsProof { + type Error = Error; + fn try_from(derived_beacon_block_header: BlockRootsProof) -> Result { + let branch = derived_beacon_block_header + .block_header_branch + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?; + + Ok(types::BlockRootsProof { + block_header_index: derived_beacon_block_header.block_header_index, + block_header_branch: branch, + }) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] +pub enum AncestryProof { + /// This variant defines the proof data for a beacon chain header in the `state.block_roots` + BlockRoots { + /// Proof for the header in `state.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] + block_roots_branch: Vec>, + }, + /// This variant defines the neccessary proofs for a beacon chain header in the + /// `state.historical_roots`. + HistoricalRoots { + /// Proof for the header in `historical_batch.block_roots` + block_roots_proof: BlockRootsProof, + /// The proof for the `historical_batch.block_roots`, needed to reconstruct + /// `hash_tree_root(historical_batch)` + historical_batch_proof: Vec>, + /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` + historical_roots_proof: Vec>, + /// The generalized index for the historical_batch in `state.historical_roots`. + historical_roots_index: u64, + /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in + /// [`BeaconState`] + historical_roots_branch: Vec>, + }, +} + +impl TryFrom for AncestryProof { + type Error = Error; + fn try_from(ancestry_proof: types::AncestryProof) -> Result { + Ok(match ancestry_proof { + types::AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => + AncestryProof::BlockRoots { + block_roots_proof: block_roots_proof.try_into()?, + block_roots_branch: block_roots_branch + .iter() + .map(|hash| hash.to_vec()) + .collect(), + }, + types::AncestryProof::HistoricalRoots { + block_roots_proof, + historical_batch_proof, + historical_roots_proof, + historical_roots_index, + historical_roots_branch, + } => AncestryProof::HistoricalRoots { + block_roots_proof: block_roots_proof.try_into()?, + historical_batch_proof: historical_batch_proof + .iter() + .map(|hash| hash.to_vec()) + .collect(), + historical_roots_proof: historical_roots_proof + .iter() + .map(|hash| hash.to_vec()) + .collect(), + historical_roots_index, + historical_roots_branch: historical_roots_branch + .iter() + .map(|hash| hash.to_vec()) + .collect(), + }, + }) + } +} + +impl TryFrom for types::AncestryProof { + type Error = Error; + fn try_from(ancestry_proof: AncestryProof) -> Result { + Ok(match ancestry_proof { + AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => + types::AncestryProof::BlockRoots { + block_roots_proof: block_roots_proof.try_into()?, + block_roots_branch: block_roots_branch + .iter() + .map(|proof| { + Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof) + }) + .collect::, _>>()?, + }, + AncestryProof::HistoricalRoots { + block_roots_proof, + historical_batch_proof, + historical_roots_proof, + historical_roots_index, + historical_roots_branch, + } => types::AncestryProof::HistoricalRoots { + block_roots_proof: block_roots_proof.try_into()?, + historical_batch_proof: historical_batch_proof + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?, + historical_roots_proof: historical_roots_proof + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?, + historical_roots_index, + historical_roots_branch: historical_roots_branch + .iter() + .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) + .collect::, _>>()?, + }, + }) + } +} diff --git a/primitives/src/error.rs b/primitives/src/error.rs new file mode 100644 index 000000000..0188f669d --- /dev/null +++ b/primitives/src/error.rs @@ -0,0 +1,24 @@ +use core::fmt::{Display, Formatter}; + +#[derive(Debug)] +pub enum Error { + InvalidRoot, + InvalidPublicKey, + InvalidProof, + InvalidBitVec, + ErrorConvertingAncestorBlock, + InvalidNodeBytes, +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self { + Error::InvalidRoot => write!(f, "Invalid root",), + Error::InvalidPublicKey => write!(f, "Invalid public key",), + Error::InvalidProof => write!(f, "Invalid proof",), + Error::InvalidBitVec => write!(f, "Invalid bit vec",), + Error::InvalidNodeBytes => write!(f, "Invalid node bytes",), + Error::ErrorConvertingAncestorBlock => write!(f, "Error deriving ancestor block",), + } + } +} diff --git a/primitives/src/helpers.rs b/primitives/src/helpers.rs new file mode 100644 index 000000000..b16e8b9ec --- /dev/null +++ b/primitives/src/helpers.rs @@ -0,0 +1,162 @@ +use crate::{ + derived_types, + error::Error, + types, + types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, +}; +use alloc::vec::Vec; +use ethereum_consensus::{ + bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, + crypto::PublicKey, + primitives::BlsSignature, +}; +use ssz_rs::{Bitvector, Deserialize, Node, Vector}; + +pub fn to_no_codec_beacon_header( + derived_header: derived_types::BeaconBlockHeader, +) -> Result { + let finalized_header = BeaconBlockHeader { + slot: derived_header.slot, + proposer_index: derived_header.proposer_index as usize, + parent_root: Node::from_bytes( + derived_header.parent_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, + ), + state_root: Node::from_bytes( + derived_header.state_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, + ), + body_root: Node::from_bytes( + derived_header.body_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, + ), + }; + + Ok(finalized_header) +} + +pub fn to_no_codec_sync_committee( + derived_sync_committee: derived_types::SyncCommittee, +) -> Result, Error> { + let public_keys_vector: Vec = derived_sync_committee + .public_keys + .iter() + .map(|public_key| { + PublicKey::try_from(public_key.as_slice()).map_err(|_| Error::InvalidPublicKey) + }) + .collect::, Error>>()?; + let sync_committee = SyncCommittee { + public_keys: Vector::try_from(public_keys_vector).unwrap(), + aggregate_public_key: PublicKey::try_from( + derived_sync_committee.aggregate_public_key.as_slice(), + ) + .map_err(|_| Error::InvalidPublicKey)?, + }; + + Ok(sync_committee) +} + +pub fn to_no_codec_sync_aggregate( + derived_sync_aggregate: derived_types::SyncAggregate, +) -> Result, Error> { + let derived_sync_committee_bits = derived_sync_aggregate.sync_committee_bits; + let bit_vector = Bitvector::::deserialize(&derived_sync_committee_bits) + .map_err(|_| Error::InvalidBitVec)?; + + let sync_aggregate = SyncAggregate { + sync_committee_bits: bit_vector, + sync_committee_signature: BlsSignature::try_from( + derived_sync_aggregate.sync_committee_signature.as_ref(), + ) + .map_err(|_| Error::InvalidPublicKey)?, + }; + + Ok(sync_aggregate) +} + +pub fn to_no_codec_light_client_state( + state: derived_types::LightClientState, +) -> Result, Error> { + let finalized_header = to_no_codec_beacon_header(state.finalized_header)?; + + let current_sync_committee = to_no_codec_sync_committee(state.current_sync_committee.clone())?; + let next_sync_committee = to_no_codec_sync_committee(state.next_sync_committee)?; + + Ok(LightClientState { + finalized_header, + latest_finalized_epoch: state.latest_finalized_epoch, + current_sync_committee, + next_sync_committee, + }) +} + +pub fn to_no_codec_light_client_update( + derived_update: derived_types::LightClientUpdate, +) -> Result, Error> { + let sync_committee_update_option: Option>; + + match derived_update.sync_committee_update { + Some(sync_committee_update) => + sync_committee_update_option = Some(sync_committee_update.try_into()?), + None => sync_committee_update_option = None, + } + Ok(LightClientUpdate { + attested_header: to_no_codec_beacon_header(derived_update.attested_header)?, + sync_committee_update: sync_committee_update_option, + finalized_header: to_no_codec_beacon_header(derived_update.finalized_header)?, + execution_payload: derived_update.execution_payload.try_into()?, + finality_proof: derived_update.finality_proof.try_into()?, + sync_aggregate: to_no_codec_sync_aggregate(derived_update.sync_aggregate)?, + signature_slot: derived_update.signature_slot, + ancestor_blocks: derived_update + .ancestor_blocks + .iter() + .map(|ancestor_block| { + ancestor_block + .clone() + .try_into() + .map_err(|_| Error::ErrorConvertingAncestorBlock) + }) + .collect::, Error>>()?, + }) +} + +pub fn to_codec_light_client_state( + state: types::LightClientState, +) -> Result { + Ok(derived_types::LightClientState { + finalized_header: state.finalized_header.try_into()?, + latest_finalized_epoch: state.latest_finalized_epoch, + current_sync_committee: state.current_sync_committee.try_into()?, + next_sync_committee: state.next_sync_committee.try_into()?, + }) +} + +pub fn to_codec_light_client_update( + update: types::LightClientUpdate, +) -> Result { + let sync_committee_update_option: Option; + + match update.sync_committee_update { + Some(sync_committee_update) => + sync_committee_update_option = Some(sync_committee_update.try_into()?), + + None => sync_committee_update_option = None, + } + Ok(derived_types::LightClientUpdate { + attested_header: update.attested_header.try_into()?, + sync_committee_update: sync_committee_update_option, + finalized_header: update.finalized_header.try_into()?, + execution_payload: update.execution_payload.try_into()?, + finality_proof: update.finality_proof.try_into()?, + sync_aggregate: update.sync_aggregate.try_into()?, + signature_slot: update.signature_slot, + ancestor_blocks: update + .ancestor_blocks + .iter() + .map(|ancestor_block| { + ancestor_block + .clone() + .try_into() + .map_err(|_| Error::ErrorConvertingAncestorBlock) + }) + .collect::, Error>>()?, + }) +} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 23d346f32..620e20b9b 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -2,6 +2,10 @@ #[warn(unused_imports)] #[warn(unused_variables)] extern crate alloc; +extern crate core; +pub mod derived_types; +pub mod error; +pub mod helpers; pub mod types; pub mod util; From ea8ed638ebf53b6a2e91e4ec7cf72f20da1ff48a Mon Sep 17 00:00:00 2001 From: Femi Bankole Date: Mon, 27 Mar 2023 08:50:02 +0100 Subject: [PATCH 090/100] CI on merge (#23) * run ci only on merge to main --- .github/workflows/test.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ad55a846..f5710f738 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,9 @@ -name: Test +name: CI on: push: - branches: - - main + branches: [main] pull_request: - branches: - - main jobs: check: @@ -29,9 +26,7 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - # defaults: - # run: - # shell: bash + if: github.ref == 'refs/heads/main' env: TUID: 123 steps: @@ -118,7 +113,7 @@ jobs: sed -i 's/BELLATRIX_FORK_VERSION=.*/BELLATRIX_FORK_VERSION="0x02000000"/' values.env sed -i 's/CAPELLA_FORK_VERSION=.*/CAPELLA_FORK_VERSION="0x03000000"/' values.env sed -i 's/EIP4844_FORK_VERSION=.*/EIP4844_FORK_VERSION="0x04000000"/' values.env - + - name: remove tty flag from docker command in create-config recipe run: | cd eth-testnet-runner From c0b949babb9f323028a57e41670e2bff0302773e Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Thu, 6 Apr 2023 16:00:01 +0100 Subject: [PATCH 091/100] Fix wasm build and add wasm build check to CI (#24) * fix wasm build * nit * fix workflow --- .github/workflows/test.yml | 21 +++++++++++---------- Cargo.lock | 25 +++---------------------- primitives/Cargo.toml | 1 - primitives/src/lib.rs | 1 - primitives/src/util.rs | 6 ------ 5 files changed, 14 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5710f738..c1e9accf7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,16 +13,19 @@ jobs: - name: Checkout sources uses: actions/checkout@main - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly with: - profile: minimal - toolchain: stable - override: true + toolchain: nightly + targets: wasm32-unknown-unknown - name: Run cargo check run: cargo check + - name: Build `no-std` + run: | + cargo +nightly check -p sync-committee-verifier --no-default-features --target=wasm32-unknown-unknown --verbose + test: name: Test Suite runs-on: ubuntu-latest @@ -47,9 +50,7 @@ jobs: - name: Install rust stable toolchain uses: actions-rs/toolchain@v1 with: - profile: minimal - toolchain: stable - override: true + toolchain: nightly - name: Install protoc run: | @@ -71,7 +72,7 @@ jobs: git clone https://github.com/sigp/lighthouse.git cd lighthouse git checkout 38514c07f222ff7783834c48cf5c0a6ee7f346d0 - cargo build -p lighthouse --release + cargo +nightly build -p lighthouse --release mv target/release/lighthouse ../bin - name: Install go @@ -161,4 +162,4 @@ jobs: - name: Run all tests run: | - cargo test -p sync-committee-prover -- --nocapture + cargo +nightly test -p sync-committee-prover -- --nocapture diff --git a/Cargo.lock b/Cargo.lock index 2a58f1bf3..f06426e69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,16 +112,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" dependencies = [ - "int 0.2.11", -] - -[[package]] -name = "base2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" -dependencies = [ - "int 0.3.0", + "int", ] [[package]] @@ -777,15 +768,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "int" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" -dependencies = [ - "num-traits", -] - [[package]] name = "integer-sqrt" version = "0.1.5" @@ -1653,7 +1635,6 @@ dependencies = [ name = "sync-committee-primitives" version = "0.1.0" dependencies = [ - "base2 0.3.1", "ethereum-consensus", "hex-literal", "parity-scale-codec", @@ -1667,7 +1648,7 @@ dependencies = [ "actix-rt", "anyhow", "async-stream", - "base2 0.2.2", + "base2", "env_logger", "ethereum-consensus", "hex", @@ -1685,7 +1666,7 @@ dependencies = [ name = "sync-committee-verifier" version = "0.1.0" dependencies = [ - "base2 0.2.2", + "base2", "ethereum-consensus", "log", "milagro_bls", diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index cef917f0a..18e3e8b72 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -6,7 +6,6 @@ authors = ["Polytope Labs"] [dependencies] -base2 = { version = "0.3.1", default-features = false} ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 620e20b9b..b53869e0d 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -2,7 +2,6 @@ #[warn(unused_imports)] #[warn(unused_variables)] extern crate alloc; -extern crate core; pub mod derived_types; pub mod error; diff --git a/primitives/src/util.rs b/primitives/src/util.rs index 8be6d1474..20701c9e5 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -1,4 +1,3 @@ -use base2::Base2; use ethereum_consensus::{ altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD, configs::mainnet::{ @@ -8,11 +7,6 @@ use ethereum_consensus::{ phase0::mainnet::SLOTS_PER_EPOCH, }; -/// Calculate the subtree index from the ``generalized_index`` -pub fn get_subtree_index(generalized_index: u64) -> u64 { - generalized_index % 2 ^ (generalized_index.floor_log2() as u64) -} - /// Return the sync committe period at the given ``epoch`` pub fn compute_sync_committee_period(epoch: u64) -> u64 { epoch / EPOCHS_PER_SYNC_COMMITTEE_PERIOD From 508367385f68761410f358dd87d7f636a4df1778 Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Thu, 6 Apr 2023 16:32:07 +0100 Subject: [PATCH 092/100] remove base2 package (#25) --- Cargo.lock | 1 - primitives/src/types.rs | 6 ++++++ verifier/Cargo.toml | 1 - verifier/src/lib.rs | 27 +++++++++++++-------------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f06426e69..2d2423b7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1666,7 +1666,6 @@ dependencies = [ name = "sync-committee-verifier" version = "0.1.0" dependencies = [ - "base2", "ethereum-consensus", "log", "milagro_bls", diff --git a/primitives/src/types.rs b/primitives/src/types.rs index 643a9de52..d5fc44b7a 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -15,6 +15,12 @@ pub const BLOCK_ROOTS_INDEX: u64 = 37; pub const HISTORICAL_ROOTS_INDEX: u64 = 39; pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; pub const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 25; +pub const FINALIZED_ROOT_INDEX_LOG2: u64 = 5; +pub const EXECUTION_PAYLOAD_INDEX_LOG2: u64 = 5; +pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 5; +pub const BLOCK_ROOTS_INDEX_LOG2: u64 = 5; +pub const HISTORICAL_ROOTS_INDEX_LOG2: u64 = 5; + #[cfg(not(feature = "testing"))] pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 357c12a77..7d50acb10 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" authors = ["Polytope Labs"] [dependencies] -base2 = { version="0.2.2", default-features = false } sync-committee-primitives = { path= "../primitives", default-features = false } ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index fff66eb0a..fa40bc9ad 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -7,25 +7,24 @@ pub mod error; use crate::error::Error; use alloc::vec::Vec; -use base2::Base2; use ethereum_consensus::{ bellatrix::{compute_domain, mainnet::SYNC_COMMITTEE_SIZE, Checkpoint}, primitives::Root, signing::compute_signing_root, state_transition::Context, }; - use ssz_rs::{ calculate_merkle_root, calculate_multi_merkle_root, prelude::is_valid_merkle_branch, GeneralizedIndex, Merkleized, Node, }; use sync_committee_primitives::{ types::{ - AncestryProof, BLOCK_ROOTS_INDEX, DOMAIN_SYNC_COMMITTEE, + AncestryProof, BLOCK_ROOTS_INDEX, BLOCK_ROOTS_INDEX_LOG2, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, - EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, - FINALIZED_ROOT_INDEX, GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, - HISTORICAL_ROOTS_INDEX, NEXT_SYNC_COMMITTEE_INDEX, + EXECUTION_PAYLOAD_INDEX_LOG2, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, + EXECUTION_PAYLOAD_TIMESTAMP_INDEX, FINALIZED_ROOT_INDEX, FINALIZED_ROOT_INDEX_LOG2, + GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, + HISTORICAL_ROOTS_INDEX_LOG2, NEXT_SYNC_COMMITTEE_INDEX, NEXT_SYNC_COMMITTEE_INDEX_LOG2, }, util::{compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot}, }; @@ -39,10 +38,10 @@ pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { - if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX.floor_log2() as usize && + if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX_LOG2 as usize && update.sync_committee_update.is_some() && update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize + NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize { Err(Error::InvalidUpdate)? } @@ -137,7 +136,7 @@ pub fn verify_sync_committee_attestation( let is_merkle_branch_valid = is_valid_merkle_branch( &finalized_checkpoint.hash_tree_root().map_err(|_| Error::InvalidRoot)?, branch.iter(), - FINALIZED_ROOT_INDEX.floor_log2() as usize, + FINALIZED_ROOT_INDEX_LOG2 as usize, FINALIZED_ROOT_INDEX as usize, &update.attested_header.state_root, ); @@ -185,7 +184,7 @@ pub fn verify_sync_committee_attestation( let is_merkle_branch_valid = is_valid_merkle_branch( &execution_payload_root, execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + EXECUTION_PAYLOAD_INDEX_LOG2 as usize, EXECUTION_PAYLOAD_INDEX as usize, &update.finalized_header.state_root, ); @@ -213,7 +212,7 @@ pub fn verify_sync_committee_attestation( .hash_tree_root() .map_err(|_| Error::MerkleizationError)?, next_sync_committee_branch.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, &update.attested_header.state_root, ); @@ -247,7 +246,7 @@ pub fn verify_sync_committee_attestation( let is_merkle_branch_valid = is_valid_merkle_branch( &block_roots_root, block_roots_branch_node.iter(), - BLOCK_ROOTS_INDEX.floor_log2() as usize, + BLOCK_ROOTS_INDEX_LOG2 as usize, BLOCK_ROOTS_INDEX as usize, &update.finalized_header.state_root, ); @@ -304,7 +303,7 @@ pub fn verify_sync_committee_attestation( let is_merkle_branch_valid = is_valid_merkle_branch( &historical_roots_root, historical_roots_branch_nodes.iter(), - HISTORICAL_ROOTS_INDEX.floor_log2() as usize, + HISTORICAL_ROOTS_INDEX_LOG2 as usize, HISTORICAL_ROOTS_INDEX as usize, &Node::from_bytes( update @@ -375,7 +374,7 @@ pub fn verify_sync_committee_attestation( let is_merkle_branch_valid = is_valid_merkle_branch( &execution_payload_root, execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, + EXECUTION_PAYLOAD_INDEX_LOG2 as usize, EXECUTION_PAYLOAD_INDEX as usize, &Node::from_bytes( ancestor.header.state_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, From 4e45ae9797198a617abfcbff098253cedc8a1f2e Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:49:55 +0100 Subject: [PATCH 093/100] update dependencies (#26) --- Cargo.lock | 339 +++++++++++++++++++++++++++++------------- primitives/Cargo.toml | 4 +- prover/Cargo.toml | 4 +- verifier/Cargo.toml | 4 +- 4 files changed, 241 insertions(+), 110 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d2423b7b..38ed99daa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,6 +23,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.3" @@ -74,9 +89,9 @@ checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" [[package]] name = "async-stream" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", @@ -85,13 +100,13 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.13", ] [[package]] @@ -100,6 +115,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base16ct" version = "0.1.1" @@ -229,9 +259,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core2" @@ -244,9 +274,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" dependencies = [ "libc", ] @@ -390,13 +420,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.45.0", ] [[package]] @@ -415,19 +445,19 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" dependencies = [ + "backtrace", "version_check", ] [[package]] name = "ethereum-consensus" version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?rev=d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f#d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" +source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=main#48335b5c8074d63553ee4681993e294eba947f88" dependencies = [ "async-stream", "bs58", "enr", "error-chain", - "getrandom", "hashbrown 0.13.2", "hex", "integer-sqrt", @@ -501,36 +531,36 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-task", @@ -540,9 +570,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -550,17 +580,21 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" + [[package]] name = "group" version = "0.12.1" @@ -742,9 +776,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -779,31 +813,31 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -859,9 +893,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "linked-hash-map" @@ -871,9 +905,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" [[package]] name = "lock_api" @@ -918,6 +952,15 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -945,6 +988,7 @@ dependencies = [ "serde", "static_assertions", "unsigned-varint", + "url", ] [[package]] @@ -1032,6 +1076,15 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -1046,9 +1099,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.47" +version = "0.10.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b277f87dacc05a6b709965d1cbafac4649d6ce9f3ce9ceb88508b5666dfec9" +checksum = "4d2f106ab837a24e03672c59b1239669a0596406ff657c3c0835b6b7f0f35a33" dependencies = [ "bitflags", "cfg-if", @@ -1061,13 +1114,13 @@ dependencies = [ [[package]] name = "openssl-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.13", ] [[package]] @@ -1078,11 +1131,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.82" +version = "0.9.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" +checksum = "3a20eace9dc2d82904039cb76dcf50fb1a0bba071cfd1629720b5d6f1ddba0fa" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -1133,7 +1185,7 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.45.0", ] @@ -1214,9 +1266,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -1275,11 +1327,20 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "regex" -version = "1.7.1" +version = "1.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", @@ -1288,15 +1349,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "reqwest" -version = "0.11.15" +version = "0.11.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba30cc2c0cd02af1222ed216ba659cdb2f879dfe3181852fe7c50b1d0005949" +checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" dependencies = [ "base64 0.21.0", "bytes", @@ -1350,6 +1411,12 @@ dependencies = [ "rustc-hex", ] +[[package]] +name = "rustc-demangle" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -1358,16 +1425,16 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.36.11" +version = "0.37.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" +checksum = "1aef160324be24d31a62147fae491c14d2204a3865c7ca8c3b0d7f7bcb3ea635" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1430,29 +1497,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.158" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" +checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.158" +version = "1.0.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" +checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.13", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" dependencies = [ "itoa", "ryu", @@ -1574,7 +1641,7 @@ dependencies = [ [[package]] name = "ssz-rs" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#96f9a89ccc56ab2abb4c3a83eaedb415034ada49" dependencies = [ "as-any", "bitvec", @@ -1584,13 +1651,12 @@ dependencies = [ "serde", "sha2 0.9.9", "ssz-rs-derive", - "thiserror", ] [[package]] name = "ssz-rs-derive" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?rev=2e28a8800787392045fb3f8f1eaef6c65a8600d7#2e28a8800787392045fb3f8f1eaef6c65a8600d7" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#96f9a89ccc56ab2abb4c3a83eaedb415034ada49" dependencies = [ "proc-macro2", "quote", @@ -1622,9 +1688,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.4" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c622ae390c9302e214c31013517c2061ecb2699935882c60a9b37f82f8625ae" +checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" dependencies = [ "proc-macro2", "quote", @@ -1693,15 +1759,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1730,7 +1796,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.4", + "syn 2.0.13", ] [[package]] @@ -1750,14 +1816,13 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot", @@ -1770,13 +1835,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.13", ] [[package]] @@ -2046,13 +2111,13 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -2061,7 +2126,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -2070,13 +2144,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] @@ -2085,42 +2174,84 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winreg" version = "0.10.1" @@ -2150,6 +2281,6 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 18e3e8b72..8fbf3d9a7 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -6,8 +6,8 @@ authors = ["Polytope Labs"] [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive" diff --git a/prover/Cargo.toml b/prover/Cargo.toml index d6546c55d..e81fafe4e 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f" } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7" } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main" } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" } reqwest = {version="0.11.14", features=["json"]} serde = { version = "1.0", features = ["derive"]} serde_json = { version = "1.0.81"} diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 7d50acb10..debc638e3 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -6,8 +6,8 @@ authors = ["Polytope Labs"] [dependencies] sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", rev = "d3fe0ad76613b52cdfbdea7c317ecdc35f271e4f", default-features = false } -ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", rev = "2e28a8800787392045fb3f8f1eaef6c65a8600d7", default-features = false } +ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } +ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" , default-features = false } milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = { version = "0.4.17", default-features = false } From c5afca4fbb92cb60dde29c3a89454c288b022d97 Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:38:35 +0100 Subject: [PATCH 094/100] Generic signature verification, clonable prover (#27) * generic signature verification * cargo update --- Cargo.lock | 601 ++++++++++++++++++------------------------ primitives/Cargo.toml | 2 +- prover/Cargo.toml | 2 +- prover/src/lib.rs | 1 + prover/src/test.rs | 9 +- verifier/Cargo.toml | 2 - verifier/src/lib.rs | 21 +- 7 files changed, 278 insertions(+), 360 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38ed99daa..c7cd1afab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,12 +4,12 @@ version = 3 [[package]] name = "actix-macros" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 1.0.109", + "syn 2.0.28", ] [[package]] @@ -25,9 +25,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" dependencies = [ "gimli", ] @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c" dependencies = [ "memchr", ] @@ -65,9 +65,9 @@ source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee67 [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "arrayref" @@ -77,9 +77,9 @@ checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "as-any" @@ -106,7 +106,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.28", ] [[package]] @@ -117,9 +117,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ "addr2line", "cc", @@ -138,9 +138,9 @@ checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" [[package]] name = "base2" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd838cfd751f573f3ce2c7a959df55eed90f5cbdcfbacd1acf77eaffd51daa8c" +checksum = "f0d6cf42565b8bd996c9f583069619124475caa645d598d75918923b240409be" dependencies = [ "int", ] @@ -153,9 +153,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" @@ -169,6 +169,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitvec" version = "1.0.1" @@ -207,9 +213,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" @@ -231,9 +237,12 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cc" -version = "1.0.79" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -243,9 +252,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "core-foundation" @@ -274,9 +283,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -305,9 +314,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "der" @@ -330,9 +339,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", @@ -353,9 +362,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" @@ -366,7 +375,7 @@ dependencies = [ "base16ct", "crypto-bigint", "der", - "digest 0.10.6", + "digest 0.10.7", "ff", "generic-array", "group", @@ -420,13 +429,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -476,12 +485,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "ff" @@ -516,9 +522,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -580,9 +586,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -591,9 +597,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "group" @@ -608,9 +614,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.16" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -642,18 +648,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -663,9 +660,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "hmac" @@ -673,7 +670,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -706,9 +703,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -718,9 +715,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.25" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -733,7 +730,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -755,9 +752,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -784,20 +781,11 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "int" -version = "0.2.11" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719740841ea8a9c2df2da3d37adb237fa85121ef91ef7e0aeda5afb2c79a2a85" +checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" dependencies = [ "num-traits", ] @@ -811,33 +799,21 @@ dependencies = [ "num-traits", ] -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", + "hermit-abi", "rustix", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] @@ -851,15 +827,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -873,14 +849,14 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "sha2 0.10.7", ] [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] @@ -893,9 +869,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linked-hash-map" @@ -905,15 +881,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -921,12 +897,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" @@ -954,23 +927,22 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "log", "wasi", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -998,9 +970,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" dependencies = [ "core2", - "digest 0.10.6", + "digest 0.10.7", "multihash-derive", - "sha2 0.10.6", + "sha2 0.10.7", "unsigned-varint", ] @@ -1059,37 +1031,37 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi", "libc", ] [[package]] name = "object" -version = "0.30.3" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -1099,11 +1071,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.49" +version = "0.10.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d2f106ab837a24e03672c59b1239669a0596406ff657c3c0835b6b7f0f35a33" +checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -1120,7 +1092,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.28", ] [[package]] @@ -1131,9 +1103,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.84" +version = "0.9.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a20eace9dc2d82904039cb76dcf50fb1a0bba071cfd1629720b5d6f1ddba0fa" +checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" dependencies = [ "cc", "libc", @@ -1143,9 +1115,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec", "bitvec", @@ -1157,9 +1129,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.4" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1179,28 +1151,28 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "pin-utils" @@ -1220,9 +1192,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "ppv-lite86" @@ -1266,18 +1238,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -1320,27 +1292,30 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] -name = "redox_syscall" -version = "0.3.5" +name = "regex" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ - "bitflags", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", ] [[package]] -name = "regex" -version = "1.7.3" +name = "regex-automata" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" dependencies = [ "aho-corasick", "memchr", @@ -1349,17 +1324,17 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "reqwest" -version = "0.11.16" +version = "0.11.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" dependencies = [ - "base64 0.21.0", + "base64 0.21.2", "bytes", "encoding_rs", "futures-core", @@ -1413,9 +1388,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hex" @@ -1425,38 +1400,37 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustix" -version = "0.37.8" +version = "0.38.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aef160324be24d31a62147fae491c14d2204a3865c7ca8c3b0d7f7bcb3ea635" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" dependencies = [ - "bitflags", + "bitflags 2.4.0", "errno", - "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.48.0", + "windows-sys", ] [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys", ] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sec1" @@ -1474,11 +1448,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.2" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -1487,9 +1461,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -1497,29 +1471,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.159" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c04e8343c3daeec41f58990b9d77068df31209f2af111e059e9fe9646693065" +checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.159" +version = "1.0.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c614d17805b093df4b147b51339e7e44bf05ef59fba1e45d83500bcfb4d8585" +checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.28", ] [[package]] name = "serde_json" -version = "1.0.95" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -1565,22 +1539,22 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] @@ -1599,7 +1573,7 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core", ] @@ -1614,9 +1588,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" @@ -1628,6 +1602,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "spki" version = "0.6.0" @@ -1671,9 +1655,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "subtle" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" @@ -1688,9 +1672,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.13" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -1734,7 +1718,6 @@ version = "0.1.0" dependencies = [ "ethereum-consensus", "log", - "milagro_bls", "ssz-rs", "sync-committee-primitives", ] @@ -1759,15 +1742,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall", "rustix", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] @@ -1781,22 +1764,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.28", ] [[package]] @@ -1816,11 +1799,11 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" dependencies = [ - "autocfg", + "backtrace", "bytes", "libc", "mio", @@ -1828,20 +1811,20 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.3", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn 2.0.28", ] [[package]] @@ -1856,9 +1839,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -1867,9 +1850,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -1907,9 +1890,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", ] @@ -1934,9 +1917,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -1961,9 +1944,9 @@ checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -1984,11 +1967,10 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -2000,9 +1982,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2010,24 +1992,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.28", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -2037,9 +2019,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2047,28 +2029,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.28", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -2105,147 +2087,66 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 8fbf3d9a7..b5af4614e 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Polytope Labs"] [dependencies] ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } -hex-literal = { package = "hex-literal", version = "0.3.3", default-features = false } +hex-literal = { package = "hex-literal", version = "0.4.1", default-features = false } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive" ] } diff --git a/prover/Cargo.toml b/prover/Cargo.toml index e81fafe4e..5ec1cae68 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -18,7 +18,7 @@ actix-rt = "*" tokio = { version = "1.18.2", features = ["full"]} tokio-stream = { version = "0.1.8" } async-stream = { version = "0.3.3"} -base2 = {version="0.2.2", default-features=false} +base2 = {version= "0.3.1", default-features=false} env_logger = "0.10.0" [dev-dependencies] diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 863550ff7..a519aca7b 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -58,6 +58,7 @@ pub type BeaconStateType = BeaconState< MAX_TRANSACTIONS_PER_PAYLOAD, >; +#[derive(Clone)] pub struct SyncCommitteeProver { pub node_url: String, pub client: Client, diff --git a/prover/src/test.rs b/prover/src/test.rs index 3618cb63e..9acc97fdd 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -15,7 +15,7 @@ use sync_committee_primitives::{ types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, util::compute_fork_version, }; -use sync_committee_verifier::verify_sync_committee_attestation; +use sync_committee_verifier::{verify_sync_committee_attestation, SignatureVerifier}; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; @@ -437,8 +437,11 @@ async fn test_prover() { ancestor_blocks: vec![], }; - client_state = - verify_sync_committee_attestation(client_state.clone(), light_client_update).unwrap(); + client_state = verify_sync_committee_attestation::( + client_state.clone(), + light_client_update, + ) + .unwrap(); println!( "Sucessfully verified Ethereum block at slot {:?}", client_state.finalized_header.slot diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index debc638e3..e381b0445 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -8,14 +8,12 @@ authors = ["Polytope Labs"] sync-committee-primitives = { path= "../primitives", default-features = false } ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" , default-features = false } -milagro_bls = { git = "https://github.com/sigp/milagro_bls", default-features = false } log = { version = "0.4.17", default-features = false } [features] default = ["std"] std = [ "ssz-rs/std", - "milagro_bls/std", "log/std" ] testing = ["sync-committee-primitives/testing"] diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index fa40bc9ad..56958c01c 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -9,6 +9,7 @@ use crate::error::Error; use alloc::vec::Vec; use ethereum_consensus::{ bellatrix::{compute_domain, mainnet::SYNC_COMMITTEE_SIZE, Checkpoint}, + crypto::{PublicKey, Signature}, primitives::Root, signing::compute_signing_root, state_transition::Context, @@ -33,8 +34,13 @@ pub type LightClientState = sync_committee_primitives::types::LightClientState; +/// Verify sync committee signatures +pub trait BlsVerify { + fn verify(public_keys: &[&PublicKey], msg: &[u8], signature: &Signature) -> Result<(), Error>; +} + /// This function simply verifies a sync committee's attestation & it's finalized counterpart. -pub fn verify_sync_committee_attestation( +pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { @@ -107,8 +113,7 @@ pub fn verify_sync_committee_attestation( let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain); - // todo: should be generic - ethereum_consensus::crypto::fast_aggregate_verify( + V::verify( &*participant_pubkeys, signing_root.map_err(|_| Error::InvalidRoot)?.as_bytes(), &update.sync_aggregate.sync_committee_signature, @@ -399,3 +404,13 @@ pub fn verify_sync_committee_attestation( Ok(new_light_client_state) } + +pub struct SignatureVerifier; + +impl BlsVerify for SignatureVerifier { + fn verify(public_keys: &[&PublicKey], msg: &[u8], signature: &Signature) -> Result<(), Error> { + ethereum_consensus::crypto::fast_aggregate_verify(public_keys, msg, signature)?; + + Ok(()) + } +} From 13f2034529aa2be5e6bc59d11c1586b0ce3d2fe1 Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Thu, 7 Sep 2023 17:18:13 +0100 Subject: [PATCH 095/100] Arkworks for signature verification (#28) * signature verification * nit * chore * fix no-std * rebase (#29) Co-authored-by: David Salami * fix verifier * remove cloning of beacon state * cleanup verifier * provide function for generating light client updates * wait for block production on el * run docker in background * fix test failures * change port in ci --------- Co-authored-by: dharjeezy --- .github/workflows/test.yml | 115 +- Cargo.lock | 2649 ++++++++++++++--- primitives/Cargo.toml | 22 +- primitives/src/consensus_types.rs | 406 +++ primitives/src/constants.rs | 138 + primitives/src/derived_types.rs | 488 --- primitives/src/domains.rs | 29 + primitives/src/helpers.rs | 162 - primitives/src/lib.rs | 10 +- primitives/src/serde.rs | 142 + primitives/src/ssz/byte_list.rs | 88 + primitives/src/ssz/byte_vector.rs | 81 + primitives/src/ssz/mod.rs | 16 + primitives/src/types.rs | 82 +- primitives/src/util.rs | 61 +- prover/Cargo.toml | 35 +- prover/src/lib.rs | 295 +- .../responses/beacon_block_header_response.rs | 2 +- prover/src/responses/beacon_block_response.rs | 16 +- prover/src/responses/beacon_state_response.rs | 16 +- .../responses/finality_checkpoint_response.rs | 2 +- prover/src/responses/validator_response.rs | 2 +- prover/src/test.rs | 401 +-- verifier/Cargo.toml | 19 +- verifier/src/error.rs | 10 +- verifier/src/lib.rs | 266 +- verifier/src/signature_verification.rs | 108 + 27 files changed, 3856 insertions(+), 1805 deletions(-) create mode 100644 primitives/src/consensus_types.rs create mode 100644 primitives/src/constants.rs delete mode 100644 primitives/src/derived_types.rs create mode 100644 primitives/src/domains.rs delete mode 100644 primitives/src/helpers.rs create mode 100644 primitives/src/serde.rs create mode 100644 primitives/src/ssz/byte_list.rs create mode 100644 primitives/src/ssz/byte_vector.rs create mode 100644 primitives/src/ssz/mod.rs create mode 100644 verifier/src/signature_verification.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1e9accf7..7d506ab68 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' +# if: github.ref == 'refs/heads/main' env: TUID: 123 steps: @@ -41,12 +41,6 @@ jobs: - name: Checkout sources uses: actions/checkout@master - - name: Clone eth-testnet-runner repository - run: | - git clone https://github.com/ralexstokes/eth-testnet-runner.git - cd eth-testnet-runner - git checkout 5f43097a03f8ff37217c843407bf7729617f2dff - - name: Install rust stable toolchain uses: actions-rs/toolchain@v1 with: @@ -57,108 +51,13 @@ jobs: sudo apt update sudo apt install protobuf-compiler - - name: Fetch geth binary - run: | - cd eth-testnet-runner - mkdir bin - wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.11.3-5ed08c47.tar.gz -O ./geth-linux-amd64-1.11.3-5ed08c47.tar.gz - tar -xvf geth-linux-amd64-1.11.3-5ed08c47.tar.gz - cd geth-linux-amd64-1.11.3-5ed08c47 - cp geth ../bin - - - name: Build lighthouse from source - run: | - cd eth-testnet-runner - git clone https://github.com/sigp/lighthouse.git - cd lighthouse - git checkout 38514c07f222ff7783834c48cf5c0a6ee7f346d0 - cargo +nightly build -p lighthouse --release - mv target/release/lighthouse ../bin - - - name: Install go - uses: actions/setup-go@v3 - with: - go-version: "stable" - - - name: check go version - run: go version - - - name: Clone eth2-val-tools repository - run: | - git clone https://github.com/protolambda/eth2-val-tools.git - cd eth2-val-tools - git checkout 4bf01453537ad1a9323c7cd99afc4f8ba2a420b1 - - - name: build eth2-val-tools and move binary to eth-testnet-runner bin folder - run: | - cd eth2-val-tools - go build - cp eth2-val-tools ../eth-testnet-runner/bin - - # Make $UID available to the justfile - - name: set UID env variable as a local justfile variable - run: | - cd eth-testnet-runner - sed -i 's/$UID/{{UID}}/' justfile - sed -i 's/^NOW := `date +%s`/NOW := `date +%s`\nUID := "${{ env.TUID }}"/' justfile - - - name: install just - run: | - cargo install just - - - name: modify testnet config values - run: | - cd eth-testnet-runner/testnet-config - sed -i 's/GENESIS_FORK_VERSION=.*/GENESIS_FORK_VERSION="0x00000000"/' values.env - sed -i 's/ALTAIR_FORK_VERSION=.*/ALTAIR_FORK_VERSION="0x01000000"/' values.env - sed -i 's/BELLATRIX_FORK_VERSION=.*/BELLATRIX_FORK_VERSION="0x02000000"/' values.env - sed -i 's/CAPELLA_FORK_VERSION=.*/CAPELLA_FORK_VERSION="0x03000000"/' values.env - sed -i 's/EIP4844_FORK_VERSION=.*/EIP4844_FORK_VERSION="0x04000000"/' values.env - - - name: remove tty flag from docker command in create-config recipe - run: | - cd eth-testnet-runner - sed -i 's/-it/-i/' justfile - - - name: run create-config - run: | - cd eth-testnet-runner - just create-config & ../scripts/wait_for_tcp_port_opening.sh localhost 8000 - - - name: set shanghaiTime - run: | - cd eth-testnet-runner/config-data/custom_config_data - sed -i 's/"shanghaiTime":.*/"shanghaiTime": 167119236847838392/' genesis.json - - - name: Set MIN_GENESIS_TIME - run: | - cd eth-testnet-runner/config-data/custom_config_data/ - sed -i 's/^MIN_GENESIS_TIME:.*/MIN_GENESIS_TIME: 1678876062/' config.yaml - - - name: run generate-keys - run: | - cd eth-testnet-runner - just generate-keys - - - name: run init-geth - run: | - cd eth-testnet-runner - just init-geth - - - name: run run-el - run: | - cd eth-testnet-runner - just run-el & ../scripts/wait_for_tcp_port_opening.sh localhost 8545 - - - name: run run-cl - run: | - cd eth-testnet-runner - just run-cl & ../scripts/wait_for_tcp_port_opening.sh localhost 5052 - - - name: run run-validator + - name: Clone eth-pos-devnet repository run: | - cd eth-testnet-runner - just run-validator & ../scripts/wait_for_tcp_port_opening.sh localhost 5062 + git clone https://github.com/polytope-labs/eth-pos-devnet.git + cd eth-pos-devnet + docker compose up & + ../scripts/wait_for_tcp_port_opening.sh localhost 3500 + ../scripts/wait_for_tcp_port_opening.sh localhost 8545 - name: Run all tests run: | diff --git a/Cargo.lock b/Cargo.lock index c7cd1afab..00e32893f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,24 +3,13 @@ version = 3 [[package]] -name = "actix-macros" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" -dependencies = [ - "quote", - "syn 2.0.28", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" +name = "Inflector" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" dependencies = [ - "actix-macros", - "futures-core", - "tokio", + "lazy_static", + "regex", ] [[package]] @@ -38,6 +27,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.8.3" @@ -59,21 +59,137 @@ dependencies = [ ] [[package]] -name = "amcl" -version = "0.3.0" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] -name = "anyhow" -version = "1.0.72" +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] [[package]] -name = "arrayref" -version = "0.3.7" +name = "array-init" +version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" +dependencies = [ + "nodrop", +] [[package]] name = "arrayvec" @@ -87,6 +203,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3419eecc9f5967e6f0f29a0c3fefe22bda6ea34b15798f3c452cb81f2c3fa7" +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -109,6 +234,40 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "async-trait" +version = "0.1.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version", +] + +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -132,9 +291,9 @@ dependencies = [ [[package]] name = "base16ct" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base2" @@ -163,6 +322,27 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -205,11 +385,32 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bls_on_arkworks" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc35f5286b3fa350a0a77df5166c034c5a12dc4a3ee13bf2126ac9e9109ef8e" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "hkdf", + "hmac", + "libm", + "sha2 0.10.7", +] + [[package]] name = "bs58" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "sha2 0.10.7", + "tinyvec", +] [[package]] name = "bumpalo" @@ -234,147 +435,435 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] [[package]] -name = "cc" -version = "1.0.82" +name = "bzip2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" dependencies = [ + "bzip2-sys", "libc", ] [[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "const-oid" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" - -[[package]] -name = "core-foundation" -version = "0.9.3" +name = "bzip2-sys" +version = "0.1.11+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" dependencies = [ - "core-foundation-sys", + "cc", "libc", + "pkg-config", ] [[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "core2" -version = "0.4.0" +name = "camino" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ - "memchr", + "serde", ] [[package]] -name = "cpufeatures" -version = "0.2.9" +name = "cargo-platform" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ - "libc", + "serde", ] [[package]] -name = "crypto-bigint" -version = "0.4.9" +name = "cargo_metadata" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", ] [[package]] -name = "crypto-common" -version = "0.1.6" +name = "cc" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" dependencies = [ - "generic-array", - "typenum", + "jobserver", + "libc", ] [[package]] -name = "data-encoding" -version = "2.4.0" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "der" -version = "0.6.1" +name = "chrono" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "d87d9d13be47a5b7c3907137f1290b0459a7f80efb26be8c52afb11963bccb02" dependencies = [ - "const-oid", - "zeroize", + "num-traits", ] [[package]] -name = "digest" -version = "0.9.0" +name = "cipher" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] -name = "digest" -version = "0.10.7" +name = "coins-bip32" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" dependencies = [ - "block-buffer 0.10.4", - "crypto-common", - "subtle", + "bs58", + "coins-core", + "digest 0.10.7", + "hmac", + "k256", + "serde", + "sha2 0.10.7", + "thiserror", ] [[package]] -name = "ecdsa" -version = "0.14.8" +name = "coins-bip39" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" dependencies = [ - "der", - "elliptic-curve", - "rfc6979", - "signature", + "bitvec", + "coins-bip32", + "hmac", + "once_cell", + "pbkdf2 0.12.2", + "rand", + "sha2 0.10.7", + "thiserror", ] [[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" +name = "coins-core" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base16ct", - "crypto-bigint", - "der", + "base64 0.21.2", + "bech32", + "bs58", + "digest 0.10.7", + "generic-array", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2 0.10.7", + "sha3", + "thiserror", +] + +[[package]] +name = "const-hex" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849ed393c907c90016652a01465a12d86361cd38ad2a7de026c56a520cc259" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "serde", +] + +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "data-encoding" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct", + "crypto-bigint", "digest 0.10.7", "ff", "generic-array", @@ -386,6 +875,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ena" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +dependencies = [ + "log", +] + [[package]] name = "encoding_rs" version = "0.8.32" @@ -396,107 +894,434 @@ dependencies = [ ] [[package]] -name = "enr" -version = "0.6.2" +name = "enr" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" +dependencies = [ + "base64 0.21.2", + "bytes", + "hex", + "k256", + "log", + "rand", + "rlp", + "serde", + "serde-hex", + "sha3", + "zeroize", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "eth-keystore" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" +dependencies = [ + "aes", + "ctr", + "digest 0.10.7", + "hex", + "hmac", + "pbkdf2 0.11.0", + "rand", + "scrypt", + "serde", + "serde_json", + "sha2 0.10.7", + "sha3", + "thiserror", + "uuid", +] + +[[package]] +name = "ethabi" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3", + "thiserror", + "uint", +] + +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "primitive-types", + "scale-info", + "uint", +] + +[[package]] +name = "ethers" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba3fd516c15a9a587135229466dbbfc85796de55c5660afbbb1b1c78517d85c" +dependencies = [ + "ethers-addressbook", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-middleware", + "ethers-providers", + "ethers-signers", + "ethers-solc", +] + +[[package]] +name = "ethers-addressbook" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0245617f11b8178fa50b52e433e2c34ac69f39116b62c8be2437decf2edf1986" +dependencies = [ + "ethers-core", + "once_cell", + "serde", + "serde_json", +] + +[[package]] +name = "ethers-contract" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bb80fd2c22631a5eb8a02cbf373cc5fd86937fc966bb670b9a884580c8e71c" +dependencies = [ + "const-hex", + "ethers-contract-abigen", + "ethers-contract-derive", + "ethers-core", + "ethers-providers", + "futures-util", + "once_cell", + "pin-project", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "ethers-contract-abigen" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22c54db0d393393e732a5b20273e4f8ab89f0cce501c84e75fab9c126799a6e6" +dependencies = [ + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "ethers-etherscan", + "eyre", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "reqwest", + "serde", + "serde_json", + "syn 2.0.28", + "toml 0.7.6", + "walkdir", +] + +[[package]] +name = "ethers-contract-derive" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ee4f216184a1304b707ed258f4f70aa40bf7e1522ab8963d127a8d516eaa1a" +dependencies = [ + "Inflector", + "const-hex", + "ethers-contract-abigen", + "ethers-core", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.28", +] + +[[package]] +name = "ethers-core" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c29523f73c12753165781c6e5dc11c84d3e44c080a15f7c6cfbd70b514cb6f1" +dependencies = [ + "arrayvec", + "bytes", + "cargo_metadata", + "chrono", + "const-hex", + "elliptic-curve", + "ethabi", + "generic-array", + "k256", + "num_enum", + "once_cell", + "open-fastrlp", + "rand", + "rlp", + "serde", + "serde_json", + "strum", + "syn 2.0.28", + "tempfile", + "thiserror", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "ethers-etherscan" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aab5af432b3fe5b7756b60df5c9ddeb85a13414575ad8a9acd707c24f0a77a5" +dependencies = [ + "ethers-core", + "reqwest", + "semver", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "ethers-middleware" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356151d5ded56d4918146366abc9dfc9df367cf0096492a7a5477b21b7693615" +dependencies = [ + "async-trait", + "auto_impl", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-providers", + "ethers-signers", + "futures-channel", + "futures-locks", + "futures-util", + "instant", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", +] + +[[package]] +name = "ethers-providers" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c84664b294e47fc2860d6db0db0246f79c4c724e552549631bb9505b834bee" +dependencies = [ + "async-trait", + "auto_impl", + "base64 0.21.2", + "bytes", + "const-hex", + "enr", + "ethers-core", + "futures-channel", + "futures-core", + "futures-timer", + "futures-util", + "hashers", + "http", + "instant", + "jsonwebtoken", + "once_cell", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-tungstenite", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "ws_stream_wasm", +] + +[[package]] +name = "ethers-signers" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fa0a0be8915790626d5759eb51fe47435a8eac92c2f212bd2da9aa7f30ea56" +checksum = "170b299698702ef1f53d2275af7d6d97409cfa4f9398ee9ff518f6bc9102d0ad" dependencies = [ - "base64 0.13.1", - "bs58", - "bytes", - "hex", - "k256", - "log", + "async-trait", + "coins-bip32", + "coins-bip39", + "const-hex", + "elliptic-curve", + "eth-keystore", + "ethers-core", "rand", - "rlp", - "serde", - "sha3", - "zeroize", + "sha2 0.10.7", + "thiserror", + "tracing", ] [[package]] -name = "env_logger" -version = "0.10.0" +name = "ethers-solc" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "66559c8f774712df303c907d087275a52a2046b256791aaa566d5abc8ea66731" dependencies = [ - "humantime", - "is-terminal", - "log", + "cfg-if", + "const-hex", + "dirs", + "dunce", + "ethers-core", + "glob", + "home", + "md-5", + "num_cpus", + "once_cell", + "path-slash", + "rayon", "regex", - "termcolor", + "semver", + "serde", + "serde_json", + "solang-parser", + "svm-rs", + "thiserror", + "tiny-keccak", + "tokio", + "tracing", + "walkdir", + "yansi", ] [[package]] -name = "errno" -version = "0.3.2" +name = "eyre" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", + "indenter", + "once_cell", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "fastrand" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] -name = "error-chain" -version = "0.12.4" +name = "ff" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "backtrace", - "version_check", + "rand_core", + "subtle", ] [[package]] -name = "ethereum-consensus" -version = "0.1.1" -source = "git+https://github.com/polytope-labs/ethereum-consensus?branch=main#48335b5c8074d63553ee4681993e294eba947f88" +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "async-stream", - "bs58", - "enr", - "error-chain", - "hashbrown 0.13.2", - "hex", - "integer-sqrt", - "milagro_bls", - "multiaddr", - "multihash", + "byteorder", "rand", - "serde", - "serde_json", - "serde_yaml", - "sha2 0.9.9", - "ssz-rs", - "tokio", - "tokio-stream", + "rustc-hex", + "static_assertions", ] [[package]] -name = "fastrand" -version = "2.0.0" +name = "fixedbitset" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] -name = "ff" -version = "0.12.1" +name = "flate2" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ - "rand_core", - "subtle", + "crc32fast", + "miniz_oxide", ] [[package]] @@ -529,12 +1354,37 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.28" @@ -542,6 +1392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -550,6 +1401,44 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +[[package]] +name = "futures-executor" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", +] + +[[package]] +name = "futures-macro" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "futures-sink" version = "0.3.28" @@ -562,16 +1451,41 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] + [[package]] name = "futures-util" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", ] [[package]] @@ -582,6 +1496,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -601,11 +1516,29 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core", @@ -624,7 +1557,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -646,6 +1579,27 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.2" @@ -664,6 +1618,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -673,6 +1636,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "http" version = "0.2.9" @@ -737,6 +1709,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -760,41 +1746,93 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + [[package]] name = "impl-trait-for-tuples" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "equivalent", + "hashbrown 0.14.0", ] [[package]] -name = "indexmap" -version = "1.9.3" +name = "inout" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "generic-array", ] [[package]] -name = "int" -version = "0.3.0" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "num-traits", + "cfg-if", ] [[package]] -name = "integer-sqrt" -version = "0.1.5" +name = "int" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +checksum = "9d64bb35c7fc709fa8934dd85f3d0c0e418a3b067e62e6c6041dd19519c0899b" dependencies = [ "num-traits", ] @@ -831,6 +1869,15 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.64" @@ -840,16 +1887,32 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.2", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "k256" -version = "0.11.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", + "once_cell", "sha2 0.10.7", + "signature", ] [[package]] @@ -861,6 +1924,34 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "lalrpop" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da4081d44f4611b66c6dd725e6de3169f9f63905421e8626fcb86b6a898998b8" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f35c735096c0293d313e8f2a641627472b83d01b937177fe76e5e2708d31e0d" + [[package]] name = "lazy_static" version = "1.4.0" @@ -874,10 +1965,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] -name = "linked-hash-map" -version = "0.5.6" +name = "libm" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "linux-raw-sys" @@ -901,6 +1992,21 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "md-5" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "memchr" version = "2.5.0" @@ -908,15 +2014,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] -name = "milagro_bls" -version = "1.5.1" -source = "git+https://github.com/sigp/milagro_bls#d3fc0a40cfe8b72ccda46ba050ee6786a59ce753" +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ - "amcl", - "hex", - "lazy_static", - "rand", - "zeroize", + "autocfg", ] [[package]] @@ -945,51 +2048,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "multiaddr" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c580bfdd8803cce319b047d239559a22f809094aaea4ac13902a1fdcfcd4261" -dependencies = [ - "arrayref", - "bs58", - "byteorder", - "data-encoding", - "multihash", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - -[[package]] -name = "multihash" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" -dependencies = [ - "core2", - "digest 0.10.7", - "multihash-derive", - "sha2 0.10.7", - "unsigned-varint", -] - -[[package]] -name = "multihash-derive" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -1008,6 +2066,18 @@ dependencies = [ "tempfile", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "num-bigint" version = "0.4.3" @@ -1048,6 +2118,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "object" version = "0.31.1" @@ -1069,6 +2160,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", + "ethereum-types", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "openssl" version = "0.10.56" @@ -1102,71 +2218,222 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] -name = "openssl-sys" -version = "0.9.91" +name = "openssl-sys" +version = "0.9.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "parity-scale-codec" +version = "3.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec 1.11.0", + "windows-targets", +] + +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "path-slash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", + "hmac", + "password-hash", + "sha2 0.10.7", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac", +] + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.0", +] + +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version", +] + +[[package]] +name = "phf" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", + "phf_macros", + "phf_shared 0.11.2", ] [[package]] -name = "parity-scale-codec" -version = "3.6.4" +name = "phf_generator" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", + "phf_shared 0.11.2", + "rand", ] [[package]] -name = "parity-scale-codec-derive" -version = "3.6.4" +name = "phf_macros" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" dependencies = [ - "proc-macro-crate", + "phf_generator", + "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.28", ] [[package]] -name = "parking_lot" -version = "0.12.1" +name = "phf_shared" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" dependencies = [ - "lock_api", - "parking_lot_core", + "siphasher", ] [[package]] -name = "parking_lot_core" -version = "0.9.8" +name = "phf_shared" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", + "siphasher", ] [[package]] -name = "percent-encoding" -version = "2.3.0" +name = "pin-project" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] [[package]] name = "pin-project-lite" @@ -1182,9 +2449,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -1202,6 +2469,36 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "prettyplease" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +dependencies = [ + "proc-macro2", + "syn 2.0.28", +] + +[[package]] +name = "primitive-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "scale-info", + "uint", +] + [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -1209,7 +2506,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", - "toml", + "toml 0.5.11", ] [[package]] @@ -1290,6 +2587,37 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -1299,6 +2627,17 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regex" version = "1.9.3" @@ -1330,9 +2669,9 @@ checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ "base64 0.21.2", "bytes", @@ -1343,6 +2682,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -1352,28 +2692,55 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.2", "winreg", ] [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint", "hmac", - "zeroize", + "subtle", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", ] [[package]] @@ -1383,9 +2750,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", + "rlp-derive", "rustc-hex", ] +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1398,6 +2777,15 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.8" @@ -1411,12 +2799,101 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustls" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +dependencies = [ + "log", + "ring", + "rustls-webpki 0.101.4", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.2", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scale-info" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +dependencies = [ + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "schannel" version = "0.1.22" @@ -1432,11 +2909,33 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac", + "pbkdf2 0.11.0", + "salsa20", + "sha2 0.10.7", +] + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sec1" -version = "0.3.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", @@ -1469,20 +2968,52 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +dependencies = [ + "serde", +] + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" -version = "1.0.183" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-hex" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca37e3e4d1b39afd7ff11ee4e947efae85adfddf4841787bfa47c470e96dc26d" +dependencies = [ + "array-init", + "serde", + "smallvec 0.6.14", +] + [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -1500,6 +3031,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1513,15 +3053,14 @@ dependencies = [ ] [[package]] -name = "serde_yaml" -version = "0.8.26" +name = "sha1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ - "indexmap", - "ryu", - "serde", - "yaml-rust", + "cfg-if", + "cpufeatures", + "digest 0.10.7", ] [[package]] @@ -1559,31 +3098,49 @@ dependencies = [ ] [[package]] -name = "signal-hook-registry" -version = "1.4.1" +name = "signature" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ - "libc", + "digest 0.10.7", + "rand_core", ] [[package]] -name = "signature" -version = "1.6.4" +name = "simple_asn1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" dependencies = [ - "digest 0.10.7", - "rand_core", + "num-bigint", + "num-traits", + "thiserror", + "time", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" dependencies = [ - "autocfg", + "maybe-uninit", ] [[package]] @@ -1612,11 +3169,31 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "solang-parser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c792fe9fae2a2f716846f214ca10d5a1e21133e0bf36cef34bcc4a852467b21" +dependencies = [ + "itertools", + "lalrpop", + "lalrpop-util", + "phf", + "thiserror", + "unicode-xid", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spki" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", "der", @@ -1625,13 +3202,14 @@ dependencies = [ [[package]] name = "ssz-rs" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#96f9a89ccc56ab2abb4c3a83eaedb415034ada49" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#81e9f63c93ca33f5f484ac301553f04912f2de23" dependencies = [ "as-any", "bitvec", "hex", "itertools", "num-bigint", + "parity-scale-codec", "serde", "sha2 0.9.9", "ssz-rs-derive", @@ -1640,7 +3218,7 @@ dependencies = [ [[package]] name = "ssz-rs-derive" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#96f9a89ccc56ab2abb4c3a83eaedb415034ada49" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#81e9f63c93ca33f5f484ac301553f04912f2de23" dependencies = [ "proc-macro2", "quote", @@ -1653,12 +3231,67 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.28", +] + [[package]] name = "subtle" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "svm-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597e3a746727984cb7ea2487b6a40726cad0dbe86628e7d429aa6b8c4c153db4" +dependencies = [ + "dirs", + "fs2", + "hex", + "once_cell", + "reqwest", + "semver", + "serde", + "serde_json", + "sha2 0.10.7", + "thiserror", + "url", + "zip", +] + [[package]] name = "syn" version = "1.0.109" @@ -1685,9 +3318,15 @@ dependencies = [ name = "sync-committee-primitives" version = "0.1.0" dependencies = [ - "ethereum-consensus", + "anyhow", + "ark-bls12-381", + "ark-ec", + "bls_on_arkworks", + "hex", "hex-literal", "parity-scale-codec", + "primitive-types", + "serde", "ssz-rs", ] @@ -1695,13 +3334,17 @@ dependencies = [ name = "sync-committee-prover" version = "0.1.0" dependencies = [ - "actix-rt", "anyhow", + "ark-bls12-381", + "ark-ec", "async-stream", "base2", + "bls_on_arkworks", "env_logger", - "ethereum-consensus", + "ethers", "hex", + "log", + "primitive-types", "reqwest", "serde", "serde_json", @@ -1716,24 +3359,16 @@ dependencies = [ name = "sync-committee-verifier" version = "0.1.0" dependencies = [ - "ethereum-consensus", + "anyhow", + "ark-bls12-381", + "ark-ec", + "bls_on_arkworks", + "hex", "log", "ssz-rs", "sync-committee-primitives", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "tap" version = "1.0.1" @@ -1742,17 +3377,28 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", "windows-sys", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "termcolor" version = "1.2.0" @@ -1782,6 +3428,43 @@ dependencies = [ "syn 2.0.28", ] +[[package]] +name = "time" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +dependencies = [ + "deranged", + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +dependencies = [ + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -1799,18 +3482,16 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.31.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ "backtrace", "bytes", "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2 0.5.3", "tokio-macros", "windows-sys", @@ -1837,6 +3518,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + [[package]] name = "tokio-stream" version = "0.1.14" @@ -1848,6 +3539,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" +dependencies = [ + "futures-util", + "log", + "rustls", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots 0.23.1", +] + [[package]] name = "tokio-util" version = "0.7.8" @@ -1871,6 +3577,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -1885,9 +3625,21 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -1897,18 +3649,60 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "try-lock" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "tungstenite" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e862a1c4128df0112ab625f55cd5c934bcb4312ba80b39ae4b4835a3fd58e649" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "rustls", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -1937,10 +3731,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] -name = "unsigned-varint" +name = "untrusted" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" @@ -1953,6 +3747,22 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -1965,6 +3775,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -2056,6 +3876,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki 0.100.2", +] + +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "winapi" version = "0.3.9" @@ -2153,13 +3988,42 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winnow" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys", +] + +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", ] [[package]] @@ -2172,16 +4036,77 @@ dependencies = [ ] [[package]] -name = "yaml-rust" -version = "0.4.5" +name = "yansi" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2 0.11.0", + "sha1", + "time", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.8+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +dependencies = [ + "cc", + "libc", + "pkg-config", +] diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index b5af4614e..f80ade770 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -6,17 +6,31 @@ authors = ["Polytope Labs"] [dependencies] -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main", default-features = false } hex-literal = { package = "hex-literal", version = "0.4.1", default-features = false } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive" ] } +primitive-types = { version = "0.12.1", default-features = false, features = ["serde_no_std", "impl-codec"] } +serde = { version = "1.0.185", optional = true, features = ["derive"] } +hex = { version = "0.4.3", default-features = false, features = ["alloc"] } +anyhow = {version = "1.0.75", default-features = false} +ark-ec = { version = "0.4.2", default-features = false } +ark-bls12-381 = { version = "0.4.0", default-features = false } +bls_on_arkworks = { version = "0.2.2", default-features = false } [features] default = ["std"] std = [ - "ssz-rs/std", - 'codec/std' + "ssz-rs/default", + 'codec/std', + "primitive-types/std", + "anyhow/std", + "ark-ec/std", + "bls_on_arkworks/std", + "ark-bls12-381/std", + "primitive-types/std", + "serde" ] -testing = [] +mainnet = [] +testnet = [] diff --git a/primitives/src/consensus_types.rs b/primitives/src/consensus_types.rs new file mode 100644 index 000000000..52d4af5f1 --- /dev/null +++ b/primitives/src/consensus_types.rs @@ -0,0 +1,406 @@ +use crate::{ + constants::{ + BlsPublicKey, BlsSignature, Bytes32, Epoch, ExecutionAddress, Gwei, Hash32, + ParticipationFlags, Root, Slot, ValidatorIndex, Version, WithdrawalIndex, + DEPOSIT_PROOF_LENGTH, JUSTIFICATION_BITS_LENGTH, + }, + ssz::{ByteList, ByteVector}, +}; +use alloc::{vec, vec::Vec}; +use ssz_rs::{prelude::*, Deserialize, List, Vector}; + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct BeaconBlockHeader { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub slot: u64, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub proposer_index: u64, + pub parent_root: Root, + pub state_root: Root, + pub body_root: Root, +} + +#[derive(Default, Clone, Debug, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Checkpoint { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub epoch: u64, + pub root: Root, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Eth1Data { + pub deposit_root: Root, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub deposit_count: u64, + pub block_hash: Hash32, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Validator { + #[cfg_attr(feature = "std", serde(rename = "pubkey"))] + pub public_key: BlsPublicKey, + pub withdrawal_credentials: Bytes32, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub effective_balance: Gwei, + pub slashed: bool, + // Status epochs + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub activation_eligibility_epoch: Epoch, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub activation_epoch: Epoch, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub exit_epoch: Epoch, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub withdrawable_epoch: Epoch, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ProposerSlashing { + pub signed_header_1: SignedBeaconBlockHeader, + pub signed_header_2: SignedBeaconBlockHeader, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct SignedBeaconBlockHeader { + pub message: BeaconBlockHeader, + pub signature: BlsSignature, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct IndexedAttestation { + #[cfg_attr(feature = "std", serde(with = "crate::serde::collection_over_string"))] + pub attesting_indices: List, + pub data: AttestationData, + pub signature: BlsSignature, +} + +#[derive(Default, Clone, Debug, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct AttestationData { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub slot: u64, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub index: u64, + pub beacon_block_root: Root, + pub source: Checkpoint, + pub target: Checkpoint, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct AttesterSlashing { + pub attestation_1: IndexedAttestation, + pub attestation_2: IndexedAttestation, +} + +#[derive(Default, Debug, SimpleSerialize, codec::Encode, codec::Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Attestation { + pub aggregation_bits: Bitlist, + pub data: AttestationData, + pub signature: BlsSignature, +} + +#[derive(Default, Debug, SimpleSerialize, codec::Encode, codec::Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Deposit { + pub proof: Vector, + pub data: DepositData, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, codec::Encode, codec::Decode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct DepositData { + #[cfg_attr(feature = "std", serde(rename = "pubkey"))] + pub public_key: BlsPublicKey, + pub withdrawal_credentials: Hash32, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub amount: u64, + pub signature: BlsSignature, +} + +#[derive(Default, Debug, SimpleSerialize, codec::Encode, codec::Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct VoluntaryExit { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub epoch: u64, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub validator_index: u64, +} + +#[derive(Default, Debug, SimpleSerialize, codec::Encode, codec::Decode, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct SignedVoluntaryExit { + pub message: VoluntaryExit, + pub signature: BlsSignature, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, codec::Encode, codec::Decode, PartialEq, Eq)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct SyncAggregate { + pub sync_committee_bits: Bitvector, + pub sync_committee_signature: BlsSignature, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct SyncCommittee { + #[cfg_attr(feature = "std", serde(rename = "pubkeys"))] + pub public_keys: Vector, + #[cfg_attr(feature = "std", serde(rename = "aggregate_pubkey"))] + pub aggregate_public_key: BlsPublicKey, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Withdrawal { + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub index: WithdrawalIndex, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub validator_index: ValidatorIndex, + pub address: ExecutionAddress, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub amount: Gwei, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct BlsToExecutionChange { + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub validator_index: ValidatorIndex, + #[cfg_attr(feature = "serde", serde(rename = "from_bls_pubkey"))] + pub from_bls_public_key: BlsPublicKey, + pub to_execution_address: ExecutionAddress, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct SignedBlsToExecutionChange { + message: BlsToExecutionChange, + signature: BlsSignature, +} + +pub type Transaction = ByteList; + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ExecutionPayload< + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, + const MAX_BYTES_PER_TRANSACTION: usize, + const MAX_TRANSACTIONS_PER_PAYLOAD: usize, + const MAX_WITHDRAWALS_PER_PAYLOAD: usize, +> { + pub parent_hash: Hash32, + pub fee_recipient: ExecutionAddress, + pub state_root: Bytes32, + pub receipts_root: Bytes32, + pub logs_bloom: ByteVector, + pub prev_randao: Bytes32, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub block_number: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub gas_limit: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub gas_used: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub timestamp: u64, + pub extra_data: ByteList, + pub base_fee_per_gas: U256, + pub block_hash: Hash32, + pub transactions: List, MAX_TRANSACTIONS_PER_PAYLOAD>, + pub withdrawals: List, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ExecutionPayloadHeader< + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, +> { + pub parent_hash: Hash32, + pub fee_recipient: ExecutionAddress, + pub state_root: Bytes32, + pub receipts_root: Bytes32, + pub logs_bloom: ByteVector, + pub prev_randao: Bytes32, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub block_number: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub gas_limit: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub gas_used: u64, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub timestamp: u64, + pub extra_data: ByteList, + pub base_fee_per_gas: U256, + pub block_hash: Hash32, + pub transactions_root: Root, + pub withdrawals_root: Root, +} + +#[derive(Default, Debug, Clone, SimpleSerialize, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct BeaconBlockBody< + const MAX_PROPOSER_SLASHINGS: usize, + const MAX_VALIDATORS_PER_COMMITTEE: usize, + const MAX_ATTESTER_SLASHINGS: usize, + const MAX_ATTESTATIONS: usize, + const MAX_DEPOSITS: usize, + const MAX_VOLUNTARY_EXITS: usize, + const SYNC_COMMITTEE_SIZE: usize, + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, + const MAX_BYTES_PER_TRANSACTION: usize, + const MAX_TRANSACTIONS_PER_PAYLOAD: usize, + const MAX_WITHDRAWALS_PER_PAYLOAD: usize, + const MAX_BLS_TO_EXECUTION_CHANGES: usize, +> { + pub randao_reveal: BlsSignature, + pub eth1_data: Eth1Data, + pub graffiti: Bytes32, + pub proposer_slashings: List, + pub attester_slashings: + List, MAX_ATTESTER_SLASHINGS>, + pub attestations: List, MAX_ATTESTATIONS>, + pub deposits: List, + pub voluntary_exits: List, + pub sync_aggregate: SyncAggregate, + pub execution_payload: ExecutionPayload< + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_WITHDRAWALS_PER_PAYLOAD, + >, + pub bls_to_execution_changes: List, +} + +#[derive(Default, Debug, Clone, PartialEq, Eq, SimpleSerialize, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct BeaconBlock< + const MAX_PROPOSER_SLASHINGS: usize, + const MAX_VALIDATORS_PER_COMMITTEE: usize, + const MAX_ATTESTER_SLASHINGS: usize, + const MAX_ATTESTATIONS: usize, + const MAX_DEPOSITS: usize, + const MAX_VOLUNTARY_EXITS: usize, + const SYNC_COMMITTEE_SIZE: usize, + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, + const MAX_BYTES_PER_TRANSACTION: usize, + const MAX_TRANSACTIONS_PER_PAYLOAD: usize, + const MAX_WITHDRAWALS_PER_PAYLOAD: usize, + const MAX_BLS_TO_EXECUTION_CHANGES: usize, +> { + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub slot: Slot, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub proposer_index: ValidatorIndex, + pub parent_root: Root, + pub state_root: Root, + pub body: BeaconBlockBody< + MAX_PROPOSER_SLASHINGS, + MAX_VALIDATORS_PER_COMMITTEE, + MAX_ATTESTER_SLASHINGS, + MAX_ATTESTATIONS, + MAX_DEPOSITS, + MAX_VOLUNTARY_EXITS, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + MAX_BYTES_PER_TRANSACTION, + MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_WITHDRAWALS_PER_PAYLOAD, + MAX_BLS_TO_EXECUTION_CHANGES, + >, +} +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct Fork { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_hex"))] + pub previous_version: Version, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_hex"))] + pub current_version: Version, + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_string"))] + pub epoch: Epoch, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ForkData { + #[cfg_attr(feature = "std", serde(with = "crate::serde::as_hex"))] + pub current_version: Version, + pub genesis_validators_root: Root, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct HistoricalSummary { + pub block_summary_root: Root, + pub state_summary_root: Root, +} + +#[derive(Default, Debug, SimpleSerialize, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct BeaconState< + const SLOTS_PER_HISTORICAL_ROOT: usize, + const HISTORICAL_ROOTS_LIMIT: usize, + const ETH1_DATA_VOTES_BOUND: usize, + const VALIDATOR_REGISTRY_LIMIT: usize, + const EPOCHS_PER_HISTORICAL_VECTOR: usize, + const EPOCHS_PER_SLASHINGS_VECTOR: usize, + const MAX_VALIDATORS_PER_COMMITTEE: usize, + const SYNC_COMMITTEE_SIZE: usize, + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, + const MAX_BYTES_PER_TRANSACTION: usize, + const MAX_TRANSACTIONS_PER_PAYLOAD: usize, +> { + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub genesis_time: u64, + pub genesis_validators_root: Root, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub slot: Slot, + pub fork: Fork, + pub latest_block_header: BeaconBlockHeader, + pub block_roots: Vector, + pub state_roots: Vector, + pub historical_roots: List, + pub eth1_data: Eth1Data, + pub eth1_data_votes: List, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub eth1_deposit_index: u64, + pub validators: List, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::collection_over_string"))] + pub balances: List, + pub randao_mixes: Vector, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::collection_over_string"))] + pub slashings: Vector, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::collection_over_string"))] + pub previous_epoch_participation: List, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::collection_over_string"))] + pub current_epoch_participation: List, + pub justification_bits: Bitvector, + pub previous_justified_checkpoint: Checkpoint, + pub current_justified_checkpoint: Checkpoint, + pub finalized_checkpoint: Checkpoint, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::collection_over_string"))] + pub inactivity_scores: List, + pub current_sync_committee: SyncCommittee, + pub next_sync_committee: SyncCommittee, + pub latest_execution_payload_header: + ExecutionPayloadHeader, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub next_withdrawal_index: WithdrawalIndex, + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_string"))] + pub next_withdrawal_validator_index: ValidatorIndex, + pub historical_summaries: List, +} diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs new file mode 100644 index 000000000..df7a0247e --- /dev/null +++ b/primitives/src/constants.rs @@ -0,0 +1,138 @@ +use crate::domains::DomainType; +use ssz_rs::Node; + +pub type BlsPublicKey = ByteVector; +pub type BlsSignature = ByteVector; + +pub type Epoch = u64; +pub type Slot = u64; +pub type Root = Node; +pub type ParticipationFlags = u8; + +pub type CommitteeIndex = u64; +pub type ValidatorIndex = u64; +pub type WithdrawalIndex = u64; +pub type Gwei = u64; +pub type Hash32 = Bytes32; + +pub type Version = [u8; 4]; +pub type ForkDigest = [u8; 4]; +pub type Domain = [u8; 32]; + +pub type ExecutionAddress = ByteVector<20>; + +pub type ChainId = usize; +pub type NetworkId = usize; + +pub type RandaoReveal = BlsSignature; +pub type Bytes32 = ByteVector<32>; + +pub const BLS_PUBLIC_KEY_BYTES_LEN: usize = 48; +pub const BLS_SECRET_KEY_BYTES_LEN: usize = 32; +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_VALIDATORS_PER_COMMITTEE: usize = 2048; +pub const EPOCHS_PER_ETH1_VOTING_PERIOD: Epoch = 64; +pub const SLOTS_PER_HISTORICAL_ROOT: usize = 8192; +pub const EPOCHS_PER_HISTORICAL_VECTOR: usize = 65536; +pub const EPOCHS_PER_SLASHINGS_VECTOR: usize = 8192; +pub const HISTORICAL_ROOTS_LIMIT: usize = 16_777_216; +pub const VALIDATOR_REGISTRY_LIMIT: usize = 2usize.saturating_pow(40); +pub const MAX_PROPOSER_SLASHINGS: usize = 16; +pub const MAX_ATTESTER_SLASHINGS: usize = 2; +pub const MAX_ATTESTATIONS: usize = 128; +pub const MAX_DEPOSITS: usize = 16; +pub const MAX_VOLUNTARY_EXITS: usize = 16; +pub const JUSTIFICATION_BITS_LENGTH: usize = 4; + +pub const MAX_BYTES_PER_TRANSACTION: usize = 1_073_741_824; +pub const MAX_TRANSACTIONS_PER_PAYLOAD: usize = 1_048_576; +pub const BYTES_PER_LOGS_BLOOM: usize = 256; +pub const MAX_EXTRA_DATA_BYTES: usize = 32; + +pub const DEPOSIT_PROOF_LENGTH: usize = 33; + +pub const ETH1_DATA_VOTES_BOUND: usize = (EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH) as usize; +pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; +pub const FINALIZED_ROOT_INDEX: u64 = 52; +pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; +pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; +pub const EXECUTION_PAYLOAD_INDEX: u64 = 56; +pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; +pub const BLOCK_ROOTS_INDEX: u64 = 37; +pub const HISTORICAL_ROOTS_INDEX: u64 = 39; +pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; +pub const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 25; +pub const FINALIZED_ROOT_INDEX_LOG2: u64 = 5; +pub const EXECUTION_PAYLOAD_INDEX_LOG2: u64 = 5; +pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 5; +pub const BLOCK_ROOTS_INDEX_LOG2: u64 = 5; +pub const HISTORICAL_ROOTS_INDEX_LOG2: u64 = 5; + +#[cfg(feature = "testnet")] +pub use testnet::*; + +#[cfg(feature = "mainnet")] +pub use mainnet::*; + +use crate::ssz::ByteVector; +#[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))] +pub use devnet::*; + +#[cfg(feature = "testnet")] +pub mod testnet { + use super::*; + pub const SLOTS_PER_EPOCH: Slot = 32; + pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); + pub const BELLATRIX_FORK_VERSION: Version = [3, 0, 16, 32]; + pub const ALTAIR_FORK_VERSION: Version = [1, 0, 16, 32]; + pub const GENESIS_FORK_VERSION: Version = [0; 4]; + pub const ALTAIR_FORK_EPOCH: Epoch = 36660; + 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")] +pub mod mainnet { + use super::*; + pub const SLOTS_PER_EPOCH: Slot = 32; + pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); + pub const BELLATRIX_FORK_VERSION: Version = [2, 0, 0, 0]; + pub const ALTAIR_FORK_VERSION: Version = [1, 0, 0, 0]; + pub const GENESIS_FORK_VERSION: Version = [0, 0, 0, 0]; + pub const ALTAIR_FORK_EPOCH: Epoch = 74240; + 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")))] +pub mod devnet { + use super::*; + use hex_literal::hex; + pub const SLOTS_PER_EPOCH: Slot = 6; + pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = + hex_literal::hex!("83431ec7fcf92cfc44947fc0418e831c25e1d0806590231c439830db7ad54fda"); + pub const BELLATRIX_FORK_VERSION: Version = hex!("52525502"); + pub const ALTAIR_FORK_VERSION: Version = hex!("52525501"); + pub const GENESIS_FORK_VERSION: Version = hex!("52525500"); + pub const ALTAIR_FORK_EPOCH: Epoch = 0; + 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; +} diff --git a/primitives/src/derived_types.rs b/primitives/src/derived_types.rs deleted file mode 100644 index 3610e22d2..000000000 --- a/primitives/src/derived_types.rs +++ /dev/null @@ -1,488 +0,0 @@ -use crate::{ - error::Error, - helpers::{ - to_codec_light_client_state, to_codec_light_client_update, to_no_codec_beacon_header, - to_no_codec_light_client_state, to_no_codec_light_client_update, - to_no_codec_sync_committee, - }, - types, -}; -use alloc::vec::Vec; -use codec::{Decode, Encode}; -use ethereum_consensus::{bellatrix, primitives::Hash32}; - -/// Minimum state required by the light client to validate new sync committee attestations -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] -pub struct LightClientState { - /// The latest recorded finalized header - pub finalized_header: BeaconBlockHeader, - /// Latest finalized epoch - pub latest_finalized_epoch: u64, - // Sync committees corresponding to the finalized header - pub current_sync_committee: SyncCommittee, - pub next_sync_committee: SyncCommittee, -} - -impl TryFrom> - for LightClientState -{ - type Error = Error; - fn try_from(state: types::LightClientState) -> Result { - to_codec_light_client_state(state) - } -} - -impl TryFrom - for types::LightClientState -{ - type Error = Error; - fn try_from(state: LightClientState) -> Result { - to_no_codec_light_client_state(state) - } -} - -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] -pub struct BeaconBlockHeader { - pub slot: u64, - pub proposer_index: u64, - pub parent_root: [u8; 32], - pub state_root: [u8; 32], - pub body_root: [u8; 32], -} - -impl TryFrom for BeaconBlockHeader { - type Error = Error; - - fn try_from(beacon_block_header: bellatrix::BeaconBlockHeader) -> Result { - Ok(BeaconBlockHeader { - slot: beacon_block_header.slot, - proposer_index: beacon_block_header.proposer_index as u64, - parent_root: beacon_block_header - .parent_root - .as_bytes() - .try_into() - .map_err(|_| Error::InvalidNodeBytes)?, - state_root: beacon_block_header - .state_root - .as_bytes() - .try_into() - .map_err(|_| Error::InvalidNodeBytes)?, - body_root: beacon_block_header - .body_root - .as_bytes() - .try_into() - .map_err(|_| Error::InvalidNodeBytes)?, - }) - } -} - -#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, Default)] -pub struct SyncCommittee { - pub public_keys: Vec>, - pub aggregate_public_key: Vec, -} - -impl TryFrom> - for SyncCommittee -{ - type Error = Error; - - fn try_from( - sync_committee: bellatrix::SyncCommittee, - ) -> Result { - Ok(SyncCommittee { - public_keys: sync_committee - .public_keys - .iter() - .map(|public_key| public_key.to_vec()) - .collect(), - aggregate_public_key: sync_committee.aggregate_public_key.to_vec(), - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] -pub struct LightClientUpdate { - /// the header that the sync committee signed - pub attested_header: BeaconBlockHeader, - /// the sync committee has potentially changed, here's an ssz proof for that. - pub sync_committee_update: Option, - /// the actual header which was finalized by the ethereum attestation protocol. - pub finalized_header: BeaconBlockHeader, - /// execution payload of the finalized header - pub execution_payload: ExecutionPayloadProof, - /// Finalized header proof - pub finality_proof: FinalityProof, - /// signature & participation bits - pub sync_aggregate: SyncAggregate, - /// slot at which signature was produced - pub signature_slot: u64, - /// ancestors of the finalized block to be verified, may be empty. - pub ancestor_blocks: Vec, -} - -impl TryFrom> - for LightClientUpdate -{ - type Error = Error; - fn try_from( - update: types::LightClientUpdate, - ) -> Result { - to_codec_light_client_update(update) - } -} - -impl TryFrom - for types::LightClientUpdate -{ - type Error = Error; - fn try_from(derived_update: LightClientUpdate) -> Result { - to_no_codec_light_client_update(derived_update) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] -pub struct SyncCommitteeUpdate { - // actual sync committee - pub next_sync_committee: SyncCommittee, - // sync committee, ssz merkle proof. - pub next_sync_committee_branch: Vec>, -} - -impl TryFrom> - for SyncCommitteeUpdate -{ - type Error = Error; - - fn try_from( - sync_committee_update: types::SyncCommitteeUpdate, - ) -> Result { - Ok(SyncCommitteeUpdate { - next_sync_committee: sync_committee_update.next_sync_committee.try_into()?, - next_sync_committee_branch: sync_committee_update - .next_sync_committee_branch - .iter() - .map(|hash| hash.to_vec()) - .collect(), - }) - } -} - -impl TryFrom - for types::SyncCommitteeUpdate -{ - type Error = Error; - - fn try_from(sync_committee_update: SyncCommitteeUpdate) -> Result { - let next_sync_committee = - to_no_codec_sync_committee(sync_committee_update.next_sync_committee)?; - Ok(types::SyncCommitteeUpdate { - next_sync_committee, - next_sync_committee_branch: sync_committee_update - .next_sync_committee_branch - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, Error>>()?, - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] -pub struct ExecutionPayloadProof { - /// The state root in the `ExecutionPayload` which represents the commitment to - /// the ethereum world state in the yellow paper. - pub state_root: Vec, - /// the block number of the execution header. - pub block_number: u64, - /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. - pub multi_proof: Vec>, - /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. - pub execution_payload_branch: Vec>, - /// timestamp - pub timestamp: u64, -} - -impl TryFrom for ExecutionPayloadProof { - type Error = Error; - fn try_from( - execution_payload_proof: types::ExecutionPayloadProof, - ) -> Result { - Ok(ExecutionPayloadProof { - state_root: execution_payload_proof.state_root.to_vec(), - block_number: execution_payload_proof.block_number, - multi_proof: execution_payload_proof - .multi_proof - .iter() - .map(|proof| proof.to_vec()) - .collect(), - execution_payload_branch: execution_payload_proof - .execution_payload_branch - .iter() - .map(|branch| branch.to_vec()) - .collect(), - timestamp: execution_payload_proof.timestamp, - }) - } -} - -impl TryFrom for types::ExecutionPayloadProof { - type Error = Error; - fn try_from( - derived_execution_payload_proof: ExecutionPayloadProof, - ) -> Result { - let multi_proof = derived_execution_payload_proof - .multi_proof - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?; - - let execution_payload_branch = derived_execution_payload_proof - .execution_payload_branch - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?; - - Ok(types::ExecutionPayloadProof { - state_root: Hash32::try_from(derived_execution_payload_proof.state_root.as_slice()) - .map_err(|_| Error::InvalidRoot)?, - block_number: derived_execution_payload_proof.block_number, - multi_proof, - execution_payload_branch, - timestamp: derived_execution_payload_proof.timestamp, - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] -pub struct FinalityProof { - /// The latest finalized epoch - pub epoch: u64, - /// Finalized header proof - pub finality_branch: Vec>, -} - -impl TryFrom for FinalityProof { - type Error = Error; - fn try_from(finality_proof: types::FinalityProof) -> Result { - Ok(FinalityProof { - epoch: finality_proof.epoch, - finality_branch: finality_proof - .finality_branch - .iter() - .map(|branch| branch.to_vec()) - .collect(), - }) - } -} - -impl TryFrom for types::FinalityProof { - type Error = Error; - fn try_from(derived_finality_proof: FinalityProof) -> Result { - Ok(types::FinalityProof { - epoch: derived_finality_proof.epoch, - finality_branch: derived_finality_proof - .finality_branch - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?, - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default, Encode, Decode)] -pub struct SyncAggregate { - pub sync_committee_bits: Vec, - pub sync_committee_signature: Vec, -} - -impl TryFrom> - for SyncAggregate -{ - type Error = Error; - fn try_from( - sync_aggregate: bellatrix::SyncAggregate, - ) -> Result { - Ok(SyncAggregate { - sync_committee_bits: sync_aggregate.sync_committee_bits.clone().to_bitvec().into_vec(), - sync_committee_signature: sync_aggregate.sync_committee_signature.clone().to_vec(), - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] -pub struct AncestorBlock { - /// The actual beacon chain header - pub header: BeaconBlockHeader, - /// Associated execution header proofs - pub execution_payload: ExecutionPayloadProof, - /// Ancestry proofs of the beacon chain header. - pub ancestry_proof: AncestryProof, -} - -impl TryFrom for AncestorBlock { - type Error = Error; - fn try_from(ancestor_block: types::AncestorBlock) -> Result { - Ok(AncestorBlock { - header: ancestor_block.header.try_into()?, - execution_payload: ancestor_block.execution_payload.try_into()?, - ancestry_proof: ancestor_block.ancestry_proof.try_into()?, - }) - } -} - -impl TryFrom for types::AncestorBlock { - type Error = Error; - fn try_from(derived_ancestor_block: AncestorBlock) -> Result { - let beacon_block_header = to_no_codec_beacon_header(derived_ancestor_block.header)?; - Ok(types::AncestorBlock { - header: beacon_block_header, - execution_payload: derived_ancestor_block.execution_payload.try_into()?, - ancestry_proof: derived_ancestor_block.ancestry_proof.try_into()?, - }) - } -} - -/// Holds the neccessary proofs required to verify a header in the `block_roots` field -/// either in [`BeaconState`] or [`HistoricalBatch`]. -#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] -pub struct BlockRootsProof { - /// Generalized index of the header in the `block_roots` list. - pub block_header_index: u64, - /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` - pub block_header_branch: Vec>, -} - -impl TryFrom for BlockRootsProof { - type Error = Error; - fn try_from(beacon_block_header: types::BlockRootsProof) -> Result { - Ok(BlockRootsProof { - block_header_index: beacon_block_header.block_header_index, - block_header_branch: beacon_block_header - .block_header_branch - .iter() - .map(|hash| hash.to_vec()) - .collect(), - }) - } -} - -impl TryFrom for types::BlockRootsProof { - type Error = Error; - fn try_from(derived_beacon_block_header: BlockRootsProof) -> Result { - let branch = derived_beacon_block_header - .block_header_branch - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?; - - Ok(types::BlockRootsProof { - block_header_index: derived_beacon_block_header.block_header_index, - block_header_branch: branch, - }) - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] -pub enum AncestryProof { - /// This variant defines the proof data for a beacon chain header in the `state.block_roots` - BlockRoots { - /// Proof for the header in `state.block_roots` - block_roots_proof: BlockRootsProof, - /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] - block_roots_branch: Vec>, - }, - /// This variant defines the neccessary proofs for a beacon chain header in the - /// `state.historical_roots`. - HistoricalRoots { - /// Proof for the header in `historical_batch.block_roots` - block_roots_proof: BlockRootsProof, - /// The proof for the `historical_batch.block_roots`, needed to reconstruct - /// `hash_tree_root(historical_batch)` - historical_batch_proof: Vec>, - /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` - historical_roots_proof: Vec>, - /// The generalized index for the historical_batch in `state.historical_roots`. - historical_roots_index: u64, - /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in - /// [`BeaconState`] - historical_roots_branch: Vec>, - }, -} - -impl TryFrom for AncestryProof { - type Error = Error; - fn try_from(ancestry_proof: types::AncestryProof) -> Result { - Ok(match ancestry_proof { - types::AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => - AncestryProof::BlockRoots { - block_roots_proof: block_roots_proof.try_into()?, - block_roots_branch: block_roots_branch - .iter() - .map(|hash| hash.to_vec()) - .collect(), - }, - types::AncestryProof::HistoricalRoots { - block_roots_proof, - historical_batch_proof, - historical_roots_proof, - historical_roots_index, - historical_roots_branch, - } => AncestryProof::HistoricalRoots { - block_roots_proof: block_roots_proof.try_into()?, - historical_batch_proof: historical_batch_proof - .iter() - .map(|hash| hash.to_vec()) - .collect(), - historical_roots_proof: historical_roots_proof - .iter() - .map(|hash| hash.to_vec()) - .collect(), - historical_roots_index, - historical_roots_branch: historical_roots_branch - .iter() - .map(|hash| hash.to_vec()) - .collect(), - }, - }) - } -} - -impl TryFrom for types::AncestryProof { - type Error = Error; - fn try_from(ancestry_proof: AncestryProof) -> Result { - Ok(match ancestry_proof { - AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => - types::AncestryProof::BlockRoots { - block_roots_proof: block_roots_proof.try_into()?, - block_roots_branch: block_roots_branch - .iter() - .map(|proof| { - Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof) - }) - .collect::, _>>()?, - }, - AncestryProof::HistoricalRoots { - block_roots_proof, - historical_batch_proof, - historical_roots_proof, - historical_roots_index, - historical_roots_branch, - } => types::AncestryProof::HistoricalRoots { - block_roots_proof: block_roots_proof.try_into()?, - historical_batch_proof: historical_batch_proof - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?, - historical_roots_proof: historical_roots_proof - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?, - historical_roots_index, - historical_roots_branch: historical_roots_branch - .iter() - .map(|proof| Hash32::try_from(proof.as_ref()).map_err(|_| Error::InvalidProof)) - .collect::, _>>()?, - }, - }) - } -} diff --git a/primitives/src/domains.rs b/primitives/src/domains.rs new file mode 100644 index 000000000..fd8bd651b --- /dev/null +++ b/primitives/src/domains.rs @@ -0,0 +1,29 @@ +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum DomainType { + BeaconProposer, + BeaconAttester, + Randao, + Deposit, + VoluntaryExit, + SelectionProof, + AggregateAndProof, + SyncCommittee, + SyncCommitteeSelectionProof, + ContributionAndProof, + BlsToExecutionChange, + ApplicationMask, + ApplicationBuilder, +} + +impl DomainType { + pub fn as_bytes(&self) -> [u8; 4] { + match self { + Self::ApplicationMask => [0, 0, 0, 1], + Self::ApplicationBuilder => [0, 0, 0, 1], + _ => { + let data = *self as u32; + data.to_le_bytes() + }, + } + } +} diff --git a/primitives/src/helpers.rs b/primitives/src/helpers.rs deleted file mode 100644 index b16e8b9ec..000000000 --- a/primitives/src/helpers.rs +++ /dev/null @@ -1,162 +0,0 @@ -use crate::{ - derived_types, - error::Error, - types, - types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, -}; -use alloc::vec::Vec; -use ethereum_consensus::{ - bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, - crypto::PublicKey, - primitives::BlsSignature, -}; -use ssz_rs::{Bitvector, Deserialize, Node, Vector}; - -pub fn to_no_codec_beacon_header( - derived_header: derived_types::BeaconBlockHeader, -) -> Result { - let finalized_header = BeaconBlockHeader { - slot: derived_header.slot, - proposer_index: derived_header.proposer_index as usize, - parent_root: Node::from_bytes( - derived_header.parent_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, - ), - state_root: Node::from_bytes( - derived_header.state_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, - ), - body_root: Node::from_bytes( - derived_header.body_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, - ), - }; - - Ok(finalized_header) -} - -pub fn to_no_codec_sync_committee( - derived_sync_committee: derived_types::SyncCommittee, -) -> Result, Error> { - let public_keys_vector: Vec = derived_sync_committee - .public_keys - .iter() - .map(|public_key| { - PublicKey::try_from(public_key.as_slice()).map_err(|_| Error::InvalidPublicKey) - }) - .collect::, Error>>()?; - let sync_committee = SyncCommittee { - public_keys: Vector::try_from(public_keys_vector).unwrap(), - aggregate_public_key: PublicKey::try_from( - derived_sync_committee.aggregate_public_key.as_slice(), - ) - .map_err(|_| Error::InvalidPublicKey)?, - }; - - Ok(sync_committee) -} - -pub fn to_no_codec_sync_aggregate( - derived_sync_aggregate: derived_types::SyncAggregate, -) -> Result, Error> { - let derived_sync_committee_bits = derived_sync_aggregate.sync_committee_bits; - let bit_vector = Bitvector::::deserialize(&derived_sync_committee_bits) - .map_err(|_| Error::InvalidBitVec)?; - - let sync_aggregate = SyncAggregate { - sync_committee_bits: bit_vector, - sync_committee_signature: BlsSignature::try_from( - derived_sync_aggregate.sync_committee_signature.as_ref(), - ) - .map_err(|_| Error::InvalidPublicKey)?, - }; - - Ok(sync_aggregate) -} - -pub fn to_no_codec_light_client_state( - state: derived_types::LightClientState, -) -> Result, Error> { - let finalized_header = to_no_codec_beacon_header(state.finalized_header)?; - - let current_sync_committee = to_no_codec_sync_committee(state.current_sync_committee.clone())?; - let next_sync_committee = to_no_codec_sync_committee(state.next_sync_committee)?; - - Ok(LightClientState { - finalized_header, - latest_finalized_epoch: state.latest_finalized_epoch, - current_sync_committee, - next_sync_committee, - }) -} - -pub fn to_no_codec_light_client_update( - derived_update: derived_types::LightClientUpdate, -) -> Result, Error> { - let sync_committee_update_option: Option>; - - match derived_update.sync_committee_update { - Some(sync_committee_update) => - sync_committee_update_option = Some(sync_committee_update.try_into()?), - None => sync_committee_update_option = None, - } - Ok(LightClientUpdate { - attested_header: to_no_codec_beacon_header(derived_update.attested_header)?, - sync_committee_update: sync_committee_update_option, - finalized_header: to_no_codec_beacon_header(derived_update.finalized_header)?, - execution_payload: derived_update.execution_payload.try_into()?, - finality_proof: derived_update.finality_proof.try_into()?, - sync_aggregate: to_no_codec_sync_aggregate(derived_update.sync_aggregate)?, - signature_slot: derived_update.signature_slot, - ancestor_blocks: derived_update - .ancestor_blocks - .iter() - .map(|ancestor_block| { - ancestor_block - .clone() - .try_into() - .map_err(|_| Error::ErrorConvertingAncestorBlock) - }) - .collect::, Error>>()?, - }) -} - -pub fn to_codec_light_client_state( - state: types::LightClientState, -) -> Result { - Ok(derived_types::LightClientState { - finalized_header: state.finalized_header.try_into()?, - latest_finalized_epoch: state.latest_finalized_epoch, - current_sync_committee: state.current_sync_committee.try_into()?, - next_sync_committee: state.next_sync_committee.try_into()?, - }) -} - -pub fn to_codec_light_client_update( - update: types::LightClientUpdate, -) -> Result { - let sync_committee_update_option: Option; - - match update.sync_committee_update { - Some(sync_committee_update) => - sync_committee_update_option = Some(sync_committee_update.try_into()?), - - None => sync_committee_update_option = None, - } - Ok(derived_types::LightClientUpdate { - attested_header: update.attested_header.try_into()?, - sync_committee_update: sync_committee_update_option, - finalized_header: update.finalized_header.try_into()?, - execution_payload: update.execution_payload.try_into()?, - finality_proof: update.finality_proof.try_into()?, - sync_aggregate: update.sync_aggregate.try_into()?, - signature_slot: update.signature_slot, - ancestor_blocks: update - .ancestor_blocks - .iter() - .map(|ancestor_block| { - ancestor_block - .clone() - .try_into() - .map_err(|_| Error::ErrorConvertingAncestorBlock) - }) - .collect::, Error>>()?, - }) -} diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index b53869e0d..afce5f503 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -1,10 +1,16 @@ +//! Primitive types for sync committee verifier +//! This crate contains code adapted from https://github.com/ralexstokes/ethereum-consensus #![cfg_attr(not(feature = "std"), no_std)] #[warn(unused_imports)] #[warn(unused_variables)] extern crate alloc; -pub mod derived_types; +pub mod consensus_types; +pub mod constants; +pub mod domains; pub mod error; -pub mod helpers; +#[cfg(feature = "std")] +pub mod serde; +mod ssz; pub mod types; pub mod util; diff --git a/primitives/src/serde.rs b/primitives/src/serde.rs new file mode 100644 index 000000000..e1c59c77b --- /dev/null +++ b/primitives/src/serde.rs @@ -0,0 +1,142 @@ +use core::fmt::{Display, Formatter}; +use hex::FromHexError; + +const HEX_ENCODING_PREFIX: &str = "0x"; + +#[cfg_attr(feature = "serde", derive(Debug))] +pub enum HexError { + Hex, + MissingPrefix, +} + +impl From for HexError { + fn from(_: FromHexError) -> Self { + HexError::Hex + } +} + +impl Display for HexError { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self { + HexError::Hex => write!(f, ""), + HexError::MissingPrefix => write!(f, "missing prefix when deserializing hex data"), + } + } +} + +pub fn try_bytes_from_hex_str(s: &str) -> Result, HexError> { + let target = s.strip_prefix(HEX_ENCODING_PREFIX).ok_or(HexError::MissingPrefix)?; + let data = hex::decode(target)?; + Ok(data) +} + +pub mod as_hex { + use super::*; + use alloc::format; + use serde::de::Deserialize; + + pub fn serialize>(data: T, serializer: S) -> Result + where + S: serde::Serializer, + { + let encoding = hex::encode(data.as_ref()); + let output = format!("{HEX_ENCODING_PREFIX}{encoding}"); + serializer.collect_str(&output) + } + + pub fn deserialize<'de, D, T>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + T: TryFrom>, + { + let s = ::deserialize(deserializer)?; + + let data = try_bytes_from_hex_str(&s).map_err(serde::de::Error::custom)?; + + let inner = T::try_from(data) + .map_err(|_| serde::de::Error::custom("type failed to parse bytes from hex data"))?; + Ok(inner) + } +} + +pub mod as_string { + use alloc::format; + use core::{fmt, str::FromStr}; + use serde::de::Deserialize; + + pub fn serialize(data: T, serializer: S) -> Result + where + S: serde::Serializer, + { + let output = format!("{data}"); + serializer.collect_str(&output) + } + + pub fn deserialize<'de, D, T: FromStr>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let s: String = ::deserialize(deserializer)?; + let inner: T = s + .parse() + .map_err(|_| serde::de::Error::custom("failure to parse string data"))?; + Ok(inner) + } +} + +pub mod collection_over_string { + use core::{fmt, marker::PhantomData, str::FromStr}; + use serde::{ + de::{Deserializer, Error}, + ser::SerializeSeq, + }; + + pub fn serialize(data: T, serializer: S) -> Result + where + S: serde::Serializer, + T: AsRef<[U]>, + U: fmt::Display, + { + let mut seq = serializer.serialize_seq(None)?; + for elem in data.as_ref().iter() { + let rendered_elem = format!("{elem}"); + seq.serialize_element(&rendered_elem)?; + } + seq.end() + } + + struct Visitor(PhantomData>); + + impl<'de, T: FromStr> serde::de::Visitor<'de> for Visitor { + type Value = Vec; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("array of string") + } + + fn visit_seq(self, mut access: S) -> Result + where + S: serde::de::SeqAccess<'de>, + { + let mut coll = Vec::with_capacity(access.size_hint().unwrap_or(0)); + + while let Some(elem) = access.next_element()? { + let recovered_elem = T::from_str(elem).map_err(|_| { + Error::custom("failure to parse element of sequence from string") + })?; + coll.push(recovered_elem); + } + Ok(coll) + } + } + + pub fn deserialize<'de, D, T, U>(deserializer: D) -> Result + where + D: Deserializer<'de>, + T: TryFrom>, + U: FromStr, + { + let data = deserializer.deserialize_seq(Visitor(PhantomData))?; + T::try_from(data).map_err(|_| serde::de::Error::custom("failure to parse collection")) + } +} diff --git a/primitives/src/ssz/byte_list.rs b/primitives/src/ssz/byte_list.rs new file mode 100644 index 000000000..a22b2c1b4 --- /dev/null +++ b/primitives/src/ssz/byte_list.rs @@ -0,0 +1,88 @@ +use super::write_bytes_to_lower_hex; +use alloc::{vec, vec::Vec}; +use core::{ + fmt, + hash::{Hash, Hasher}, + ops::{Deref, DerefMut}, +}; +use ssz_rs::prelude::*; + +#[derive(Default, Clone, Eq, SimpleSerialize, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ByteList( + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_hex"))] List, +); + +impl TryFrom<&[u8]> for ByteList { + type Error = ssz_rs::DeserializeError; + + fn try_from(bytes: &[u8]) -> Result { + ByteList::::deserialize(bytes) + } +} + +// impl here to satisfy clippy +impl PartialEq for ByteList { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Hash for ByteList { + fn hash(&self, state: &mut H) { + self.as_ref().hash(state); + } +} + +impl fmt::LowerHex for ByteList { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write_bytes_to_lower_hex(f, self) + } +} + +impl fmt::Debug for ByteList { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ByteList<{N}>(len={})({:#x})", self.len(), self) + } +} + +impl fmt::Display for ByteList { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#x}") + } +} + +impl AsRef<[u8]> for ByteList { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +impl Deref for ByteList { + type Target = List; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for ByteList { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_byte_list_serde() { + let list = ByteList::<32>::try_from([255u8, 255u8].as_ref()).unwrap(); + let encoding = ssz_rs::serialize(&list).unwrap(); + assert_eq!(encoding, [255, 255]); + + let recovered_list = ByteList::<32>::deserialize(&encoding).unwrap(); + assert_eq!(list, recovered_list); + } +} diff --git a/primitives/src/ssz/byte_vector.rs b/primitives/src/ssz/byte_vector.rs new file mode 100644 index 000000000..1b1b5ba7d --- /dev/null +++ b/primitives/src/ssz/byte_vector.rs @@ -0,0 +1,81 @@ +use super::write_bytes_to_lower_hex; +use alloc::{vec, vec::Vec}; +use core::{ + fmt, + hash::{Hash, Hasher}, + ops::{Deref, DerefMut}, +}; +use ssz_rs::prelude::*; + +#[derive(Default, Clone, Eq, SimpleSerialize, codec::Encode, codec::Decode)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +pub struct ByteVector( + #[cfg_attr(feature = "serde", serde(with = "crate::serde::as_hex"))] Vector, +); + +impl TryFrom<&[u8]> for ByteVector { + type Error = ssz_rs::DeserializeError; + + fn try_from(bytes: &[u8]) -> Result { + ByteVector::::deserialize(bytes) + } +} + +impl TryFrom> for ByteVector { + type Error = ssz_rs::DeserializeError; + + fn try_from(bytes: Vec) -> Result { + ByteVector::::deserialize(&bytes) + } +} + +// impl here to satisfy clippy +impl PartialEq for ByteVector { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Hash for ByteVector { + fn hash(&self, state: &mut H) { + self.as_ref().hash(state); + } +} + +impl fmt::LowerHex for ByteVector { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write_bytes_to_lower_hex(f, self) + } +} + +impl fmt::Debug for ByteVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ByteVector<{N}>({self:#x})") + } +} + +impl fmt::Display for ByteVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:#x}") + } +} + +impl AsRef<[u8]> for ByteVector { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +impl Deref for ByteVector { + type Target = Vector; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for ByteVector { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} diff --git a/primitives/src/ssz/mod.rs b/primitives/src/ssz/mod.rs new file mode 100644 index 000000000..ebeaa9b3b --- /dev/null +++ b/primitives/src/ssz/mod.rs @@ -0,0 +1,16 @@ +mod byte_list; +mod byte_vector; +use core::fmt; + +fn write_bytes_to_lower_hex>(f: &mut fmt::Formatter<'_>, data: T) -> fmt::Result { + if f.alternate() { + write!(f, "0x")?; + } + for i in data.as_ref() { + write!(f, "{i:02x}")?; + } + Ok(()) +} + +pub use byte_list::ByteList; +pub use byte_vector::ByteVector; diff --git a/primitives/src/types.rs b/primitives/src/types.rs index d5fc44b7a..c0ca114a5 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -1,69 +1,47 @@ -use alloc::vec::Vec; -use ethereum_consensus::{ - bellatrix::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, - domains::DomainType, - primitives::{Hash32, Slot}, +use crate::{ + consensus_types::{BeaconBlockHeader, SyncAggregate, SyncCommittee}, + constants::{Slot, SYNC_COMMITTEE_SIZE}, }; - -pub const DOMAIN_SYNC_COMMITTEE: DomainType = DomainType::SyncCommittee; -pub const FINALIZED_ROOT_INDEX: u64 = 52; -pub const EXECUTION_PAYLOAD_STATE_ROOT_INDEX: u64 = 18; -pub const EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX: u64 = 22; -pub const EXECUTION_PAYLOAD_INDEX: u64 = 56; -pub const NEXT_SYNC_COMMITTEE_INDEX: u64 = 55; -pub const BLOCK_ROOTS_INDEX: u64 = 37; -pub const HISTORICAL_ROOTS_INDEX: u64 = 39; -pub const HISTORICAL_BATCH_BLOCK_ROOTS_INDEX: u64 = 2; -pub const EXECUTION_PAYLOAD_TIMESTAMP_INDEX: u64 = 25; -pub const FINALIZED_ROOT_INDEX_LOG2: u64 = 5; -pub const EXECUTION_PAYLOAD_INDEX_LOG2: u64 = 5; -pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 5; -pub const BLOCK_ROOTS_INDEX_LOG2: u64 = 5; -pub const HISTORICAL_ROOTS_INDEX_LOG2: u64 = 5; - -#[cfg(not(feature = "testing"))] -pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = - hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); -#[cfg(feature = "testing")] -pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = - hex_literal::hex!("6034f557b4560fc549ac0e2c63269deb07bfac7bf2bbd0b8b7d4d321240bffd9"); +use alloc::vec::Vec; +use primitive_types::H256; +use ssz_rs::Node; /// This holds the relevant data required to prove the state root in the execution payload. -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] pub struct ExecutionPayloadProof { /// The state root in the `ExecutionPayload` which represents the commitment to /// the ethereum world state in the yellow paper. - pub state_root: Hash32, + pub state_root: H256, /// the block number of the execution header. pub block_number: u64, /// merkle mutli proof for the state_root & block_number in the [`ExecutionPayload`]. - pub multi_proof: Vec, + pub multi_proof: Vec, /// merkle proof for the `ExecutionPayload` in the [`BeaconBlockBody`]. - pub execution_payload_branch: Vec, + pub execution_payload_branch: Vec, /// timestamp pub timestamp: u64, } /// Holds the neccessary proofs required to verify a header in the `block_roots` field /// either in [`BeaconState`] or [`HistoricalBatch`]. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] pub struct BlockRootsProof { /// Generalized index of the header in the `block_roots` list. pub block_header_index: u64, /// The proof for the header, needed to reconstruct `hash_tree_root(state.block_roots)` - pub block_header_branch: Vec, + pub block_header_branch: Vec, } /// The block header ancestry proof, this is an enum because the header may either exist in /// `state.block_roots` or `state.historical_roots`. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] pub enum AncestryProof { /// This variant defines the proof data for a beacon chain header in the `state.block_roots` BlockRoots { /// Proof for the header in `state.block_roots` block_roots_proof: BlockRootsProof, /// The proof for the reconstructed `hash_tree_root(state.block_roots)` in [`BeaconState`] - block_roots_branch: Vec, + block_roots_branch: Vec, }, /// This variant defines the neccessary proofs for a beacon chain header in the /// `state.historical_roots`. @@ -72,20 +50,20 @@ pub enum AncestryProof { block_roots_proof: BlockRootsProof, /// The proof for the `historical_batch.block_roots`, needed to reconstruct /// `hash_tree_root(historical_batch)` - historical_batch_proof: Vec, + historical_batch_proof: Vec, /// The proof for the `hash_tree_root(historical_batch)` in `state.historical_roots` - historical_roots_proof: Vec, + historical_roots_proof: Vec, /// The generalized index for the historical_batch in `state.historical_roots`. historical_roots_index: u64, /// The proof for the reconstructed `hash_tree_root(state.historical_roots)` in /// [`BeaconState`] - historical_roots_branch: Vec, + historical_roots_branch: Vec, }, } /// This defines the neccesary data needed to prove ancestor blocks, relative to the finalized /// header. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, codec::Encode, codec::Decode)] pub struct AncestorBlock { /// The actual beacon chain header pub header: BeaconBlockHeader, @@ -97,17 +75,17 @@ pub struct AncestorBlock { /// Holds the latest sync committee as well as an ssz proof for it's existence /// in a finalized header. -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct SyncCommitteeUpdate { +#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] +pub struct SyncCommitteeUpdate { // actual sync committee pub next_sync_committee: SyncCommittee, // sync committee, ssz merkle proof. - pub next_sync_committee_branch: Vec, + pub next_sync_committee_branch: Vec, } /// Minimum state required by the light client to validate new sync committee attestations -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct LightClientState { +#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] +pub struct LightClientState { /// The latest recorded finalized header pub finalized_header: BeaconBlockHeader, /// Latest finalized epoch @@ -118,21 +96,21 @@ pub struct LightClientState { } /// Finalized header proof -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] pub struct FinalityProof { /// The latest finalized epoch pub epoch: u64, /// Finalized header proof - pub finality_branch: Vec, + pub finality_branch: Vec, } /// Data required to advance the state of the light client. -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct LightClientUpdate { +#[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] +pub struct LightClientUpdate { /// the header that the sync committee signed pub attested_header: BeaconBlockHeader, /// the sync committee has potentially changed, here's an ssz proof for that. - pub sync_committee_update: Option>, + pub sync_committee_update: Option, /// the actual header which was finalized by the ethereum attestation protocol. pub finalized_header: BeaconBlockHeader, /// execution payload of the finalized header @@ -143,6 +121,6 @@ pub struct LightClientUpdate { pub sync_aggregate: SyncAggregate, /// slot at which signature was produced pub signature_slot: Slot, - /// ancestors of the finalized block to be verified, may be empty. - pub ancestor_blocks: Vec, + // ancestors of the finalized block to be verified, may be empty. + // pub ancestor_blocks: Vec, } diff --git a/primitives/src/util.rs b/primitives/src/util.rs index 20701c9e5..4c1abaab4 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -1,11 +1,15 @@ -use ethereum_consensus::{ - altair::mainnet::EPOCHS_PER_SYNC_COMMITTEE_PERIOD, - configs::mainnet::{ - ALTAIR_FORK_EPOCH, ALTAIR_FORK_VERSION, BELLATRIX_FORK_EPOCH, BELLATRIX_FORK_VERSION, - GENESIS_FORK_VERSION, +use crate::{ + consensus_types::ForkData, + constants::{ + Domain, Root, 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, }, - phase0::mainnet::SLOTS_PER_EPOCH, + domains::DomainType, }; +use alloc::{vec, vec::Vec}; +use anyhow::anyhow; +use ssz_rs::prelude::*; /// Return the sync committe period at the given ``epoch`` pub fn compute_sync_committee_period(epoch: u64) -> u64 { @@ -20,7 +24,9 @@ pub fn compute_epoch_at_slot(slot: u64) -> u64 { #[cfg(not(feature = "testing"))] /// Return the fork version at the given ``epoch``. pub fn compute_fork_version(epoch: u64) -> [u8; 4] { - if epoch >= BELLATRIX_FORK_EPOCH { + if epoch >= CAPELLA_FORK_EPOCH { + CAPELLA_FORK_VERSION + } else if epoch >= BELLATRIX_FORK_EPOCH { BELLATRIX_FORK_VERSION } else if epoch >= ALTAIR_FORK_EPOCH { ALTAIR_FORK_VERSION @@ -29,9 +35,44 @@ pub fn compute_fork_version(epoch: u64) -> [u8; 4] { } } -#[cfg(feature = "testing")] -pub fn compute_fork_version(_epoch: u64) -> [u8; 4] { - BELLATRIX_FORK_VERSION +pub fn compute_domain( + domain_type: DomainType, + fork_version: Option, + genesis_validators_root: Option, + genesis_fork_version: Version, +) -> Result { + let fork_version = fork_version.unwrap_or(genesis_fork_version); + let genesis_validators_root = genesis_validators_root.unwrap_or_default(); + let fork_data_root = compute_fork_data_root(fork_version, genesis_validators_root)?; + let mut domain = Domain::default(); + domain[..4].copy_from_slice(&domain_type.as_bytes()); + domain[4..].copy_from_slice(&fork_data_root.as_ref()[..28]); + Ok(domain) +} + +#[derive(Default, Debug, SimpleSerialize)] +pub struct SigningData { + pub object_root: Root, + pub domain: Domain, +} + +pub fn compute_signing_root( + ssz_object: &mut T, + domain: Domain, +) -> Result { + let object_root = ssz_object.hash_tree_root().map_err(|e| anyhow!("{:?}", e))?; + + let mut s = SigningData { object_root, domain }; + s.hash_tree_root().map_err(|e| anyhow!("{:?}", e)) +} + +pub fn compute_fork_data_root( + current_version: Version, + genesis_validators_root: Root, +) -> Result { + ForkData { current_version, genesis_validators_root } + .hash_tree_root() + .map_err(|e| anyhow!("{:?}", e)) } /// Return the sync committee period at ``slot`` diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 5ec1cae68..1abc687ed 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -8,22 +8,41 @@ edition = "2021" [dependencies] sync-committee-primitives = { path= "../primitives" } sync-committee-verifier = { path= "../verifier" } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main" } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" } reqwest = {version="0.11.14", features=["json"]} -serde = { version = "1.0", features = ["derive"]} +serde = { version = "1.0.185", features = ["derive"] } serde_json = { version = "1.0.81"} anyhow = "1.0.68" -actix-rt = "*" -tokio = { version = "1.18.2", features = ["full"]} +tokio = { version = "1.32.0", features = ["sync"]} tokio-stream = { version = "0.1.8" } async-stream = { version = "0.3.3"} -base2 = {version= "0.3.1", default-features=false} +base2 = {version= "0.3.1" } env_logger = "0.10.0" +ark-ec = { version = "0.4.2" } +ark-bls12-381 = { version = "0.4.0" } +bls_on_arkworks = { version = "0.2.2" } +primitive-types = { version = "0.12.1", features = ["serde_no_std", "impl-codec"] } +log = "0.4.20" +hex = "0.4.3" [dev-dependencies] -hex = "0.4.3" -sync-committee-primitives = { path= "../primitives", features = ["testing"] } -sync-committee-verifier = { path= "../verifier", features = ["testing"] } +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"]} + +[features] +default = ["std"] +std = [ + "ssz-rs/default", + "sync-committee-primitives/std", + "anyhow/std", + "ark-ec/std", + "bls_on_arkworks/std", + "ark-bls12-381/std" +] +testnet = ["sync-committee-primitives/testnet", "sync-committee-verifier/testnet"] +mainnet = ["sync-committee-primitives/mainnet", "sync-committee-verifier/mainnet"] diff --git a/prover/src/lib.rs b/prover/src/lib.rs index a519aca7b..5fe4bfe4c 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -5,11 +5,14 @@ mod routes; #[cfg(test)] mod test; -use ethereum_consensus::{ - altair::Validator, - bellatrix::{BeaconBlock, BeaconBlockHeader, BeaconState, SyncCommittee}, -}; +use anyhow::anyhow; +use bls_on_arkworks::{point_to_pubkey, types::G1ProjectivePoint}; +use log::debug; use reqwest::Client; +use std::time::Duration; +use sync_committee_primitives::consensus_types::{ + BeaconBlock, BeaconBlockHeader, BeaconState, SyncCommittee, Validator, +}; use crate::{ responses::{ @@ -18,30 +21,28 @@ use crate::{ }, routes::*, }; -use ethereum_consensus::{ - bellatrix::mainnet::{ - BYTES_PER_LOGS_BLOOM, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, SYNC_COMMITTEE_SIZE, - }, - crypto::eth_aggregate_public_keys, - phase0::mainnet::{ - EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, - HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_DEPOSITS, - MAX_PROPOSER_SLASHINGS, MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SLOTS_PER_EPOCH, - SLOTS_PER_HISTORICAL_ROOT, VALIDATOR_REGISTRY_LIMIT, - }, - primitives::{BlsPublicKey, Bytes32, Hash32, ValidatorIndex}, -}; +use primitive_types::H256; use ssz_rs::{List, Merkleized, Node, Vector}; use sync_committee_primitives::{ - types::{ - AncestryProof, BlockRootsProof, ExecutionPayloadProof, BLOCK_ROOTS_INDEX, + constants::{ + BlsPublicKey, ValidatorIndex, BLOCK_ROOTS_INDEX, BYTES_PER_LOGS_BLOOM, + EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, - FINALIZED_ROOT_INDEX, NEXT_SYNC_COMMITTEE_INDEX, + FINALIZED_ROOT_INDEX, HISTORICAL_ROOTS_LIMIT, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, + MAX_BLS_TO_EXECUTION_CHANGES, MAX_BYTES_PER_TRANSACTION, MAX_DEPOSITS, + MAX_EXTRA_DATA_BYTES, MAX_PROPOSER_SLASHINGS, MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, MAX_WITHDRAWALS_PER_PAYLOAD, + NEXT_SYNC_COMMITTEE_INDEX, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, SYNC_COMMITTEE_SIZE, + VALIDATOR_REGISTRY_LIMIT, }, - util::compute_epoch_at_slot, + types::{ + AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, LightClientUpdate, + SyncCommitteeUpdate, + }, + util::{compute_epoch_at_slot, compute_sync_committee_period_at_slot}, }; +use sync_committee_verifier::{signature_verification::pubkey_to_projective, LightClientState}; pub type BeaconStateType = BeaconState< SLOTS_PER_HISTORICAL_ROOT, @@ -71,7 +72,7 @@ impl SyncCommitteeProver { SyncCommitteeProver { node_url, client } } - pub async fn fetch_finalized_checkpoint(&self) -> Result { + pub async fn fetch_finalized_checkpoint(&self) -> Result { let full_url = self.generate_route(&finality_checkpoints("head")); let response = self.client.get(full_url).send().await?; @@ -80,7 +81,7 @@ impl SyncCommitteeProver { Ok(response_data.data) } - pub async fn fetch_header(&self, block_id: &str) -> Result { + pub async fn fetch_header(&self, block_id: &str) -> Result { let path = header_route(block_id); let full_url = self.generate_route(&path); let response = self.client.get(full_url).send().await?; @@ -109,8 +110,10 @@ impl SyncCommitteeProver { MAX_EXTRA_DATA_BYTES, MAX_BYTES_PER_TRANSACTION, MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_WITHDRAWALS_PER_PAYLOAD, + MAX_BLS_TO_EXECUTION_CHANGES, >, - reqwest::Error, + anyhow::Error, > { let path = block_route(block_id); let full_url = self.generate_route(&path); @@ -127,7 +130,7 @@ impl SyncCommitteeProver { pub async fn fetch_sync_committee( &self, state_id: &str, - ) -> Result { + ) -> Result { let path = sync_committee_route(state_id); let full_url = self.generate_route(&path); @@ -144,7 +147,7 @@ impl SyncCommitteeProver { &self, state_id: &str, validator_index: &str, - ) -> Result { + ) -> Result { let path = validator_route(state_id, validator_index); let full_url = self.generate_route(&path); @@ -160,7 +163,7 @@ impl SyncCommitteeProver { pub async fn fetch_beacon_state( &self, state_id: &str, - ) -> Result { + ) -> Result { let path = beacon_state_route(state_id); let full_url = self.generate_route(&path); @@ -176,14 +179,14 @@ impl SyncCommitteeProver { pub async fn fetch_processed_sync_committee( &self, state_id: &str, - ) -> Result, reqwest::Error> { + ) -> Result, anyhow::Error> { // fetches sync committee from Node - let node_sync_committee = self.fetch_sync_committee(state_id.clone()).await?; + let node_sync_committee = self.fetch_sync_committee(state_id).await?; let mut validators: List = Default::default(); - for validator_index in node_sync_committee.validators.clone() { + for validator_index in node_sync_committee.validators.iter() { // fetches validator based on validator index - let validator = self.fetch_validator(state_id.clone(), &validator_index).await?; + let validator = self.fetch_validator(state_id, validator_index).await?; validators.push(validator); } @@ -191,16 +194,16 @@ impl SyncCommitteeProver { .validators .into_iter() .map(|i| { - let validator_index: ValidatorIndex = i.parse().unwrap(); - validators[validator_index].public_key.clone() + let validator_index: ValidatorIndex = i.parse()?; + Ok(validators[validator_index as usize].public_key.clone()) }) - .collect::>(); + .collect::, anyhow::Error>>()?; - let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector).unwrap(); + let aggregate_public_key = eth_aggregate_public_keys(&public_keys_vector)?; let sync_committee = SyncCommittee:: { public_keys: Vector::::try_from(public_keys_vector) - .unwrap(), + .map_err(|e| anyhow!("{:?}", e))?, aggregate_public_key, }; @@ -210,6 +213,152 @@ impl SyncCommitteeProver { fn generate_route(&self, path: &str) -> String { format!("{}{}", self.node_url.clone(), path) } + + pub async fn fetch_light_client_update( + &self, + client_state: LightClientState, + debug_target: &str, + ) -> Result, anyhow::Error> { + let finality_checkpoint = self.fetch_finalized_checkpoint().await?; + if finality_checkpoint.finalized.root == Node::default() || + finality_checkpoint.finalized.epoch <= client_state.latest_finalized_epoch || + finality_checkpoint.finalized.root == + client_state.finalized_header.clone().hash_tree_root()? + { + return Ok(None) + } + + debug!(target: debug_target, "A new epoch has been finalized {}", finality_checkpoint.finalized.epoch); + + let block_id = { + let mut block_id = hex::encode(finality_checkpoint.finalized.root.as_bytes()); + block_id.insert_str(0, "0x"); + block_id + }; + + let finalized_header = self.fetch_header(&block_id).await?; + let mut finalized_state = + self.fetch_beacon_state(finalized_header.slot.to_string().as_str()).await?; + let execution_payload_proof = prove_execution_payload(&mut finalized_state)?; + + let mut attested_epoch = finality_checkpoint.finalized.epoch + 2; + // Get attested header and the signature slot + + let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; + // Due to the fact that all slots in an epoch can be missed we are going to try and fetch + // the attested block from four possible epochs. + let mut attested_epoch_loop_count = 0; + let (attested_block_header, signature_block) = loop { + if attested_epoch_loop_count == 4 { + Err(anyhow!("Could not fetch any block from the attested epoch after going through four epochs"))? + } + // If we have maxed out the slots in the current epoch and still didn't find any block, + // we move to the next epoch + if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == + attested_slot + { + // No block was found in attested epoch we move to the next possible attested epoch + debug!(target: debug_target, + "No slots found in epoch {attested_epoch} Moving to the next possible epoch {}", + attested_epoch + 1 + ); + tokio::time::sleep(Duration::from_secs(24)).await; + attested_epoch += 1; + attested_slot = attested_epoch * SLOTS_PER_EPOCH; + attested_epoch_loop_count += 1; + } + + if let Ok(header) = self.fetch_header(attested_slot.to_string().as_str()).await { + let mut signature_slot = header.slot + 1; + let mut loop_count = 0; + let signature_block = loop { + if loop_count == 2 { + break None + } + if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == + signature_slot + { + debug!(target: debug_target, "Waiting for signature block for attested header"); + tokio::time::sleep(Duration::from_secs(24)).await; + signature_slot = header.slot + 1; + loop_count += 1; + } + if let Ok(signature_block) = + self.fetch_block(signature_slot.to_string().as_str()).await + { + break Some(signature_block) + } + signature_slot += 1; + }; + // If the next block does not have sufficient sync committee participants + if let Some(signature_block) = signature_block { + if signature_block + .body + .sync_aggregate + .sync_committee_bits + .as_bitslice() + .count_ones() < (2 * (SYNC_COMMITTEE_SIZE)) / 3 + { + attested_slot += 1; + debug!(target:debug_target, "Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); + continue + } + break (header, signature_block) + } else { + debug!(target: debug_target,"No signature block found in {attested_epoch} Moving to the next possible epoch {}", attested_epoch + 1); + tokio::time::sleep(Duration::from_secs(24)).await; + attested_epoch += 1; + attested_slot = attested_epoch * SLOTS_PER_EPOCH; + attested_epoch_loop_count += 1; + continue + } + } + attested_slot += 1 + }; + + let mut attested_state = + self.fetch_beacon_state(attested_block_header.slot.to_string().as_str()).await?; + + let finalized_hash_tree_root = finalized_header.clone().hash_tree_root()?; + + if cfg!(test) { + assert_eq!(finalized_hash_tree_root, attested_state.finalized_checkpoint.root); + } + + let finality_proof = FinalityProof { + epoch: finality_checkpoint.finalized.epoch, + finality_branch: prove_finalized_header(&mut attested_state)?, + }; + + let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); + + let update_attested_period = + compute_sync_committee_period_at_slot(attested_block_header.slot); + + let sync_committee_update = if state_period == update_attested_period { + let sync_committee_proof = prove_sync_committee_update(&mut attested_state)?; + + Some(SyncCommitteeUpdate { + next_sync_committee: attested_state.next_sync_committee, + next_sync_committee_branch: sync_committee_proof, + }) + } else { + None + }; + + // construct light client + let light_client_update = LightClientUpdate { + attested_header: attested_block_header, + sync_committee_update, + finalized_header, + execution_payload: execution_payload_proof, + finality_proof, + sync_aggregate: signature_block.body.sync_aggregate, + signature_slot: signature_block.slot, + }; + + Ok(Some(light_client_update)) + } } pub fn get_attested_epoch(finalized_epoch: u64) -> u64 { @@ -217,7 +366,7 @@ pub fn get_attested_epoch(finalized_epoch: u64) -> u64 { } pub fn prove_execution_payload( - mut beacon_state: BeaconStateType, + beacon_state: &mut BeaconStateType, ) -> anyhow::Result { let indices = [ EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize, @@ -231,40 +380,33 @@ pub fn prove_execution_payload( )?; Ok(ExecutionPayloadProof { - state_root: beacon_state.latest_execution_payload_header.state_root.clone(), + state_root: H256::from_slice( + beacon_state.latest_execution_payload_header.state_root.as_slice(), + ), block_number: beacon_state.latest_execution_payload_header.block_number, timestamp: beacon_state.latest_execution_payload_header.timestamp, - multi_proof: multi_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), + multi_proof, execution_payload_branch: ssz_rs::generate_proof( - &mut beacon_state, + beacon_state, &[EXECUTION_PAYLOAD_INDEX as usize], - )? - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect(), + )?, }) } -pub fn prove_sync_committee_update(mut state: BeaconStateType) -> anyhow::Result> { - let proof = ssz_rs::generate_proof(&mut state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; +pub fn prove_sync_committee_update(state: &mut BeaconStateType) -> anyhow::Result> { + let proof = ssz_rs::generate_proof(state, &[NEXT_SYNC_COMMITTEE_INDEX as usize])?; Ok(proof) } -pub fn prove_finalized_header(mut state: BeaconStateType) -> anyhow::Result> { +pub fn prove_finalized_header(state: &mut BeaconStateType) -> anyhow::Result> { let indices = [FINALIZED_ROOT_INDEX as usize]; - let proof = ssz_rs::generate_proof(&mut state, indices.as_slice())?; + let proof = ssz_rs::generate_proof(state, indices.as_slice())?; - Ok(proof - .into_iter() - .map(|node| Hash32::try_from(node.as_ref()).expect("Node is always a 32 byte slice")) - .collect()) + Ok(proof) } pub fn prove_block_roots_proof( - mut state: BeaconStateType, + state: &mut BeaconStateType, mut header: BeaconBlockHeader, ) -> anyhow::Result { // Check if block root should still be part of the block roots vector on the beacon state @@ -288,25 +430,26 @@ pub fn prove_block_roots_proof( let proof = ssz_rs::generate_proof(&mut state.block_roots, &[block_index])?; - let block_roots_proof = BlockRootsProof { - block_header_index: block_index as u64, - block_header_branch: proof - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect(), - }; + let block_roots_proof = + BlockRootsProof { block_header_index: block_index as u64, block_header_branch: proof }; - let block_roots_branch = ssz_rs::generate_proof(&mut state, &[BLOCK_ROOTS_INDEX as usize])?; - Ok(AncestryProof::BlockRoots { - block_roots_proof, - block_roots_branch: block_roots_branch - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect(), - }) + let block_roots_branch = ssz_rs::generate_proof(state, &[BLOCK_ROOTS_INDEX as usize])?; + Ok(AncestryProof::BlockRoots { block_roots_proof, block_roots_branch }) } } + +pub fn eth_aggregate_public_keys(points: &[BlsPublicKey]) -> anyhow::Result { + let points = points + .iter() + .map(|point| pubkey_to_projective(point)) + .collect::, _>>()?; + let aggregate = points + .into_iter() + .fold(G1ProjectivePoint::default(), |acc, g1_point| acc + g1_point); + let public_key = point_to_pubkey(aggregate.into()); + + let bls_public_key = + BlsPublicKey::try_from(public_key.as_slice()).map_err(|e| anyhow!("{:?}", e))?; + + Ok(bls_public_key) +} diff --git a/prover/src/responses/beacon_block_header_response.rs b/prover/src/responses/beacon_block_header_response.rs index 3d6d3a533..9a3e6b167 100644 --- a/prover/src/responses/beacon_block_header_response.rs +++ b/prover/src/responses/beacon_block_header_response.rs @@ -1,4 +1,4 @@ -use ethereum_consensus::bellatrix::BeaconBlockHeader; +use sync_committee_primitives::consensus_types::BeaconBlockHeader; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { diff --git a/prover/src/responses/beacon_block_response.rs b/prover/src/responses/beacon_block_response.rs index 62839e3c4..ac3c2b290 100644 --- a/prover/src/responses/beacon_block_response.rs +++ b/prover/src/responses/beacon_block_response.rs @@ -1,10 +1,12 @@ -use ethereum_consensus::bellatrix::{ - mainnet::{ - BYTES_PER_LOGS_BLOOM, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, MAX_BYTES_PER_TRANSACTION, - MAX_DEPOSITS, MAX_EXTRA_DATA_BYTES, MAX_PROPOSER_SLASHINGS, MAX_TRANSACTIONS_PER_PAYLOAD, - MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, SYNC_COMMITTEE_SIZE, +use sync_committee_primitives::{ + consensus_types::BeaconBlock, + constants::{ + BYTES_PER_LOGS_BLOOM, MAX_ATTESTATIONS, MAX_ATTESTER_SLASHINGS, + MAX_BLS_TO_EXECUTION_CHANGES, MAX_BYTES_PER_TRANSACTION, MAX_DEPOSITS, + MAX_EXTRA_DATA_BYTES, MAX_PROPOSER_SLASHINGS, MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_VALIDATORS_PER_COMMITTEE, MAX_VOLUNTARY_EXITS, MAX_WITHDRAWALS_PER_PAYLOAD, + SYNC_COMMITTEE_SIZE, }, - BeaconBlock, }; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] @@ -28,6 +30,8 @@ pub struct ResponseData { MAX_EXTRA_DATA_BYTES, MAX_BYTES_PER_TRANSACTION, MAX_TRANSACTIONS_PER_PAYLOAD, + MAX_WITHDRAWALS_PER_PAYLOAD, + MAX_BLS_TO_EXECUTION_CHANGES, >, pub signature: String, } diff --git a/prover/src/responses/beacon_state_response.rs b/prover/src/responses/beacon_state_response.rs index 14b0b91ee..56c5059db 100644 --- a/prover/src/responses/beacon_state_response.rs +++ b/prover/src/responses/beacon_state_response.rs @@ -1,11 +1,13 @@ -use ethereum_consensus::bellatrix::BeaconState; - -use ethereum_consensus::bellatrix::mainnet::{ - BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, - ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_BYTES_PER_TRANSACTION, MAX_EXTRA_DATA_BYTES, - MAX_TRANSACTIONS_PER_PAYLOAD, MAX_VALIDATORS_PER_COMMITTEE, SLOTS_PER_HISTORICAL_ROOT, - SYNC_COMMITTEE_SIZE, VALIDATOR_REGISTRY_LIMIT, +use sync_committee_primitives::{ + consensus_types::BeaconState, + constants::{ + BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, + ETH1_DATA_VOTES_BOUND, HISTORICAL_ROOTS_LIMIT, MAX_BYTES_PER_TRANSACTION, + MAX_EXTRA_DATA_BYTES, MAX_TRANSACTIONS_PER_PAYLOAD, MAX_VALIDATORS_PER_COMMITTEE, + SLOTS_PER_HISTORICAL_ROOT, SYNC_COMMITTEE_SIZE, VALIDATOR_REGISTRY_LIMIT, + }, }; + #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { version: String, diff --git a/prover/src/responses/finality_checkpoint_response.rs b/prover/src/responses/finality_checkpoint_response.rs index db251def7..c0e439ea9 100644 --- a/prover/src/responses/finality_checkpoint_response.rs +++ b/prover/src/responses/finality_checkpoint_response.rs @@ -1,4 +1,4 @@ -use ethereum_consensus::bellatrix::Checkpoint; +use sync_committee_primitives::consensus_types::Checkpoint; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub(crate) struct Response { diff --git a/prover/src/responses/validator_response.rs b/prover/src/responses/validator_response.rs index 6a37e0afd..d4969cc7a 100644 --- a/prover/src/responses/validator_response.rs +++ b/prover/src/responses/validator_response.rs @@ -1,4 +1,4 @@ -use ethereum_consensus::bellatrix::Validator; +use sync_committee_primitives::consensus_types::Validator; #[derive(Default, Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct Response { diff --git a/prover/src/test.rs b/prover/src/test.rs index 9acc97fdd..a509501f4 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -1,86 +1,126 @@ use super::*; use base2::Base2; -use sync_committee_primitives::{ - types::{LightClientState, LightClientUpdate, SyncCommitteeUpdate}, - util::compute_sync_committee_period_at_slot, +use ethers::{ + prelude::{Http, Middleware, ProviderExt}, + providers::Provider, }; - -use ethereum_consensus::{ - bellatrix::compute_domain, primitives::Root, signing::compute_signing_root, - state_transition::Context, +use ssz_rs::{ + calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, + Merkleized, SszVariableOrIndex, }; -use ssz_rs::{calculate_multi_merkle_root, is_valid_merkle_branch, GeneralizedIndex, Merkleized}; use std::time::Duration; use sync_committee_primitives::{ - types::{AncestorBlock, FinalityProof, DOMAIN_SYNC_COMMITTEE, GENESIS_VALIDATORS_ROOT}, - util::compute_fork_version, + constants::{Root, DOMAIN_SYNC_COMMITTEE, GENESIS_FORK_VERSION, GENESIS_VALIDATORS_ROOT}, + types::LightClientState, + util::{compute_domain, compute_fork_version, compute_signing_root}, +}; +use sync_committee_verifier::{ + signature_verification::verify_aggregate_signature, verify_sync_committee_attestation, }; -use sync_committee_verifier::{verify_sync_committee_attestation, SignatureVerifier}; use tokio::time; use tokio_stream::{wrappers::IntervalStream, StreamExt}; -const NODE_URL: &'static str = "http://localhost:5052"; +const CONSENSUS_NODE_URL: &'static str = "http://localhost:3500"; +const EL_NODE_URL: &'static str = "http://localhost:8545"; + +async fn wait_for_el() { + let provider = Provider::::connect(EL_NODE_URL).await; + let sub = provider.watch_blocks().await.unwrap(); + let _ = sub.take(10).collect::>(); +} #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn fetch_block_header_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block_header = sync_committee_prover.fetch_header("head").await; assert!(block_header.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn fetch_block_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block = sync_committee_prover.fetch_block("head").await; assert!(block.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_sync_committee_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); - let block = sync_committee_prover.fetch_sync_committee("head").await; - assert!(block.is_ok()); +#[tokio::test] +async fn fetch_validator_works() { + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let validator = sync_committee_prover.fetch_validator("head", "0").await; + assert!(validator.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] -async fn fetch_validator_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); - let validator = sync_committee_prover.fetch_validator("head", "48").await; +#[tokio::test] +async fn fetch_processed_sync_committee_works() { + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let validator = sync_committee_prover.fetch_processed_sync_committee("head").await; assert!(validator.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] #[ignore] -async fn fetch_processed_sync_committee_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); - let validator = sync_committee_prover.fetch_processed_sync_committee("head").await; - assert!(validator.is_ok()); +async fn generate_indexes() { + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); + let execution_payload_index = get_generalized_index( + &beacon_state, + &[SszVariableOrIndex::Name("latest_execution_payload_header")], + ); + let next_sync = + get_generalized_index(&beacon_state, &[SszVariableOrIndex::Name("next_sync_committee")]); + let finalized = + get_generalized_index(&beacon_state, &[SszVariableOrIndex::Name("finalized_checkpoint")]); + let execution_payload_root = get_generalized_index( + &beacon_state.latest_execution_payload_header, + &[SszVariableOrIndex::Name("state_root")], + ); + let block_number = get_generalized_index( + &beacon_state.latest_execution_payload_header, + &[SszVariableOrIndex::Name("block_number")], + ); + let timestamp = get_generalized_index( + &beacon_state.latest_execution_payload_header, + &[SszVariableOrIndex::Name("timestamp")], + ); + + dbg!(execution_payload_index); + dbg!(next_sync); + dbg!(finalized); + dbg!(execution_payload_root); + dbg!(block_number); + dbg!(timestamp); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn fetch_beacon_state_works() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let beacon_state = sync_committee_prover.fetch_beacon_state("head").await; assert!(beacon_state.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn state_root_and_block_header_root_matches() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_header = sync_committee_prover.fetch_header(&beacon_state.slot.to_string()).await; @@ -89,23 +129,25 @@ async fn state_root_and_block_header_root_matches() { let block_header = block_header.unwrap(); let hash_tree_root = beacon_state.hash_tree_root(); - assert!(block_header.state_root == hash_tree_root.unwrap()); + assert_eq!(block_header.state_root, hash_tree_root.unwrap()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn fetch_finality_checkpoints_work() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; assert!(finality_checkpoint.is_ok()); } #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn test_finalized_header() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let proof = ssz_rs::generate_proof(&mut state, &vec![FINALIZED_ROOT_INDEX as usize]); @@ -129,30 +171,27 @@ async fn test_finalized_header() { #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn test_execution_payload_proof() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); - let finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); + let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_id = finalized_state.slot.to_string(); - let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); + let execution_payload_proof = prove_execution_payload(&mut finalized_state).unwrap(); let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); // verify the associated execution header of the finalized beacon header. let mut execution_payload = execution_payload_proof.clone(); let multi_proof_vec = execution_payload.multi_proof; - let multi_proof_nodes = multi_proof_vec - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); let execution_payload_root = calculate_multi_merkle_root( &[ Node::from_bytes(execution_payload.state_root.as_ref().try_into().unwrap()), execution_payload.block_number.hash_tree_root().unwrap(), execution_payload.timestamp.hash_tree_root().unwrap(), ], - &multi_proof_nodes, + &multi_proof_vec, &[ GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), @@ -168,18 +207,14 @@ async fn test_execution_payload_proof() { assert_eq!(execution_payload_root, execution_payload_hash_tree_root); - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); + let execution_payload_branch = execution_payload.execution_payload_branch.iter(); let is_merkle_branch_valid = is_valid_merkle_branch( &execution_payload_root, - execution_payload_branch.iter(), + execution_payload_branch, EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, - &Node::from_bytes(finalized_header.clone().state_root.as_ref().try_into().unwrap()), + &finalized_header.state_root, ); assert!(is_merkle_branch_valid); @@ -187,43 +222,30 @@ async fn test_execution_payload_proof() { #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn test_sync_committee_update_proof() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); - let finalized_header = sync_committee_prover.fetch_header("head").await.unwrap(); - - let finalized_state = sync_committee_prover - .fetch_beacon_state(&finalized_header.slot.to_string()) - .await - .unwrap(); + let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); + let block_id = finalized_state.slot.to_string(); + let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - let sync_committee_proof = prove_sync_committee_update(finalized_state.clone()).unwrap(); + let sync_committee_proof = prove_sync_committee_update(&mut finalized_state).unwrap(); - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice")) - .collect::>(); let mut sync_committee = finalized_state.next_sync_committee; let calculated_finalized_root = calculate_multi_merkle_root( - &[Node::from_bytes(sync_committee.hash_tree_root().unwrap().as_ref().try_into().unwrap())], - &sync_committee_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(), + &[sync_committee.hash_tree_root().unwrap()], + &sync_committee_proof, &[GeneralizedIndex(NEXT_SYNC_COMMITTEE_INDEX as usize)], ); assert_eq!(calculated_finalized_root.as_bytes(), finalized_header.state_root.as_bytes()); - let next_sync_committee_branch = sync_committee_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( &Node::from_bytes(sync_committee.hash_tree_root().unwrap().as_ref().try_into().unwrap()), - next_sync_committee_branch.iter(), + sync_committee_proof.iter(), NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), @@ -234,12 +256,17 @@ async fn test_sync_committee_update_proof() { #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn test_prover() { - env_logger::init(); + use log::LevelFilter; + env_logger::builder() + .filter_module("prover", LevelFilter::Debug) + .format_module_path(false) + .init(); + wait_for_el().await; let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 12))); - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block_id = "head"; @@ -259,190 +286,20 @@ async fn test_prover() { let mut count = 0; while let Some(_ts) = stream.next().await { - let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await.unwrap(); - if finality_checkpoint.finalized.root == Node::default() || - finality_checkpoint.finalized.epoch <= client_state.latest_finalized_epoch || - finality_checkpoint.finalized.root == - client_state.finalized_header.clone().hash_tree_root().unwrap() - { - continue - } - - println!("A new epoch has been finalized {}", finality_checkpoint.finalized.epoch); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.finalized.root.as_bytes()); - block_id.insert_str(0, "0x"); - block_id - }; - - let finalized_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); - let finalized_state = sync_committee_prover - .fetch_beacon_state(finalized_header.slot.to_string().as_str()) + let light_client_update = if let Some(update) = sync_committee_prover + .fetch_light_client_update(client_state.clone(), "prover") .await - .unwrap(); - let execution_payload_proof = prove_execution_payload(finalized_state.clone()).unwrap(); - - let mut attested_epoch = finality_checkpoint.finalized.epoch + 2; - // Get attested header and the signature slot - - let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; - // Due to the fact that all slots in an epoch can be missed we are going to try and fetch - // the attested block from four possible epochs. - let mut attested_epoch_loop_count = 0; - let (attested_block_header, signature_block) = loop { - if attested_epoch_loop_count == 4 { - panic!("Could not fetch any block from the attested epoch after going through four epochs, your Eth devnet is fucked") - } - // If we have maxed out the slots in the current epoch and still didn't find any block, - // we move to the next epoch - if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == - attested_slot - { - // No block was found in attested epoch we move to the next possible attested epoch - println!( - "No slots found in epoch {attested_epoch} Moving to the next possible epoch {}", - attested_epoch + 1 - ); - std::thread::sleep(Duration::from_secs(24)); - attested_epoch += 1; - attested_slot = attested_epoch * SLOTS_PER_EPOCH; - attested_epoch_loop_count += 1; - } - - if let Ok(header) = - sync_committee_prover.fetch_header(attested_slot.to_string().as_str()).await - { - let mut signature_slot = header.slot + 1; - let mut loop_count = 0; - let signature_block = loop { - if loop_count == 2 { - break None - } - if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == - signature_slot - { - println!("Waiting for signature block for attested header"); - std::thread::sleep(Duration::from_secs(24)); - signature_slot = header.slot + 1; - loop_count += 1; - } - if let Ok(signature_block) = - sync_committee_prover.fetch_block(signature_slot.to_string().as_str()).await - { - break Some(signature_block) - } - signature_slot += 1; - }; - // If the next block does not have sufficient sync committee participants - if let Some(signature_block) = signature_block { - if signature_block - .body - .sync_aggregate - .sync_committee_bits - .as_bitslice() - .count_ones() < (2 * (SYNC_COMMITTEE_SIZE)) / 3 - { - attested_slot += 1; - println!("Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); - continue - } - break (header, signature_block) - } else { - println!("No signature block found in {attested_epoch} Moving to the next possible epoch {}", attested_epoch + 1); - std::thread::sleep(Duration::from_secs(24)); - attested_epoch += 1; - attested_slot = attested_epoch * SLOTS_PER_EPOCH; - attested_epoch_loop_count += 1; - continue - } - } - attested_slot += 1 - }; - - let attested_state = sync_committee_prover - .fetch_beacon_state(attested_block_header.slot.to_string().as_str()) - .await - .unwrap(); - - let finalized_hash_tree_root = finalized_header.clone().hash_tree_root().unwrap(); - println!("{:?}, {}", attested_state.finalized_checkpoint, attested_state.slot); - println!("{:?}, {}", finalized_hash_tree_root, finalized_header.slot); - - assert_eq!(finalized_hash_tree_root, attested_state.finalized_checkpoint.root); - - let finality_proof = FinalityProof { - epoch: finality_checkpoint.finalized.epoch, - finality_branch: prove_finalized_header(attested_state.clone()).unwrap(), - }; - - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - let update_attested_period = - compute_sync_committee_period_at_slot(attested_block_header.slot); - - let sync_committee_update = if state_period == update_attested_period { - let sync_committee_proof = prove_sync_committee_update(attested_state.clone()).unwrap(); - - let sync_committee_proof = sync_committee_proof - .into_iter() - .map(|node| { - Bytes32::try_from(node.as_bytes()).expect("Node is always 32 byte slice") - }) - .collect::>(); - - Some(SyncCommitteeUpdate { - next_sync_committee: attested_state.next_sync_committee, - next_sync_committee_branch: sync_committee_proof, - }) + .unwrap() + { + update } else { - None - }; - - let mut i = finalized_header.slot - 1; - let mut ancestor_blocks = vec![]; - while ancestor_blocks.len() < 5 { - if (finalized_header.slot - i) > 100 { - break - } - if let Ok(ancestor_header) = - sync_committee_prover.fetch_header(i.to_string().as_str()).await - { - let ancestry_proof = - prove_block_roots_proof(finalized_state.clone(), ancestor_header.clone()) - .unwrap(); - let header_state = - sync_committee_prover.fetch_beacon_state(i.to_string().as_str()).await.unwrap(); - let execution_payload_proof = prove_execution_payload(header_state).unwrap(); - ancestor_blocks.push(AncestorBlock { - header: ancestor_header, - execution_payload: execution_payload_proof, - ancestry_proof, - }) - } - i -= 1; - } - - println!("\nAncestor blocks count: \n {:?} \n", ancestor_blocks.len()); - - // construct light client - let light_client_update = LightClientUpdate { - attested_header: attested_block_header, - sync_committee_update, - finalized_header, - execution_payload: execution_payload_proof, - finality_proof, - sync_aggregate: signature_block.body.sync_aggregate, - signature_slot: signature_block.slot, - ancestor_blocks: vec![], + continue }; - client_state = verify_sync_committee_attestation::( - client_state.clone(), - light_client_update, - ) - .unwrap(); - println!( + client_state = + verify_sync_committee_attestation(client_state.clone(), light_client_update).unwrap(); + debug!( + target: "prover", "Sucessfully verified Ethereum block at slot {:?}", client_state.finalized_header.slot ); @@ -455,11 +312,13 @@ async fn test_prover() { } } +#[ignore] #[cfg(test)] #[allow(non_snake_case)] -#[actix_rt::test] +#[tokio::test] async fn test_sync_committee_signature_verification() { - let sync_committee_prover = SyncCommitteeProver::new(NODE_URL.to_string()); + wait_for_el().await; + let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block = loop { let block = sync_committee_prover.fetch_block("head").await.unwrap(); if block.slot < 16 { @@ -480,31 +339,31 @@ async fn test_sync_committee_signature_verification() { let sync_committee_pubkeys = sync_committee.public_keys; - let participant_pubkeys = block + let non_participant_pubkeys = block .body .sync_aggregate .sync_committee_bits .iter() .zip(sync_committee_pubkeys.iter()) - .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) + .filter_map(|(bit, key)| if !(*bit) { Some(key.clone()) } else { None }) .collect::>(); let fork_version = compute_fork_version(compute_epoch_at_slot(block.slot)); - let context = Context::for_mainnet(); let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().unwrap())), - &context, + GENESIS_FORK_VERSION, ) .unwrap(); - let signing_root = compute_signing_root(&mut attested_header, domain); + let signing_root = compute_signing_root(&mut attested_header, domain).unwrap(); - ethereum_consensus::crypto::fast_aggregate_verify( - &*participant_pubkeys, - signing_root.unwrap().as_bytes(), + verify_aggregate_signature( + &sync_committee.aggregate_public_key, + &non_participant_pubkeys, + signing_root.as_bytes().to_vec(), &block.body.sync_aggregate.sync_committee_signature, ) .unwrap(); diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index e381b0445..2bfc47504 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -6,14 +6,27 @@ authors = ["Polytope Labs"] [dependencies] sync-committee-primitives = { path= "../primitives", default-features = false } -ethereum-consensus = { git = "https://github.com/polytope-labs/ethereum-consensus", branch = "main", default-features = false } ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" , default-features = false } log = { version = "0.4.17", default-features = false } +anyhow = { version = "1.0.75", default-features = false } +ark-ec = { version = "0.4.2", default-features = false } +ark-bls12-381 = { version = "0.4.0", default-features = false } +bls_on_arkworks = { version = "0.2.2", default-features = false } [features] default = ["std"] std = [ "ssz-rs/std", - "log/std" + "log/std", + "sync-committee-primitives/std", + "log/std", + "anyhow/std", + "ark-ec/std", + "ark-bls12-381/std", + "bls_on_arkworks/std" ] -testing = ["sync-committee-primitives/testing"] +testnet = ["sync-committee-primitives/testnet"] +mainnet = ["sync-committee-primitives/mainnet"] + +[dev-dependencies] +hex = "0.4.3" \ No newline at end of file diff --git a/verifier/src/error.rs b/verifier/src/error.rs index 4fd88fabc..567e74c6a 100644 --- a/verifier/src/error.rs +++ b/verifier/src/error.rs @@ -5,16 +5,10 @@ pub enum Error { SyncCommitteeParticipantsTooLow, InvalidUpdate, DomainError, - FastAggregateError(ethereum_consensus::crypto::Error), InvalidMerkleBranch, InvalidRoot, MerkleizationError, -} - -impl From for Error { - fn from(error: ethereum_consensus::crypto::Error) -> Self { - Error::FastAggregateError(error) - } + SignatureVerification, } impl Display for Error { @@ -25,10 +19,10 @@ impl Display for Error { }, Error::InvalidUpdate => write!(f, "Invalid update"), Error::DomainError => write!(f, "Couldn't get domain"), - Error::FastAggregateError(err) => write!(f, "Fast aggregate error {:?}", err), Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), Error::InvalidRoot => write!(f, "Invalid root"), Error::MerkleizationError => write!(f, "Merkleization error"), + Error::SignatureVerification => write!(f, "Signature verification failed"), } } } diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 56958c01c..157da6a93 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -4,43 +4,34 @@ extern crate alloc; pub mod error; +pub mod signature_verification; -use crate::error::Error; +use crate::{error::Error, signature_verification::verify_aggregate_signature}; use alloc::vec::Vec; -use ethereum_consensus::{ - bellatrix::{compute_domain, mainnet::SYNC_COMMITTEE_SIZE, Checkpoint}, - crypto::{PublicKey, Signature}, - primitives::Root, - signing::compute_signing_root, - state_transition::Context, -}; use ssz_rs::{ - calculate_merkle_root, calculate_multi_merkle_root, prelude::is_valid_merkle_branch, - GeneralizedIndex, Merkleized, Node, + calculate_multi_merkle_root, prelude::is_valid_merkle_branch, GeneralizedIndex, Merkleized, + Node, }; use sync_committee_primitives::{ - types::{ - AncestryProof, BLOCK_ROOTS_INDEX, BLOCK_ROOTS_INDEX_LOG2, DOMAIN_SYNC_COMMITTEE, - EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, + consensus_types::Checkpoint, + constants::{ + Root, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_INDEX_LOG2, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, FINALIZED_ROOT_INDEX, FINALIZED_ROOT_INDEX_LOG2, - GENESIS_VALIDATORS_ROOT, HISTORICAL_BATCH_BLOCK_ROOTS_INDEX, HISTORICAL_ROOTS_INDEX, - HISTORICAL_ROOTS_INDEX_LOG2, NEXT_SYNC_COMMITTEE_INDEX, NEXT_SYNC_COMMITTEE_INDEX_LOG2, + GENESIS_FORK_VERSION, GENESIS_VALIDATORS_ROOT, NEXT_SYNC_COMMITTEE_INDEX, + NEXT_SYNC_COMMITTEE_INDEX_LOG2, + }, + util::{ + compute_domain, compute_epoch_at_slot, compute_fork_version, compute_signing_root, + compute_sync_committee_period_at_slot, }, - util::{compute_epoch_at_slot, compute_fork_version, compute_sync_committee_period_at_slot}, }; -pub type LightClientState = sync_committee_primitives::types::LightClientState; -pub type LightClientUpdate = - sync_committee_primitives::types::LightClientUpdate; - -/// Verify sync committee signatures -pub trait BlsVerify { - fn verify(public_keys: &[&PublicKey], msg: &[u8], signature: &Signature) -> Result<(), Error>; -} +pub type LightClientState = sync_committee_primitives::types::LightClientState; +pub type LightClientUpdate = sync_committee_primitives::types::LightClientUpdate; /// This function simply verifies a sync committee's attestation & it's finalized counterpart. -pub fn verify_sync_committee_attestation( +pub fn verify_sync_committee_attestation( trusted_state: LightClientState, update: LightClientUpdate, ) -> Result { @@ -94,30 +85,32 @@ pub fn verify_sync_committee_attestation( let sync_committee_pubkeys = sync_committee.public_keys; - let participant_pubkeys = sync_committee_bits + let non_participant_pubkeys = sync_committee_bits .iter() .zip(sync_committee_pubkeys.iter()) - .filter_map(|(bit, key)| if *bit { Some(key) } else { None }) + .filter_map(|(bit, key)| if !(*bit) { Some(key.clone()) } else { None }) .collect::>(); let fork_version = compute_fork_version(compute_epoch_at_slot(update.signature_slot)); - let context = Context::for_mainnet(); let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().map_err(|_| Error::InvalidRoot)?)), - &context, + GENESIS_FORK_VERSION, ) .map_err(|_| Error::InvalidUpdate)?; - let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain); + let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain) + .map_err(|_| Error::InvalidRoot)?; - V::verify( - &*participant_pubkeys, - signing_root.map_err(|_| Error::InvalidRoot)?.as_bytes(), + verify_aggregate_signature( + &trusted_state.current_sync_committee.aggregate_public_key, + &non_participant_pubkeys, + signing_root.as_bytes().to_vec(), &update.sync_aggregate.sync_committee_signature, - )?; + ) + .map_err(|_| Error::SignatureVerification)?; // Verify that the `finality_branch` confirms `finalized_header` // to match the finalized checkpoint root saved in the state of `attested_header`. @@ -131,16 +124,9 @@ pub fn verify_sync_committee_attestation( .map_err(|_| Error::InvalidRoot)?, }; - let branch = update - .finality_proof - .finality_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( &finalized_checkpoint.hash_tree_root().map_err(|_| Error::InvalidRoot)?, - branch.iter(), + update.finality_proof.finality_branch.iter(), FINALIZED_ROOT_INDEX_LOG2 as usize, FINALIZED_ROOT_INDEX as usize, &update.attested_header.state_root, @@ -152,11 +138,6 @@ pub fn verify_sync_committee_attestation( // verify the associated execution header of the finalized beacon header. let mut execution_payload = update.execution_payload; - let multi_proof_vec = execution_payload.multi_proof; - let multi_proof_nodes = multi_proof_vec - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); let execution_payload_root = calculate_multi_merkle_root( &[ Node::from_bytes( @@ -172,7 +153,7 @@ pub fn verify_sync_committee_attestation( .map_err(|_| Error::InvalidRoot)?, execution_payload.timestamp.hash_tree_root().map_err(|_| Error::InvalidRoot)?, ], - &multi_proof_nodes, + &execution_payload.multi_proof, &[ GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), @@ -180,15 +161,9 @@ pub fn verify_sync_committee_attestation( ], ); - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( &execution_payload_root, - execution_payload_branch.iter(), + execution_payload.execution_payload_branch.iter(), EXECUTION_PAYLOAD_INDEX_LOG2 as usize, EXECUTION_PAYLOAD_INDEX as usize, &update.finalized_header.state_root, @@ -206,17 +181,12 @@ pub fn verify_sync_committee_attestation( Err(Error::InvalidUpdate)? } - let next_sync_committee_branch = sync_committee_update - .next_sync_committee_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); let is_merkle_branch_valid = is_valid_merkle_branch( &sync_committee_update .next_sync_committee .hash_tree_root() .map_err(|_| Error::MerkleizationError)?, - next_sync_committee_branch.iter(), + sync_committee_update.next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, &update.attested_header.state_root, @@ -227,170 +197,6 @@ pub fn verify_sync_committee_attestation( } } - // verify the ancestry proofs - for mut ancestor in update.ancestor_blocks { - match ancestor.ancestry_proof { - AncestryProof::BlockRoots { block_roots_proof, block_roots_branch } => { - let block_header_branch = block_roots_proof - .block_header_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let block_roots_root = calculate_merkle_root( - &ancestor.header.hash_tree_root().map_err(|_| Error::MerkleizationError)?, - &*block_header_branch, - &GeneralizedIndex(block_roots_proof.block_header_index as usize), - ); - - let block_roots_branch_node = block_roots_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - - let is_merkle_branch_valid = is_valid_merkle_branch( - &block_roots_root, - block_roots_branch_node.iter(), - BLOCK_ROOTS_INDEX_LOG2 as usize, - BLOCK_ROOTS_INDEX as usize, - &update.finalized_header.state_root, - ); - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - }, - AncestryProof::HistoricalRoots { - block_roots_proof, - historical_batch_proof, - historical_roots_proof, - historical_roots_index, - historical_roots_branch, - } => { - let block_header_branch = block_roots_proof - .block_header_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let block_roots_root = calculate_merkle_root( - &ancestor - .header - .clone() - .hash_tree_root() - .map_err(|_| Error::MerkleizationError)?, - &block_header_branch, - &GeneralizedIndex(block_roots_proof.block_header_index as usize), - ); - - let historical_batch_proof_nodes = historical_batch_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let historical_batch_root = calculate_merkle_root( - &block_roots_root, - &historical_batch_proof_nodes, - &GeneralizedIndex(HISTORICAL_BATCH_BLOCK_ROOTS_INDEX as usize), - ); - - let historical_roots_proof_nodes = historical_roots_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let historical_roots_root = calculate_merkle_root( - &historical_batch_root, - &historical_roots_proof_nodes, - &GeneralizedIndex(historical_roots_index as usize), - ); - - let historical_roots_branch_nodes = historical_roots_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &historical_roots_root, - historical_roots_branch_nodes.iter(), - HISTORICAL_ROOTS_INDEX_LOG2 as usize, - HISTORICAL_ROOTS_INDEX as usize, - &Node::from_bytes( - update - .finalized_header - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ); - - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - }, - }; - - // verify the associated execution paylaod header. - let execution_payload = ancestor.execution_payload; - let multi_proof = execution_payload - .multi_proof - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let execution_payload_root = calculate_multi_merkle_root( - &[ - Node::from_bytes( - execution_payload - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - Node::from_bytes( - execution_payload - .block_number - .clone() - .hash_tree_root() - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - Node::from_bytes( - execution_payload - .timestamp - .clone() - .hash_tree_root() - .map_err(|_| Error::MerkleizationError)? - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), - ], - &multi_proof, - &[ - GeneralizedIndex(EXECUTION_PAYLOAD_STATE_ROOT_INDEX as usize), - GeneralizedIndex(EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX as usize), - GeneralizedIndex(EXECUTION_PAYLOAD_TIMESTAMP_INDEX as usize), - ], - ); - - let execution_payload_branch = execution_payload - .execution_payload_branch - .iter() - .map(|node| Node::from_bytes(node.as_ref().try_into().unwrap())) - .collect::>(); - let is_merkle_branch_valid = is_valid_merkle_branch( - &execution_payload_root, - execution_payload_branch.iter(), - EXECUTION_PAYLOAD_INDEX_LOG2 as usize, - EXECUTION_PAYLOAD_INDEX as usize, - &Node::from_bytes( - ancestor.header.state_root.as_ref().try_into().map_err(|_| Error::InvalidRoot)?, - ), - ); - - if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; - } - } - let new_light_client_state = if let Some(sync_committee_update) = update.sync_committee_update { LightClientState { finalized_header: update.finalized_header, @@ -404,13 +210,3 @@ pub fn verify_sync_committee_attestation( Ok(new_light_client_state) } - -pub struct SignatureVerifier; - -impl BlsVerify for SignatureVerifier { - fn verify(public_keys: &[&PublicKey], msg: &[u8], signature: &Signature) -> Result<(), Error> { - ethereum_consensus::crypto::fast_aggregate_verify(public_keys, msg, signature)?; - - Ok(()) - } -} diff --git a/verifier/src/signature_verification.rs b/verifier/src/signature_verification.rs new file mode 100644 index 000000000..06aa4f27c --- /dev/null +++ b/verifier/src/signature_verification.rs @@ -0,0 +1,108 @@ +use alloc::vec::Vec; +use anyhow::anyhow; +use ark_bls12_381::Bls12_381; +use ark_ec::{pairing::Pairing, AffineRepr}; +use bls_on_arkworks::{ + hash_to_point, pubkey_to_point, signature_to_point, + types::{BLS12381Pairing, G1AffinePoint, G1ProjectivePoint, G2AffinePoint, Signature}, + DST_ETHEREUM, +}; +use sync_committee_primitives::constants::BlsPublicKey; + +pub fn pubkey_to_projective(compressed_key: &BlsPublicKey) -> anyhow::Result { + let affine_point = pubkey_to_point(&compressed_key.to_vec()).map_err(|e| anyhow!("{:?}", e))?; + Ok(affine_point.into()) +} + +fn subtract_points_from_aggregate( + aggregate: &BlsPublicKey, + points: &[BlsPublicKey], +) -> anyhow::Result { + let aggregate = pubkey_to_projective(aggregate)?; + let points = points + .iter() + .map(|point| pubkey_to_projective(point)) + .collect::, _>>()?; + let subset_aggregate = points.into_iter().fold(aggregate, |acc, point| acc - point); + Ok(subset_aggregate) +} + +fn pairing(u: G2AffinePoint, v: G1AffinePoint) -> BLS12381Pairing { + Bls12_381::pairing(v, u) +} + +/// Adapted from https://github.com/ArnaudBrousseau/bls_on_arkworks/blob/main/src/lib.rs#L335 +/// Verifies an aggregate bls12-381 signature from ethereum sync-committee +/// Expects signature subgroup to be valid +pub fn verify_aggregate_signature( + aggregate: &BlsPublicKey, + non_participants: &[BlsPublicKey], + msg: Vec, + signature: &Signature, +) -> anyhow::Result<()> { + let subset_aggregate = subtract_points_from_aggregate(aggregate, non_participants)?; + let aggregate_key_point: G1AffinePoint = subset_aggregate.into(); + let signature = signature_to_point(signature).map_err(|e| anyhow!("{:?}", e))?; + let dst = DST_ETHEREUM.as_bytes().to_vec(); + + let q = hash_to_point(&msg, &dst); + + let c1 = pairing(q, aggregate_key_point); + + // From the spec: + // > When the signature variant is minimal-pubkey-size, P is the distinguished point P1 that + // > generates the group G1. + // + let p = G1AffinePoint::generator(); + + let c2 = pairing(signature, p); + + if c1 == c2 { + Ok(()) + } else { + Err(anyhow!("Aggregate signature verification failed")) + } +} + +#[cfg(test)] +mod tests { + use crate::signature_verification::verify_aggregate_signature; + + #[test] + fn test_signature_verification() { + let pks = vec![ + hex::decode("882417eb57b98c7dd8e4adb5d4c7b59cb46ad093072f10db99e02597e3432fe094e2698df4c3bf65ff757ac602182f87").unwrap(), + hex::decode("8ef016d09c49af41d028fdf6ef04972d11f6931bf57f0922df4e77a52847227c880581eebb6b485af1d68bb4895cc35c").unwrap(), + hex::decode("88b92def24f441be1eba41ff76182e0eb224cf06e751df45635db1530bf37765861c82a8f381f81f6ac6a2b3d3d9875b").unwrap(), + hex::decode("afc92546e835a4dbe31e2b3a4e6f44a94466a6f9b5752113b9b828349254582eb7b5b596a32b79fc936a82db8802af0c").unwrap(), + hex::decode("8391e3a00add4bcbe4c339fa7c35238855861cbbc89ceefa6832de6b28bc378a0d038a329636d53404e0deaa444bdfd0").unwrap(), + hex::decode("9102e77817e572a16fab849f7681d130d10876880d7fe05d40091af93592150ad4829145a7327d125e71a8847a368121").unwrap(), + hex::decode("8d966a5cfd601661bfb6e15b8c849d3bd85006aec628b44e88022b01054be5159de73f16504a969d6009a59d9214b043").unwrap(), + hex::decode("b6778f88f9df6d5d09baf9bccd2ea1e4cb88469239a0a14ffcca37fc1c29bad69711dc64fc4e1bb1be0792b005a1729a").unwrap(), + hex::decode("afc664d1160d2a55fab55fe9d94551b18aa2543f218b9fbdd733509463416c96ee13da6cf75f97165922ca61372c6fb7").unwrap(), + hex::decode("ad413282bc501315d2cccf8e2a5dd54a5baca851515a04e5f252c98cfeeb670604fa48c707127017e0b8cda218d98207").unwrap() + ]; + + let message = + hex::decode("813a89a296973e35545cfa74fe3efd172a7d19443c97c625d699e9737229b0a2") + .unwrap(); + let aggregate_signature = hex::decode("a1abfcf9bd54b7a003e1f45f7543b194d8d25b816577b02ee4f1c99aa9821c620be6ecedbc8c5fab64d343a6cc832040029040e591fa24db54f5441f28d73918775e8feeac6177c9e016d2576b982d1cce453896a8aace2bda7374e5a76ce213").unwrap(); + let aggregate_pub_key = hex::decode("a3f2da752bd1dfc7288b46cc061668856e0cefa93ba6e8ff4699f355138f63a541fdb3444ddebcdce695d6313fa4b244").unwrap().try_into().unwrap(); + + let bit_vector = hex::decode("01000100010001000100").unwrap(); + + let non_participants = pks + .into_iter() + .zip(bit_vector) + .filter_map(|(pk, bit)| if bit == 0 { Some(pk.try_into().unwrap()) } else { None }) + .collect::>(); + + verify_aggregate_signature( + &aggregate_pub_key, + &non_participants, + message, + &aggregate_signature, + ) + .unwrap() + } +} From 106f53e045cc85c4a8d984c8e295800cebaa2475 Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:13:26 +0100 Subject: [PATCH 096/100] Rewrite of method for fetching client updates (#30) * refactor of prover * nit * some fixes * cargo update * fix lower bound for valid signature block search * doc * nit * nit * minor fix --- .github/workflows/test.yml | 2 +- Cargo.lock | 64 ++++++++++++++- primitives/src/constants.rs | 12 +-- primitives/src/types.rs | 8 +- primitives/src/util.rs | 10 ++- prover/Cargo.toml | 4 +- prover/src/lib.rs | 158 ++++++++++++------------------------ prover/src/test.rs | 134 ++++++++++++++++++------------ verifier/src/error.rs | 17 ++-- verifier/src/lib.rs | 89 ++++++++++---------- 10 files changed, 264 insertions(+), 234 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d506ab68..c704c3b1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/Cargo.lock b/Cargo.lock index 00e32893f..881214b8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1270,6 +1270,17 @@ dependencies = [ "yansi", ] +[[package]] +name = "eventsource-stream" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74fef4569247a5f429d9156b9d0a2599914385dd189c539334c625d8099d90ab" +dependencies = [ + "futures-core", + "nom", + "pin-project-lite", +] + [[package]] name = "eyre" version = "0.6.8" @@ -2028,6 +2039,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -2078,6 +2095,16 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -2700,15 +2727,33 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls", + "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams", "web-sys", "webpki-roots 0.25.2", "winreg", ] +[[package]] +name = "reqwest-eventsource" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f03f570355882dd8d15acc3a313841e6e90eddbc76a93c748fd82cc13ba9f51" +dependencies = [ + "eventsource-stream", + "futures-core", + "futures-timer", + "mime", + "nom", + "pin-project-lite", + "reqwest", + "thiserror", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -3202,7 +3247,7 @@ dependencies = [ [[package]] name = "ssz-rs" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#81e9f63c93ca33f5f484ac301553f04912f2de23" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#6f5d37b7f92875b5cbb6ef60e8c498ca013943cb" dependencies = [ "as-any", "bitvec", @@ -3218,7 +3263,7 @@ dependencies = [ [[package]] name = "ssz-rs-derive" version = "0.8.0" -source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#81e9f63c93ca33f5f484ac301553f04912f2de23" +source = "git+https://github.com/polytope-labs/ssz-rs?branch=main#6f5d37b7f92875b5cbb6ef60e8c498ca013943cb" dependencies = [ "proc-macro2", "quote", @@ -3344,8 +3389,10 @@ dependencies = [ "ethers", "hex", "log", + "parity-scale-codec", "primitive-types", "reqwest", + "reqwest-eventsource", "serde", "serde_json", "ssz-rs", @@ -3866,6 +3913,19 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +[[package]] +name = "wasm-streams" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.64" diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index df7a0247e..04c24300f 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -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; @@ -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")] @@ -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")))] @@ -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; } diff --git a/primitives/src/types.rs b/primitives/src/types.rs index c0ca114a5..de5ad4be4 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -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, ssz merkle proof. + /// next sync committee, ssz merkle proof. pub next_sync_committee_branch: Vec, } @@ -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, pub next_sync_committee: SyncCommittee, } diff --git a/primitives/src/util.rs b/primitives/src/util.rs index 4c1abaab4..227d5e503 100644 --- a/primitives/src/util.rs +++ b/primitives/src/util.rs @@ -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, }, @@ -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 } diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 1abc687ed..21ae744da 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -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"] diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 5fe4bfe4c..6cfc7366a 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -9,9 +9,8 @@ use anyhow::anyhow; use bls_on_arkworks::{point_to_pubkey, types::G1ProjectivePoint}; use log::debug; use reqwest::Client; -use std::time::Duration; use sync_committee_primitives::consensus_types::{ - BeaconBlock, BeaconBlockHeader, BeaconState, SyncCommittee, Validator, + BeaconBlock, BeaconBlockHeader, BeaconState, Checkpoint, SyncCommittee, Validator, }; use crate::{ @@ -25,7 +24,7 @@ use primitive_types::H256; use ssz_rs::{List, Merkleized, Node, Vector}; use sync_committee_primitives::{ constants::{ - BlsPublicKey, ValidatorIndex, BLOCK_ROOTS_INDEX, BYTES_PER_LOGS_BLOOM, + BlsPublicKey, Root, ValidatorIndex, BLOCK_ROOTS_INDEX, BYTES_PER_LOGS_BLOOM, EPOCHS_PER_HISTORICAL_VECTOR, EPOCHS_PER_SLASHINGS_VECTOR, ETH1_DATA_VOTES_BOUND, EXECUTION_PAYLOAD_BLOCK_NUMBER_INDEX, EXECUTION_PAYLOAD_INDEX, EXECUTION_PAYLOAD_STATE_ROOT_INDEX, EXECUTION_PAYLOAD_TIMESTAMP_INDEX, @@ -40,8 +39,12 @@ use sync_committee_primitives::{ AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, LightClientUpdate, SyncCommitteeUpdate, }, - util::{compute_epoch_at_slot, compute_sync_committee_period_at_slot}, + util::{ + compute_epoch_at_slot, compute_sync_committee_period_at_slot, + should_get_sync_committee_update, + }, }; + use sync_committee_verifier::{signature_verification::pubkey_to_projective, LightClientState}; pub type BeaconStateType = BeaconState< @@ -217,127 +220,70 @@ impl SyncCommitteeProver { pub async fn fetch_light_client_update( &self, client_state: LightClientState, + finality_checkpoint: Checkpoint, debug_target: &str, ) -> Result, anyhow::Error> { - let finality_checkpoint = self.fetch_finalized_checkpoint().await?; - if finality_checkpoint.finalized.root == Node::default() || - finality_checkpoint.finalized.epoch <= client_state.latest_finalized_epoch || - finality_checkpoint.finalized.root == - client_state.finalized_header.clone().hash_tree_root()? + if finality_checkpoint.root == Node::default() || + finality_checkpoint.epoch <= client_state.latest_finalized_epoch { return Ok(None) } - debug!(target: debug_target, "A new epoch has been finalized {}", finality_checkpoint.finalized.epoch); - - let block_id = { - let mut block_id = hex::encode(finality_checkpoint.finalized.root.as_bytes()); + debug!(target: debug_target, "A new epoch has been finalized {}", finality_checkpoint.epoch); + // Find the highest block with the a threshhold number of sync committee signatures + let latest_header = self.fetch_header("head").await?; + let latest_root = latest_header.clone().hash_tree_root()?; + let get_block_id = |root: Root| { + let mut block_id = hex::encode(root.0.to_vec()); block_id.insert_str(0, "0x"); block_id }; + let mut block = self.fetch_block(&get_block_id(latest_root)).await?; + let min_signatures = (2 * SYNC_COMMITTEE_SIZE) / 3; + let state_period = + compute_sync_committee_period_at_slot(client_state.finalized_header.slot); + loop { + // If we get to an epoch that is less than the attested epoch for the last known + // finalized header we exit + if compute_epoch_at_slot(block.slot) < client_state.latest_finalized_epoch + 2 { + return Ok(None) + } - let finalized_header = self.fetch_header(&block_id).await?; - let mut finalized_state = - self.fetch_beacon_state(finalized_header.slot.to_string().as_str()).await?; - let execution_payload_proof = prove_execution_payload(&mut finalized_state)?; + let parent_root = block.parent_root; + let block_id = get_block_id(parent_root); + block = self.fetch_block(&block_id).await?; - let mut attested_epoch = finality_checkpoint.finalized.epoch + 2; - // Get attested header and the signature slot + let num_signatures = block.body.sync_aggregate.sync_committee_bits.count_ones(); - let mut attested_slot = attested_epoch * SLOTS_PER_EPOCH; - // Due to the fact that all slots in an epoch can be missed we are going to try and fetch - // the attested block from four possible epochs. - let mut attested_epoch_loop_count = 0; - let (attested_block_header, signature_block) = loop { - if attested_epoch_loop_count == 4 { - Err(anyhow!("Could not fetch any block from the attested epoch after going through four epochs"))? - } - // If we have maxed out the slots in the current epoch and still didn't find any block, - // we move to the next epoch - if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == - attested_slot + let signature_period = compute_sync_committee_period_at_slot(block.slot); + if num_signatures >= min_signatures && + (state_period..=state_period + 1).contains(&signature_period) { - // No block was found in attested epoch we move to the next possible attested epoch - debug!(target: debug_target, - "No slots found in epoch {attested_epoch} Moving to the next possible epoch {}", - attested_epoch + 1 - ); - tokio::time::sleep(Duration::from_secs(24)).await; - attested_epoch += 1; - attested_slot = attested_epoch * SLOTS_PER_EPOCH; - attested_epoch_loop_count += 1; + break } + } - if let Ok(header) = self.fetch_header(attested_slot.to_string().as_str()).await { - let mut signature_slot = header.slot + 1; - let mut loop_count = 0; - let signature_block = loop { - if loop_count == 2 { - break None - } - if (attested_epoch * SLOTS_PER_EPOCH).saturating_add(SLOTS_PER_EPOCH - 1) == - signature_slot - { - debug!(target: debug_target, "Waiting for signature block for attested header"); - tokio::time::sleep(Duration::from_secs(24)).await; - signature_slot = header.slot + 1; - loop_count += 1; - } - if let Ok(signature_block) = - self.fetch_block(signature_slot.to_string().as_str()).await - { - break Some(signature_block) - } - signature_slot += 1; - }; - // If the next block does not have sufficient sync committee participants - if let Some(signature_block) = signature_block { - if signature_block - .body - .sync_aggregate - .sync_committee_bits - .as_bitslice() - .count_ones() < (2 * (SYNC_COMMITTEE_SIZE)) / 3 - { - attested_slot += 1; - debug!(target:debug_target, "Signature block does not have sufficient sync committee participants -> participants {}", signature_block.body.sync_aggregate.sync_committee_bits.as_bitslice().count_ones()); - continue - } - break (header, signature_block) - } else { - debug!(target: debug_target,"No signature block found in {attested_epoch} Moving to the next possible epoch {}", attested_epoch + 1); - tokio::time::sleep(Duration::from_secs(24)).await; - attested_epoch += 1; - attested_slot = attested_epoch * SLOTS_PER_EPOCH; - attested_epoch_loop_count += 1; - continue - } - } - attested_slot += 1 - }; - + let attested_block_id = get_block_id(block.parent_root); + let attested_header = self.fetch_header(&attested_block_id).await?; let mut attested_state = - self.fetch_beacon_state(attested_block_header.slot.to_string().as_str()).await?; - - let finalized_hash_tree_root = finalized_header.clone().hash_tree_root()?; + self.fetch_beacon_state(&get_block_id(attested_header.state_root)).await?; - if cfg!(test) { - assert_eq!(finalized_hash_tree_root, attested_state.finalized_checkpoint.root); + if attested_state.finalized_checkpoint.root == Node::default() { + return Ok(None) } - + let finalized_block_id = get_block_id(attested_state.finalized_checkpoint.root); + let finalized_header = self.fetch_header(&finalized_block_id).await?; + let mut finalized_state = + self.fetch_beacon_state(&get_block_id(finalized_header.state_root)).await?; let finality_proof = FinalityProof { - epoch: finality_checkpoint.finalized.epoch, + epoch: attested_state.finalized_checkpoint.epoch, finality_branch: prove_finalized_header(&mut attested_state)?, }; - let state_period = compute_sync_committee_period_at_slot(finalized_header.slot); - - let update_attested_period = - compute_sync_committee_period_at_slot(attested_block_header.slot); + let execution_payload_proof = prove_execution_payload(&mut finalized_state)?; - let sync_committee_update = if state_period == update_attested_period { + let sync_committee_update = if should_get_sync_committee_update(attested_state.slot) { let sync_committee_proof = prove_sync_committee_update(&mut attested_state)?; - Some(SyncCommitteeUpdate { next_sync_committee: attested_state.next_sync_committee, next_sync_committee_branch: sync_committee_proof, @@ -348,23 +294,19 @@ impl SyncCommitteeProver { // construct light client let light_client_update = LightClientUpdate { - attested_header: attested_block_header, + attested_header, sync_committee_update, finalized_header, execution_payload: execution_payload_proof, finality_proof, - sync_aggregate: signature_block.body.sync_aggregate, - signature_slot: signature_block.slot, + sync_aggregate: block.body.sync_aggregate, + signature_slot: block.slot, }; Ok(Some(light_client_update)) } } -pub fn get_attested_epoch(finalized_epoch: u64) -> u64 { - finalized_epoch + 2 -} - pub fn prove_execution_payload( beacon_state: &mut BeaconStateType, ) -> anyhow::Result { diff --git a/prover/src/test.rs b/prover/src/test.rs index a509501f4..de293a47a 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -4,36 +4,39 @@ use ethers::{ prelude::{Http, Middleware, ProviderExt}, providers::Provider, }; +use reqwest_eventsource::EventSource; use ssz_rs::{ calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, Merkleized, SszVariableOrIndex, }; use std::time::Duration; use sync_committee_primitives::{ - constants::{Root, DOMAIN_SYNC_COMMITTEE, GENESIS_FORK_VERSION, GENESIS_VALIDATORS_ROOT}, + constants::{ + Root, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_INDEX_LOG2, GENESIS_FORK_VERSION, + GENESIS_VALIDATORS_ROOT, NEXT_SYNC_COMMITTEE_INDEX_LOG2, + }, types::LightClientState, util::{compute_domain, compute_fork_version, compute_signing_root}, }; use sync_committee_verifier::{ signature_verification::verify_aggregate_signature, verify_sync_committee_attestation, }; -use tokio::time; -use tokio_stream::{wrappers::IntervalStream, StreamExt}; +use tokio_stream::StreamExt; const CONSENSUS_NODE_URL: &'static str = "http://localhost:3500"; const EL_NODE_URL: &'static str = "http://localhost:8545"; -async fn wait_for_el() { +async fn wait_for_el(blocks: usize) { let provider = Provider::::connect(EL_NODE_URL).await; let sub = provider.watch_blocks().await.unwrap(); - let _ = sub.take(10).collect::>(); + let _ = sub.take(blocks).collect::>(); } #[cfg(test)] #[allow(non_snake_case)] #[tokio::test] async fn fetch_block_header_works() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block_header = sync_committee_prover.fetch_header("head").await; assert!(block_header.is_ok()); @@ -43,7 +46,7 @@ async fn fetch_block_header_works() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_block_works() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block = sync_committee_prover.fetch_block("head").await; assert!(block.is_ok()); @@ -53,7 +56,7 @@ async fn fetch_block_works() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_validator_works() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let validator = sync_committee_prover.fetch_validator("head", "0").await; assert!(validator.is_ok()); @@ -62,8 +65,9 @@ async fn fetch_validator_works() { #[cfg(test)] #[allow(non_snake_case)] #[tokio::test] +#[ignore] async fn fetch_processed_sync_committee_works() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let validator = sync_committee_prover.fetch_processed_sync_committee("head").await; assert!(validator.is_ok()); @@ -96,20 +100,21 @@ async fn generate_indexes() { &beacon_state.latest_execution_payload_header, &[SszVariableOrIndex::Name("timestamp")], ); - dbg!(execution_payload_index); dbg!(next_sync); dbg!(finalized); dbg!(execution_payload_root); dbg!(block_number); dbg!(timestamp); + + dbg!(next_sync.floor_log2()); } #[cfg(test)] #[allow(non_snake_case)] #[tokio::test] async fn fetch_beacon_state_works() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let beacon_state = sync_committee_prover.fetch_beacon_state("head").await; assert!(beacon_state.is_ok()); @@ -119,7 +124,7 @@ async fn fetch_beacon_state_works() { #[allow(non_snake_case)] #[tokio::test] async fn state_root_and_block_header_root_matches() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); @@ -136,7 +141,7 @@ async fn state_root_and_block_header_root_matches() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_finality_checkpoints_work() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; assert!(finality_checkpoint.is_ok()); @@ -146,11 +151,11 @@ async fn fetch_finality_checkpoints_work() { #[allow(non_snake_case)] #[tokio::test] async fn test_finalized_header() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); - let proof = ssz_rs::generate_proof(&mut state, &vec![FINALIZED_ROOT_INDEX as usize]); + let proof = ssz_rs::generate_proof(&mut state, &vec![FINALIZED_ROOT_INDEX as usize]).unwrap(); let leaves = vec![Node::from_bytes( state @@ -163,7 +168,7 @@ async fn test_finalized_header() { )]; let root = calculate_multi_merkle_root( &leaves, - &proof.unwrap(), + &proof, &[GeneralizedIndex(FINALIZED_ROOT_INDEX as usize)], ); assert_eq!(root, state.hash_tree_root().unwrap()); @@ -173,7 +178,7 @@ async fn test_finalized_header() { #[allow(non_snake_case)] #[tokio::test] async fn test_execution_payload_proof() { - wait_for_el().await; + wait_for_el(10).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); @@ -212,8 +217,8 @@ async fn test_execution_payload_proof() { let is_merkle_branch_valid = is_valid_merkle_branch( &execution_payload_root, execution_payload_branch, - EXECUTION_PAYLOAD_INDEX.floor_log2() as usize, - GeneralizedIndex(EXECUTION_PAYLOAD_INDEX as usize).0, + EXECUTION_PAYLOAD_INDEX_LOG2 as usize, + EXECUTION_PAYLOAD_INDEX as usize, &finalized_header.state_root, ); @@ -224,7 +229,7 @@ async fn test_execution_payload_proof() { #[allow(non_snake_case)] #[tokio::test] async fn test_sync_committee_update_proof() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); @@ -244,11 +249,11 @@ async fn test_sync_committee_update_proof() { assert_eq!(calculated_finalized_root.as_bytes(), finalized_header.state_root.as_bytes()); let is_merkle_branch_valid = is_valid_merkle_branch( - &Node::from_bytes(sync_committee.hash_tree_root().unwrap().as_ref().try_into().unwrap()), + &sync_committee.hash_tree_root().unwrap(), sync_committee_proof.iter(), - NEXT_SYNC_COMMITTEE_INDEX.floor_log2() as usize, + NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, - &Node::from_bytes(finalized_header.state_root.as_ref().try_into().unwrap()), + &finalized_header.state_root, ); assert!(is_merkle_branch_valid); @@ -259,18 +264,17 @@ async fn test_sync_committee_update_proof() { #[tokio::test] async fn test_prover() { use log::LevelFilter; + use parity_scale_codec::{Decode, Encode}; env_logger::builder() .filter_module("prover", LevelFilter::Debug) .format_module_path(false) .init(); - wait_for_el().await; - let mut stream = IntervalStream::new(time::interval(Duration::from_secs(12 * 12))); + wait_for_el(1).await; + let node_url = format!("{}/eth/v1/events?topics=finalized_checkpoint", CONSENSUS_NODE_URL); let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); - let block_id = "head"; - - let block_header = sync_committee_prover.fetch_header(&block_id).await.unwrap(); + let block_header = sync_committee_prover.fetch_header("head").await.unwrap(); let state = sync_committee_prover .fetch_beacon_state(&block_header.slot.to_string()) @@ -285,29 +289,47 @@ async fn test_prover() { }; let mut count = 0; - while let Some(_ts) = stream.next().await { - let light_client_update = if let Some(update) = sync_committee_prover - .fetch_light_client_update(client_state.clone(), "prover") - .await - .unwrap() - { - update - } else { - continue - }; - - client_state = - verify_sync_committee_attestation(client_state.clone(), light_client_update).unwrap(); - debug!( - target: "prover", - "Sucessfully verified Ethereum block at slot {:?}", - client_state.finalized_header.slot - ); - - count += 1; - // For CI purposes we test finalization of three epochs - if count == 3 { - break + + let mut es = EventSource::get(node_url); + while let Some(event) = es.next().await { + match event { + Ok(reqwest_eventsource::Event::Message(msg)) => { + let message: EventResponse = serde_json::from_str(&msg.data).unwrap(); + let checkpoint = + Checkpoint { epoch: message.epoch.parse().unwrap(), root: message.block }; + let light_client_update = if let Some(update) = sync_committee_prover + .fetch_light_client_update(client_state.clone(), checkpoint, "prover") + .await + .unwrap() + { + update + } else { + continue + }; + + let encoded = light_client_update.encode(); + let decoded = LightClientUpdate::decode(&mut &*encoded).unwrap(); + assert_eq!(light_client_update, decoded); + + client_state = + verify_sync_committee_attestation(client_state.clone(), light_client_update) + .unwrap(); + debug!( + target: "prover", + "Sucessfully verified Ethereum block at slot {:?}", + client_state.finalized_header.slot + ); + + count += 1; + // For CI purposes we test finalization of 3 epochs + if count == 4 { + break + } + }, + Err(err) => { + panic!("Encountered Error and closed stream {err:?}"); + }, + _ => continue, } } } @@ -317,7 +339,7 @@ async fn test_prover() { #[allow(non_snake_case)] #[tokio::test] async fn test_sync_committee_signature_verification() { - wait_for_el().await; + wait_for_el(1).await; let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); let block = loop { let block = sync_committee_prover.fetch_block("head").await.unwrap(); @@ -368,3 +390,11 @@ async fn test_sync_committee_signature_verification() { ) .unwrap(); } + +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +pub struct EventResponse { + pub block: Root, + pub state: Root, + pub epoch: String, + pub execution_optimistic: bool, +} diff --git a/verifier/src/error.rs b/verifier/src/error.rs index 567e74c6a..a1181a531 100644 --- a/verifier/src/error.rs +++ b/verifier/src/error.rs @@ -1,13 +1,14 @@ +use alloc::string::String; use core::fmt::{Display, Formatter}; #[derive(Debug)] pub enum Error { SyncCommitteeParticipantsTooLow, - InvalidUpdate, + InvalidUpdate(String), DomainError, - InvalidMerkleBranch, - InvalidRoot, - MerkleizationError, + InvalidMerkleBranch(String), + InvalidRoot(String), + MerkleizationError(String), SignatureVerification, } @@ -17,11 +18,11 @@ impl Display for Error { Error::SyncCommitteeParticipantsTooLow => { write!(f, "Sync committee participants are too low") }, - Error::InvalidUpdate => write!(f, "Invalid update"), + Error::InvalidUpdate(err) => write!(f, "Invalid update {err:?}"), Error::DomainError => write!(f, "Couldn't get domain"), - Error::InvalidMerkleBranch => write!(f, "Invalid merkle branch"), - Error::InvalidRoot => write!(f, "Invalid root"), - Error::MerkleizationError => write!(f, "Merkleization error"), + Error::InvalidMerkleBranch(err) => write!(f, "Invalid merkle branch {err:?}"), + Error::InvalidRoot(err) => write!(f, "Invalid root {err:?}"), + Error::MerkleizationError(err) => write!(f, "Merkleization error {err:?}"), Error::SignatureVerification => write!(f, "Signature verification failed"), } } diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 157da6a93..589f1cafa 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -23,7 +23,7 @@ use sync_committee_primitives::{ }, util::{ compute_domain, compute_epoch_at_slot, compute_fork_version, compute_signing_root, - compute_sync_committee_period_at_slot, + compute_sync_committee_period_at_slot, should_get_sync_committee_update, }, }; @@ -33,14 +33,14 @@ pub type LightClientUpdate = sync_committee_primitives::types::LightClientUpdate /// This function simply verifies a sync committee's attestation & it's finalized counterpart. pub fn verify_sync_committee_attestation( trusted_state: LightClientState, - update: LightClientUpdate, + mut update: LightClientUpdate, ) -> Result { if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX_LOG2 as usize && update.sync_committee_update.is_some() && update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize { - Err(Error::InvalidUpdate)? + Err(Error::InvalidUpdate("Finality branch is incorrect".into()))? } // Verify sync committee has super majority participants @@ -52,28 +52,23 @@ pub fn verify_sync_committee_attestation( Err(Error::SyncCommitteeParticipantsTooLow)? } - // Verify update does not skip a sync committee period + // Verify update is valid let is_valid_update = update.signature_slot > update.attested_header.slot && - update.attested_header.slot >= update.finalized_header.slot; + update.attested_header.slot > update.finalized_header.slot; if !is_valid_update { - Err(Error::InvalidUpdate)? + Err(Error::InvalidUpdate( + "relationship between slots does not meet the requirements".into(), + ))? } let state_period = compute_sync_committee_period_at_slot(trusted_state.finalized_header.slot); let update_signature_period = compute_sync_committee_period_at_slot(update.signature_slot); if !(state_period..=state_period + 1).contains(&update_signature_period) { - Err(Error::InvalidUpdate)? + Err(Error::InvalidUpdate("State period does not contain signature period".into()))? } - // Verify update is relevant - let update_attested_period = compute_sync_committee_period_at_slot(update.attested_header.slot); - let update_has_next_sync_committee = - update.sync_committee_update.is_some() && update_attested_period == state_period; - - if !(update.attested_header.slot > trusted_state.finalized_header.slot || - update_has_next_sync_committee) - { - Err(Error::InvalidUpdate)? + if update.attested_header.slot <= trusted_state.finalized_header.slot { + Err(Error::InvalidUpdate("Update is expired".into()))? } // Verify sync committee aggregate signature @@ -96,16 +91,16 @@ pub fn verify_sync_committee_attestation( let domain = compute_domain( DOMAIN_SYNC_COMMITTEE, Some(fork_version), - Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().map_err(|_| Error::InvalidRoot)?)), + Some(Root::from_bytes(GENESIS_VALIDATORS_ROOT.try_into().expect("Infallible"))), GENESIS_FORK_VERSION, ) - .map_err(|_| Error::InvalidUpdate)?; + .map_err(|_| Error::InvalidUpdate("Failed to compute domain".into()))?; - let signing_root = compute_signing_root(&mut update.attested_header.clone(), domain) - .map_err(|_| Error::InvalidRoot)?; + let signing_root = compute_signing_root(&mut update.attested_header, domain) + .map_err(|_| Error::InvalidRoot("Failed to compute signing root".into()))?; verify_aggregate_signature( - &trusted_state.current_sync_committee.aggregate_public_key, + &sync_committee.aggregate_public_key, &non_participant_pubkeys, signing_root.as_bytes().to_vec(), &update.sync_aggregate.sync_committee_signature, @@ -119,13 +114,14 @@ pub fn verify_sync_committee_attestation( epoch: update.finality_proof.epoch, root: update .finalized_header - .clone() .hash_tree_root() - .map_err(|_| Error::InvalidRoot)?, + .map_err(|_| Error::MerkleizationError("Error hashing finalized header".into()))?, }; let is_merkle_branch_valid = is_valid_merkle_branch( - &finalized_checkpoint.hash_tree_root().map_err(|_| Error::InvalidRoot)?, + &finalized_checkpoint + .hash_tree_root() + .map_err(|_| Error::MerkleizationError("Failed to hash finality checkpoint".into()))?, update.finality_proof.finality_branch.iter(), FINALIZED_ROOT_INDEX_LOG2 as usize, FINALIZED_ROOT_INDEX as usize, @@ -133,25 +129,21 @@ pub fn verify_sync_committee_attestation( ); if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch("Finality branch".into()))?; } // verify the associated execution header of the finalized beacon header. let mut execution_payload = update.execution_payload; let execution_payload_root = calculate_multi_merkle_root( &[ - Node::from_bytes( - execution_payload - .state_root - .as_ref() - .try_into() - .map_err(|_| Error::InvalidRoot)?, - ), + Node::from_bytes(execution_payload.state_root.as_ref().try_into().expect("Infallible")), + execution_payload.block_number.hash_tree_root().map_err(|_| { + Error::MerkleizationError("Failed to hash execution payload".into()) + })?, execution_payload - .block_number + .timestamp .hash_tree_root() - .map_err(|_| Error::InvalidRoot)?, - execution_payload.timestamp.hash_tree_root().map_err(|_| Error::InvalidRoot)?, + .map_err(|_| Error::MerkleizationError("Failed to hash timestamp".into()))?, ], &execution_payload.multi_proof, &[ @@ -170,22 +162,21 @@ pub fn verify_sync_committee_attestation( ); if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch("Execution payload branch".into()))?; } if let Some(mut sync_committee_update) = update.sync_committee_update.clone() { - if update_attested_period == state_period && - sync_committee_update.next_sync_committee != - trusted_state.next_sync_committee.clone() - { - Err(Error::InvalidUpdate)? + if !should_get_sync_committee_update(update.attested_header.slot) { + Err(Error::InvalidUpdate("Current sync committee period has not elapsed".into()))? } + let sync_root = sync_committee_update + .next_sync_committee + .hash_tree_root() + .map_err(|_| Error::MerkleizationError("Failed to hash next sync committee".into()))?; + let is_merkle_branch_valid = is_valid_merkle_branch( - &sync_committee_update - .next_sync_committee - .hash_tree_root() - .map_err(|_| Error::MerkleizationError)?, + &sync_root, sync_committee_update.next_sync_committee_branch.iter(), NEXT_SYNC_COMMITTEE_INDEX_LOG2 as usize, NEXT_SYNC_COMMITTEE_INDEX as usize, @@ -193,7 +184,7 @@ pub fn verify_sync_committee_attestation( ); if !is_merkle_branch_valid { - Err(Error::InvalidMerkleBranch)?; + Err(Error::InvalidMerkleBranch("Next sync committee branch".into()))?; } } @@ -205,7 +196,11 @@ pub fn verify_sync_committee_attestation( next_sync_committee: sync_committee_update.next_sync_committee, } } else { - LightClientState { finalized_header: update.finalized_header, ..trusted_state } + LightClientState { + finalized_header: update.finalized_header, + latest_finalized_epoch: update.finality_proof.epoch, + ..trusted_state + } }; Ok(new_light_client_state) From c22405cb664292db72053f3245b80850b3075d4f Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Sat, 30 Sep 2023 16:04:19 +0100 Subject: [PATCH 097/100] Update constants for mainnet and goerli (#31) * fix constants * nit --- Cargo.lock | 7 +++++ primitives/Cargo.toml | 2 +- primitives/src/constants.rs | 28 ++++++++--------- prover/Cargo.toml | 3 +- prover/src/test.rs | 63 ++++++++++++++----------------------- verifier/Cargo.toml | 4 +-- 6 files changed, 49 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 881214b8e..c60772bbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -830,6 +830,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + [[package]] name = "dunce" version = "1.0.4" @@ -3385,6 +3391,7 @@ dependencies = [ "async-stream", "base2", "bls_on_arkworks", + "dotenv", "env_logger", "ethers", "hex", diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index f80ade770..17fa0fa16 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -33,4 +33,4 @@ std = [ "serde" ] mainnet = [] -testnet = [] +goerli = [] diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 04c24300f..0934398ea 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -76,7 +76,7 @@ pub const BLOCK_ROOTS_INDEX_LOG2: u64 = 5; pub const HISTORICAL_ROOTS_INDEX_LOG2: u64 = 5; #[cfg(feature = "testnet")] -pub use testnet::*; +pub use goerli::*; #[cfg(feature = "mainnet")] pub use mainnet::*; @@ -85,19 +85,19 @@ use crate::ssz::ByteVector; #[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))] pub use devnet::*; -#[cfg(feature = "testnet")] -pub mod testnet { +#[cfg(feature = "goerli")] +pub mod goerli { use super::*; pub const SLOTS_PER_EPOCH: Slot = 32; pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = - hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); - pub const BELLATRIX_FORK_VERSION: Version = [3, 0, 16, 32]; - pub const ALTAIR_FORK_VERSION: Version = [1, 0, 16, 32]; - pub const GENESIS_FORK_VERSION: Version = [0; 4]; + hex_literal::hex!("043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb"); + pub const BELLATRIX_FORK_VERSION: Version = hex_literal::hex!("02001020"); + pub const ALTAIR_FORK_VERSION: Version = hex_literal::hex!("01001020"); + pub const GENESIS_FORK_VERSION: Version = hex_literal::hex!("00001020"); pub const ALTAIR_FORK_EPOCH: Epoch = 36660; 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 CAPELLA_FORK_EPOCH: Epoch = 162304; + pub const CAPELLA_FORK_VERSION: Version = hex_literal::hex!("03001020"); } #[cfg(feature = "mainnet")] @@ -106,13 +106,13 @@ pub mod mainnet { pub const SLOTS_PER_EPOCH: Slot = 32; pub const GENESIS_VALIDATORS_ROOT: [u8; 32] = hex_literal::hex!("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"); - pub const BELLATRIX_FORK_VERSION: Version = [2, 0, 0, 0]; - pub const ALTAIR_FORK_VERSION: Version = [1, 0, 0, 0]; - pub const GENESIS_FORK_VERSION: Version = [0, 0, 0, 0]; + pub const BELLATRIX_FORK_VERSION: Version = hex_literal::hex!("02000000"); + pub const ALTAIR_FORK_VERSION: Version = hex_literal::hex!("01000000"); + pub const GENESIS_FORK_VERSION: Version = hex_literal::hex!("00000000"); pub const ALTAIR_FORK_EPOCH: Epoch = 74240; 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 CAPELLA_FORK_EPOCH: Epoch = 194048; + pub const CAPELLA_FORK_VERSION: Version = hex_literal::hex!("03000000"); } #[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))] diff --git a/prover/Cargo.toml b/prover/Cargo.toml index 21ae744da..5dca6e39b 100644 --- a/prover/Cargo.toml +++ b/prover/Cargo.toml @@ -34,6 +34,7 @@ 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" +dotenv = "0.15.0" [features] default = ["std"] @@ -45,6 +46,6 @@ std = [ "bls_on_arkworks/std", "ark-bls12-381/std" ] -testnet = ["sync-committee-primitives/testnet", "sync-committee-verifier/testnet"] +goerli = ["sync-committee-primitives/goerli", "sync-committee-verifier/goerli"] mainnet = ["sync-committee-primitives/mainnet", "sync-committee-verifier/mainnet"] diff --git a/prover/src/test.rs b/prover/src/test.rs index de293a47a..a8cd07e98 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -1,9 +1,5 @@ use super::*; use base2::Base2; -use ethers::{ - prelude::{Http, Middleware, ProviderExt}, - providers::Provider, -}; use reqwest_eventsource::EventSource; use ssz_rs::{ calculate_multi_merkle_root, get_generalized_index, is_valid_merkle_branch, GeneralizedIndex, @@ -23,21 +19,11 @@ use sync_committee_verifier::{ }; use tokio_stream::StreamExt; -const CONSENSUS_NODE_URL: &'static str = "http://localhost:3500"; -const EL_NODE_URL: &'static str = "http://localhost:8545"; - -async fn wait_for_el(blocks: usize) { - let provider = Provider::::connect(EL_NODE_URL).await; - let sub = provider.watch_blocks().await.unwrap(); - let _ = sub.take(blocks).collect::>(); -} - #[cfg(test)] #[allow(non_snake_case)] #[tokio::test] async fn fetch_block_header_works() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let block_header = sync_committee_prover.fetch_header("head").await; assert!(block_header.is_ok()); } @@ -46,8 +32,7 @@ async fn fetch_block_header_works() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_block_works() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let block = sync_committee_prover.fetch_block("head").await; assert!(block.is_ok()); } @@ -56,8 +41,7 @@ async fn fetch_block_works() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_validator_works() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let validator = sync_committee_prover.fetch_validator("head", "0").await; assert!(validator.is_ok()); } @@ -67,8 +51,7 @@ async fn fetch_validator_works() { #[tokio::test] #[ignore] async fn fetch_processed_sync_committee_works() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let validator = sync_committee_prover.fetch_processed_sync_committee("head").await; assert!(validator.is_ok()); } @@ -78,7 +61,7 @@ async fn fetch_processed_sync_committee_works() { #[tokio::test] #[ignore] async fn generate_indexes() { - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let execution_payload_index = get_generalized_index( &beacon_state, @@ -114,8 +97,7 @@ async fn generate_indexes() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_beacon_state_works() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let beacon_state = sync_committee_prover.fetch_beacon_state("head").await; assert!(beacon_state.is_ok()); } @@ -124,8 +106,7 @@ async fn fetch_beacon_state_works() { #[allow(non_snake_case)] #[tokio::test] async fn state_root_and_block_header_root_matches() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let mut beacon_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_header = sync_committee_prover.fetch_header(&beacon_state.slot.to_string()).await; @@ -141,8 +122,7 @@ async fn state_root_and_block_header_root_matches() { #[allow(non_snake_case)] #[tokio::test] async fn fetch_finality_checkpoints_work() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let finality_checkpoint = sync_committee_prover.fetch_finalized_checkpoint().await; assert!(finality_checkpoint.is_ok()); } @@ -151,8 +131,7 @@ async fn fetch_finality_checkpoints_work() { #[allow(non_snake_case)] #[tokio::test] async fn test_finalized_header() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let mut state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let proof = ssz_rs::generate_proof(&mut state, &vec![FINALIZED_ROOT_INDEX as usize]).unwrap(); @@ -177,9 +156,9 @@ async fn test_finalized_header() { #[cfg(test)] #[allow(non_snake_case)] #[tokio::test] +#[ignore] async fn test_execution_payload_proof() { - wait_for_el(10).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_id = finalized_state.slot.to_string(); @@ -229,8 +208,7 @@ async fn test_execution_payload_proof() { #[allow(non_snake_case)] #[tokio::test] async fn test_sync_committee_update_proof() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let mut finalized_state = sync_committee_prover.fetch_beacon_state("head").await.unwrap(); let block_id = finalized_state.slot.to_string(); @@ -269,11 +247,10 @@ async fn test_prover() { .filter_module("prover", LevelFilter::Debug) .format_module_path(false) .init(); - wait_for_el(1).await; - let node_url = format!("{}/eth/v1/events?topics=finalized_checkpoint", CONSENSUS_NODE_URL); - - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); + let node_url = + format!("{}/eth/v1/events?topics=finalized_checkpoint", sync_committee_prover.node_url); let block_header = sync_committee_prover.fetch_header("head").await.unwrap(); let state = sync_committee_prover @@ -339,8 +316,7 @@ async fn test_prover() { #[allow(non_snake_case)] #[tokio::test] async fn test_sync_committee_signature_verification() { - wait_for_el(1).await; - let sync_committee_prover = SyncCommitteeProver::new(CONSENSUS_NODE_URL.to_string()); + let sync_committee_prover = setup_prover(); let block = loop { let block = sync_committee_prover.fetch_block("head").await.unwrap(); if block.slot < 16 { @@ -398,3 +374,10 @@ pub struct EventResponse { pub epoch: String, pub execution_optimistic: bool, } + +fn setup_prover() -> SyncCommitteeProver { + dotenv::dotenv().ok(); + let consensus_url = + std::env::var("CONSENSUS_NODE_URL").unwrap_or("http://localhost:3500".to_string()); + SyncCommitteeProver::new(consensus_url) +} diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 2bfc47504..8d2a6bb0f 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -10,7 +10,7 @@ ssz-rs = { git = "https://github.com/polytope-labs/ssz-rs", branch = "main" , de log = { version = "0.4.17", default-features = false } anyhow = { version = "1.0.75", default-features = false } ark-ec = { version = "0.4.2", default-features = false } -ark-bls12-381 = { version = "0.4.0", default-features = false } +ark-bls12-381 = { version = "0.4.0", default-features = false, features = ["curve"] } bls_on_arkworks = { version = "0.2.2", default-features = false } [features] @@ -25,7 +25,7 @@ std = [ "ark-bls12-381/std", "bls_on_arkworks/std" ] -testnet = ["sync-committee-primitives/testnet"] +goerli = ["sync-committee-primitives/goerli"] mainnet = ["sync-committee-primitives/mainnet"] [dev-dependencies] From 9438b0530d7c741bc72875b722c1d9c13c1a7dea Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:28:15 +0100 Subject: [PATCH 098/100] fix feature flags (#32) --- primitives/src/constants.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 0934398ea..f8491b49d 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -75,14 +75,14 @@ pub const NEXT_SYNC_COMMITTEE_INDEX_LOG2: u64 = 5; pub const BLOCK_ROOTS_INDEX_LOG2: u64 = 5; pub const HISTORICAL_ROOTS_INDEX_LOG2: u64 = 5; -#[cfg(feature = "testnet")] +#[cfg(feature = "goerli")] pub use goerli::*; #[cfg(feature = "mainnet")] pub use mainnet::*; use crate::ssz::ByteVector; -#[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))] +#[cfg(all(not(feature = "mainnet"), not(feature = "goerli")))] pub use devnet::*; #[cfg(feature = "goerli")] @@ -115,7 +115,7 @@ pub mod mainnet { pub const CAPELLA_FORK_VERSION: Version = hex_literal::hex!("03000000"); } -#[cfg(all(not(feature = "mainnet"), not(feature = "testnet")))] +#[cfg(all(not(feature = "mainnet"), not(feature = "goerli")))] pub mod devnet { use super::*; use hex_literal::hex; From 942f435a5cf5fae6d2a13ff2716351fbc0231f3b Mon Sep 17 00:00:00 2001 From: David Salami <31099392+Wizdave97@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:02:01 +0100 Subject: [PATCH 099/100] Update loop boundary for signature search (#33) * change loop exit case for signature block search * nit * nit --- prover/src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 6cfc7366a..b537d2c22 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -243,9 +243,9 @@ impl SyncCommitteeProver { let state_period = compute_sync_committee_period_at_slot(client_state.finalized_header.slot); loop { - // If we get to an epoch that is less than the attested epoch for the last known - // finalized header we exit - if compute_epoch_at_slot(block.slot) < client_state.latest_finalized_epoch + 2 { + // If we get to an epoch that is less than the finalized epoch for the notification + if compute_epoch_at_slot(block.slot) <= finality_checkpoint.epoch { + debug!(target: "prover", "Signature block search has reached epoch <= finalized epoch {} block_epoch {}", finality_checkpoint.epoch, compute_epoch_at_slot(block.slot)); return Ok(None) } @@ -267,7 +267,6 @@ impl SyncCommitteeProver { let attested_header = self.fetch_header(&attested_block_id).await?; let mut attested_state = self.fetch_beacon_state(&get_block_id(attested_header.state_root)).await?; - if attested_state.finalized_checkpoint.root == Node::default() { return Ok(None) } From ed038d7c7fcf0da679778d9fcb7cfb27707ca34f Mon Sep 17 00:00:00 2001 From: Seun Lanlege Date: Thu, 5 Oct 2023 21:11:16 +0100 Subject: [PATCH 100/100] dedupe proofs --- primitives/src/types.rs | 4 +-- prover/src/lib.rs | 28 +++++++++++-------- prover/src/test.rs | 8 +++--- verifier/Cargo.toml | 6 ++-- .../{signature_verification.rs => crypto.rs} | 12 ++++---- verifier/src/lib.rs | 22 +++++++-------- 6 files changed, 42 insertions(+), 38 deletions(-) rename verifier/src/{signature_verification.rs => crypto.rs} (92%) diff --git a/primitives/src/types.rs b/primitives/src/types.rs index de5ad4be4..16f2b4f7c 100644 --- a/primitives/src/types.rs +++ b/primitives/src/types.rs @@ -85,7 +85,7 @@ pub struct SyncCommitteeUpdate { /// Minimum state required by the light client to validate new sync committee attestations #[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] -pub struct LightClientState { +pub struct VerifierState { /// The latest recorded finalized header pub finalized_header: BeaconBlockHeader, /// Latest finalized epoch @@ -106,7 +106,7 @@ pub struct FinalityProof { /// Data required to advance the state of the light client. #[derive(Debug, Clone, PartialEq, Eq, Default, codec::Encode, codec::Decode)] -pub struct LightClientUpdate { +pub struct VerifierStateUpdate { /// the header that the sync committee signed pub attested_header: BeaconBlockHeader, /// the sync committee has potentially changed, here's an ssz proof for that. diff --git a/prover/src/lib.rs b/prover/src/lib.rs index b537d2c22..d0c376ecd 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -9,8 +9,11 @@ use anyhow::anyhow; use bls_on_arkworks::{point_to_pubkey, types::G1ProjectivePoint}; use log::debug; use reqwest::Client; -use sync_committee_primitives::consensus_types::{ - BeaconBlock, BeaconBlockHeader, BeaconState, Checkpoint, SyncCommittee, Validator, +use sync_committee_primitives::{ + consensus_types::{ + BeaconBlock, BeaconBlockHeader, BeaconState, Checkpoint, SyncCommittee, Validator, + }, + types::VerifierState, }; use crate::{ @@ -36,8 +39,8 @@ use sync_committee_primitives::{ VALIDATOR_REGISTRY_LIMIT, }, types::{ - AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, LightClientUpdate, - SyncCommitteeUpdate, + AncestryProof, BlockRootsProof, ExecutionPayloadProof, FinalityProof, SyncCommitteeUpdate, + VerifierStateUpdate, }, util::{ compute_epoch_at_slot, compute_sync_committee_period_at_slot, @@ -45,7 +48,7 @@ use sync_committee_primitives::{ }, }; -use sync_committee_verifier::{signature_verification::pubkey_to_projective, LightClientState}; +use sync_committee_verifier::{crypto::pubkey_to_projective, VerifierState}; pub type BeaconStateType = BeaconState< SLOTS_PER_HISTORICAL_ROOT, @@ -219,12 +222,12 @@ impl SyncCommitteeProver { pub async fn fetch_light_client_update( &self, - client_state: LightClientState, + client_state: VerifierState, finality_checkpoint: Checkpoint, debug_target: &str, - ) -> Result, anyhow::Error> { + ) -> Result, anyhow::Error> { if finality_checkpoint.root == Node::default() || - finality_checkpoint.epoch <= client_state.latest_finalized_epoch + client_state.latest_finalized_epoch >= finality_checkpoint.epoch { return Ok(None) } @@ -244,8 +247,11 @@ impl SyncCommitteeProver { compute_sync_committee_period_at_slot(client_state.finalized_header.slot); loop { // If we get to an epoch that is less than the finalized epoch for the notification - if compute_epoch_at_slot(block.slot) <= finality_checkpoint.epoch { - debug!(target: "prover", "Signature block search has reached epoch <= finalized epoch {} block_epoch {}", finality_checkpoint.epoch, compute_epoch_at_slot(block.slot)); + let current_epoch = compute_epoch_at_slot(block.slot); + if current_epoch <= finality_checkpoint.epoch || + current_epoch == client_state.latest_finalized_epoch + { + debug!(target: "prover", "Signature block search has reached an invalid epoch {} finalized_block_epoch {}", compute_epoch_at_slot(block.slot), finality_checkpoint.epoch); return Ok(None) } @@ -292,7 +298,7 @@ impl SyncCommitteeProver { }; // construct light client - let light_client_update = LightClientUpdate { + let light_client_update = VerifierStateUpdate { attested_header, sync_committee_update, finalized_header, diff --git a/prover/src/test.rs b/prover/src/test.rs index a8cd07e98..ef77c9262 100644 --- a/prover/src/test.rs +++ b/prover/src/test.rs @@ -11,11 +11,11 @@ use sync_committee_primitives::{ Root, DOMAIN_SYNC_COMMITTEE, EXECUTION_PAYLOAD_INDEX_LOG2, GENESIS_FORK_VERSION, GENESIS_VALIDATORS_ROOT, NEXT_SYNC_COMMITTEE_INDEX_LOG2, }, - types::LightClientState, + types::VerifierState, util::{compute_domain, compute_fork_version, compute_signing_root}, }; use sync_committee_verifier::{ - signature_verification::verify_aggregate_signature, verify_sync_committee_attestation, + crypto::verify_aggregate_signature, verify_sync_committee_attestation, }; use tokio_stream::StreamExt; @@ -258,7 +258,7 @@ async fn test_prover() { .await .unwrap(); - let mut client_state = LightClientState { + let mut client_state = VerifierState { finalized_header: block_header.clone(), latest_finalized_epoch: 0, current_sync_committee: state.current_sync_committee, @@ -285,7 +285,7 @@ async fn test_prover() { }; let encoded = light_client_update.encode(); - let decoded = LightClientUpdate::decode(&mut &*encoded).unwrap(); + let decoded = VerifierStateUpdate::decode(&mut &*encoded).unwrap(); assert_eq!(light_client_update, decoded); client_state = diff --git a/verifier/Cargo.toml b/verifier/Cargo.toml index 8d2a6bb0f..a4fa84e76 100644 --- a/verifier/Cargo.toml +++ b/verifier/Cargo.toml @@ -11,7 +11,7 @@ log = { version = "0.4.17", default-features = false } anyhow = { version = "1.0.75", default-features = false } ark-ec = { version = "0.4.2", default-features = false } ark-bls12-381 = { version = "0.4.0", default-features = false, features = ["curve"] } -bls_on_arkworks = { version = "0.2.2", default-features = false } +bls = { package = "bls_on_arkworks", version = "0.2.2", default-features = false } [features] default = ["std"] @@ -23,10 +23,10 @@ std = [ "anyhow/std", "ark-ec/std", "ark-bls12-381/std", - "bls_on_arkworks/std" + "bls/std" ] goerli = ["sync-committee-primitives/goerli"] mainnet = ["sync-committee-primitives/mainnet"] [dev-dependencies] -hex = "0.4.3" \ No newline at end of file +hex = "0.4.3" diff --git a/verifier/src/signature_verification.rs b/verifier/src/crypto.rs similarity index 92% rename from verifier/src/signature_verification.rs rename to verifier/src/crypto.rs index 06aa4f27c..2cbaa1dee 100644 --- a/verifier/src/signature_verification.rs +++ b/verifier/src/crypto.rs @@ -2,15 +2,15 @@ use alloc::vec::Vec; use anyhow::anyhow; use ark_bls12_381::Bls12_381; use ark_ec::{pairing::Pairing, AffineRepr}; -use bls_on_arkworks::{ - hash_to_point, pubkey_to_point, signature_to_point, +use bls::{ types::{BLS12381Pairing, G1AffinePoint, G1ProjectivePoint, G2AffinePoint, Signature}, DST_ETHEREUM, }; use sync_committee_primitives::constants::BlsPublicKey; pub fn pubkey_to_projective(compressed_key: &BlsPublicKey) -> anyhow::Result { - let affine_point = pubkey_to_point(&compressed_key.to_vec()).map_err(|e| anyhow!("{:?}", e))?; + let affine_point = + bls::pubkey_to_point(&compressed_key.to_vec()).map_err(|e| anyhow!("{:?}", e))?; Ok(affine_point.into()) } @@ -42,10 +42,10 @@ pub fn verify_aggregate_signature( ) -> anyhow::Result<()> { let subset_aggregate = subtract_points_from_aggregate(aggregate, non_participants)?; let aggregate_key_point: G1AffinePoint = subset_aggregate.into(); - let signature = signature_to_point(signature).map_err(|e| anyhow!("{:?}", e))?; + let signature = bls::signature_to_point(signature).map_err(|e| anyhow!("{:?}", e))?; let dst = DST_ETHEREUM.as_bytes().to_vec(); - let q = hash_to_point(&msg, &dst); + let q = bls::hash_to_point(&msg, &dst); let c1 = pairing(q, aggregate_key_point); @@ -66,7 +66,7 @@ pub fn verify_aggregate_signature( #[cfg(test)] mod tests { - use crate::signature_verification::verify_aggregate_signature; + use crate::crypto::verify_aggregate_signature; #[test] fn test_signature_verification() { diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index 589f1cafa..f64f1b72e 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -3,10 +3,10 @@ #[warn(unused_variables)] extern crate alloc; +pub mod crypto; pub mod error; -pub mod signature_verification; -use crate::{error::Error, signature_verification::verify_aggregate_signature}; +use crate::{crypto::verify_aggregate_signature, error::Error}; use alloc::vec::Vec; use ssz_rs::{ calculate_multi_merkle_root, prelude::is_valid_merkle_branch, GeneralizedIndex, Merkleized, @@ -21,20 +21,18 @@ use sync_committee_primitives::{ GENESIS_FORK_VERSION, GENESIS_VALIDATORS_ROOT, NEXT_SYNC_COMMITTEE_INDEX, NEXT_SYNC_COMMITTEE_INDEX_LOG2, }, + types::{VerifierState, VerifierStateUpdate}, util::{ compute_domain, compute_epoch_at_slot, compute_fork_version, compute_signing_root, compute_sync_committee_period_at_slot, should_get_sync_committee_update, }, }; -pub type LightClientState = sync_committee_primitives::types::LightClientState; -pub type LightClientUpdate = sync_committee_primitives::types::LightClientUpdate; - /// This function simply verifies a sync committee's attestation & it's finalized counterpart. pub fn verify_sync_committee_attestation( - trusted_state: LightClientState, - mut update: LightClientUpdate, -) -> Result { + trusted_state: VerifierState, + mut update: VerifierStateUpdate, +) -> Result { if update.finality_proof.finality_branch.len() != FINALIZED_ROOT_INDEX_LOG2 as usize && update.sync_committee_update.is_some() && update.sync_committee_update.as_ref().unwrap().next_sync_committee_branch.len() != @@ -188,20 +186,20 @@ pub fn verify_sync_committee_attestation( } } - let new_light_client_state = if let Some(sync_committee_update) = update.sync_committee_update { - LightClientState { + let verifier_state = if let Some(sync_committee_update) = update.sync_committee_update { + VerifierState { finalized_header: update.finalized_header, latest_finalized_epoch: update.finality_proof.epoch, current_sync_committee: trusted_state.next_sync_committee, next_sync_committee: sync_committee_update.next_sync_committee, } } else { - LightClientState { + VerifierState { finalized_header: update.finalized_header, latest_finalized_epoch: update.finality_proof.epoch, ..trusted_state } }; - Ok(new_light_client_state) + Ok(verifier_state) }