pace RPC requests, extend storage lock, and improve logs
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
014ed7d5dc
commit
2ade4c9637
@ -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
|
||||
|
||||
@ -68,13 +68,14 @@ fn parse_pending_requests<'a, R: Copy + Into<RequestId> + 'static>(
|
||||
) -> impl Iterator<Item = NetworkResponseType> + '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::<u32>::DeadlineReached,
|
||||
"🕸️ Weaver: RPC request [index {}] timed out (deadline reached).",
|
||||
idx
|
||||
)
|
||||
})
|
||||
.ok()?;
|
||||
@ -83,7 +84,8 @@ fn parse_pending_requests<'a, R: Copy + Into<RequestId> + 'static>(
|
||||
.inspect_err(|err| {
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"🕸️ Error during response parsing: {:?}",
|
||||
"🕸️ Weaver: RPC request [index {}] failed with HTTP error: {:?}",
|
||||
idx,
|
||||
err,
|
||||
)
|
||||
})
|
||||
|
||||
@ -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<T: Config> Pallet<T> {
|
||||
|
||||
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<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(
|
||||
|
||||
@ -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<NetworkId> {
|
||||
Block(ExternalBlockNumber, NetworkId),
|
||||
Block(ExternalBlockNumber, u32, NetworkId),
|
||||
Hash(ExternalBlockNumber, H256, WeavingSession, NetworkId),
|
||||
}
|
||||
|
||||
impl<NetworkId> core::fmt::Display for WeavingOk<NetworkId>
|
||||
impl<NetworkId> core::fmt::Debug for WeavingOk<NetworkId>
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user