Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
overall: code format
Browse files Browse the repository at this point in the history
  • Loading branch information
ashWhiteHat committed Jul 29, 2023
1 parent 080eb78 commit 880ae14
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 94 deletions.
156 changes: 89 additions & 67 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ where
.propose_with(inherent_data, inherent_digests, deadline, block_size_limit)
.await;
if tx.send(res).is_err() {
trace!(target: LOG_TARGET, "Could not send block production result to proposer!");
trace!(
target: LOG_TARGET,
"Could not send block production result to proposer!"
);
}
}),
);
Expand Down Expand Up @@ -384,7 +387,10 @@ where
for inherent in inherents {
match block_builder.push(inherent) {
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
warn!(target: LOG_TARGET, "⚠️ Dropping non-mandatory inherent from overweight block.")
warn!(
target: LOG_TARGET,
"⚠️ Dropping non-mandatory inherent from overweight block."
)
},
Err(ApplyExtrinsicFailed(Validity(e))) if e.was_mandatory() => {
error!(
Expand All @@ -393,7 +399,10 @@ where
return Err(ApplyExtrinsicFailed(Validity(e)))
},
Err(e) => {
warn!(target: LOG_TARGET, "❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e);
warn!(
target: LOG_TARGET,
"❗️ Inherent extrinsic returned unexpected error: {}. Dropping.", e
);
},
Ok(_) => {},
}
Expand Down Expand Up @@ -440,86 +449,99 @@ where
debug!(target: LOG_TARGET, "Pool status: {:?}", self.transaction_pool.status());
let mut transaction_pushed = false;

let end_reason = loop {
let pending_tx = if let Some(pending_tx) = pending_iterator.next() {
pending_tx
} else {
break EndProposingReason::NoMoreTransactions
};
let end_reason =
loop {
let pending_tx = if let Some(pending_tx) = pending_iterator.next() {
pending_tx
} else {
break EndProposingReason::NoMoreTransactions
};

let now = (self.now)();
if now > deadline {
debug!(target: LOG_TARGET,
"Consensus deadline reached when pushing block transactions, \
let now = (self.now)();
if now > deadline {
debug!(
target: LOG_TARGET,
"Consensus deadline reached when pushing block transactions, \
proceeding with proposing."
);
break EndProposingReason::HitDeadline
}

let pending_tx_data = pending_tx.data().clone();
let pending_tx_hash = pending_tx.hash().clone();

let block_size =
block_builder.estimate_block_size(self.include_proof_in_block_size_estimation);
if block_size + pending_tx_data.encoded_size() > block_size_limit {
pending_iterator.report_invalid(&pending_tx);
if skipped < MAX_SKIPPED_TRANSACTIONS {
skipped += 1;
debug!(target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but will try {} more transactions before quitting.",
MAX_SKIPPED_TRANSACTIONS - skipped,
);
continue
} else if now < soft_deadline {
debug!(target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but we still have time before the soft deadline, so \
we will try a bit more."
);
continue
} else {
debug!(target: LOG_TARGET, "Reached block size limit, proceeding with proposing.");
break EndProposingReason::HitBlockSizeLimit
break EndProposingReason::HitDeadline
}
}

trace!(target: LOG_TARGET, "[{:?}] Pushing to the block.", pending_tx_hash);
match sc_block_builder::BlockBuilder::push(block_builder, pending_tx_data) {
Ok(()) => {
transaction_pushed = true;
debug!(target: LOG_TARGET, "[{:?}] Pushed to the block.", pending_tx_hash);
},
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
let pending_tx_data = pending_tx.data().clone();
let pending_tx_hash = pending_tx.hash().clone();

let block_size =
block_builder.estimate_block_size(self.include_proof_in_block_size_estimation);
if block_size + pending_tx_data.encoded_size() > block_size_limit {
pending_iterator.report_invalid(&pending_tx);
if skipped < MAX_SKIPPED_TRANSACTIONS {
skipped += 1;
debug!(target: LOG_TARGET,
debug!(
target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but will try {} more transactions before quitting.",
MAX_SKIPPED_TRANSACTIONS - skipped,
);
continue
} else if now < soft_deadline {
debug!(
target: LOG_TARGET,
"Transaction would overflow the block size limit, \
but we still have time before the soft deadline, so \
we will try a bit more."
);
continue
} else {
debug!(
target: LOG_TARGET,
"Reached block size limit, proceeding with proposing."
);
break EndProposingReason::HitBlockSizeLimit
}
}

trace!(target: LOG_TARGET, "[{:?}] Pushing to the block.", pending_tx_hash);
match sc_block_builder::BlockBuilder::push(block_builder, pending_tx_data) {
Ok(()) => {
transaction_pushed = true;
debug!(target: LOG_TARGET, "[{:?}] Pushed to the block.", pending_tx_hash);
},
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
pending_iterator.report_invalid(&pending_tx);
if skipped < MAX_SKIPPED_TRANSACTIONS {
skipped += 1;
debug!(target: LOG_TARGET,
"Block seems full, but will try {} more transactions before quitting.",
MAX_SKIPPED_TRANSACTIONS - skipped,
);
} else if (self.now)() < soft_deadline {
debug!(target: LOG_TARGET,
} else if (self.now)() < soft_deadline {
debug!(target: LOG_TARGET,
"Block seems full, but we still have time before the soft deadline, \
so we will try a bit more before quitting."
);
} else {
debug!(target: LOG_TARGET, "Reached block weight limit, proceeding with proposing.");
break EndProposingReason::HitBlockWeightLimit
}
},
Err(e) => {
pending_iterator.report_invalid(&pending_tx);
debug!(target: LOG_TARGET, "[{:?}] Invalid transaction: {}", pending_tx_hash, e);
unqueue_invalid.push(pending_tx_hash);
},
}
};
} else {
debug!(
target: LOG_TARGET,
"Reached block weight limit, proceeding with proposing."
);
break EndProposingReason::HitBlockWeightLimit
}
},
Err(e) => {
pending_iterator.report_invalid(&pending_tx);
debug!(
target: LOG_TARGET,
"[{:?}] Invalid transaction: {}", pending_tx_hash, e
);
unqueue_invalid.push(pending_tx_hash);
},
}
};

if matches!(end_reason, EndProposingReason::HitBlockSizeLimit) && !transaction_pushed {
warn!(target: LOG_TARGET,
"Hit block size limit of `{}` without including any transaction!",
block_size_limit,
warn!(
target: LOG_TARGET,
"Hit block size limit of `{}` without including any transaction!", block_size_limit,
);
}

Expand Down
3 changes: 1 addition & 2 deletions client/consensus/grandpa/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,7 @@ where
} else {
debug!(
target: LOG_TARGET,
"Ignoring unnecessary justification for block #{}",
number,
"Ignoring unnecessary justification for block #{}", number,
);
}
},
Expand Down
15 changes: 4 additions & 11 deletions client/network/src/protocol_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,7 @@ impl ProtocolController {
PeerState::Connected(direction)
},
None => {
trace!(
target: LOG_TARGET,
"Adding reserved node {peer_id} on {:?}.",
self.set_id,
);
trace!(target: LOG_TARGET, "Adding reserved node {peer_id} on {:?}.", self.set_id,);
PeerState::NotConnected
},
};
Expand All @@ -426,8 +422,7 @@ impl ProtocolController {
None => {
warn!(
target: LOG_TARGET,
"Trying to remove unknown reserved node {peer_id} from {:?}.",
self.set_id,
"Trying to remove unknown reserved node {peer_id} from {:?}.", self.set_id,
);
return
},
Expand Down Expand Up @@ -524,8 +519,7 @@ impl ProtocolController {
if self.reserved_nodes.contains_key(&peer_id) {
debug!(
target: LOG_TARGET,
"Ignoring request to disconnect reserved peer {peer_id} from {:?}.",
self.set_id,
"Ignoring request to disconnect reserved peer {peer_id} from {:?}.", self.set_id,
);
return
}
Expand All @@ -546,8 +540,7 @@ impl ProtocolController {
None => {
debug!(
target: LOG_TARGET,
"Trying to disconnect unknown peer {peer_id} from {:?}.",
self.set_id,
"Trying to disconnect unknown peer {peer_id} from {:?}.", self.set_id,
);
},
}
Expand Down
6 changes: 4 additions & 2 deletions client/network/src/service/out_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl OutChannels {
debug!(
target: LOG_TARGET,
"Channel `{}` is overflowed again. Number of events: {}",
sender.name, current_pending
sender.name,
current_pending
);
}
sender.warning_fired = SenderWarningState::FiredFull;
Expand All @@ -212,7 +213,8 @@ impl OutChannels {
debug!(
target: LOG_TARGET,
"Channel `{}` is no longer overflowed. Number of events: {}",
sender.name, current_pending
sender.name,
current_pending
);
}

Expand Down
6 changes: 1 addition & 5 deletions frame/society/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ impl<
fn on_runtime_upgrade() -> Weight {
let onchain = Pallet::<T, I>::on_chain_storage_version();
if onchain < 2 {
log::info!(
target: TARGET,
"Running migration against onchain version {:?}",
onchain
);
log::info!(target: TARGET, "Running migration against onchain version {:?}", onchain);
from_original::<T, I>(&mut PastPayouts::get()).defensive_unwrap_or(Weight::MAX)
} else {
log::warn!("Unexpected onchain version: {:?} (expected 0)", onchain);
Expand Down
6 changes: 3 additions & 3 deletions primitives/runtime/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2299,12 +2299,12 @@ pub trait BlockNumberProvider {
mod tests {
use super::*;
use crate::codec::{Decode, Encode, Input};
#[cfg(feature = "bls-experimental")]
use sp_core::{bls377, bls381};
use sp_core::{
crypto::{Pair, UncheckedFrom},
ecdsa, ed25519, sr25519
ecdsa, ed25519, sr25519,
};
#[cfg(feature = "bls-experimental")]
use sp_core::{bls377, bls381};

macro_rules! signature_verify_test {
($algorithm:ident) => {
Expand Down
5 changes: 1 addition & 4 deletions utils/frame/remote-externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,7 @@ where
.collect::<Vec<_>>();

if child_roots.is_empty() {
info!(
target: LOG_TARGET,
"👩‍👦 no child roots found to scrape",
);
info!(target: LOG_TARGET, "👩‍👦 no child roots found to scrape",);
return Ok(Default::default())
}

Expand Down

0 comments on commit 880ae14

Please sign in to comment.