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

Add integration with pallet_offences + pallet_session::historical #61

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

Conversation

NachoPal
Copy link
Contributor

@NachoPal NachoPal commented Aug 11, 2023

This PR intends to add capability for automatic removal of disabled validators. It would be an optional feature to be integrated along with pallet_offences and pallet_session::historical.

validator_set implements OnOffenceHandler trait which is expected by type OnOffenceHandler in pallet_offences::Config.

Trait implementation expects Offender to be pallet_session::historical::IdentificationTuple<T>.

Added two new Config types:

  • OnDisabled: action to be executed when a validator is disabled
  • MinAuthoritiesOnDisabled: boolean that indicates whether MinAuthorities should be checked before removing a disabled validator from the next active set.

Two new Config types could be added for more granularity in the im_online integration:

  • OnOffline: action to be executed when a validator is offline.
  • MinAuthoritiesOnOffline: boolean that indicates whether MinAuthorities should be checked before removing an offline validator from the next active set.

Example of runtime configuration:

parameter_types! {
	pub const MinAuthorities: u32 = 2;
	pub const MinAuthoritiesOnDisabled: bool = true;
}

impl validator_set::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type AddRemoveOrigin = EnsureRoot<AccountId>;
	type MinAuthorities = MinAuthorities;
	type OnDisabled = ();
	type MinAuthoritiesOnDisabled = MinAuthoritiesOnDisabled;
	type WeightInfo = validator_set::weights::SubstrateWeight<Runtime>;
}

impl pallet_session::historical::Config for Runtime {
	type FullIdentification = Self::ValidatorId;
	type FullIdentificationOf = Self::ValidatorIdOf;
}

impl pallet_offences::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
	type OnOffenceHandler = ValidatorSet;
}

@NachoPal NachoPal changed the title Add integration with pallet_offences Add integration with pallet_offences + pallet_session::historical Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant