-
Notifications
You must be signed in to change notification settings - Fork 690
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
base: master
Are you sure you want to change the base?
Conversation
// 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)) | ||
} |
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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:
- relax the dependency to the staking model which the user may don't want to use.
- 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
# Provide the default equivocation report system. | ||
default-equivocation-report-system = [ | ||
"pallet-authorship", | ||
"pallet-session", | ||
] |
There was a problem hiding this comment.
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.
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()) | ||
} |
There was a problem hiding this comment.
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.
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
* Define method for checking message lane weights * Docs for public function * Renamings
(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 functionRuntime implements
session-pallet
to map the block number to session index.session-pallet
Config
must use thePeriodicSessions
type as itsNextSessionRotation
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