From 461770e5455188e24d41ab8d87758c89017901c1 Mon Sep 17 00:00:00 2001 From: Giacomo Pasini Date: Mon, 2 Sep 2024 14:27:46 +0200 Subject: [PATCH] adjust test timoeut --- nomos-core/src/wire.rs | 2 +- nomos-libp2p/src/lib.rs | 1 + .../cryptarchia-consensus/src/leadership.rs | 44 ++++++++++++------- .../cryptarchia-consensus/src/lib.rs | 2 +- tests/src/nodes/nomos.rs | 2 +- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/nomos-core/src/wire.rs b/nomos-core/src/wire.rs index 917f33d6..a58aae91 100644 --- a/nomos-core/src/wire.rs +++ b/nomos-core/src/wire.rs @@ -24,7 +24,7 @@ type BincodeOptions = WithOtherTrailing< RejectTrailing, >; -const DATA_LIMIT: u64 = 2048; // Do not serialize/deserialize more than 2Kb +const DATA_LIMIT: u64 = 1 << 19; // Do not serialize/deserialize more than 16Kb static OPTIONS: Lazy = Lazy::new(|| { bincode::DefaultOptions::new() .with_little_endian() diff --git a/nomos-libp2p/src/lib.rs b/nomos-libp2p/src/lib.rs index 686671cc..f3244675 100644 --- a/nomos-libp2p/src/lib.rs +++ b/nomos-libp2p/src/lib.rs @@ -43,6 +43,7 @@ impl Behaviour { gossipsub::ConfigBuilder::from(gossipsub_config) .validation_mode(gossipsub::ValidationMode::None) .message_id_fn(compute_message_id) + .max_transmit_size(1 << 19) .build()?, )?; Ok(Self { diff --git a/nomos-services/cryptarchia-consensus/src/leadership.rs b/nomos-services/cryptarchia-consensus/src/leadership.rs index 18d6297a..a0dbd511 100644 --- a/nomos-services/cryptarchia-consensus/src/leadership.rs +++ b/nomos-services/cryptarchia-consensus/src/leadership.rs @@ -38,7 +38,7 @@ impl Leader { } } - pub fn build_proof_for( + pub async fn build_proof_for( &self, note_tree: &NoteTree, epoch_state: &EpochState, @@ -47,9 +47,19 @@ impl Leader { ) -> Option { let notes = self.notes.get(&parent)?; for note in notes { - let cm_root = [0; 32]; + let Some(index) = note_tree + .commitments() + .iter() + .position(|cm| cm == ¬e.note_commitment()) + else { + continue; + }; + + let input_cm_path = note_tree + .witness(index) + .expect("Note was found in the tree"); let public_inputs = LeaderPublic::new( - cm_root, + note_tree.root(), *epoch_state.nonce(), slot.into(), self.config.consensus_config.active_slot_coeff, @@ -64,20 +74,20 @@ impl Leader { note.note.value, epoch_state.total_stake() ); - let index = note_tree - .commitments() - .iter() - .position(|cm| cm == ¬e.note_commitment())?; - let input_cm_path = note_tree - .witness(index) - .expect("Note was found in the tree"); - return Some(Risc0LeaderProof::build( - public_inputs, - LeaderPrivate { - input: *note, - input_cm_path, - }, - )); + let input = *note; + return Some( + tokio::task::spawn_blocking(move || { + Risc0LeaderProof::build( + public_inputs, + LeaderPrivate { + input, + input_cm_path, + }, + ) + }) + .await + .ok()?, + ); } } diff --git a/nomos-services/cryptarchia-consensus/src/lib.rs b/nomos-services/cryptarchia-consensus/src/lib.rs index ab63eb70..6cb0902e 100644 --- a/nomos-services/cryptarchia-consensus/src/lib.rs +++ b/nomos-services/cryptarchia-consensus/src/lib.rs @@ -344,7 +344,7 @@ where tracing::error!("trying to propose a block for slot {} but epoch state is not available", u64::from(slot)); continue; }; - if let Some(proof) = leader.build_proof_for(note_tree, epoch_state, slot, parent) { + if let Some(proof) = leader.build_proof_for(note_tree, epoch_state, slot, parent).await { tracing::debug!("proposing block..."); // TODO: spawn as a separate task? let block = Self::propose_block( diff --git a/tests/src/nodes/nomos.rs b/tests/src/nodes/nomos.rs index 94abb23c..94146fbd 100644 --- a/tests/src/nodes/nomos.rs +++ b/tests/src/nodes/nomos.rs @@ -258,7 +258,7 @@ impl Node for NomosNode { }, }; let time_config = TimeConfig { - slot_duration: Duration::from_secs(1), + slot_duration: Duration::from_secs(30), chain_start_time: OffsetDateTime::now_utc(), };