Use same fmt and clippy configs as in Substrate (#7611)

* Use same rustfmt.toml as Substrate

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* format format file

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Format with new config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add Substrate Clippy config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Print Clippy version in CI

Otherwise its difficult to reproduce locally.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make fmt happy

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-08-14 16:29:29 +02:00
committed by GitHub
parent ac435c96cf
commit 342d720573
203 changed files with 1880 additions and 1504 deletions
@@ -42,8 +42,8 @@ pub enum RequiredTranches {
/// assignments that are before the local time.
maximum_broadcast: DelayTranche,
/// The clock drift, in ticks, to apply to the local clock when determining whether
/// to broadcast an assignment or when to schedule a wakeup. The local clock should be treated
/// as though it is `clock_drift` ticks earlier.
/// to broadcast an assignment or when to schedule a wakeup. The local clock should be
/// treated as though it is `clock_drift` ticks earlier.
clock_drift: Tick,
},
/// An exact number of required tranches and a number of no-shows. This indicates that
@@ -55,8 +55,8 @@ pub enum RequiredTranches {
/// The amount of missing votes that should be tolerated.
tolerated_missing: usize,
/// When the next no-show would be, if any. This is used to schedule the next wakeup in the
/// event that there are some assignments that don't have corresponding approval votes. If this
/// is `None`, all assignments have approvals.
/// event that there are some assignments that don't have corresponding approval votes. If
/// this is `None`, all assignments have approvals.
next_no_show: Option<Tick>,
/// The last tick at which a needed assignment was received.
last_assignment_tick: Option<Tick>,
@@ -218,13 +218,14 @@ impl AssignmentCriteria for RealAssignmentCriteria {
}
/// Compute the assignments for a given block. Returns a map containing all assignments to cores in
/// the block. If more than one assignment targets the given core, only the earliest assignment is kept.
/// the block. If more than one assignment targets the given core, only the earliest assignment is
/// kept.
///
/// The `leaving_cores` parameter indicates all cores within the block where a candidate was included,
/// as well as the group index backing those.
/// The `leaving_cores` parameter indicates all cores within the block where a candidate was
/// included, as well as the group index backing those.
///
/// The current description of the protocol assigns every validator to check every core. But at different times.
/// The idea is that most assignments are never triggered and fall by the wayside.
/// The current description of the protocol assigns every validator to check every core. But at
/// different times. The idea is that most assignments are never triggered and fall by the wayside.
///
/// This will not assign to anything the local validator was part of the backing group for.
pub(crate) fn compute_assignments(
@@ -463,8 +464,8 @@ pub(crate) enum InvalidAssignmentReason {
/// * Sample is out of bounds
/// * Validator is present in backing group.
///
/// This function does not check whether the core is actually a valid assignment or not. That should be done
/// outside the scope of this function.
/// This function does not check whether the core is actually a valid assignment or not. That should
/// be done outside the scope of this function.
pub(crate) fn check_assignment_cert(
claimed_core_index: CoreIndex,
validator_index: ValidatorIndex,
@@ -104,7 +104,8 @@ enum ImportedBlockInfoError {
VrfInfoUnavailable,
}
/// Computes information about the imported block. Returns an error if the info couldn't be extracted.
/// Computes information about the imported block. Returns an error if the info couldn't be
/// extracted.
#[overseer::contextbounds(ApprovalVoting, prefix = self::overseer)]
async fn imported_block_info<Context>(
ctx: &mut Context,
@@ -181,20 +182,21 @@ async fn imported_block_info<Context>(
// It's not obvious whether to use the hash or the parent hash for this, intuitively. We
// want to use the block hash itself, and here's why:
//
// First off, 'epoch' in BABE means 'session' in other places. 'epoch' is the terminology from
// the paper, which we fulfill using 'session's, which are a Substrate consensus concept.
// First off, 'epoch' in BABE means 'session' in other places. 'epoch' is the terminology
// from the paper, which we fulfill using 'session's, which are a Substrate consensus
// concept.
//
// In BABE, the on-chain and off-chain view of the current epoch can differ at epoch boundaries
// because epochs change precisely at a slot. When a block triggers a new epoch, the state of
// its parent will still have the old epoch. Conversely, we have the invariant that every
// block in BABE has the epoch _it was authored in_ within its post-state. So we use the
// block, and not its parent.
// In BABE, the on-chain and off-chain view of the current epoch can differ at epoch
// boundaries because epochs change precisely at a slot. When a block triggers a new epoch,
// the state of its parent will still have the old epoch. Conversely, we have the invariant
// that every block in BABE has the epoch _it was authored in_ within its post-state. So we
// use the block, and not its parent.
//
// It's worth nothing that Polkadot session changes, at least for the purposes of parachains,
// would function the same way, except for the fact that they're always delayed by one block.
// This gives us the opposite invariant for sessions - the parent block's post-state gives
// us the canonical information about the session index for any of its children, regardless
// of which slot number they might be produced at.
// It's worth nothing that Polkadot session changes, at least for the purposes of
// parachains, would function the same way, except for the fact that they're always delayed
// by one block. This gives us the opposite invariant for sessions - the parent block's
// post-state gives us the canonical information about the session index for any of its
// children, regardless of which slot number they might be produced at.
ctx.send_message(RuntimeApiMessage::Request(
block_hash,
RuntimeApiRequest::CurrentBabeEpoch(s_tx),
+20 -15
View File
@@ -1232,8 +1232,8 @@ async fn handle_from_overseer<Context>(
);
// Our first wakeup will just be the tranche of our assignment,
// if any. This will likely be superseded by incoming assignments
// and approvals which trigger rescheduling.
// if any. This will likely be superseded by incoming
// assignments and approvals which trigger rescheduling.
actions.push(Action::ScheduleWakeup {
block_hash: block_batch.block_hash,
block_number: block_batch.block_number,
@@ -1256,12 +1256,14 @@ async fn handle_from_overseer<Context>(
crate::ops::canonicalize(db, block_number, block_hash)
.map_err(|e| SubsystemError::with_origin("db", e))?;
// `prune_finalized_wakeups` prunes all finalized block hashes. We prune spans accordingly.
// `prune_finalized_wakeups` prunes all finalized block hashes. We prune spans
// accordingly.
wakeups.prune_finalized_wakeups(block_number, &mut state.spans);
// // `prune_finalized_wakeups` prunes all finalized block hashes. We prune spans accordingly.
// let hash_set = wakeups.block_numbers.values().flatten().collect::<HashSet<_>>();
// state.spans.retain(|hash, _| hash_set.contains(hash));
// // `prune_finalized_wakeups` prunes all finalized block hashes. We prune spans
// accordingly. let hash_set =
// wakeups.block_numbers.values().flatten().collect::<HashSet<_>>(); state.spans.
// retain(|hash, _| hash_set.contains(hash));
Vec::new()
},
@@ -1403,8 +1405,8 @@ async fn get_approval_signatures_for_candidate<Context>(
tx_distribution,
));
// Because of the unbounded sending and the nature of the call (just fetching data from state),
// this should not block long:
// Because of the unbounded sending and the nature of the call (just fetching data from
// state), this should not block long:
match rx_distribution.timeout(WAIT_FOR_SIGS_TIMEOUT).await {
None => {
gum::warn!(
@@ -2117,9 +2119,10 @@ impl ApprovalStateTransition {
}
}
// Advance the approval state, either by importing an approval vote which is already checked to be valid and corresponding to an assigned
// validator on the candidate and block, or by noting that there are no further wakeups or tranches needed. This updates the block entry and candidate entry as
// necessary and schedules any further wakeups.
// Advance the approval state, either by importing an approval vote which is already checked to be
// valid and corresponding to an assigned validator on the candidate and block, or by noting that
// there are no further wakeups or tranches needed. This updates the block entry and candidate entry
// as necessary and schedules any further wakeups.
async fn advance_approval_state<Sender>(
sender: &mut Sender,
state: &State,
@@ -2251,7 +2254,8 @@ where
// 1. This is not a local approval, as we don't store anything new in the approval entry.
// 2. The candidate is not newly approved, as we haven't altered the approval entry's
// approved flag with `mark_approved` above.
// 3. The approver, if any, had already approved the candidate, as we haven't altered the bitfield.
// 3. The approver, if any, had already approved the candidate, as we haven't altered the
// bitfield.
if transition.is_local_approval() || newly_approved || !already_approved_by.unwrap_or(true)
{
// In all other cases, we need to write the candidate entry.
@@ -2279,7 +2283,8 @@ fn should_trigger_assignment(
&approval_entry,
RequiredTranches::All,
)
.is_approved(Tick::max_value()), // when all are required, we are just waiting for the first 1/3+
// when all are required, we are just waiting for the first 1/3+
.is_approved(Tick::max_value()),
RequiredTranches::Pending { maximum_broadcast, clock_drift, .. } => {
let drifted_tranche_now =
tranche_now.saturating_sub(clock_drift as DelayTranche);
@@ -2615,8 +2620,8 @@ async fn launch_approval<Context>(
match val_rx.await {
Err(_) => return ApprovalState::failed(validator_index, candidate_hash),
Ok(Ok(ValidationResult::Valid(_, _))) => {
// Validation checked out. Issue an approval command. If the underlying service is unreachable,
// then there isn't anything we can do.
// Validation checked out. Issue an approval command. If the underlying service is
// unreachable, then there isn't anything we can do.
gum::trace!(target: LOG_TARGET, ?candidate_hash, ?para_id, "Candidate Valid");
@@ -161,7 +161,8 @@ pub fn canonicalize(
}
}
// Update all blocks-at-height keys, deleting all those which now have empty `block_assignments`.
// Update all blocks-at-height keys, deleting all those which now have empty
// `block_assignments`.
for (h, at) in visited_heights.into_iter() {
if at.is_empty() {
overlay_db.delete_blocks_at_height(h);
@@ -170,8 +171,8 @@ pub fn canonicalize(
}
}
// due to the fork pruning, this range actually might go too far above where our actual highest block is,
// if a relatively short fork is canonicalized.
// due to the fork pruning, this range actually might go too far above where our actual highest
// block is, if a relatively short fork is canonicalized.
// TODO https://github.com/paritytech/polkadot/issues/3389
let new_range = StoredBlockRange(canon_number + 1, std::cmp::max(range.1, canon_number + 2));