pace RPC requests, extend storage lock, and improve logs

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2026-10-30 19:45:04 +03:00
parent 014ed7d5dc
commit 2ade4c9637
Signed by: st1nky
GPG Key ID: 016064BD97603B40
4 changed files with 16 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ghost-weaver" name = "ghost-weaver"
version = "0.0.22" version = "0.0.23"
description = "Weaving a secure cryptographic tapestry across different external chains." description = "Weaving a secure cryptographic tapestry across different external chains."
license.workspace = true license.workspace = true
authors.workspace = true authors.workspace = true

View File

@ -68,13 +68,14 @@ fn parse_pending_requests<'a, R: Copy + Into<RequestId> + 'static>(
) -> impl Iterator<Item = NetworkResponseType> + 'a { ) -> impl Iterator<Item = NetworkResponseType> + 'a {
PendingRequest::try_wait_all(pending_requests, Some(deadline)) PendingRequest::try_wait_all(pending_requests, Some(deadline))
.into_iter() .into_iter()
.filter_map(move |wait_result| { .enumerate()
.filter_map(move |(idx, wait_result)| {
let http_result = wait_result let http_result = wait_result
.inspect_err(|_| { .inspect_err(|_| {
log::error!( log::error!(
target: LOG_TARGET, target: LOG_TARGET,
"🕸️ Error during request preparation: {:?}", "🕸️ Weaver: RPC request [index {}] timed out (deadline reached).",
WeavingError::<u32>::DeadlineReached, idx
) )
}) })
.ok()?; .ok()?;
@ -83,7 +84,8 @@ fn parse_pending_requests<'a, R: Copy + Into<RequestId> + 'static>(
.inspect_err(|err| { .inspect_err(|err| {
log::error!( log::error!(
target: LOG_TARGET, target: LOG_TARGET,
"🕸️ Error during response parsing: {:?}", "🕸️ Weaver: RPC request [index {}] failed with HTTP error: {:?}",
idx,
err, err,
) )
}) })

View File

@ -78,8 +78,8 @@ const LOG_TARGET: &str = "runtime::ghost-weaver";
const DB_PREFIX: &[u8] = b"ghost-weaver::"; const DB_PREFIX: &[u8] = b"ghost-weaver::";
const LOCK_BLOCK_EXPIRATION: u64 = 20; const LOCK_BLOCK_EXPIRATION: u64 = 20;
const MIN_LOCK_GUARD_PERIOD: u64 = 15_000; const MIN_LOCK_GUARD_PERIOD: u64 = 60_000;
const FETCH_TIMEOUT_PERIOD: u64 = 3_000; const FETCH_TIMEOUT_PERIOD: u64 = 5_000;
type AuthIndex = ghost_helpers::AuthIndexU16; type AuthIndex = ghost_helpers::AuthIndexU16;
type BitmapChunk = ghost_helpers::BitmapChunkU32; type BitmapChunk = ghost_helpers::BitmapChunkU32;
@ -591,7 +591,7 @@ pub mod pallet {
if sp_io::offchain::is_validator() { if sp_io::offchain::is_validator() {
log::warn!(target: LOG_TARGET, "🕸️ Weaver started at block #{:?}", now); log::warn!(target: LOG_TARGET, "🕸️ Weaver started at block #{:?}", now);
match Self::start_weaving(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), Err(e) => log::warn!(target: LOG_TARGET, "🕸️ Weaver failed at block #{:?}: {:?}", now, e),
} }
} }
@ -921,6 +921,7 @@ impl<T: Config> Pallet<T> {
let total_blocks = block_numbers.len(); let total_blocks = block_numbers.len();
let weaving_threshold = get_byzantium_quorum_threshold(total_blocks); 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( let median_block = Self::validate_block_numbers_consensus(
&mut block_numbers, &mut block_numbers,
@ -969,7 +970,7 @@ impl<T: Config> Pallet<T> {
} }
}); });
Ok(WeavingOk::Block(finalized_block, network_id)) Ok(WeavingOk::Block(finalized_block, parsed_blocks_count, network_id))
} }
fn prepare_pending_requests( fn prepare_pending_requests(

View File

@ -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]; const PROTOCOL_PREFIX: [u8; 7] = [0x47, 0x48, 0x53, 0x54, 0x74, 0x6F, 0x3A];
pub enum WeavingOk<NetworkId> { pub enum WeavingOk<NetworkId> {
Block(ExternalBlockNumber, NetworkId), Block(ExternalBlockNumber, u32, NetworkId),
Hash(ExternalBlockNumber, H256, WeavingSession, NetworkId), Hash(ExternalBlockNumber, H256, WeavingSession, NetworkId),
} }
impl<NetworkId> core::fmt::Display for WeavingOk<NetworkId> impl<NetworkId> core::fmt::Debug for WeavingOk<NetworkId>
where where
NetworkId: core::fmt::Debug, NetworkId: core::fmt::Debug,
{ {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
match self { match self {
Self::Block(block, network_id) => write!(fmt, "Verified block height #{:?} found for network: {:?}.", 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 {:?} where next session is {:?}; from block #{:?} for network: {:?}.", hash, next_session, block, network_id), 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),
} }
} }
} }