mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Delay reputation updates (#7214)
* Add futures-timer * Make cost_or_benefit public * Update ReportPeer message format * Add delay to reputation updates (dirtywork) * Update ReputationAggregator * Update tests * Fix flucky tests * Move reputation to state * Use the main loop for handling reputation sendings * Update * Move reputation to utils * Update reputation sending * Fix arguments order * Update state * Remove new from state * Add constant * Add failing test for delay * Change mocking approach * Fix type errors * Fix comments * Add message handling to select * Fix bitfields-distribution tests * Add docs to reputation aggregator * Replace .into_base_rep * Use one REPUTATION_CHANGE_INTERVAL by default * Add reputation change to statement-distribution * Update polkadot-availability-bitfield-distribution * Update futures selecting in subsystems * Update reputation adding * Send malicious changes right away without adding to state * Add reputation to StatementDistributionSubsystem * Handle reputation in statement distribution * Add delay test for polkadot-statement-distribution * Fix collator-protocol tests before applying reputation delay * Remove into_base_rep * Add reputation to State * Fix failed tests * Add reputation delay * Update tests * Add batched network message for peer reporting * Update approval-distribution tests * Update bitfield-distribution tests * Update statement-distribution tests * Update collator-protocol tests * Remove levels in matching * Address clippy errors * Fix overseer test * Add a metric for original count of rep changes * Update Reputation * Revert "Add a metric for original count of rep changes" This reverts commit 6c9b0c1ec34491d16e562bdcba8db6b9dcf484db. * Update node/subsystem-util/src/reputation.rs Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io> * Remove redundant vec --------- Co-authored-by: Vsevolod Stakhov <vsevolod.stakhov@parity.io>
This commit is contained in:
@@ -42,7 +42,7 @@ impl UnifiedReputationChange {
|
||||
///
|
||||
/// The whole range of an `i32` should be used, so order of magnitude of
|
||||
/// something malicious should be `1<<20` (give or take).
|
||||
const fn cost_or_benefit(&self) -> i32 {
|
||||
pub const fn cost_or_benefit(&self) -> i32 {
|
||||
match self {
|
||||
Self::CostMinor(_) => -100_000,
|
||||
Self::CostMajor(_) => -300_000,
|
||||
@@ -81,9 +81,10 @@ impl UnifiedReputationChange {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert into a base reputation as used with substrate.
|
||||
pub const fn into_base_rep(self) -> ReputationChange {
|
||||
ReputationChange::new(self.cost_or_benefit(), self.description())
|
||||
impl From<UnifiedReputationChange> for ReputationChange {
|
||||
fn from(value: UnifiedReputationChange) -> Self {
|
||||
ReputationChange::new(value.cost_or_benefit(), value.description())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,7 @@ where
|
||||
let payload = match Req::decode(&mut payload.as_ref()) {
|
||||
Ok(payload) => payload,
|
||||
Err(err) => {
|
||||
let reputation_changes =
|
||||
reputation_changes.into_iter().map(|r| r.into_base_rep()).collect();
|
||||
let reputation_changes = reputation_changes.into_iter().map(|r| r.into()).collect();
|
||||
let response = sc_network::config::OutgoingResponse {
|
||||
result: Err(()),
|
||||
reputation_changes,
|
||||
@@ -175,7 +174,7 @@ where
|
||||
|
||||
let response = netconfig::OutgoingResponse {
|
||||
result: result.map(|v| v.encode()),
|
||||
reputation_changes: reputation_changes.into_iter().map(|c| c.into_base_rep()).collect(),
|
||||
reputation_changes: reputation_changes.into_iter().map(|c| c.into()).collect(),
|
||||
sent_feedback,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user