From d4afe081d73c3036696dd7d120a347f923617a8e Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 12:15:43 +0300 Subject: [PATCH 1/6] generate_ancestry_proof() --- polkadot/node/service/src/fake_runtime_api.rs | 7 +++++++ polkadot/runtime/rococo/src/lib.rs | 11 +++++++++++ polkadot/runtime/test-runtime/src/lib.rs | 7 +++++++ polkadot/runtime/westend/src/lib.rs | 11 +++++++++++ substrate/bin/node/runtime/src/lib.rs | 11 +++++++++++ substrate/frame/beefy-mmr/src/lib.rs | 18 ++++++++++++++++++ substrate/frame/beefy/src/mock.rs | 7 +++++++ .../primitives/consensus/beefy/src/lib.rs | 14 ++++++++++++++ 8 files changed, 86 insertions(+) diff --git a/polkadot/node/service/src/fake_runtime_api.rs b/polkadot/node/service/src/fake_runtime_api.rs index e971830c95cb..2d81b9bcdfaa 100644 --- a/polkadot/node/service/src/fake_runtime_api.rs +++ b/polkadot/node/service/src/fake_runtime_api.rs @@ -258,6 +258,13 @@ sp_api::impl_runtime_apis! { ) -> Option { unimplemented!() } + + fn generate_ancestry_proof( + _: BlockNumber, + _: Option, + ) -> Option { + unimplemented!() + } } impl sp_mmr_primitives::MmrApi for Runtime { diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index ef629c7dad15..eb87ea436f27 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2089,6 +2089,17 @@ sp_api::impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + MmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } #[api_version(2)] diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 96392c026d5c..377b38c6e649 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -1032,6 +1032,13 @@ sp_api::impl_runtime_apis! { ) -> Option { None } + + fn generate_ancestry_proof( + _prev_block_number: BlockNumber, + _best_known_block_number: Option, + ) -> Option { + None + } } impl mmr::MmrApi for Runtime { diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 0d7a8a6a4ac2..94ecd62cded1 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2046,6 +2046,17 @@ sp_api::impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + BeefyMmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } impl mmr::MmrApi for Runtime { diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index fc87fea57ba2..38c2ea8bb48d 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -3067,6 +3067,17 @@ impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + MmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } impl pallet_mmr::primitives::MmrApi< diff --git a/substrate/frame/beefy-mmr/src/lib.rs b/substrate/frame/beefy-mmr/src/lib.rs index 18ebc9d8f38a..f4caaaff91a5 100644 --- a/substrate/frame/beefy-mmr/src/lib.rs +++ b/substrate/frame/beefy-mmr/src/lib.rs @@ -181,6 +181,24 @@ where type Proof = AncestryProof>; type ValidationContext = MerkleRootOf; + fn generate_proof( + prev_block_number: BlockNumberFor, + best_known_block_number: Option>, + ) -> Option { + pallet_mmr::Pallet::::generate_ancestry_proof(prev_block_number, best_known_block_number) + .map_err(|e| { + log::error!( + target: "runtime::beefy", + "Failed to generate ancestry proof for block {:?} at {:?}: {:?}", + prev_block_number, + best_known_block_number, + e + ); + e + }) + .ok() + } + fn extract_validation_context(header: HeaderFor) -> Option { // Check if the provided header is canonical. let expected_hash = frame_system::Pallet::::block_hash(header.number()); diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 03efccff7643..a0880660d051 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -111,6 +111,13 @@ impl AncestryHelper
for MockAncestryHelper { type Proof = MockAncestryProof; type ValidationContext = MockAncestryProofContext; + fn generate_proof( + _prev_block_number: Header::Number, + _best_known_block_number: Option, + ) -> Option { + unimplemented!() + } + fn extract_validation_context(_header: Header) -> Option { AncestryProofContext::get() } diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index 7f6f733d0e39..85005d84bfa4 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -428,6 +428,13 @@ pub trait AncestryHelper { /// The data needed for validating the proof. type ValidationContext; + /// Generates a proof that the `prev_block_number` is part of the canonical chain at + /// `best_known_block_number`. + fn generate_proof( + prev_block_number: Header::Number, + best_known_block_number: Option, + ) -> Option; + /// Extract the validation context from the provided header. fn extract_validation_context(header: Header) -> Option; @@ -489,6 +496,13 @@ sp_api::decl_runtime_apis! { set_id: ValidatorSetId, authority_id: AuthorityId, ) -> Option; + + /// Generates a proof that the `prev_block_number` is part of the canonical chain at + /// `best_known_block_number`. + fn generate_ancestry_proof( + prev_block_number: NumberFor, + best_known_block_number: Option>, + ) -> Option; } } From bb39d600311102625dc9fb19069ca4636d65e669 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 13:47:20 +0300 Subject: [PATCH 2/6] submit_report_fork_voting_unsigned_extrinsic() --- polkadot/node/service/src/fake_runtime_api.rs | 11 ++++++++ polkadot/runtime/rococo/src/lib.rs | 15 +++++++++++ polkadot/runtime/test-runtime/src/lib.rs | 12 +++++++++ polkadot/runtime/westend/src/lib.rs | 15 +++++++++++ substrate/bin/node/runtime/src/lib.rs | 15 +++++++++++ substrate/frame/beefy/src/lib.rs | 22 +++++++++++++-- .../primitives/consensus/beefy/src/lib.rs | 27 +++++++++++++++++++ 7 files changed, 115 insertions(+), 2 deletions(-) diff --git a/polkadot/node/service/src/fake_runtime_api.rs b/polkadot/node/service/src/fake_runtime_api.rs index 2d81b9bcdfaa..aef64f60ed29 100644 --- a/polkadot/node/service/src/fake_runtime_api.rs +++ b/polkadot/node/service/src/fake_runtime_api.rs @@ -252,6 +252,17 @@ sp_api::impl_runtime_apis! { unimplemented!() } + fn submit_report_fork_voting_unsigned_extrinsic( + _: sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + _: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + unimplemented!() + } + fn generate_key_ownership_proof( _: sp_consensus_beefy::ValidatorSetId, _: BeefyId, diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index eb87ea436f27..3c0936e5a2e5 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2079,6 +2079,21 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 377b38c6e649..87778e840e56 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -1026,6 +1026,18 @@ sp_api::impl_runtime_apis! { None } + fn submit_report_fork_voting_unsigned_extrinsic( + _equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, _authority_id: BeefyId, diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 94ecd62cded1..829e3b4695ff 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2036,6 +2036,21 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 38c2ea8bb48d..6e40a61d4ed4 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -3059,6 +3059,21 @@ impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/substrate/frame/beefy/src/lib.rs b/substrate/frame/beefy/src/lib.rs index a49f5d28f455..02d3f253df93 100644 --- a/substrate/frame/beefy/src/lib.rs +++ b/substrate/frame/beefy/src/lib.rs @@ -536,8 +536,8 @@ impl Pallet { ValidatorSet::::new(validators, id) } - /// Submits an extrinsic to report an equivocation. This method will create - /// an unsigned extrinsic with a call to `report_equivocation_unsigned` and + /// Submits an extrinsic to report a double voting equivocation. This method will create + /// an unsigned extrinsic with a call to `report_double_voting_unsigned` and /// will push the transaction to the pool. Only useful in an offchain context. pub fn submit_unsigned_double_voting_report( equivocation_proof: DoubleVotingProof< @@ -554,6 +554,24 @@ impl Pallet { .ok() } + /// Submits an extrinsic to report a fork voting equivocation. This method will create + /// an unsigned extrinsic with a call to `report_fork_voting_unsigned` and + /// will push the transaction to the pool. Only useful in an offchain context. + pub fn submit_unsigned_fork_voting_report( + equivocation_proof: ForkVotingProof< + HeaderFor, + T::BeefyId, + >>::Proof, + >, + key_owner_proof: T::KeyOwnerProof, + ) -> Option<()> { + T::EquivocationReportSystem::publish_evidence(EquivocationEvidenceFor::ForkVotingProof( + equivocation_proof, + key_owner_proof, + )) + .ok() + } + fn change_authorities( new: BoundedVec, queued: BoundedVec, diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index 85005d84bfa4..63500fc1066f 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -349,6 +349,19 @@ pub struct ForkVotingProof pub header: Header, } +impl ForkVotingProof { + /// Try to decode the `AncestryProof`. + pub fn try_into( + self, + ) -> Option> { + Some(ForkVotingProof:: { + vote: self.vote, + ancestry_proof: self.ancestry_proof.decode()?, + header: self.header, + }) + } +} + /// Proof showing that an authority voted for a future block. #[derive(Clone, Debug, Decode, Encode, PartialEq, TypeInfo)] pub struct FutureBlockVotingProof { @@ -481,6 +494,20 @@ sp_api::decl_runtime_apis! { key_owner_proof: OpaqueKeyOwnershipProof, ) -> Option<()>; + /// Submits an unsigned extrinsic to report a fork voting equivocation. The caller + /// must provide the fork voting proof (the ancestry proof should be obtained using + /// `generate_ancestry_proof`) and a key ownership proof (should be obtained using + /// `generate_key_ownership_proof`). The extrinsic will be unsigned and should only + /// be accepted for local authorship (not to be broadcast to the network). This method + /// returns `None` when creation of the extrinsic fails, e.g. if equivocation + /// reporting is disabled for the given runtime (i.e. this method is + /// hardcoded to return `None`). Only useful in an offchain context. + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + ForkVotingProof, + key_owner_proof: OpaqueKeyOwnershipProof, + ) -> Option<()>; + /// Generates a proof of key ownership for the given authority in the /// given set. An example usage of this module is coupled with the /// session historical module to prove that a given authority key is From c63b2fd275be92f58e146bf5a670c8affc36fb07 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 14:02:43 +0300 Subject: [PATCH 3/6] submit_report_future_block_voting_unsigned_extrinsic() --- polkadot/node/service/src/fake_runtime_api.rs | 7 +++++++ polkadot/runtime/rococo/src/lib.rs | 10 ++++++++++ polkadot/runtime/test-runtime/src/lib.rs | 7 +++++++ polkadot/runtime/westend/src/lib.rs | 10 ++++++++++ substrate/bin/node/runtime/src/lib.rs | 10 ++++++++++ substrate/frame/beefy/src/lib.rs | 13 +++++++++++++ substrate/primitives/consensus/beefy/src/lib.rs | 14 ++++++++++++++ 7 files changed, 71 insertions(+) diff --git a/polkadot/node/service/src/fake_runtime_api.rs b/polkadot/node/service/src/fake_runtime_api.rs index aef64f60ed29..cdef39d5bdf1 100644 --- a/polkadot/node/service/src/fake_runtime_api.rs +++ b/polkadot/node/service/src/fake_runtime_api.rs @@ -263,6 +263,13 @@ sp_api::impl_runtime_apis! { unimplemented!() } + fn submit_report_future_block_voting_unsigned_extrinsic( + _: sp_consensus_beefy::FutureBlockVotingProof, + _: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + unimplemented!() + } + fn generate_key_ownership_proof( _: sp_consensus_beefy::ValidatorSetId, _: BeefyId, diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 3c0936e5a2e5..075028d183af 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2094,6 +2094,16 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 87778e840e56..23a41c6cf7bd 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -1038,6 +1038,13 @@ sp_api::impl_runtime_apis! { None } + fn submit_report_future_block_voting_unsigned_extrinsic( + _equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, _authority_id: BeefyId, diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 829e3b4695ff..e92cae0aabe3 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2051,6 +2051,16 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 6e40a61d4ed4..983cc6e31b20 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -3074,6 +3074,16 @@ impl_runtime_apis! { ) } + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, diff --git a/substrate/frame/beefy/src/lib.rs b/substrate/frame/beefy/src/lib.rs index 02d3f253df93..7e17148d600f 100644 --- a/substrate/frame/beefy/src/lib.rs +++ b/substrate/frame/beefy/src/lib.rs @@ -572,6 +572,19 @@ impl Pallet { .ok() } + /// Submits an extrinsic to report a future block voting equivocation. This method will create + /// an unsigned extrinsic with a call to `report_future_block_voting_unsigned` and + /// will push the transaction to the pool. Only useful in an offchain context. + pub fn submit_unsigned_future_block_voting_report( + equivocation_proof: FutureBlockVotingProof, T::BeefyId>, + key_owner_proof: T::KeyOwnerProof, + ) -> Option<()> { + T::EquivocationReportSystem::publish_evidence( + EquivocationEvidenceFor::FutureBlockVotingProof(equivocation_proof, key_owner_proof), + ) + .ok() + } + fn change_authorities( new: BoundedVec, queued: BoundedVec, diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index 63500fc1066f..166a5f36ac5f 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -508,6 +508,20 @@ sp_api::decl_runtime_apis! { key_owner_proof: OpaqueKeyOwnershipProof, ) -> Option<()>; + /// Submits an unsigned extrinsic to report a future block voting equivocation. The caller + /// must provide the future block voting proof and a key ownership proof + /// (should be obtained using `generate_key_ownership_proof`). + /// The extrinsic will be unsigned and should only be accepted for local + /// authorship (not to be broadcast to the network). This method returns + /// `None` when creation of the extrinsic fails, e.g. if equivocation + /// reporting is disabled for the given runtime (i.e. this method is + /// hardcoded to return `None`). Only useful in an offchain context. + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: + FutureBlockVotingProof, AuthorityId>, + key_owner_proof: OpaqueKeyOwnershipProof, + ) -> Option<()>; + /// Generates a proof of key ownership for the given authority in the /// given set. An example usage of this module is coupled with the /// session historical module to prove that a given authority key is From 7c84aa3ee51b5ca3fffc6fba36587a3e321e7e85 Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 14:26:08 +0300 Subject: [PATCH 4/6] Increment BeefyApi version --- polkadot/runtime/rococo/src/lib.rs | 2 +- polkadot/runtime/westend/src/lib.rs | 2 +- substrate/bin/node/runtime/src/lib.rs | 2 +- substrate/primitives/consensus/beefy/src/lib.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 075028d183af..9ad55b797a9a 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2053,7 +2053,7 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index e92cae0aabe3..c7ad749334f2 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -2010,7 +2010,7 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 983cc6e31b20..3400262fdf4a 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -3033,7 +3033,7 @@ impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() diff --git a/substrate/primitives/consensus/beefy/src/lib.rs b/substrate/primitives/consensus/beefy/src/lib.rs index 166a5f36ac5f..020e1667cbc7 100644 --- a/substrate/primitives/consensus/beefy/src/lib.rs +++ b/substrate/primitives/consensus/beefy/src/lib.rs @@ -470,7 +470,7 @@ pub type OpaqueKeyOwnershipProof = OpaqueValue; sp_api::decl_runtime_apis! { /// API necessary for BEEFY voters. - #[api_version(4)] + #[api_version(5)] pub trait BeefyApi where AuthorityId : Codec + RuntimeAppPublic, { From 2e3991c07e3bdb6ba9577ea111744c57c3e6665e Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 15:25:03 +0300 Subject: [PATCH 5/6] Add prdoc --- prdoc/pr_4993.prdoc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 prdoc/pr_4993.prdoc diff --git a/prdoc/pr_4993.prdoc b/prdoc/pr_4993.prdoc new file mode 100644 index 000000000000..cc71ac3974ca --- /dev/null +++ b/prdoc/pr_4993.prdoc @@ -0,0 +1,27 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Added BEEFY equivocation-related methods to BeefyApi + +doc: + - audience: Node Dev + description: | + This PR adds the `generate_ancestry_proof`, `submit_report_fork_voting_unsigned_extrinsic` and + `submit_report_future_block_voting_unsigned_extrinsic` to `BeefyApi` and bumps the `BeefyApi` version + from 4 to 5. + +crates: + - name: pallet-beefy + bump: patch + - name: pallet-beefy-mmr + bump: patch + - name: sc-consensus-beefy + bump: patch + - name: kitchensink-runtime + bump: major + - name: rococo-runtime + bump: major + - name: westend-runtime + bump: major + - name: sp-consensus-beefy + bump: major From df1784b49268c5e1ad5962fa882ccfc01e3895bf Mon Sep 17 00:00:00 2001 From: Serban Iorga Date: Wed, 10 Jul 2024 16:12:56 +0300 Subject: [PATCH 6/6] Fix prdoc --- prdoc/pr_4993.prdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prdoc/pr_4993.prdoc b/prdoc/pr_4993.prdoc index cc71ac3974ca..d822d5cd6c76 100644 --- a/prdoc/pr_4993.prdoc +++ b/prdoc/pr_4993.prdoc @@ -12,11 +12,9 @@ doc: crates: - name: pallet-beefy - bump: patch + bump: minor - name: pallet-beefy-mmr - bump: patch - - name: sc-consensus-beefy - bump: patch + bump: minor - name: kitchensink-runtime bump: major - name: rococo-runtime @@ -24,4 +22,6 @@ crates: - name: westend-runtime bump: major - name: sp-consensus-beefy - bump: major + bump: minor + - name: polkadot-service + bump: patch