Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AURA offence report system #1766

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

Conversation

davxy
Copy link
Member

@davxy davxy commented Oct 1, 2023

(Requires tweaks to cumulus, but first I want to be sure that there are not blockers with the implementation)

Due to some characteristics of current aura-pallet implementation, the report system depends on some other pallets.

In particular it requires that:

  • Runtime implements pallet-authorship to get reporter identity when not directly passed to the report system function

    • This is a requirement which is set by other consensus protocols offence report systems provided by Substrate (i.e. babe, grandpa, beefy).
    • not a huge requirement as most of the implementations who may need the offence report system already include this pallet
  • Runtime implements session-pallet to map the block number to session index.

    • not a huge requirement as most of the implementations who may need the offence report system already include this pallet
  • session-pallet Config must use the PeriodicSessions type as its NextSessionRotation associated type. This is to reliably map the block number to session number. The session index is simply given by the block number divided by session duration (which in this case is constant).


The ideas were mostly picked from BABE, BEEFY and GRANDPA.
So there isn't really anything new beside the trick to compute the session index from the block number.

During the implementation I also spotted a couple of possible improvement areas which I'm going to highlight in the code comments.


Closes #70

@davxy davxy requested a review from andresilva as a code owner October 1, 2023 13:56
@davxy davxy requested review from a team October 1, 2023 13:56
@davxy davxy self-assigned this Oct 1, 2023
@davxy davxy requested a review from a team October 1, 2023 13:57
@davxy davxy added T0-node This PR/Issue is related to the topic “node”. T1-FRAME This PR/Issue is related to core FRAME, the framework. T2-pallets This PR/Issue is related to a particular pallet. R1-breaking_change This PR introduces a breaking change and should be highlighted in the upcoming release. and removed T1-FRAME This PR/Issue is related to core FRAME, the framework. labels Oct 1, 2023
Comment on lines +36 to +53
// Checking membership proof
Weight::from_parts(35u64 * WEIGHT_REF_TIME_PER_MICROS, 0)
.saturating_add(
Weight::from_parts(175u64 * WEIGHT_REF_TIME_PER_NANOS, 0)
.saturating_mul(validator_count),
)
.saturating_add(DbWeight::get().reads(5))
// Check equivocation proof
.saturating_add(Weight::from_parts(110u64 * WEIGHT_REF_TIME_PER_MICROS, 0))
// Report offence
.saturating_add(Weight::from_parts(110u64 * WEIGHT_REF_TIME_PER_MICROS, 0))
.saturating_add(Weight::from_parts(
25u64 * WEIGHT_REF_TIME_PER_MICROS * max_nominators_per_validator as u64,
0,
))
.saturating_add(DbWeight::get().reads(14 + 3 * max_nominators_per_validator as u64))
.saturating_add(DbWeight::get().writes(10 + 3 * max_nominators_per_validator as u64))
}
Copy link
Member Author

@davxy davxy Oct 1, 2023

Choose a reason for hiding this comment

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

Honestly I don't know how these hardcoded were computed.
Are these estimation? Empirical results? Guesses 😃

I picked these values from babe/aura/grandpa implementations

};

/// Default `WeightInfo` implementation generic over the max number of validator's nominators (`N`).
pub struct SubstrateWeight<const N: u32>;
Copy link
Member Author

Choose a reason for hiding this comment

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

Here I tried to experiment and detach a bit the consensus from the staking.

That is, instead of adding the MaxNominators directly in the Config, I decided to provide the (const) value as part of the weight type we provide.

IMO this makes sense as:

  1. relax the dependency to the staking model which the user may don't want to use.
  2. the MaxNominators value is only used here, to compute the weight

Maybe I can also provide the () implementation where we set the max nominators to 0.

If the idea is good, I'm going to do the same for the other consensus protocols (in a follow-up PR)

cc @andresilva

Comment on lines +62 to +66
# Provide the default equivocation report system.
default-equivocation-report-system = [
"pallet-authorship",
"pallet-session",
]
Copy link
Member Author

Choose a reason for hiding this comment

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

These pallets are required only if the user decides to use the offence report system which ships with substrate.

These pallets are not used otherwise.

@paritytech paritytech deleted a comment from paritytech-cicd-pr Oct 1, 2023
Comment on lines +201 to +212
let idx1 = block_num1
.saturating_sub(Offset::get())
.checked_div(&Period::get())
.unwrap_or(Zero::zero());
let idx2 = block_num2
.saturating_sub(Offset::get())
.checked_div(&Period::get())
.unwrap_or(Zero::zero());

if BlockNumberFor::<T>::from(session_index as u32) != idx1 || idx1 != idx2 {
return Err(Error::<T>::InvalidKeyOwnershipProof.into())
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the trick to map block num to session index.

@paritytech paritytech deleted a comment from paritytech-cicd-pr Oct 1, 2023
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Mar 26, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Mar 27, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
bkchr pushed a commit that referenced this pull request Apr 10, 2024
* Define method for checking message lane weights

* Docs for public function

* Renamings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R1-breaking_change This PR introduces a breaking change and should be highlighted in the upcoming release. T0-node This PR/Issue is related to the topic “node”. T2-pallets This PR/Issue is related to a particular pallet.
Projects
Status: code in review
Development

Successfully merging this pull request may close these issues.

Report Aura Equivocations to runtime
1 participant