From 2ade4c9637bec7e77c4d51ee3c6969187d67532f Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Fri, 30 Oct 2026 19:45:04 +0300 Subject: [PATCH] pace RPC requests, extend storage lock, and improve logs Signed-off-by: Uncle Stinky --- pallets/weaver/Cargo.toml | 2 +- pallets/weaver/src/impls.rs | 10 ++++++---- pallets/weaver/src/lib.rs | 9 +++++---- pallets/weaver/src/types.rs | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pallets/weaver/Cargo.toml b/pallets/weaver/Cargo.toml index 7e7cb26..1c28d62 100644 --- a/pallets/weaver/Cargo.toml +++ b/pallets/weaver/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghost-weaver" -version = "0.0.22" +version = "0.0.23" description = "Weaving a secure cryptographic tapestry across different external chains." license.workspace = true authors.workspace = true diff --git a/pallets/weaver/src/impls.rs b/pallets/weaver/src/impls.rs index 07ad2c5..9052b61 100644 --- a/pallets/weaver/src/impls.rs +++ b/pallets/weaver/src/impls.rs @@ -68,13 +68,14 @@ fn parse_pending_requests<'a, R: Copy + Into + 'static>( ) -> impl Iterator + 'a { PendingRequest::try_wait_all(pending_requests, Some(deadline)) .into_iter() - .filter_map(move |wait_result| { + .enumerate() + .filter_map(move |(idx, wait_result)| { let http_result = wait_result .inspect_err(|_| { log::error!( target: LOG_TARGET, - "🕸️ Error during request preparation: {:?}", - WeavingError::::DeadlineReached, + "🕸️ Weaver: RPC request [index {}] timed out (deadline reached).", + idx ) }) .ok()?; @@ -83,7 +84,8 @@ fn parse_pending_requests<'a, R: Copy + Into + 'static>( .inspect_err(|err| { log::error!( target: LOG_TARGET, - "🕸️ Error during response parsing: {:?}", + "🕸️ Weaver: RPC request [index {}] failed with HTTP error: {:?}", + idx, err, ) }) diff --git a/pallets/weaver/src/lib.rs b/pallets/weaver/src/lib.rs index 6e01a67..e3ed38d 100644 --- a/pallets/weaver/src/lib.rs +++ b/pallets/weaver/src/lib.rs @@ -78,8 +78,8 @@ const LOG_TARGET: &str = "runtime::ghost-weaver"; const DB_PREFIX: &[u8] = b"ghost-weaver::"; const LOCK_BLOCK_EXPIRATION: u64 = 20; -const MIN_LOCK_GUARD_PERIOD: u64 = 15_000; -const FETCH_TIMEOUT_PERIOD: u64 = 3_000; +const MIN_LOCK_GUARD_PERIOD: u64 = 60_000; +const FETCH_TIMEOUT_PERIOD: u64 = 5_000; type AuthIndex = ghost_helpers::AuthIndexU16; type BitmapChunk = ghost_helpers::BitmapChunkU32; @@ -591,7 +591,7 @@ pub mod pallet { if sp_io::offchain::is_validator() { log::warn!(target: LOG_TARGET, "🕸️ Weaver started at block #{:?}", now); match Self::start_weaving(now) { - Ok(_) => log::warn!(target: LOG_TARGET, "🕸️ Weaver finished gracefully at block #{:?}", now), + Ok(msg) => log::warn!(target: LOG_TARGET, "🕸️ Weaver finished gracefully at block #{:?}: {:?}", now, msg), Err(e) => log::warn!(target: LOG_TARGET, "🕸️ Weaver failed at block #{:?}: {:?}", now, e), } } @@ -921,6 +921,7 @@ impl Pallet { let total_blocks = block_numbers.len(); let weaving_threshold = get_byzantium_quorum_threshold(total_blocks); + let parsed_blocks_count = total_blocks.unique_saturated_into(); let median_block = Self::validate_block_numbers_consensus( &mut block_numbers, @@ -969,7 +970,7 @@ impl Pallet { } }); - Ok(WeavingOk::Block(finalized_block, network_id)) + Ok(WeavingOk::Block(finalized_block, parsed_blocks_count, network_id)) } fn prepare_pending_requests( diff --git a/pallets/weaver/src/types.rs b/pallets/weaver/src/types.rs index e4be6c6..29cde6c 100644 --- a/pallets/weaver/src/types.rs +++ b/pallets/weaver/src/types.rs @@ -36,18 +36,18 @@ const PROTOCOL_PREFIX: [u8; 7] = [0x69, 0x64, 0x2b, 0x5b, 0xb6, 0x66, 0xac]; const PROTOCOL_PREFIX: [u8; 7] = [0x47, 0x48, 0x53, 0x54, 0x74, 0x6F, 0x3A]; pub enum WeavingOk { - Block(ExternalBlockNumber, NetworkId), + Block(ExternalBlockNumber, u32, NetworkId), Hash(ExternalBlockNumber, H256, WeavingSession, NetworkId), } -impl core::fmt::Display for WeavingOk +impl core::fmt::Debug for WeavingOk where NetworkId: core::fmt::Debug, { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { match self { - Self::Block(block, network_id) => write!(fmt, "Verified block height #{:?} found for network: {:?}.", block, network_id), - Self::Hash(block, hash, next_session, network_id) => write!(fmt, "Extracted Merkle Root {:?} where next session is {:?}; from block #{:?} for network: {:?}.", hash, next_session, block, network_id), + Self::Block(block, count, network_id) => write!(fmt, "Verified block height #{:?} for network: {:?} based on {} parsed requests.", block, network_id, count), + Self::Hash(block, hash, next_session, network_id) => write!(fmt, "Extracted Merkle Root {:?} (next session is {:?}) from block #{:?} for network: {:?}.", hash, next_session, block, network_id), } } }