diff --git a/.licensesnip b/.licensesnip index 56670fa5..5814dadc 100644 --- a/.licensesnip +++ b/.licensesnip @@ -1,3 +1,3 @@ The Licensed Work is (c) 2023 ChainSafe -Source: https://github.com/ChainSafe/Spectre +Code: https://github.com/ChainSafe/Spectre SPDX-License-Identifier: LGPL-3.0-only diff --git a/contract-tests/tests/rotation_input_encoding.rs b/contract-tests/tests/rotation_input_encoding.rs index 64688b19..4cb1864e 100644 --- a/contract-tests/tests/rotation_input_encoding.rs +++ b/contract-tests/tests/rotation_input_encoding.rs @@ -11,7 +11,7 @@ use itertools::Itertools; use lightclient_circuits::committee_update_circuit::CommitteeUpdateCircuit; use lightclient_circuits::halo2_proofs::halo2curves::bn256; use lightclient_circuits::poseidon::poseidon_committee_commitment_from_compressed; -use lightclient_circuits::witness::CommitteeRotationArgs; +use lightclient_circuits::witness::CommitteeUpdateArgs; use rstest::rstest; use ssz_rs::prelude::*; use ssz_rs::Merkleized; @@ -24,11 +24,11 @@ abigen!( ); // CommitteeRotationArgs type produced by abigen macro matches the solidity struct type -impl From> for RotateInput +impl From> for RotateInput where [(); Spec::SYNC_COMMITTEE_SIZE]:, { - fn from(args: CommitteeRotationArgs) -> Self { + fn from(args: CommitteeUpdateArgs) -> Self { let poseidon_commitment = poseidon_committee_commitment_from_compressed( &args.pubkeys_compressed.iter().cloned().collect_vec(), ); diff --git a/contracts/rust-abi/lib.rs b/contracts/rust-abi/lib.rs index 42043dc9..9c41e9c2 100644 --- a/contracts/rust-abi/lib.rs +++ b/contracts/rust-abi/lib.rs @@ -4,7 +4,7 @@ use ethers::{contract::abigen, types::U256}; use itertools::Itertools; use lightclient_circuits::{ poseidon::poseidon_committee_commitment_from_compressed, - witness::{CommitteeRotationArgs, SyncStepArgs}, + witness::{CommitteeUpdateArgs, SyncStepArgs}, }; use ssz_rs::{Merkleized, Vector}; use std::ops::Deref; @@ -63,11 +63,11 @@ impl SyncStepInput { } // CommitteeRotationArgs type produced by abigen macro matches the solidity struct type -impl From> for RotateInput +impl From> for RotateInput where [(); Spec::SYNC_COMMITTEE_SIZE]:, { - fn from(args: CommitteeRotationArgs) -> Self { + fn from(args: CommitteeUpdateArgs) -> Self { let sync_committee_poseidon = poseidon_committee_commitment_from_compressed( &args.pubkeys_compressed.iter().cloned().collect_vec(), ); diff --git a/lightclient-circuits/src/committee_update_circuit.rs b/lightclient-circuits/src/committee_update_circuit.rs index 8f201ac0..421f8752 100644 --- a/lightclient-circuits/src/committee_update_circuit.rs +++ b/lightclient-circuits/src/committee_update_circuit.rs @@ -1,6 +1,6 @@ use crate::{ gadget::crypto::{HashInstructions, Sha256ChipWide, ShaBitGateManager, ShaCircuitBuilder}, - poseidon::{fq_array_poseidon, fq_array_poseidon_native}, + poseidon::{fq_array_poseidon, poseidon_hash_fq_array}, ssz_merkle::{ssz_merkleize_chunks, verify_merkle_proof}, sync_step_circuit::clear_3_bits, util::{AppCircuit, CommonGateManager, Eth2ConfigPinning, IntoWitness}, @@ -23,7 +23,9 @@ use itertools::Itertools; use ssz_rs::{Merkleized, Vector}; use std::{env::var, iter, marker::PhantomData, vec}; -#[allow(type_alias_bounds)] +/// `CommitteeUpdateCircuit` maps next sync committee SSZ root in the finalized state root to the corresponding Poseidon commitment to the public keys. +/// +/// #[derive(Clone, Debug, Default)] pub struct CommitteeUpdateCircuit { _f: PhantomData, @@ -34,7 +36,7 @@ impl CommitteeUpdateCircuit { fn synthesize( builder: &mut ShaCircuitBuilder>, fp_chip: &FpChip, - args: &witness::CommitteeRotationArgs, + args: &witness::CommitteeUpdateArgs, ) -> Result>, Error> { let range = fp_chip.range(); @@ -156,8 +158,10 @@ impl CommitteeUpdateCircuit { ssz_merkleize_chunks(builder, hasher, pubkeys_hashes) } + // Computes public inputs to `CommitteeUpdateCircuit` matching the in-circuit logic from `synthesise` method. + // Note, this function outputes only instances of the `CommitteeUpdateCircuit` proof, not the aggregated proof which will also include 12 accumulator limbs. pub fn get_instances( - args: &witness::CommitteeRotationArgs, + args: &witness::CommitteeUpdateArgs, limb_bits: usize, ) -> Vec> where @@ -169,7 +173,7 @@ impl CommitteeUpdateCircuit { .expect("bad bls12_381::Fq encoding") }); - let poseidon_commitment = fq_array_poseidon_native::(pubkeys_x, limb_bits); + let poseidon_commitment = poseidon_hash_fq_array::(pubkeys_x, limb_bits); let mut pk_vector: Vector, { S::SYNC_COMMITTEE_SIZE }> = args .pubkeys_compressed @@ -200,12 +204,12 @@ impl CommitteeUpdateCircuit { impl AppCircuit for CommitteeUpdateCircuit { type Pinning = Eth2ConfigPinning; - type Witness = witness::CommitteeRotationArgs; + type Witness = witness::CommitteeUpdateArgs; fn create_circuit( stage: CircuitBuilderStage, pinning: Option, - witness: &witness::CommitteeRotationArgs, + witness: &witness::CommitteeUpdateArgs, k: u32, ) -> Result, Error> { let mut builder = Eth2CircuitBuilder::>::from_stage(stage) @@ -244,7 +248,7 @@ mod tests { use crate::{ aggregation_circuit::AggregationConfigPinning, util::Halo2ConfigPinning, - witness::CommitteeRotationArgs, + witness::CommitteeUpdateArgs, }; use super::*; @@ -263,7 +267,7 @@ mod tests { use snark_verifier_sdk::evm::{evm_verify, gen_evm_proof_shplonk}; use snark_verifier_sdk::{halo2::aggregation::AggregationCircuit, CircuitExt, Snark}; - fn load_circuit_args() -> CommitteeRotationArgs { + fn load_circuit_args() -> CommitteeUpdateArgs { #[derive(serde::Deserialize)] struct ArgsJson { finalized_header: BeaconBlockHeader, @@ -277,7 +281,7 @@ mod tests { finalized_header, } = serde_json::from_slice(&fs::read("../test_data/rotation_512.json").unwrap()).unwrap(); - CommitteeRotationArgs { + CommitteeUpdateArgs { pubkeys_compressed, _spec: PhantomData, finalized_header, @@ -288,7 +292,7 @@ mod tests { fn gen_application_snark( params: &ParamsKZG, pk: &ProvingKey, - witness: &CommitteeRotationArgs, + witness: &CommitteeUpdateArgs, pinning_path: &str, ) -> Snark { CommitteeUpdateCircuit::::gen_snark_shplonk( @@ -335,7 +339,7 @@ mod tests { PKEY_PATH, PINNING_PATH, false, - &CommitteeRotationArgs::::default(), + &CommitteeUpdateArgs::::default(), ); let witness = load_circuit_args(); @@ -363,7 +367,7 @@ mod tests { APP_PK_PATH, APP_PINNING_PATH, false, - &CommitteeRotationArgs::::default(), + &CommitteeUpdateArgs::::default(), ); let witness = load_circuit_args(); diff --git a/lightclient-circuits/src/gadget.rs b/lightclient-circuits/src/gadget/mod.rs similarity index 100% rename from lightclient-circuits/src/gadget.rs rename to lightclient-circuits/src/gadget/mod.rs diff --git a/lightclient-circuits/src/poseidon.rs b/lightclient-circuits/src/poseidon.rs index ab6dcbb6..71810e10 100644 --- a/lightclient-circuits/src/poseidon.rs +++ b/lightclient-circuits/src/poseidon.rs @@ -18,11 +18,20 @@ const N_ROUNDS_PC: [usize; 16] = [ 56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68, ]; +// Empirically chosen to take the least space in circuit. const POSEIDON_SIZE: usize = 11; const T: usize = POSEIDON_SIZE + 1; const R_P: usize = N_ROUNDS_PC[T - 2]; const R_F: usize = 8; +/// Generates Poseidon hash commitment to a list of BLS12-381 Fq elements. +/// +/// Fields elements are initially represented as `NUM_LIMBS` limbs of `LIMB_BITS` bits each. +/// By composing element two limbs in one, we reduce the number of inputs to Poseidon in half. +/// +/// Each Poseidon sponge absorbs `POSEIDON_SIZE`-2 elements and previos sponge output if it's not the first batch, ie. onion commitment. +/// +/// Assumes that LIMB_BITS * 2 < 254 (BN254). pub fn fq_array_poseidon<'a, F: Field>( ctx: &mut Context, fp_chip: &FpChip, @@ -60,7 +69,10 @@ pub fn fq_array_poseidon<'a, F: Field>( Ok(current_poseidon_hash.unwrap()) } -pub fn fq_array_poseidon_native(elems: impl Iterator, limb_bits: usize) -> F { +/// Generates Poseidon hash commitment to a list of BLS12-381 Fq elements. +/// +/// This is the off-circuit analog of `fq_array_poseidon`. +pub fn poseidon_hash_fq_array(elems: impl Iterator, limb_bits: usize) -> F { let limbs = elems // Converts Fq elements to Fr limbs. .flat_map(|x| { @@ -83,6 +95,7 @@ pub fn fq_array_poseidon_native(elems: impl Iterator, limb_ current_poseidon_hash.unwrap() } +/// Wrapper on `poseidon_hash_fq_array` taking pubkeys encoded as uncompressed bytes. pub fn poseidon_committee_commitment_from_uncompressed( pubkeys_uncompressed: &[Vec], ) -> bn256::Fr { @@ -97,14 +110,15 @@ pub fn poseidon_committee_commitment_from_uncompressed( }) .collect_vec(); - fq_array_poseidon_native::(pubkey_affines.iter().map(|p| p.x), LIMB_BITS) + poseidon_hash_fq_array::(pubkey_affines.iter().map(|p| p.x), LIMB_BITS) } +/// Wrapper on `poseidon_hash_fq_array` taking pubkeys encoded as compressed bytes. pub fn poseidon_committee_commitment_from_compressed(pubkeys_compressed: &[Vec]) -> bn256::Fr { let pubkeys_x = pubkeys_compressed.iter().cloned().map(|mut bytes| { bytes[0] &= 0b00011111; bls12_381::Fq::from_bytes_be(&bytes.try_into().unwrap()) .expect("bad bls12_381::Fq encoding") }); - fq_array_poseidon_native::(pubkeys_x, LIMB_BITS) + poseidon_hash_fq_array::(pubkeys_x, LIMB_BITS) } diff --git a/lightclient-circuits/src/ssz_merkle.rs b/lightclient-circuits/src/ssz_merkle.rs index 3a877ac4..96920858 100644 --- a/lightclient-circuits/src/ssz_merkle.rs +++ b/lightclient-circuits/src/ssz_merkle.rs @@ -1,6 +1,5 @@ use crate::{ gadget::crypto::HashInstructions, - util::IntoConstant, witness::{HashInput, HashInputChunk}, }; use eth_types::Field; @@ -10,23 +9,21 @@ use halo2_base::{ }; use itertools::Itertools; +/// Computes Merkle root of a list of SSZ chunks. +/// +/// Assumes that number if chunks is a power of two. pub fn ssz_merkleize_chunks>( builder: &mut CircuitBuilder, hasher: &impl HashInstructions, chunks: impl IntoIterator>>, ) -> Result>, Error> { let mut chunks = chunks.into_iter().collect_vec(); - let len_even = chunks.len() + chunks.len() % 2; - let height = (len_even as f64).log2().ceil() as usize; - for depth in 0..height { - // Pad to even length using 32 zero bytes assigned as constants. - let len_even = chunks.len() + chunks.len() % 2; - let padded_chunks = chunks - .into_iter() - .pad_using(len_even, |_| ZERO_HASHES[depth].as_slice().into_constant()) - .collect_vec(); + assert!(chunks.len().is_power_of_two()); + + let height = (chunks.len() as f64).log2() as usize; - chunks = padded_chunks + for _ in 0..height { + chunks = chunks .into_iter() .tuples() .map(|(left, right)| { @@ -47,17 +44,20 @@ pub fn ssz_merkleize_chunks>( Ok(root.bytes) } +/// Verifies `leaf` against the `root` using Merkle `branch`. Requires `gindex` for deterministic traversal of the tree. +/// +/// Assumes that `root` and `leaf` are 32 bytes each. pub fn verify_merkle_proof>( builder: &mut CircuitBuilder, hasher: &impl HashInstructions, - proof: impl IntoIterator>>, + branch: impl IntoIterator>>, leaf: HashInputChunk>, root: &[AssignedValue], mut gindex: usize, ) -> Result<(), Error> { let mut computed_hash = leaf; - for witness in proof.into_iter() { + for witness in branch.into_iter() { computed_hash = hasher .digest( builder, @@ -82,11 +82,3 @@ pub fn verify_merkle_proof>( Ok(()) } - -pub const ZERO_HASHES: [[u8; 32]; 2] = [ - [0; 32], - [ - 245, 165, 253, 66, 209, 106, 32, 48, 39, 152, 239, 110, 211, 9, 151, 155, 67, 0, 61, 35, - 32, 217, 240, 232, 234, 152, 49, 169, 39, 89, 251, 75, - ], -]; diff --git a/lightclient-circuits/src/sync_step_circuit.rs b/lightclient-circuits/src/sync_step_circuit.rs index 74b562c2..e1e620ec 100644 --- a/lightclient-circuits/src/sync_step_circuit.rs +++ b/lightclient-circuits/src/sync_step_circuit.rs @@ -6,7 +6,7 @@ use crate::{ }, to_bytes_le, }, - poseidon::{fq_array_poseidon, fq_array_poseidon_native}, + poseidon::{fq_array_poseidon, poseidon_hash_fq_array}, ssz_merkle::{ssz_merkleize_chunks, verify_merkle_proof}, util::{AppCircuit, Eth2ConfigPinning, IntoWitness}, witness::{self, HashInput, HashInputChunk, SyncStepArgs}, @@ -39,7 +39,15 @@ use num_bigint::BigUint; use ssz_rs::Merkleized; use std::{env::var, marker::PhantomData, vec}; -#[allow(type_alias_bounds)] +/// `StepCircuit` verifies that Beacon chain block header is attested by a lightclient sync committee via aggregated signature, +/// and the execution (Eth1) payload via Merkle proof against the finalized block header. +/// +/// Assumes that signature is a BLS12-381 point on G2, and public keys are BLS12-381 points on G1; `finality_branch` is exactly `S::FINALIZED_HEADER_DEPTH` hashes in lenght; +/// and `execution_payload_branch` is `S::EXECUTION_PAYLOAD_DEPTH` hashes in lenght. +/// +/// The circuit exposes two public inputs: +/// - `pub_inputs_commit` is SHA256(attested_slot || inalized_slot || participation_sum || finalized_header_root || execution_payload_root) truncated to 253 bits. All committed valeus are in little endian. +/// - `poseidon_commit` is a Poseidon "onion" commitment to the X coordinates of sync committee public keys. Coordinates are expressed as big-integer with two limbs of LIMB_BITS * 2 bits. #[derive(Clone, Debug, Default)] pub struct StepCircuit { _f: PhantomData, @@ -52,10 +60,7 @@ impl StepCircuit { fp_chip: &FpChip, args: &witness::SyncStepArgs, ) -> Result>, Error> { - assert!( - !args.signature_compressed.is_empty(), - "no attestations supplied" - ); + assert!(!args.signature_compressed.is_empty(), "signature expected"); let range = fp_chip.range(); let gate = range.gate(); @@ -87,13 +92,16 @@ impl StepCircuit { &args.pariticipation_bits, &mut assigned_affines, ); + + // Commit to the pubkeys using Poseidon hash. This constraints prover to use the pubkeys of the current sync committee, + // because the same commitment is computed in `CommitteeUpdateCircuit` and stored in the contract at the begining of the period. let poseidon_commit = fq_array_poseidon( builder.main(), fp_chip, assigned_affines.iter().map(|p| &p.x), )?; - // Verify attestted header + // Compute attested header root let attested_slot_bytes: HashInputChunk<_> = args.attested_header.slot.into_witness(); let attested_header_state_root = args .attested_header @@ -114,6 +122,7 @@ impl StepCircuit { ], )?; + // Compute finalized header root let finalized_block_body_root = args .finalized_header .body_root @@ -121,7 +130,6 @@ impl StepCircuit { .iter() .map(|&b| builder.main().load_witness(F::from(b as u64))) .collect_vec(); - let finalized_slot_bytes: HashInputChunk<_> = args.finalized_header.slot.into_witness(); let finalized_header_root = ssz_merkleize_chunks( builder, @@ -139,7 +147,7 @@ impl StepCircuit { builder, HashInput::TwoToOne( attested_header_root.into(), - args.domain.to_vec().into_witness(), + args.domain.to_vec().into_witness(), // `domain` can't be a constant because will change in next fork. ), )?; @@ -154,7 +162,7 @@ impl StepCircuit { bls_chip.assert_valid_signature(builder.main(), signature, msghash, agg_pubkey); - // verify finalized block header against current beacon state merkle proof + // Verify finalized block header against current state root via the Merkle "finality" proof verify_merkle_proof( builder, &sha256_chip, @@ -166,7 +174,7 @@ impl StepCircuit { S::FINALIZED_HEADER_INDEX, )?; - // verify execution state root against finilized block body merkle proof + // Verify execution payload root against finalized block body via the Merkle "execution" proof verify_merkle_proof( builder, &sha256_chip, @@ -180,31 +188,35 @@ impl StepCircuit { // Public Input Commitment // See "Onion hashing vs. Input concatenation" in https://github.com/ChainSafe/Spectre/issues/17#issuecomment-1740965182 - let participation_sum_le = to_bytes_le::<_, 8>(&participation_sum, gate, builder.main()); - let pub_inputs_concat = itertools::chain![ - attested_slot_bytes.bytes.into_iter().take(8), - finalized_slot_bytes.bytes.into_iter().take(8), - participation_sum_le - .into_iter() - .map(|b| QuantumCell::Existing(b)), - finalized_header_root - .into_iter() - .map(|b| QuantumCell::Existing(b)), - execution_payload_root.bytes.into_iter(), - ] - .collect_vec(); + let pub_inputs_commit = { + let participation_sum_le = + to_bytes_le::<_, 8>(&participation_sum, gate, builder.main()); + let pub_inputs_concat = itertools::chain![ + attested_slot_bytes.bytes.into_iter().take(8), + finalized_slot_bytes.bytes.into_iter().take(8), + participation_sum_le + .into_iter() + .map(|b| QuantumCell::Existing(b)), + finalized_header_root + .into_iter() + .map(|b| QuantumCell::Existing(b)), + execution_payload_root.bytes.into_iter(), + ] + .collect_vec(); - let pub_inputs_bytes = sha256_chip - .digest(builder, pub_inputs_concat)? - .try_into() - .unwrap(); + let pub_inputs_bytes = sha256_chip + .digest(builder, pub_inputs_concat)? + .try_into() + .unwrap(); - let pub_inputs_commit = - truncate_sha256_into_single_elem(builder.main(), range, pub_inputs_bytes); + truncate_sha256_into_single_elem(builder.main(), range, pub_inputs_bytes) + }; Ok(vec![pub_inputs_commit, poseidon_commit]) } + // Computes public inputs to `StepCircuit` matching the in-circuit logic from `synthesise` method. + // Note, this function outputes only instances of the `StepCircuit` proof, not the aggregated proof which will also include 12 accumulator limbs. pub fn get_instances(args: &SyncStepArgs, limb_bits: usize) -> Vec> { use sha2::Digest; const INPUT_SIZE: usize = 8 * 3 + 32 * 2; @@ -252,8 +264,7 @@ impl StepCircuit { }) .collect_vec(); let poseidon_commitment = - fq_array_poseidon_native::(pubkey_affines.iter().map(|p| p.x), limb_bits); - + poseidon_hash_fq_array::(pubkey_affines.iter().map(|p| p.x), limb_bits); let mut public_input_commitment = sha2::Sha256::digest(&input).to_vec(); // Truncate to 253 bits @@ -306,6 +317,7 @@ pub fn clear_3_bits( } impl StepCircuit { + /// Decompresses siganure from bytes and assigns it to the circuit. fn assign_signature( ctx: &mut Context, g2_chip: &G2Chip, @@ -318,6 +330,7 @@ impl StepCircuit { } /// Takes a list of pubkeys and aggregates them. + /// The outputs are the aggregated pubkey, the sum of participation bits, and a list of assigned pubkeys. fn aggregate_pubkeys( ctx: &mut Context, fp_chip: &FpChip<'_, F>, @@ -440,7 +453,7 @@ mod tests { } #[test] - fn test_sync_circuit() { + fn test_step_circuit() { const K: u32 = 20; let witness = load_circuit_args(); @@ -461,7 +474,7 @@ mod tests { } #[test] - fn test_sync_proofgen() { + fn test_step_proofgen() { const K: u32 = 22; let params = gen_srs(K); @@ -485,7 +498,7 @@ mod tests { } #[test] - fn test_sync_evm_verify() { + fn test_step_evm_verify() { const K: u32 = 22; let params = gen_srs(K); diff --git a/lightclient-circuits/src/util.rs b/lightclient-circuits/src/util/mod.rs similarity index 100% rename from lightclient-circuits/src/util.rs rename to lightclient-circuits/src/util/mod.rs diff --git a/lightclient-circuits/src/witness.rs b/lightclient-circuits/src/witness/mod.rs similarity index 100% rename from lightclient-circuits/src/witness.rs rename to lightclient-circuits/src/witness/mod.rs diff --git a/lightclient-circuits/src/witness/rotation.rs b/lightclient-circuits/src/witness/rotation.rs index 89c8d0d2..d25d9aef 100644 --- a/lightclient-circuits/src/witness/rotation.rs +++ b/lightclient-circuits/src/witness/rotation.rs @@ -6,7 +6,7 @@ use sha2::{Digest, Sha256}; use std::{iter, marker::PhantomData}; #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct CommitteeRotationArgs { +pub struct CommitteeUpdateArgs { pub pubkeys_compressed: Vec>, pub finalized_header: BeaconBlockHeader, @@ -17,7 +17,7 @@ pub struct CommitteeRotationArgs { pub _spec: PhantomData, } -impl Default for CommitteeRotationArgs { +impl Default for CommitteeUpdateArgs { fn default() -> Self { let dummy_x_bytes = iter::once(192).pad_using(48, |_| 0).rev().collect_vec(); @@ -99,7 +99,7 @@ mod tests { #[test] fn test_committee_update_default_witness() { const K: u32 = 18; - let witness = CommitteeRotationArgs::::default(); + let witness = CommitteeUpdateArgs::::default(); let circuit = CommitteeUpdateCircuit::::create_circuit( CircuitBuilderStage::Mock, diff --git a/preprocessor/src/lib.rs b/preprocessor/src/lib.rs index 136282d3..0364fa74 100644 --- a/preprocessor/src/lib.rs +++ b/preprocessor/src/lib.rs @@ -10,7 +10,7 @@ use ethereum_consensus_types::{ LightClientUpdateCapella, Root, }; use itertools::Itertools; -use lightclient_circuits::witness::{CommitteeRotationArgs, SyncStepArgs}; +use lightclient_circuits::witness::{CommitteeUpdateArgs, SyncStepArgs}; use serde::{Deserialize, Serialize}; use ssz_rs::{Node, Vector}; use std::ops::Deref; @@ -31,7 +31,7 @@ pub async fn light_client_update_to_args( >, pubkeys_compressed: Vector, domain: [u8; 32], -) -> eyre::Result<(SyncStepArgs, CommitteeRotationArgs)> +) -> eyre::Result<(SyncStepArgs, CommitteeUpdateArgs)> where [(); S::SYNC_COMMITTEE_SIZE]:, [(); S::FINALIZED_HEADER_DEPTH]:, diff --git a/preprocessor/src/rotation.rs b/preprocessor/src/rotation.rs index 6826d568..2c2f1c2f 100644 --- a/preprocessor/src/rotation.rs +++ b/preprocessor/src/rotation.rs @@ -4,7 +4,7 @@ use beacon_api_client::{BlockId, Client, ClientTypes}; use eth_types::Spec; use ethereum_consensus_types::{BeaconBlockHeader, LightClientUpdateCapella}; use itertools::Itertools; -use lightclient_circuits::witness::CommitteeRotationArgs; +use lightclient_circuits::witness::CommitteeUpdateArgs; use log::debug; use ssz_rs::Merkleized; use tokio::fs; @@ -13,7 +13,7 @@ use crate::{get_block_header, get_light_client_update_at_period}; pub async fn fetch_rotation_args( client: &Client, -) -> eyre::Result> +) -> eyre::Result> where [(); S::SYNC_COMMITTEE_SIZE]:, [(); S::FINALIZED_HEADER_DEPTH]:, @@ -45,7 +45,7 @@ pub async fn rotation_args_from_update( { S::BYTES_PER_LOGS_BLOOM }, { S::MAX_EXTRA_DATA_BYTES }, >, -) -> eyre::Result> +) -> eyre::Result> where [(); S::SYNC_COMMITTEE_SIZE]:, [(); S::FINALIZED_HEADER_DEPTH]:, @@ -87,7 +87,7 @@ where "Execution payload merkle proof verification failed" ); - let args = CommitteeRotationArgs:: { + let args = CommitteeUpdateArgs:: { pubkeys_compressed, finalized_header: update.attested_header.beacon.clone(), sync_committee_branch: sync_committee_branch @@ -99,7 +99,7 @@ where Ok(args) } -pub async fn read_rotation_args(path: String) -> eyre::Result> { +pub async fn read_rotation_args(path: String) -> eyre::Result> { #[derive(serde::Deserialize)] struct ArgsJson { finalized_header: BeaconBlockHeader, @@ -118,7 +118,7 @@ pub async fn read_rotation_args(path: String) -> eyre::Result { + Ok(CommitteeUpdateArgs:: { pubkeys_compressed, finalized_header, sync_committee_branch: committee_root_branch, @@ -171,7 +171,7 @@ mod tests { "../build/sync_step_21.pkey", CONFIG_PATH, false, - &CommitteeRotationArgs::::default(), + &CommitteeUpdateArgs::::default(), ); let client = MainnetClient::new(Url::parse("https://lodestar-sepolia.chainsafe.io").unwrap()); let witness = fetch_rotation_args::(&client).await.unwrap();