Companion for substrate #13121 - BEEFY Equivocations support (#6593)

* runtimes: implement new BeefyApi

Signed-off-by: acatangiu <adrian@parity.io>

* rococo-runtime: add ValidateUnsigned to pallet_beefy

* update lockfile for {"substrate"}

---------

Signed-off-by: acatangiu <adrian@parity.io>
Co-authored-by: parity-processbot <>
This commit is contained in:
Adrian Catangiu
2023-02-17 12:28:48 +02:00
committed by GitHub
parent 5ca430b649
commit d009d13523
6 changed files with 303 additions and 187 deletions
+184 -181
View File
File diff suppressed because it is too large Load Diff
+19 -1
View File
@@ -46,7 +46,7 @@ use runtime_parachains::{
};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{
generate_solution_type, onchain, NposSolution, SequentialPhragmen,
};
@@ -1746,6 +1746,24 @@ sp_api::impl_runtime_apis! {
// dummy implementation due to lack of BEEFY pallet.
None
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
None
}
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
+19 -1
View File
@@ -36,7 +36,7 @@ use runtime_parachains::{
};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{generate_solution_type, onchain, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
@@ -1867,6 +1867,24 @@ sp_api::impl_runtime_apis! {
// dummy implementation due to lack of BEEFY pallet.
None
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
None
}
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
+43 -2
View File
@@ -51,7 +51,7 @@ use runtime_parachains::{
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::{
crypto::AuthorityId as BeefyId,
crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
mmr::{BeefyDataProvider, MmrLeafVersion},
};
@@ -1249,8 +1249,22 @@ impl pallet_nis::Config for Runtime {
impl pallet_beefy::Config for Runtime {
type BeefyId = BeefyId;
type KeyOwnerProofSystem = Historical;
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, BeefyId)>>::Proof;
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
BeefyId,
)>>::IdentificationTuple;
type HandleEquivocation = pallet_beefy::EquivocationHandler<
BlockNumber,
Self::KeyOwnerIdentification,
Offences,
ReportLongevity,
>;
type MaxAuthorities = MaxAuthorities;
type OnNewValidatorSet = MmrLeaf;
type WeightInfo = ();
}
type MmrHash = <Keccak256 as sp_runtime::traits::Hash>::Output;
@@ -1443,7 +1457,7 @@ construct_runtime! {
// Rococo specific pallets (not included in Kusama). Start indices at 240
//
// BEEFY Bridges support.
Beefy: pallet_beefy::{Pallet, Storage, Config<T>} = 240,
Beefy: pallet_beefy::{Pallet, Call, Storage, Config<T>, ValidateUnsigned} = 240,
MmrLeaf: pallet_beefy_mmr::{Pallet, Storage} = 242,
ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 250,
@@ -1768,6 +1782,33 @@ sp_api::impl_runtime_apis! {
fn validator_set() -> Option<beefy_primitives::ValidatorSet<BeefyId>> {
Beefy::validator_set()
}
fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: beefy_primitives::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
let key_owner_proof = key_owner_proof.decode()?;
Beefy::submit_unsigned_equivocation_report(
equivocation_proof,
key_owner_proof,
)
}
fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
use parity_scale_codec::Encode;
Historical::prove((beefy_primitives::KEY_TYPE, authority_id))
.map(|p| p.encode())
.map(beefy_primitives::OpaqueKeyOwnershipProof::new)
}
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
+19 -1
View File
@@ -34,7 +34,7 @@ use polkadot_runtime_parachains::{
};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{onchain, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
@@ -904,6 +904,24 @@ sp_api::impl_runtime_apis! {
// dummy implementation due to lack of BEEFY pallet.
None
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
None
}
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {
+19 -1
View File
@@ -21,7 +21,7 @@
#![recursion_limit = "256"]
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use beefy_primitives::crypto::{AuthorityId as BeefyId, Signature as BeefySignature};
use frame_election_provider_support::{onchain, SequentialPhragmen};
use frame_support::{
construct_runtime, parameter_types,
@@ -1497,6 +1497,24 @@ sp_api::impl_runtime_apis! {
// dummy implementation due to lack of BEEFY pallet.
None
}
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
None
}
}
impl mmr::MmrApi<Block, Hash, BlockNumber> for Runtime {