mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Malus: add disputed block percentage (#6100)
* Malus: add disputed block percentage * Bump clap to support value_parser with range * Add rand crate and use Bernoulli and Distribution * Add conditional logic based on sampled value from Bernoulli distribution * Add SuggestGarbageCandidateOptions struct * Cleanup tests * * Replace unwrap with expect and meaningful error message * * Remove Inner * Remove intercept_outgoing * * Rename sampled variable * Move info! logs to include candidate hash of malicious candidate * * Add percentage option to dispute_ancestor * * Support static probability for `ReplaceValidationResult` proxy * Update some comments and docs * * Add `--percentage` to `back-garbage-candidate` variant * Rename structs for consistency * * Add probabilistic behavior to `dispute-ancestor` variant * Add probabilistic behavior to `back-garbage-candidate` variant * Rename structs in dispute variant * * More descriptive comments * * cargo +nightly fmt --all * * Move Bernoulli distributrion to ReplaceValidationResult constructor * Rename random_bool to behave_maliciously * * Remove dangling comment * * Consistent log * * Add logs based on sampled value * * Cargo +nightly fmt --all * * Remove unused percentage attributed after moving Bernoulli to constructor * Squashed commit of the following: commite4361b6d80Author: Chris Sosnin <48099298+slumber@users.noreply.github.com> Date: Mon Oct 10 10:06:44 2022 +0400 Fix flaky test (#6131) * Split test + decrease test timeout * fmt * spellcheck commitf614752c22Author: girazoki <gorka.irazoki@gmail.com> Date: Mon Oct 10 06:39:30 2022 +0200 Add event to asset claim (#6029) commit71197818a4Author: Leszek Wiesner <leszek@jsgenesis.com> Date: Mon Oct 10 00:23:54 2022 +0200 Companion for 12109 (#5929) * Update following `pallet-vesting` configurable `WithdrawReasons` * Update lib.rs * Update lib.rs * Update lib.rs * update lockfile for {"substrate"} * fix warning Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <> commit607350449cAuthor: Bastian Köcher <info@kchr.de> Date: Fri Oct 7 13:40:40 2022 +0200 Companion for upgrading pin-project (#6118) * Companion for upgrading pin-project This will remove some warnings with the latest rustc nightly/stable. https://github.com/paritytech/substrate/pull/12426 * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> commitc8151aed3cAuthor: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Thu Oct 6 19:20:58 2022 +0200 Maximum value for `MultiplierUpdate` (#6021) * update multiplier * fix * update lockfile for {"substrate"} * fmt * fix typo Co-authored-by: parity-processbot <> commit8d1c16dc0dAuthor: Adrian Catangiu <adrian@parity.io> Date: Thu Oct 6 12:58:39 2022 +0300 service: use MmrRootProvider as custom BEEFY payload provider (companion for 12428) (#6112) * service: use MmrRootProvider as custom BEEFY payload provider * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> commit910e21847fAuthor: Branislav Kontur <bkontur@gmail.com> Date: Thu Oct 6 10:03:34 2022 +0200 Skip `unexpected metric type` * Dump more info for `unexpected metric type` * Skip `unexpected metric type` commitaf6a5cd96aAuthor: Andronik <write@reusable.software> Date: Thu Oct 6 00:36:51 2022 +0200 update kvdb & co (#6111) * toml changes * REVERTME: patch * adapt parachains db interface * fix Cargo.toml patch after master rebase * fix av-store * fix chain-selection * fix parachains-db? * Revert "fix Cargo.toml patch after master rebase" This reverts commit 3afcbf033c86027b3f2b909d83ec703591bdd287. * Revert "REVERTME: patch" This reverts commit 464b717cf4142d3d09c3d77b83700b632d8c5f54. * Use `Ok` imported from prelude Co-authored-by: Bastian Köcher <info@kchr.de> * update lockfile for {"substrate"} * Revert "update lockfile for {"substrate"}" This reverts commit fdc623de226f7645741b86c4b1a7d030fed2172d. * cargo update -p sp-io Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: parity-processbot <> commit9a3cf4cd1fAuthor: Gavin Wood <gavin@parity.io> Date: Wed Oct 5 22:17:59 2022 +0100 Companion for #11649: Bound uses of `Call` (#5729) * Fixes * Clear out old weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Resolve merges Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix weight traits Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * polkadot runtime: Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * rococo runtime: update pallet configs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add preimage migration Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add all migrations Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Democracy is not on Westend Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * [Migration] Refund stored multisig calls (#6075) * Add Preimages to referenda config Needed since Gov V2 just merged. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add multisig migration to Westend+Rococo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix Executive syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Bump Substrate Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com> commit4aea71a95fAuthor: Alexander Theißen <alex.theissen@me.com> Date: Wed Oct 5 15:15:07 2022 +0200 Pass through `runtime-benchmark` feature (#6110) commit42c043d7f4Author: Keith Yeung <kungfukeith11@gmail.com> Date: Wed Oct 5 17:47:15 2022 +0800 Properly migrate weights to v2 (#6091) * Create migration for config pallet * Use XcmWeight in XCM pallet extrinsics * Link to PR in doc comment * cargo fmt * Fix tests * Fix tests * Remove unused import * Update runtime/parachains/src/configuration/migration.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add missing on_runtime_upgrade implementation * Use new migration API * cargo fmt * Fix log message Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> commitb13e07bc47Author: Chris Sosnin <48099298+slumber@users.noreply.github.com> Date: Wed Oct 5 11:48:50 2022 +0400 Buffered connection management for collator-protocol (#6022) * Extract metrics into a separate module * Introduce validators buffer * Integrate buffer into the subsystem * Only reconnect on new advertisements * Test * comma * doc comment * Make capacity buffer compile time non-zero * Add doc comments * nits * remove derives * review * better naming * check timeout * Extract interval stream into lib * Ensure collator disconnects after timeout * spellcheck * rename buf * Remove double interval * Add a log on timeout * Cleanup buffer on timeout commite0e836671fAuthor: Robert Klotzner <eskimor@users.noreply.github.com> Date: Tue Oct 4 18:47:52 2022 +0200 Add unknown words (#6105) commit938bc96a2cAuthor: Robert Klotzner <eskimor@users.noreply.github.com> Date: Tue Oct 4 18:02:05 2022 +0200 Batch vote import in dispute-distribution (#5894) * Start work on batching in dispute-distribution. * Guide work. * More guide changes. Still very much WIP. * Finish guide changes. * Clarification * Adjust argument about slashing. * WIP: Add constants to receiver. * Maintain order of disputes. * dispute-distribuion sender Rate limit. * Cleanup * WIP: dispute-distribution receiver. - [ ] Rate limiting - [ ] Batching * WIP: Batching. * fmt * Update `PeerQueues` to maintain more invariants. * WIP: Batching. * Small cleanup * Batching logic. * Some integration work. * Finish. Missing: Tests * Typo. * Docs. * Report missing metric. * Doc pass. * Tests for waiting_queue. * Speed up some crypto by 10x. * Fix redundant import. * Add some tracing. * Better sender rate limit * Some tests. * Tests * Add logging to rate limiter * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Update node/network/dispute-distribution/src/receiver/mod.rs Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Review feedback. * Also log peer in log messages. * Fix indentation. * waker -> timer * Guide improvement. * Remove obsolete comment. * waker -> timer * Fix spell complaints. * Fix Cargo.lock Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> commita64cc4a860Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Oct 4 11:28:21 2022 +0000 Bump lru from 0.7.8 to 0.8.0 (#6060) * Bump lru from 0.7.8 to 0.8.0 Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.8 to 0.8.0. - [Release notes](https://github.com/jeromefroe/lru-rs/releases) - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/jeromefroe/lru-rs/compare/0.7.8...0.8.0) --- updated-dependencies: - dependency-name: lru dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Change `LruCache` paramerter to `NonZeroUsize` * Change type of `session_cache_lru_size` to `NonZeroUsize` * Add expects instead of unwrap Co-authored-by: Bastian Köcher <info@kchr.de> * Use match to get rid of expects Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de> commit7114a8cfcaAuthor: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Date: Tue Oct 4 13:36:42 2022 +0300 Keep sessions in window for the full unfinalized chain (#6054) * Impl dynamic window size. Keep sessions for unfinalized chain Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Stretch also in contructor plus tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix approval-voting tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * grunting: dispute coordinator tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> commitab8f04f827Author: Serban Iorga <serban@parity.io> Date: Tue Oct 4 12:25:48 2022 +0300 Companion for BEEFY: Simplify hashing for pallet-beefy-mmr (#6098) * beefy-mmr: Simplify hashing * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> * Revert "Squashed commit of the following:" This reverts commit 5001fa5d1dcd366029d156f81c40b99ca29d8f77. * Companion for BEEFY: Simplify hashing for pallet-beefy-mmr (#6098) * beefy-mmr: Simplify hashing * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> * Keep sessions in window for the full unfinalized chain (#6054) * Impl dynamic window size. Keep sessions for unfinalized chain Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Stretch also in contructor plus tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix approval-voting tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * grunting: dispute coordinator tests Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Bump lru from 0.7.8 to 0.8.0 (#6060) * Bump lru from 0.7.8 to 0.8.0 Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.8 to 0.8.0. - [Release notes](https://github.com/jeromefroe/lru-rs/releases) - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/jeromefroe/lru-rs/compare/0.7.8...0.8.0) --- updated-dependencies: - dependency-name: lru dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Change `LruCache` paramerter to `NonZeroUsize` * Change type of `session_cache_lru_size` to `NonZeroUsize` * Add expects instead of unwrap Co-authored-by: Bastian Köcher <info@kchr.de> * Use match to get rid of expects Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de> * Batch vote import in dispute-distribution (#5894) * Start work on batching in dispute-distribution. * Guide work. * More guide changes. Still very much WIP. * Finish guide changes. * Clarification * Adjust argument about slashing. * WIP: Add constants to receiver. * Maintain order of disputes. * dispute-distribuion sender Rate limit. * Cleanup * WIP: dispute-distribution receiver. - [ ] Rate limiting - [ ] Batching * WIP: Batching. * fmt * Update `PeerQueues` to maintain more invariants. * WIP: Batching. * Small cleanup * Batching logic. * Some integration work. * Finish. Missing: Tests * Typo. * Docs. * Report missing metric. * Doc pass. * Tests for waiting_queue. * Speed up some crypto by 10x. * Fix redundant import. * Add some tracing. * Better sender rate limit * Some tests. * Tests * Add logging to rate limiter * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Update roadmap/implementers-guide/src/node/disputes/dispute-distribution.md Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Update node/network/dispute-distribution/src/receiver/mod.rs Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Review feedback. * Also log peer in log messages. * Fix indentation. * waker -> timer * Guide improvement. * Remove obsolete comment. * waker -> timer * Fix spell complaints. * Fix Cargo.lock Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> * Add unknown words (#6105) * Buffered connection management for collator-protocol (#6022) * Extract metrics into a separate module * Introduce validators buffer * Integrate buffer into the subsystem * Only reconnect on new advertisements * Test * comma * doc comment * Make capacity buffer compile time non-zero * Add doc comments * nits * remove derives * review * better naming * check timeout * Extract interval stream into lib * Ensure collator disconnects after timeout * spellcheck * rename buf * Remove double interval * Add a log on timeout * Cleanup buffer on timeout * Properly migrate weights to v2 (#6091) * Create migration for config pallet * Use XcmWeight in XCM pallet extrinsics * Link to PR in doc comment * cargo fmt * Fix tests * Fix tests * Remove unused import * Update runtime/parachains/src/configuration/migration.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add missing on_runtime_upgrade implementation * Use new migration API * cargo fmt * Fix log message Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Pass through `runtime-benchmark` feature (#6110) * Companion for #11649: Bound uses of `Call` (#5729) * Fixes * Clear out old weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Resolve merges Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix weight traits Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * polkadot runtime: Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * rococo runtime: update pallet configs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add preimage migration Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add all migrations Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Democracy is not on Westend Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * [Migration] Refund stored multisig calls (#6075) * Add Preimages to referenda config Needed since Gov V2 just merged. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add multisig migration to Westend+Rococo Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix Executive syntax Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Bump Substrate Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Roman Useinov <roman.useinov@gmail.com> * update kvdb & co (#6111) * toml changes * REVERTME: patch * adapt parachains db interface * fix Cargo.toml patch after master rebase * fix av-store * fix chain-selection * fix parachains-db? * Revert "fix Cargo.toml patch after master rebase" This reverts commit 3afcbf033c86027b3f2b909d83ec703591bdd287. * Revert "REVERTME: patch" This reverts commit 464b717cf4142d3d09c3d77b83700b632d8c5f54. * Use `Ok` imported from prelude Co-authored-by: Bastian Köcher <info@kchr.de> * update lockfile for {"substrate"} * Revert "update lockfile for {"substrate"}" This reverts commit fdc623de226f7645741b86c4b1a7d030fed2172d. * cargo update -p sp-io Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: parity-processbot <> * Skip `unexpected metric type` * Dump more info for `unexpected metric type` * Skip `unexpected metric type` * service: use MmrRootProvider as custom BEEFY payload provider (companion for 12428) (#6112) * service: use MmrRootProvider as custom BEEFY payload provider * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> * Maximum value for `MultiplierUpdate` (#6021) * update multiplier * fix * update lockfile for {"substrate"} * fmt * fix typo Co-authored-by: parity-processbot <> * Companion for upgrading pin-project (#6118) * Companion for upgrading pin-project This will remove some warnings with the latest rustc nightly/stable. https://github.com/paritytech/substrate/pull/12426 * update lockfile for {"substrate"} Co-authored-by: parity-processbot <> * Companion for 12109 (#5929) * Update following `pallet-vesting` configurable `WithdrawReasons` * Update lib.rs * Update lib.rs * Update lib.rs * update lockfile for {"substrate"} * fix warning Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: parity-processbot <> * Add event to asset claim (#6029) * Fix flaky test (#6131) * Split test + decrease test timeout * fmt * spellcheck * ci/guide: install mdbook-graphviz (#6119) * ci/guide: install mdbook-graphviz * install graphviz in build-implementers-guide * Update scripts/ci/gitlab/pipeline/build.yml Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> * Revert "Squashed commit of the following:" This reverts commit 5001fa5d1dcd366029d156f81c40b99ca29d8f77. * * Remove unused imports * * cargo +nightly fmt --all * Make tweaks based on PR comments * unit test related to gum formatting * cargo +nightly fmt --all * Resolve merge conflicts * cargo +nightly fmt --all * Fix tests so they use cli rather than cmd * CI unused import check fix * Move info! log to startup * make info log more comprehensible Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Serban Iorga <serban@parity.io> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: Robert Klotzner <eskimor@users.noreply.github.com> Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io> Co-authored-by: Chris Sosnin <48099298+slumber@users.noreply.github.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Roman Useinov <roman.useinov@gmail.com> Co-authored-by: Andronik <write@reusable.software> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Co-authored-by: Leszek Wiesner <leszek@jsgenesis.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: girazoki <gorka.irazoki@gmail.com> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a7780e0797
commit
b3532393b8
@@ -34,6 +34,8 @@ use polkadot_primitives::v2::{
|
||||
|
||||
use futures::channel::oneshot;
|
||||
|
||||
use rand::distributions::{Bernoulli, Distribution};
|
||||
|
||||
#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq)]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
#[non_exhaustive]
|
||||
@@ -109,6 +111,7 @@ impl Into<InvalidCandidate> for FakeCandidateValidationError {
|
||||
pub struct ReplaceValidationResult<Spawner> {
|
||||
fake_validation: FakeCandidateValidation,
|
||||
fake_validation_error: FakeCandidateValidationError,
|
||||
distribution: Bernoulli,
|
||||
spawner: Spawner,
|
||||
}
|
||||
|
||||
@@ -119,9 +122,12 @@ where
|
||||
pub fn new(
|
||||
fake_validation: FakeCandidateValidation,
|
||||
fake_validation_error: FakeCandidateValidationError,
|
||||
percentage: f64,
|
||||
spawner: Spawner,
|
||||
) -> Self {
|
||||
Self { fake_validation, fake_validation_error, spawner }
|
||||
let distribution = Bernoulli::new(percentage / 100.0)
|
||||
.expect("Invalid probability! Percentage must be in range [0..=100].");
|
||||
Self { fake_validation, fake_validation_error, distribution, spawner }
|
||||
}
|
||||
|
||||
/// Creates and sends the validation response for a given candidate. Queries the runtime to obtain the validation data for the
|
||||
@@ -202,13 +208,14 @@ where
|
||||
{
|
||||
type Message = CandidateValidationMessage;
|
||||
|
||||
// Capture all candidate validation requests and depending on configuration fail them.
|
||||
// Capture all (approval and backing) candidate validation requests and depending on configuration fail them.
|
||||
fn intercept_incoming(
|
||||
&self,
|
||||
subsystem_sender: &mut Sender,
|
||||
msg: FromOrchestra<Self::Message>,
|
||||
) -> Option<FromOrchestra<Self::Message>> {
|
||||
match msg {
|
||||
// Message sent by the approval voting subsystem
|
||||
FromOrchestra::Communication {
|
||||
msg:
|
||||
CandidateValidationMessage::ValidateFromExhaustive(
|
||||
@@ -236,28 +243,84 @@ where
|
||||
),
|
||||
})
|
||||
}
|
||||
create_validation_response(
|
||||
validation_data,
|
||||
candidate_receipt.descriptor,
|
||||
sender,
|
||||
);
|
||||
None
|
||||
// Create the fake response with probability `p` if the `PoV` is malicious,
|
||||
// where 'p' defaults to 100% for suggest-garbage-candidate variant.
|
||||
let behave_maliciously = self.distribution.sample(&mut rand::thread_rng());
|
||||
match behave_maliciously {
|
||||
true => {
|
||||
gum::info!(
|
||||
target: MALUS,
|
||||
?behave_maliciously,
|
||||
"😈 Creating malicious ValidationResult::Valid message with fake candidate commitments.",
|
||||
);
|
||||
|
||||
create_validation_response(
|
||||
validation_data,
|
||||
candidate_receipt.descriptor,
|
||||
sender,
|
||||
);
|
||||
None
|
||||
},
|
||||
false => {
|
||||
// Behave normally with probability `(1-p)` for a malicious `PoV`.
|
||||
gum::info!(
|
||||
target: MALUS,
|
||||
?behave_maliciously,
|
||||
"😈 Passing CandidateValidationMessage::ValidateFromExhaustive to the candidate validation subsystem.",
|
||||
);
|
||||
|
||||
Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromExhaustive(
|
||||
validation_data,
|
||||
validation_code,
|
||||
candidate_receipt,
|
||||
pov,
|
||||
timeout,
|
||||
sender,
|
||||
),
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
FakeCandidateValidation::ApprovalInvalid |
|
||||
FakeCandidateValidation::BackingAndApprovalInvalid => {
|
||||
let validation_result =
|
||||
ValidationResult::Invalid(InvalidCandidate::InvalidOutputs);
|
||||
// Set the validation result to invalid with probability `p` and trigger a dispute
|
||||
let behave_maliciously = self.distribution.sample(&mut rand::thread_rng());
|
||||
match behave_maliciously {
|
||||
true => {
|
||||
let validation_result =
|
||||
ValidationResult::Invalid(InvalidCandidate::InvalidOutputs);
|
||||
|
||||
gum::debug!(
|
||||
target: MALUS,
|
||||
para_id = ?candidate_receipt.descriptor.para_id,
|
||||
"ValidateFromExhaustive result: {:?}",
|
||||
&validation_result
|
||||
);
|
||||
// We're not even checking the candidate, this makes us appear faster than honest validators.
|
||||
sender.send(Ok(validation_result)).unwrap();
|
||||
None
|
||||
gum::info!(
|
||||
target: MALUS,
|
||||
?behave_maliciously,
|
||||
para_id = ?candidate_receipt.descriptor.para_id,
|
||||
"😈 Maliciously sending invalid validation result: {:?}.",
|
||||
&validation_result,
|
||||
);
|
||||
|
||||
// We're not even checking the candidate, this makes us appear faster than honest validators.
|
||||
sender.send(Ok(validation_result)).unwrap();
|
||||
None
|
||||
},
|
||||
false => {
|
||||
// Behave normally with probability `(1-p)`
|
||||
gum::info!(target: MALUS, "😈 'Decided' to not act maliciously.",);
|
||||
|
||||
Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromExhaustive(
|
||||
validation_data,
|
||||
validation_code,
|
||||
candidate_receipt,
|
||||
pov,
|
||||
timeout,
|
||||
sender,
|
||||
),
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
// Handle FakeCandidateValidation::Disabled
|
||||
_ => Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromExhaustive(
|
||||
validation_data,
|
||||
@@ -270,6 +333,7 @@ where
|
||||
}),
|
||||
}
|
||||
},
|
||||
// Behaviour related to the backing subsystem
|
||||
FromOrchestra::Communication {
|
||||
msg:
|
||||
CandidateValidationMessage::ValidateFromChainState(
|
||||
@@ -293,27 +357,68 @@ where
|
||||
),
|
||||
})
|
||||
}
|
||||
self.send_validation_response(
|
||||
candidate_receipt.descriptor,
|
||||
subsystem_sender.clone(),
|
||||
response_sender,
|
||||
);
|
||||
None
|
||||
// If the `PoV` is malicious, back the candidate with some probability `p`,
|
||||
// where 'p' defaults to 100% for suggest-garbage-candidate variant.
|
||||
let behave_maliciously = self.distribution.sample(&mut rand::thread_rng());
|
||||
match behave_maliciously {
|
||||
true => {
|
||||
gum::info!(
|
||||
target: MALUS,
|
||||
?behave_maliciously,
|
||||
"😈 Backing candidate with malicious PoV.",
|
||||
);
|
||||
|
||||
self.send_validation_response(
|
||||
candidate_receipt.descriptor,
|
||||
subsystem_sender.clone(),
|
||||
response_sender,
|
||||
);
|
||||
None
|
||||
},
|
||||
// If the `PoV` is malicious, we behave normally with some probability `(1-p)`
|
||||
false => Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromChainState(
|
||||
candidate_receipt,
|
||||
pov,
|
||||
timeout,
|
||||
response_sender,
|
||||
),
|
||||
}),
|
||||
}
|
||||
},
|
||||
FakeCandidateValidation::BackingInvalid |
|
||||
FakeCandidateValidation::BackingAndApprovalInvalid => {
|
||||
let validation_result =
|
||||
ValidationResult::Invalid(self.fake_validation_error.clone().into());
|
||||
gum::debug!(
|
||||
target: MALUS,
|
||||
para_id = ?candidate_receipt.descriptor.para_id,
|
||||
"ValidateFromChainState result: {:?}",
|
||||
&validation_result
|
||||
);
|
||||
// Maliciously set the validation result to invalid for a valid candidate with probability `p`
|
||||
let behave_maliciously = self.distribution.sample(&mut rand::thread_rng());
|
||||
match behave_maliciously {
|
||||
true => {
|
||||
let validation_result = ValidationResult::Invalid(
|
||||
self.fake_validation_error.clone().into(),
|
||||
);
|
||||
gum::info!(
|
||||
target: MALUS,
|
||||
para_id = ?candidate_receipt.descriptor.para_id,
|
||||
"😈 Maliciously sending invalid validation result: {:?}.",
|
||||
&validation_result,
|
||||
);
|
||||
// We're not even checking the candidate, this makes us appear faster than honest validators.
|
||||
response_sender.send(Ok(validation_result)).unwrap();
|
||||
None
|
||||
},
|
||||
// With some probability `(1-p)` we behave normally
|
||||
false => {
|
||||
gum::info!(target: MALUS, "😈 'Decided' to not act maliciously.",);
|
||||
|
||||
// We're not even checking the candidate, this makes us appear faster than honest validators.
|
||||
response_sender.send(Ok(validation_result)).unwrap();
|
||||
None
|
||||
Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromChainState(
|
||||
candidate_receipt,
|
||||
pov,
|
||||
timeout,
|
||||
response_sender,
|
||||
),
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => Some(FromOrchestra::Communication {
|
||||
msg: CandidateValidationMessage::ValidateFromChainState(
|
||||
|
||||
Reference in New Issue
Block a user