Skip to content

Commit

Permalink
add logs for deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
gianfra-t committed Jun 26, 2024
1 parent f60318f commit 04ed781
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions substrate/client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ where
Box::pin(async move {
// leave some time for evaluation and block finalization (33%)
let deadline = (self.now)() + max_duration - max_duration / 3;

let res = self
.propose_with(inherent_data, inherent_digests, deadline, block_size_limit)
.await;
Expand Down Expand Up @@ -447,6 +448,7 @@ where
};

let now = (self.now)();
debug!(target: LOG_TARGET, "now = {:?}, deadline = {:?}", now, deadline);
if now > deadline {
debug!(
target: LOG_TARGET,
Expand Down
15 changes: 12 additions & 3 deletions substrate/client/consensus/manual-seal/src/seal_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ use sp_consensus::{self, BlockOrigin, Environment, Proposer, SelectChain};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use std::{sync::Arc, time::Duration};

use log::trace;
use std::time::Instant;
use std::time;
/// max duration for creating a proposal in secs
pub const MAX_PROPOSAL_DURATION: u64 = 10;

const LOG_TARGET: &str = "manual-seal";
/// params for sealing a new block
pub struct SealBlockParams<'a, B: BlockT, BI, SC, C: ProvideRuntimeApi<B>, E, TP, CIDP, P> {
/// if true, empty blocks(without extrinsics) will be created.
Expand Down Expand Up @@ -114,12 +116,19 @@ pub async fn seal_block<B, BI, SC, C, E, TP, CIDP, P>(
} else {
Default::default()
};
let max_duration = Duration::from_secs(MAX_PROPOSAL_DURATION);
trace!(target: LOG_TARGET, "now = {:?}", time::Instant::now());
trace!(target: LOG_TARGET, "max duration = {:?}", max_duration);
trace!(target: LOG_TARGET, "max duration * 1/3 = {:?}", max_duration / 3);
let deadline = time::Instant::now() + max_duration - max_duration / 3;
trace!(target: LOG_TARGET, "deadline = {:?}", deadline);


let proposal = proposer
.propose(
inherent_data.clone(),
digest,
Duration::from_secs(MAX_PROPOSAL_DURATION),
max_duration,
None,
)
.map_err(|err| Error::StringError(err.to_string()))
Expand Down

0 comments on commit 04ed781

Please sign in to comment.