From bae6c568925e0a0501db5f32789f5fb887707a43 Mon Sep 17 00:00:00 2001 From: Rakan Alhneiti Date: Sat, 21 Dec 2024 20:48:05 +0300 Subject: [PATCH] Store unprocessed chunks --- crates/light-client-prover/src/circuit.rs | 4 ++-- crates/light-client-prover/src/da_block_handler.rs | 1 + crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/light-client-prover/src/circuit.rs b/crates/light-client-prover/src/circuit.rs index d553007c2..20c8dc8f3 100644 --- a/crates/light-client-prover/src/circuit.rs +++ b/crates/light-client-prover/src/circuit.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; use anyhow::anyhow; use borsh::BorshDeserialize; @@ -58,7 +58,7 @@ pub fn run_circuit( .map_err(|_| LightClientVerificationError::DaTxsCouldntBeVerified)?; // Mapping from initial state root to final state root and last L2 height - let mut initial_to_final = std::collections::BTreeMap::<[u8; 32], ([u8; 32], u64)>::new(); + let mut initial_to_final = BTreeMap::<[u8; 32], ([u8; 32], u64)>::new(); let (mut last_state_root, mut last_l2_height, l2_genesis_state_root, mut unprocessed_chunks) = previous_light_client_proof_output.as_ref().map_or_else( diff --git a/crates/light-client-prover/src/da_block_handler.rs b/crates/light-client-prover/src/da_block_handler.rs index 2bb46bc1e..a4962994d 100644 --- a/crates/light-client-prover/src/da_block_handler.rs +++ b/crates/light-client-prover/src/da_block_handler.rs @@ -283,6 +283,7 @@ where unchained_batch_proofs_info: circuit_output.unchained_batch_proofs_info, last_l2_height: circuit_output.last_l2_height, l2_genesis_state_root: circuit_output.l2_genesis_state_root, + unprocessed_chunks: circuit_output.unprocessed_chunks, }; self.ledger_db.insert_light_client_proof_data_by_l1_height( diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs index 6f90dad4e..af79d2e0a 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::fmt::Debug; use std::sync::Arc; @@ -83,6 +84,8 @@ pub struct StoredLightClientProofOutput { pub last_l2_height: u64, /// L2 genesis state root. pub l2_genesis_state_root: [u8; 32], + /// A list of unprocessed chunks + pub unprocessed_chunks: BTreeMap<[u8; 32], Vec>, } impl From for LightClientProofOutputRpcResponse {