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

Malus: Implement storing invalid chunks #4711

Closed
wants to merge 9 commits into from
Closed

Conversation

Lldenaurois
Copy link
Contributor

This PR implements a first attempt at intercepting AvailabilityStoreMessages and writing invalid chunks into the availability store for every StoreAvailableData message intercepted by the MessageInterceptor.

@ordian ordian added A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Jan 13, 2022
Copy link
Contributor

@sandreim sandreim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a first pass, will take a second one and pay more attention to details vs reference impl.

@@ -1039,6 +1039,7 @@ fn process_message(
let _ = tx.send(a);
},
AvailabilityStoreMessage::QueryChunk(candidate, validator_index, tx) => {
println!("THIS IS MOST DEFF WORKING");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
println!("THIS IS MOST DEFF WORKING");
println!("THIS IS MOST DEFF WORKING");

@@ -65,8 +65,8 @@ impl MalusCli {
match self.variant {
NemesisVariant::BackGarbageCandidate(cmd) =>
polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidate)?,
NemesisVariant::SuggestGarbageCandidate(cmd) =>
polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,
NemesisVariant::SuggestGarbageCandidate(_cmd) => panic! {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on purpose ?

NemesisVariant::SuggestGarbageCandidate(cmd) =>
polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,
NemesisVariant::SuggestGarbageCandidate(_cmd) => panic! {},
//polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,
//polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,

@@ -131,7 +134,8 @@ fn integrity_test_pass() {
AvailabilityStoreMessage::QueryChunk(Default::default(), 0.into(), tx),
)
.await;
let _ = rx.timeout(std::time::Duration::from_millis(100)).await.unwrap();
let resp = rx.timeout(std::time::Duration::from_secs(10)).await.unwrap();
println!("RESP {:?}", resp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add these as logs ?


/// Unix time wrapper with big-endian encoding.
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord)]
struct BETimestamp(u64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates https://github.com/paritytech/polkadot/blob/master/node/core/av-store/src/lib.rs#L78. We can reuse that to reduce the amount of code written in malus.

@@ -0,0 +1,353 @@
// Copyright 2021 Parity Technologies (UK) Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +66 to +69
NemesisVariant::StoreMaliciousAvailableData(cmd) =>
polkadot_cli::run_node(run_cmd(cmd), StoreMaliciousAvailableDataWrapper)?,
NemesisVariant::SuggestGarbageCandidate(cmd) =>
polkadot_cli::run_node(run_cmd(cmd), SuggestGarbageCandidate)?,
polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidateWrapper)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to maybe combine these eventually? So we can run tests with malicious stored available data and dispute valid candidates for example.

filter,
)
})
.replace_candidate_backing(move |cb| InterceptedSubsystem::new(cb, filter))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

sandreim added a commit that referenced this pull request Mar 28, 2022
#4711

Co-authored-by: Lldenaurois <[email protected]>
Co-authored-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>
paritytech-processbot bot pushed a commit that referenced this pull request Apr 13, 2022
…ate` implementation (#5011)

* Implement fake validation results

Signed-off-by: Andrei Sandu <[email protected]>

* refactor

Signed-off-by: Andrei Sandu <[email protected]>

* cargo lock

Signed-off-by: Andrei Sandu <[email protected]>

* spell check

Signed-off-by: Andrei Sandu <[email protected]>

* spellcheck

Signed-off-by: Andrei Sandu <[email protected]>

* typos

Signed-off-by: Andrei Sandu <[email protected]>

* Review feedback

Signed-off-by: Andrei Sandu <[email protected]>

* move stuff around

Signed-off-by: Andrei Sandu <[email protected]>

* chores

Signed-off-by: Andrei Sandu <[email protected]>

* Impl valid - still wip

Signed-off-by: Andrei Sandu <[email protected]>

* fixes

Signed-off-by: Andrei Sandu <[email protected]>

* fmt

Signed-off-by: Andrei Sandu <[email protected]>

* Pull Ladi's implementation:
#4711

Co-authored-by: Lldenaurois <[email protected]>
Co-authored-by: Andrei Sandu <[email protected]>
Signed-off-by: Andrei Sandu <[email protected]>

* Fix build

Signed-off-by: Andrei Sandu <[email protected]>

* Logs and comments

Signed-off-by: Andrei Sandu <[email protected]>

* WIP: suggest garbage candidate + implement validation result caching

Signed-off-by: Andrei Sandu <[email protected]>

* fix

Signed-off-by: Andrei Sandu <[email protected]>

* Do commitment hash checks in candidate validation

Signed-off-by: Andrei Sandu <[email protected]>

* Minor refactor in approval, backing, dispute-coord

Signed-off-by: Andrei Sandu <[email protected]>

* Working version of suggest garbage candidate

Signed-off-by: Andrei Sandu <[email protected]>

* Dedup

Signed-off-by: Andrei Sandu <[email protected]>

* cleanup #1

Signed-off-by: Andrei Sandu <[email protected]>

* Fix tests

Signed-off-by: Andrei Sandu <[email protected]>

* remove debug leftovers

Signed-off-by: Andrei Sandu <[email protected]>

* fmt

Signed-off-by: Andrei Sandu <[email protected]>

* Accidentally commited some local test

Signed-off-by: Andrei Sandu <[email protected]>

* spellcheck

Signed-off-by: Andrei Sandu <[email protected]>

* some more fixes

Signed-off-by: Andrei Sandu <[email protected]>

* Refactor and fix it

Signed-off-by: Andrei Sandu <[email protected]>

* review feedback

Signed-off-by: Andrei Sandu <[email protected]>

* typo

Signed-off-by: Andrei Sandu <[email protected]>

* tests review feedback

Signed-off-by: Andrei Sandu <[email protected]>

* refactor disputer

Signed-off-by: Andrei Sandu <[email protected]>

* fix tests

Signed-off-by: Andrei Sandu <[email protected]>

* Fix zombienet disputes test

Signed-off-by: Andrei Sandu <[email protected]>

* spellcheck

Signed-off-by: Andrei Sandu <[email protected]>

* fix

Signed-off-by: Andrei Sandu <[email protected]>

* Fix ui tests

Signed-off-by: Andrei Sandu <[email protected]>

* fix typo

Signed-off-by: Andrei Sandu <[email protected]>

Co-authored-by: Lldenaurois <[email protected]>
@drahnr
Copy link
Contributor

drahnr commented May 11, 2022

@sandreim does this bring any additional coverage to what we have? If not let's close this

@sandreim sandreim closed this May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants