Skip to content

Commit

Permalink
fix attested state source
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea committed Sep 25, 2023
1 parent ec75fa2 commit 21ff3e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 0 additions & 5 deletions lightclient-circuits/src/witness/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ pub struct SyncStepArgs<S: Spec> {

pub finality_branch: Vec<Vec<u8>>,

pub beacon_state_root: Vec<u8>,

#[serde(skip)]
pub _spec: PhantomData<S>,
}
Expand Down Expand Up @@ -66,8 +64,6 @@ impl<S: Spec> Default for SyncStepArgs<S> {

let finality_merkle_branch = vec![vec![0; 32]; S::FINALIZED_HEADER_DEPTH];

let beacon_state_root = compute_root(finalized_header, &state_merkle_branch);

Self {
signature_compressed: hex::decode("462c5acb68722355eaa568a166e6da4c46702a496586aa94c681e0b03a200394b8f4adc98d6b5a68e3caf9dae31ff7035a402aad93bdd4752e521b3b536b47dee55d129b6374177f2be8c99b6ea6618abae84b389affc5a50ad8d991f763beaa").unwrap(),
pubkeys_uncompressed: iter::repeat(dummy_pk_bytes)
Expand All @@ -81,7 +77,6 @@ impl<S: Spec> Default for SyncStepArgs<S> {
attested_header: BeaconBlockHeader::default(),
finalized_header: finalized_block,
finality_branch: finality_merkle_branch,
beacon_state_root,
execution_payload_branch: execution_merkle_branch,
execution_payload_root: execution_state_root,
_spec: PhantomData,
Expand Down
8 changes: 6 additions & 2 deletions preprocessor/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tokio::fs;
pub async fn fetch_step_args<S: Spec>(node_url: String) -> eyre::Result<SyncStepArgs<S>> {
let client = SyncCommitteeProver::new(node_url);
let state_id = "head";
let mut state = client
let state = client
.fetch_beacon_state(state_id)
.await
.map_err(|e| eyre::eyre!("Error fetching state from node. Error: {}", e))?;
Expand Down Expand Up @@ -47,6 +47,11 @@ pub async fn fetch_step_args<S: Spec>(node_url: String) -> eyre::Result<SyncStep
.map_err(|e| eyre::eyre!("Error fetching light client update. Error: {}", e))?
.expect("Light client update should be present");

let mut state = client
.fetch_beacon_state(&light_client_update.attested_header.slot.to_string())
.await
.map_err(|e| eyre::eyre!("Error fetching state from node. Error: {}", e))?;

let pubkeys_uncompressed = client_state
.current_sync_committee
.public_keys
Expand Down Expand Up @@ -157,7 +162,6 @@ pub async fn fetch_step_args<S: Spec>(node_url: String) -> eyre::Result<SyncStep
.iter()
.map(|n| n.as_bytes().to_vec())
.collect_vec(),
beacon_state_root: state_root.as_bytes().to_vec(),
_spec: PhantomData,
};

Expand Down

0 comments on commit 21ff3e3

Please sign in to comment.