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

Adds ability to clear obsolete reports in Offences pallet #14048

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b1b843d
Initial setup
gupnik Apr 30, 2023
72564c2
Adds ability to clear old reportS
gupnik Apr 30, 2023
ecfe969
Adds session change listener
gupnik May 4, 2023
b6546b5
Adds session info provider
gupnik May 5, 2023
c666aa0
Updates params everywhere
gupnik May 5, 2023
9bbe6e3
Updates params everywhere
gupnik May 5, 2023
5b4954e
adds impl for ()
gupnik May 5, 2023
8e97ca6
Adds doc
gupnik May 5, 2023
d3b7560
Minor change
gupnik May 5, 2023
81c4f99
Adds max session age everywhere
gupnik May 5, 2023
7927788
".git/.scripts/commands/fmt/fmt.sh"
May 5, 2023
8176c15
Addresses review comments
gupnik May 5, 2023
544ed3e
Minor update
gupnik May 5, 2023
217a484
Updates doc
gupnik May 5, 2023
5bae7e1
".git/.scripts/commands/fmt/fmt.sh"
May 5, 2023
74accc2
Adds doc
gupnik May 9, 2023
15b8f46
Uses map to store session reports
gupnik May 10, 2023
cd23321
Updates doc
gupnik May 10, 2023
1fa5c13
".git/.scripts/commands/fmt/fmt.sh"
May 10, 2023
8f62f4c
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik May 10, 2023
4a334f5
Fixes doc issue
gupnik May 10, 2023
6b9bc38
Trivial updates
gupnik May 10, 2023
e6e2f1d
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik May 10, 2023
003127f
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik May 10, 2023
d085786
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik May 11, 2023
d84cf00
Addresses some review comments
gupnik May 17, 2023
42c4d90
Addresses more review comments
gupnik May 17, 2023
6ac1857
Uses const for session index
gupnik May 17, 2023
30df0ed
Update frame/offences/src/lib.rs
gupnik Jul 3, 2023
b4be535
Update frame/offences/src/lib.rs
gupnik Jul 3, 2023
8fde92c
Update frame/offences/src/lib.rs
gupnik Jul 3, 2023
5f0a4f9
Update primitives/session/Cargo.toml
gupnik Jul 3, 2023
62f7c65
Merge branch 'master' of github.com:paritytech/substrate into gupnik/…
gupnik Jul 3, 2023
fe5d2c7
Update frame/offences/src/lib.rs
gupnik Jul 3, 2023
392fca3
Addresses some review comments
gupnik Jul 3, 2023
509502b
Merge branch 'gupnik/offence-pallet-optimizations' of github.com:pari…
gupnik Jul 3, 2023
6a58757
Minor fix
gupnik Jul 3, 2023
4e2d07e
No need to use double encode for SessionReports
gupnik Jul 3, 2023
ed41f99
Formatting
gupnik Jul 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ impl pallet_session::Config for Runtime {
type NextSessionRotation = Babe;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type SessionChangeListener = Offences;
type Keys = SessionKeys;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
}
Expand Down Expand Up @@ -1331,10 +1332,16 @@ impl pallet_im_online::Config for Runtime {
type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize;
}

parameter_types! {
pub const MaxSessionReportAge: u32 = BondingDuration::get() * SessionsPerEra::get();
}

impl pallet_offences::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type MaxSessionReportAge = MaxSessionReportAge;
type SessionInfoProvider = Session;
}

impl pallet_authority_discovery::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ mod tests {
type ValidatorIdOf = ConvertInto;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type WeightInfo = ();
type SessionChangeListener = ();
}

impl pallet_session::historical::Config for Test {
Expand Down
4 changes: 4 additions & 0 deletions frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ impl pallet_session::Config for Test {
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
type WeightInfo = ();
type SessionChangeListener = ();
}

impl pallet_session::historical::Config for Test {
Expand Down Expand Up @@ -166,6 +167,7 @@ parameter_types! {
pub const SlashDeferDuration: EraIndex = 0;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16);
pub const MaxSessionReportAge: SessionIndex = BondingDuration::get() * SessionsPerEra::get();
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -213,6 +215,8 @@ impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type SessionInfoProvider = Session;
type MaxSessionReportAge = MaxSessionReportAge;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ impl pallet_session::Config for Test {
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
type WeightInfo = ();
type SessionChangeListener = ();
}

pub type MmrLeaf = sp_consensus_beefy::mmr::MmrLeaf<
Expand Down
4 changes: 4 additions & 0 deletions frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl pallet_session::Config for Test {
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
type WeightInfo = ();
type SessionChangeListener = ();
}

impl pallet_session::historical::Config for Test {
Expand Down Expand Up @@ -190,6 +191,7 @@ parameter_types! {
pub const BondingDuration: EraIndex = 3;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const MaxSessionReportAge: SessionIndex = BondingDuration::get() * SessionsPerEra::get();
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -237,6 +239,8 @@ impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type SessionInfoProvider = Session;
type MaxSessionReportAge = MaxSessionReportAge;
}

// Note, that we can't use `UintAuthorityId` here. Reason is that the implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ impl pallet_session::Config for Runtime {
type ValidatorId = AccountId;
type ValidatorIdOf = pallet_staking::StashOf<Runtime>;
type WeightInfo = ();
type SessionChangeListener = ();
}
impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
Expand Down
4 changes: 4 additions & 0 deletions frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl pallet_session::Config for Test {
type SessionHandler = <TestSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = TestSessionKeys;
type WeightInfo = ();
type SessionChangeListener = ();
}

impl pallet_session::historical::Config for Test {
Expand Down Expand Up @@ -171,6 +172,7 @@ parameter_types! {
pub const BondingDuration: EraIndex = 3;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub const MaxSessionReportAge: SessionIndex = BondingDuration::get() * SessionsPerEra::get();
}

pub struct OnChainSeqPhragmen;
Expand Down Expand Up @@ -218,6 +220,8 @@ impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type SessionInfoProvider = Session;
type MaxSessionReportAge = MaxSessionReportAge;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions frame/im-online/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type WeightInfo = ();
type SessionChangeListener = ();
}

impl pallet_session::historical::Config for Runtime {
Expand Down
1 change: 1 addition & 0 deletions frame/offences/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ frame-system = { version = "4.0.0-dev", default-features = false, path = "../sys
pallet-balances = { version = "4.0.0-dev", default-features = false, path = "../balances" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" }
sp-session = { version = "4.0.0-dev", default-features = false, path = "../../primitives/session" }
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }

[dev-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions frame/offences/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl pallet_session::Config for Test {
type ValidatorId = AccountId;
type ValidatorIdOf = pallet_staking::StashOf<Test>;
type WeightInfo = ();
type SessionChangeListener = ();
}

pallet_staking_reward_curve::build! {
Expand Down Expand Up @@ -204,6 +205,8 @@ impl pallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type SessionInfoProvider = Session;
type MaxSessionReportAge = ConstU32<6>;
}

impl<T> frame_system::offchain::SendTransactionTypes<T> for Test
Expand Down
Loading