From adc2515c65e57ecfefa6b6142f3f75217a3e857a Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Wed, 2 Aug 2023 10:51:35 +0200 Subject: [PATCH 1/3] implement report of invalid fork commitment --- node/service/src/fake_runtime_api.rs | 7 +++++++ runtime/kusama/src/lib.rs | 10 ++++++++++ runtime/polkadot/src/lib.rs | 10 ++++++++++ runtime/rococo/src/lib.rs | 12 ++++++++++++ runtime/westend/src/lib.rs | 7 +++++++ 5 files changed, 46 insertions(+) diff --git a/node/service/src/fake_runtime_api.rs b/node/service/src/fake_runtime_api.rs index f9d7799d8262..68f380bf3bce 100644 --- a/node/service/src/fake_runtime_api.rs +++ b/node/service/src/fake_runtime_api.rs @@ -250,6 +250,13 @@ sp_api::impl_runtime_apis! { unimplemented!() } + fn submit_report_invalid_fork_unsigned_extrinsic( + _: beefy_primitives::InvalidForkCommitmentProof, + _: Vec, + ) -> Option<()> { + unimplemented!() + } + fn generate_key_ownership_proof( _: beefy_primitives::ValidatorSetId, _: BeefyId, diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 6779caad84be..f32794cbcf85 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1835,6 +1835,15 @@ sp_api::impl_runtime_apis! { >, _key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { + // dummy implementation due to lack of BEEFY pallet. + None + } + + fn submit_report_invalid_fork_unsigned_extrinsic( + _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + _key_owner_proofs: Vec, + ) -> Option<()> { + // dummy implementation due to lack of BEEFY pallet. None } @@ -1842,6 +1851,7 @@ sp_api::impl_runtime_apis! { _set_id: beefy_primitives::ValidatorSetId, _authority_id: BeefyId, ) -> Option { + // dummy implementation due to lack of BEEFY pallet. None } } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 55ddb4707791..622a01f7d037 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1838,6 +1838,15 @@ sp_api::impl_runtime_apis! { >, _key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, ) -> Option<()> { + // dummy implementation due to lack of BEEFY pallet. + None + } + + fn submit_report_invalid_fork_unsigned_extrinsic( + _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + _key_owner_proofs: Vec, + ) -> Option<()> { + // dummy implementation due to lack of BEEFY pallet. None } @@ -1845,6 +1854,7 @@ sp_api::impl_runtime_apis! { _set_id: beefy_primitives::ValidatorSetId, _authority_id: BeefyId, ) -> Option { + // dummy implementation due to lack of BEEFY pallet. None } } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 9800fe0ff754..c997b12e83af 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1845,6 +1845,18 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_invalid_fork_unsigned_extrinsic( + invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + key_owner_proofs: Vec, + ) -> Option<()> { + let key_owner_proofs = key_owner_proofs.iter().cloned().map(|p| p.decode()).collect::>>()?; + + Beefy::submit_unsigned_invalid_fork_report( + invalid_fork_proof, + key_owner_proofs, + ) + } + fn generate_key_ownership_proof( _set_id: beefy_primitives::ValidatorSetId, authority_id: BeefyId, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 098e65d43de4..ad203eaa0cbf 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1576,6 +1576,13 @@ sp_api::impl_runtime_apis! { None } + fn submit_report_invalid_fork_unsigned_extrinsic( + _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + _key_owner_proofs: Vec, + ) -> Option<()> { + None + } + fn generate_key_ownership_proof( _set_id: beefy_primitives::ValidatorSetId, _authority_id: BeefyId, From 982089e30fab6e5ec0664a544ca41ddd2c347901 Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Thu, 17 Aug 2023 10:16:39 +0200 Subject: [PATCH 2/3] s/EquivocationProof/VoteEquivocationProof --- node/service/src/fake_runtime_api.rs | 2 +- runtime/kusama/src/lib.rs | 2 +- runtime/polkadot/src/lib.rs | 2 +- runtime/rococo/src/lib.rs | 4 +++- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/node/service/src/fake_runtime_api.rs b/node/service/src/fake_runtime_api.rs index 68f380bf3bce..32ab76804fdb 100644 --- a/node/service/src/fake_runtime_api.rs +++ b/node/service/src/fake_runtime_api.rs @@ -240,7 +240,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _: beefy_primitives::EquivocationProof< + _: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index f32794cbcf85..16981846f400 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1828,7 +1828,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::EquivocationProof< + _equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 622a01f7d037..bc348a931f31 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1831,7 +1831,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::EquivocationProof< + _equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index c997b12e83af..4ac52e1ae542 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1270,6 +1270,8 @@ impl pallet_beefy::Config for Runtime { type KeyOwnerProof = >::Proof; type EquivocationReportSystem = pallet_beefy::EquivocationReportSystem; + type InvalidForkReportSystem = + pallet_beefy::InvalidForkReportSystem; } /// MMR helper types. @@ -1830,7 +1832,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: beefy_primitives::EquivocationProof< + equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 035adcc007c2..2ee46e94b2a2 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -951,7 +951,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::EquivocationProof< + _equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index ad203eaa0cbf..ac7b5a69f822 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1566,7 +1566,7 @@ sp_api::impl_runtime_apis! { } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::EquivocationProof< + _equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, From 0bb36785062f238b2c8510888cdd56d2bc640655 Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Thu, 17 Aug 2023 11:25:41 +0200 Subject: [PATCH 3/3] update BEEFY equivocation report interface --- node/service/src/fake_runtime_api.rs | 6 +++--- runtime/kusama/src/lib.rs | 8 ++++---- runtime/polkadot/src/lib.rs | 8 ++++---- runtime/rococo/src/lib.rs | 18 ++++++++---------- runtime/test-runtime/src/lib.rs | 11 +++++++++-- runtime/westend/src/lib.rs | 8 ++++---- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/node/service/src/fake_runtime_api.rs b/node/service/src/fake_runtime_api.rs index 6cc7181c5da7..418217997385 100644 --- a/node/service/src/fake_runtime_api.rs +++ b/node/service/src/fake_runtime_api.rs @@ -240,7 +240,7 @@ sp_api::impl_runtime_apis! { unimplemented!() } - fn submit_report_equivocation_unsigned_extrinsic( + fn submit_report_vote_equivocation_unsigned_extrinsic( _: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, @@ -251,8 +251,8 @@ sp_api::impl_runtime_apis! { unimplemented!() } - fn submit_report_invalid_fork_unsigned_extrinsic( - _: beefy_primitives::InvalidForkCommitmentProof, + fn submit_report_fork_equivocation_unsigned_extrinsic( + _: beefy_primitives::ForkEquivocationProof::Header>, _: Vec, ) -> Option<()> { unimplemented!() diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 1d77ad85b6b4..94ab803949c5 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1827,8 +1827,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::VoteEquivocationProof< + fn submit_report_vote_equivocation_unsigned_extrinsic( + _vote_equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, @@ -1839,8 +1839,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_invalid_fork_unsigned_extrinsic( - _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + fn submit_report_fork_equivocation_unsigned_extrinsic( + _fork_equivocation_proof: beefy_primitives::ForkEquivocationProof, _key_owner_proofs: Vec, ) -> Option<()> { // dummy implementation due to lack of BEEFY pallet. diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c3258b77345c..fabde9f914a6 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1808,8 +1808,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::VoteEquivocationProof< + fn submit_report_vote_equivocation_unsigned_extrinsic( + _vote_equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, @@ -1820,8 +1820,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_invalid_fork_unsigned_extrinsic( - _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + fn submit_report_fork_equivocation_unsigned_extrinsic( + _fork_equivocation_proof: beefy_primitives::ForkEquivocationProof, _key_owner_proofs: Vec, ) -> Option<()> { // dummy implementation due to lack of BEEFY pallet. diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 86dbea9067b4..073cb6ba3e0a 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1270,8 +1270,6 @@ impl pallet_beefy::Config for Runtime { type KeyOwnerProof = >::Proof; type EquivocationReportSystem = pallet_beefy::EquivocationReportSystem; - type InvalidForkReportSystem = - pallet_beefy::InvalidForkReportSystem; } /// MMR helper types. @@ -1830,8 +1828,8 @@ sp_api::impl_runtime_apis! { Beefy::validator_set() } - fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: beefy_primitives::VoteEquivocationProof< + fn submit_report_vote_equivocation_unsigned_extrinsic( + vote_equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, @@ -1840,20 +1838,20 @@ sp_api::impl_runtime_apis! { ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; - Beefy::submit_unsigned_equivocation_report( - equivocation_proof, + Beefy::submit_unsigned_vote_equivocation_report( + vote_equivocation_proof, key_owner_proof, ) } - fn submit_report_invalid_fork_unsigned_extrinsic( - invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + fn submit_report_fork_equivocation_unsigned_extrinsic( + fork_equivocation_proof: beefy_primitives::ForkEquivocationProof, key_owner_proofs: Vec, ) -> Option<()> { let key_owner_proofs = key_owner_proofs.iter().cloned().map(|p| p.decode()).collect::>>()?; - Beefy::submit_unsigned_invalid_fork_report( - invalid_fork_proof, + Beefy::submit_unsigned_fork_equivocation_report( + fork_equivocation_proof, key_owner_proofs, ) } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index bb478d3865a3..03eac628182a 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -955,8 +955,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::VoteEquivocationProof< + fn submit_report_vote_equivocation_unsigned_extrinsic( + _vote_equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, @@ -966,6 +966,13 @@ sp_api::impl_runtime_apis! { None } + fn submit_report_fork_equivocation_unsigned_extrinsic( + _fork_equivocation_proof: beefy_primitives::ForkEquivocationProof, + _key_owner_proofs: Vec, + ) -> Option<()> { + None + } + fn generate_key_ownership_proof( _set_id: beefy_primitives::ValidatorSetId, _authority_id: BeefyId, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index c481975dae80..bfa8ed29b56d 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1563,8 +1563,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::VoteEquivocationProof< + fn submit_report_vote_equivocation_unsigned_extrinsic( + _vote_equivocation_proof: beefy_primitives::VoteEquivocationProof< BlockNumber, BeefyId, BeefySignature, @@ -1574,8 +1574,8 @@ sp_api::impl_runtime_apis! { None } - fn submit_report_invalid_fork_unsigned_extrinsic( - _invalid_fork_proof: beefy_primitives::InvalidForkCommitmentProof, + fn submit_report_fork_equivocation_unsigned_extrinsic( + _fork_equivocation_proof: beefy_primitives::ForkEquivocationProof, _key_owner_proofs: Vec, ) -> Option<()> { None