-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Would really like @kianenigma to review this when he comes back... |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
bot rebase |
Rebased |
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
}; | ||
} | ||
.try_into() | ||
.defensive_proof("MaxReporters must be at least 1;") |
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.
do we have defensive_expect
? we should :D
None => vec![], | ||
} | ||
.try_into() | ||
.expect("MaxReporters must be at least 1;"); |
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.
where is this ensured? Should be in integrity_checks
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.
Its a constant, not a configuration variable, so we only have to ensure it once.
But yea, could add it to the integrity checks.
/// A handler called for every offence report. | ||
type OnOffenceHandler: OnOffenceHandler<Self::AccountId, Self::IdentificationTuple, Weight>; | ||
|
||
/// Maximum number of reports of the same kind that happened at a specific time slot. | ||
#[pallet::constant] |
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.
Do all of these really need to be in metadata? harmless, but I wonder if you had thought about each.
where | ||
AccountId: Debug + Encode + Decode + MaxEncodedLen + Clone + Eq + PartialEq, | ||
Balance: Debug + HasCompact + Encode + Decode + MaxEncodedLen + Clone + Eq + PartialEq, | ||
MaxNominations: Get<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.
Not a good name -- we use this term to determine the number of nominations that a single nominator can have. i.e. 16.
I suggest using MaxBackers
here instead.
/// The total balance backing this validator. | ||
#[codec(compact)] | ||
pub total: Balance, | ||
/// The validator's own stash that is exposed. | ||
#[codec(compact)] | ||
pub own: Balance, | ||
/// The portions of nominators stashes that are exposed. | ||
pub others: Vec<IndividualExposure<AccountId, Balance>>, | ||
pub others: BoundedVec<IndividualExposure<AccountId, Balance>, MaxNominations>, |
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 a great direction that you started here: we certainly want to bound this. Problem is that there is nothing in the ElectionProvider
trait explicitly guarantees that this is the case.
What we want to do is:
- Staking tells
ElectionProvider
how manyMaxBackers
it accepts. - Staking miner respects this when generating solution, and automatically sorts the backings of each validator, and throws away the smaller ones. (currently we area doing onchain, which is horrible)
ElectionProvider
checks this for submitted solutions and ensures it is the case.- Staking can just do a defensive truncate when it receives a solution from
ElectionProvider
. - This new
MaxBackers
should also replaceMaxRewardableNominatorsPerValidator
, and entirely replace the notion of oversubscribed validators.
If interested in doing more steps in this path, I will be happy to do a better writeup about it.
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.
Without these steps, we should set MaxBackers
to MaxElectingVoters
, because in principle it is possible that in an election everyone nominates one validator, and that single validators ends up having the whole e.g. 22500 backers backing them.
/// A typed conversion from stash account ID to the active exposure of nominators | ||
/// on that account. | ||
/// | ||
/// Active exposure is the exposure of the validator set currently validating, i.e. in | ||
/// `active_era`. It can differ from the latest planned exposure in `current_era`. | ||
pub struct ExposureOf<T>(sp_std::marker::PhantomData<T>); | ||
pub struct ActiveExposure<T>(sp_std::marker::PhantomData<T>); |
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.
better name now, but still not quite happy with it.
@@ -553,10 +552,10 @@ impl<T: Config> Pallet<T> { | |||
total = total.saturating_add(stake); | |||
}); | |||
|
|||
let exposure = Exposure { own, others, total }; | |||
let exposure = Exposure { own, others: others.try_into().expect("TODO"), total }; |
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.
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
This will someday be done by @Ank4n, but a long chain of other work is needed. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Bound the
offences
pallet.Changes:
MaxOffenders
andMaxReportes
constants with both value 100. This is necessary since the staking and offences traits would otherwise all need to be parameterized. Grandpa and BABE both only use at most 1 for these values, so 100 should be enough.MaxSameKindReportsEncodedLen
andMaxOpaqueTimeSlotEncodedLen
to bound the storage of encoded values. There is a test which tests that these constants can encode the respective values, it would be important to run that test against the real runtime config, not just the mock.MaxConcurrentReportsPerTime
andMaxSameKindReports
. These may or may not be necessary, I am not sure. Maybe they can be replaced with instances ofMaxOffenders/MaxReporters
.Exposure/ExposureOf
andActiveExposure
to avoid a name-clashvec![]
withDefault::default()
to make future refactoring easier.TODO:
expect("todo")
where I was unsure about the vector lengthPart of paritytech/polkadot-sdk#323