Skip to content

Commit

Permalink
fix default trait impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ec2 committed Jan 24, 2024
1 parent 17d03ff commit 1183658
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
24 changes: 18 additions & 6 deletions lightclient-circuits/src/witness/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::{iter, marker::PhantomData};

use crate::witness::beacon_header_multiproof_and_helper_indices;

/// Input datum for the `CommitteeUpdateCircuit` to map next sync committee SSZ root in the finalized state root to the corresponding Poseidon commitment to the public keys.
///
/// Assumes that public keys are BLS12-381 points on G1; `sync_committee_branch` is exactly `S::SYNC_COMMITTEE_PUBKEYS_DEPTH` hashes in lenght.
Expand Down Expand Up @@ -61,19 +63,29 @@ impl<S: Spec> Default for CommitteeUpdateArgs<S> {
&sync_committee_branch,
S::SYNC_COMMITTEE_PUBKEYS_ROOT_INDEX,
);
let finalized_header = BeaconBlockHeader {
state_root: state_root.as_slice().try_into().unwrap(),
..Default::default()
};

let (finalized_header_multiproof, finalized_header_helper_indices) =
beacon_header_multiproof_and_helper_indices(
&mut finalized_header.clone(),
&[S::HEADER_STATE_ROOT_INDEX],
);

Self {
pubkeys_compressed: iter::repeat(dummy_x_bytes)
.take(S::SYNC_COMMITTEE_SIZE)
.collect_vec(),
sync_committee_branch,
finalized_header: BeaconBlockHeader {
state_root: state_root.as_slice().try_into().unwrap(),
..Default::default()
},
finalized_header,
_spec: PhantomData,
finalized_header_multiproof: vec![vec![0; 32]; 3],
finalized_header_helper_indices: vec![0; 3],
finalized_header_multiproof: finalized_header_multiproof
.into_iter()
.map(|n| n.as_ref().to_vec())
.collect_vec(),
finalized_header_helper_indices,
}
}
}
Expand Down
29 changes: 25 additions & 4 deletions lightclient-circuits/src/witness/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use std::iter;
use std::marker::PhantomData;
use std::ops::Deref;

use crate::witness::beacon_header_multiproof_and_helper_indices;

use super::mock_root;

/// Input datum for the `StepCircuit` to verify `attested_header` singed by the lightclient sync committee,
Expand Down Expand Up @@ -110,6 +112,19 @@ impl<S: Spec> Default for SyncStepArgs<S> {
.to_uncompressed_be()
.to_vec();

// Proof length is 3
let (attested_header_multiproof, attested_header_helper_indices) =
beacon_header_multiproof_and_helper_indices(
&mut attested_header.clone(),
&[S::HEADER_SLOT_INDEX, S::HEADER_STATE_ROOT_INDEX],
);
// Proof length is 4
let (finalized_header_multiproof, finalized_header_helper_indices) =
beacon_header_multiproof_and_helper_indices(
&mut finalized_header.clone(),
&[S::HEADER_SLOT_INDEX, S::HEADER_BODY_ROOT_INDEX],
);

Self {
signature_compressed,
pubkeys_uncompressed: iter::repeat(pubkey_uncompressed)
Expand All @@ -124,10 +139,16 @@ impl<S: Spec> Default for SyncStepArgs<S> {
execution_payload_root: execution_root,
_spec: PhantomData,

attested_header_multiproof: vec![vec![0; 32]; 3],
attested_header_helper_indices: vec![0; 3],
finalized_header_multiproof: vec![vec![0; 32]; 4],
finalized_header_helper_indices: vec![0; 4],
attested_header_multiproof: attested_header_multiproof
.into_iter()
.map(|n| n.as_ref().to_vec())
.collect_vec(),
attested_header_helper_indices,
finalized_header_multiproof: finalized_header_multiproof
.into_iter()
.map(|n| n.as_ref().to_vec())
.collect_vec(),
finalized_header_helper_indices,
}
}
}
Expand Down

0 comments on commit 1183658

Please sign in to comment.