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

Companion for substrate#14744: BEEFY: add support for slashing validators signing forking commitments #7634

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
11 changes: 9 additions & 2 deletions node/service/src/fake_runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ sp_api::impl_runtime_apis! {
unimplemented!()
}

fn submit_report_equivocation_unsigned_extrinsic(
_: beefy_primitives::EquivocationProof<
fn submit_report_vote_equivocation_unsigned_extrinsic(
_: beefy_primitives::VoteEquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
Expand All @@ -251,6 +251,13 @@ sp_api::impl_runtime_apis! {
unimplemented!()
}

fn submit_report_fork_equivocation_unsigned_extrinsic(
_: beefy_primitives::ForkEquivocationProof<BlockNumber, BeefyId, BeefySignature, <Block as BlockT>::Header>,
_: Vec<beefy_primitives::OpaqueKeyOwnershipProof>,
) -> Option<()> {
unimplemented!()
}

fn generate_key_ownership_proof(
_: beefy_primitives::ValidatorSetId,
_: BeefyId,
Expand Down
14 changes: 12 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1833,21 +1833,31 @@ sp_api::impl_runtime_apis! {
None
}

fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
fn submit_report_vote_equivocation_unsigned_extrinsic(
_vote_equivocation_proof: beefy_primitives::VoteEquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
>,
_key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof,
) -> Option<()> {
// dummy implementation due to lack of BEEFY pallet.
None
}

fn submit_report_fork_equivocation_unsigned_extrinsic(
_fork_equivocation_proof: beefy_primitives::ForkEquivocationProof<BlockNumber, BeefyId, BeefySignature, Header>,
_key_owner_proofs: Vec<beefy_primitives::OpaqueKeyOwnershipProof>,
) -> Option<()> {
// dummy implementation due to lack of BEEFY pallet.
None
}

fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
) -> Option<beefy_primitives::OpaqueKeyOwnershipProof> {
// dummy implementation due to lack of BEEFY pallet.
None
}
}
Expand Down
20 changes: 16 additions & 4 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,8 @@ sp_api::impl_runtime_apis! {
Beefy::validator_set()
}

fn submit_report_equivocation_unsigned_extrinsic(
equivocation_proof: beefy_primitives::EquivocationProof<
fn submit_report_vote_equivocation_unsigned_extrinsic(
vote_equivocation_proof: beefy_primitives::VoteEquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
Expand All @@ -1866,12 +1866,24 @@ 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_fork_equivocation_unsigned_extrinsic(
fork_equivocation_proof: beefy_primitives::ForkEquivocationProof<BlockNumber, BeefyId, BeefySignature, Header>,
key_owner_proofs: Vec<beefy_primitives::OpaqueKeyOwnershipProof>,
) -> Option<()> {
let key_owner_proofs = key_owner_proofs.iter().cloned().map(|p| p.decode()).collect::<Option<Vec<_>>>()?;

Beefy::submit_unsigned_fork_equivocation_report(
fork_equivocation_proof,
key_owner_proofs,
)
}

fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
authority_id: BeefyId,
Expand Down
11 changes: 9 additions & 2 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,8 @@ sp_api::impl_runtime_apis! {
None
}

fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: beefy_primitives::EquivocationProof<
fn submit_report_vote_equivocation_unsigned_extrinsic(
_vote_equivocation_proof: beefy_primitives::VoteEquivocationProof<
BlockNumber,
BeefyId,
BeefySignature,
Expand All @@ -972,6 +972,13 @@ sp_api::impl_runtime_apis! {
None
}

fn submit_report_fork_equivocation_unsigned_extrinsic(
_fork_equivocation_proof: beefy_primitives::ForkEquivocationProof<BlockNumber, BeefyId, BeefySignature, Header>,
_key_owner_proofs: Vec<beefy_primitives::OpaqueKeyOwnershipProof>,
) -> Option<()> {
None
}

fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
_authority_id: BeefyId,
Expand Down
7 changes: 7 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,13 @@ sp_api::impl_runtime_apis! {
)
}

fn submit_report_fork_equivocation_unsigned_extrinsic(
_fork_equivocation_proof: beefy_primitives::ForkEquivocationProof<BlockNumber, BeefyId, BeefySignature, Header>,
_key_owner_proofs: Vec<beefy_primitives::OpaqueKeyOwnershipProof>,
) -> Option<()> {
None
}

fn generate_key_ownership_proof(
_set_id: beefy_primitives::ValidatorSetId,
authority_id: BeefyId,
Expand Down