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

[DONTMERGE] Add debug logs and make approval voting failable #3783

Open
wants to merge 97 commits into
base: master
Choose a base branch
from

Conversation

Lldenaurois
Copy link
Contributor

@Lldenaurois Lldenaurois commented Sep 4, 2021

Malicious node implementation for burn-in of disputes on Rococo.

This adds substantial logging and causes nodes to falsely raise disputes on good candidate at a frequency of 1/5000 approvals. The next step is to alter candidate-backing to second a deterministically bad candidate at a similar frequency.

@Lldenaurois Lldenaurois added A0-please_review Pull request needs code review. 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. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Sep 4, 2021
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch 2 times, most recently from ac8810e to a58867c Compare September 4, 2021 14:15
@@ -97,6 +99,7 @@ const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120);
const APPROVAL_CACHE_SIZE: usize = 1024;
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
const LOG_TARGET: &str = "parachain::approval-voting";
const MALICIOUS_FREQUENCY: usize = 5000;
Copy link
Contributor

@rphmeier rphmeier Sep 4, 2021

Choose a reason for hiding this comment

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

FYI 5000 is quite a lot. 1 parachain block requires 20ish approvals, so this means 1 in 200 parachain blocks. I'd recommend tweaking this to 50_000 or 100_000 so it's only once every few hours.

let _ = rx.send(recent_disputes.keys().cloned().collect());
},
DisputeCoordinatorMessage::ActiveDisputes(rx) => {
// TODO (ladi): Shouldn''t this load active disputes?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's only 'recent disputes' on disk, and then this filters them to be only active

@@ -103,7 +104,7 @@ impl Error {
tracing::debug!(target: LOG_TARGET, err = ?self)
},
// it's worth reporting otherwise
_ => tracing::warn!(target: LOG_TARGET, err = ?self),
_ => tracing::debug!(target: LOG_TARGET, err = ?self),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why demote this?

@@ -119,7 +120,7 @@ where
match ctx.recv().await {
Err(_) => return,
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => {
tracing::info!(target: LOG_TARGET, "Received `Conclude` signal, exiting");
tracing::debug!(target: LOG_TARGET, "Received `Conclude` signal, exiting");
Copy link
Contributor

Choose a reason for hiding this comment

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

And this?

Copy link
Contributor

Choose a reason for hiding this comment

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

And many others in the same file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's easier (for now) to just display everything in Debug logs imo. I can change it back if you see it differently.

This PR is not intended to get merged at any point

Copy link
Member

Choose a reason for hiding this comment

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

You can match logs with e.g. level =~"DEBUG|INFO|ERROR|WARN" ... just for reference.

@rphmeier rphmeier added A1-onice and removed A0-please_review Pull request needs code review. labels Sep 4, 2021
@rphmeier rphmeier changed the title Add debug logs and make approval voting failable [DONTMERGE] Add debug logs and make approval voting failable Sep 4, 2021
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from a58867c to 78abae4 Compare September 4, 2021 23:28
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from 78abae4 to d12cde4 Compare September 4, 2021 23:32
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from 603d79f to 0f4d592 Compare September 6, 2021 15:11
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from 0f4d592 to 65f7767 Compare September 6, 2021 15:20
.collect();
actions.append(&mut approvals);
}
ApprovalOutcome::Malicious((candidate, session_index)) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a lot of extra machinery to add instead of just sending the message from within the if coin_flip == 0 block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating whether or not to do it simply with the coin_flip == 0, but thought maybe this was a little cleaner.

I realize we aren't going to be re-using this code, but it wasn't a large change. Will keep in mind to keep it simple going forward.

@@ -100,7 +101,8 @@ const APPROVAL_CACHE_SIZE: usize = 1024;
const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds.
const LOG_TARGET: &str = "parachain::approval-voting";
const DEBUG_LOG_TARGET: &str = "parachain::ladi-debug-approval-voting";
const MALICIOUS_FREQUENCY: usize = 5_000;
const MALICIOUS_MEAN: f64 = 2_500f64;
const MALICIOUS_SDEV: f64 = 70f64;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: .._STDDEV is the common abbreviation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wanted MEAN and SDEV to have the same length :)

@@ -346,12 +348,15 @@ where
{
fn start(self, ctx: Context) -> SpawnedSubsystem {
let backend = DbBackend::new(self.db.clone(), self.db_config);
let normal = Normal::new(MALICIOUS_MEAN, MALICIOUS_SDEV);
let offset: u64 = normal.sample(&mut rand::thread_rng()).round() as u64;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend adding 3 * STDDEV which means 99.7% are not edited, but you avoid hickups due to huge outliers.

@@ -791,6 +797,7 @@ where
&mut approvals_cache,
&mut subsystem.mode,
actions,
if counter.fetch_add(1, Ordering::SeqCst) == offset { true } else { false },
Copy link
Contributor

@drahnr drahnr Sep 7, 2021

Choose a reason for hiding this comment

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

nit: the if case can be dropped :) just use the boolean expression

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added logging in these two cases, so for now I'll leave it as an if-statement. I'll keep the logging for deploying to one node but can drop the logging before deploying to all validators.

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

LGTM (for test)

ggwpez and others added 11 commits January 19, 2022 12:33
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
* changed lease period to 1 day

* bumped version

* bumped version again

* changed 356 to 365 days to mimic one year

Co-authored-by: Santi Balaguer <[email protected]>
* changed lease period to 1 day

* bumped version

* bumped version again

* changed 356 to 365 days to mimic one year

Co-authored-by: Santi Balaguer <[email protected]>
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from 8aa9955 to e63e448 Compare January 21, 2022 21:48
Lldenaurois and others added 9 commits January 22, 2022 02:10
* Switch substrate branch to polkadot-v0.9.16

* Bump spec_version

* Bump version to 0.9.16
* New changelog scripts (paritytech#4491)

* Add templates

* Add folder for local storage of the digests

* Add first draft of the changelog scripts

* Enable Audits in the change template

* Fixes for Polkadot

* Fix templating issue in case there is no high prio change

* Fix Ruby setup

* Remove shell

* Fix chain names

* Fix ENV

* Fix how to get runtime

* Fix runtime_dir

* Fix context location

* Pin changelogerator to a specific version

* New weights for Westend

* New weights for Kusama

* New weights for Polkadot

* deps update
@Lldenaurois Lldenaurois requested a review from chevdor as a code owner January 25, 2022 18:12
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from ce4e0b0 to cd4b791 Compare January 25, 2022 18:26
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from 35a6216 to f58d17b Compare January 27, 2022 03:44
@Lldenaurois Lldenaurois force-pushed the ladi-logging-disputes branch from f58d17b to 61de01c Compare January 27, 2022 03:47
@the-right-joyce the-right-joyce added S5-on_ice Work is currently on hold, see comments for further information. and removed A1-onice labels Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S5-on_ice Work is currently on hold, see comments for further information.
Projects
None yet
Development

Successfully merging this pull request may close these issues.