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

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

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ee6c180
sc-consensus-beefy: add BEEFY fisherman to gossip network
acatangiu Jul 5, 2023
ce03ec8
sp-consensus-beefy: add invalid fork vote proof and equivalent BeefyApi
acatangiu Jul 5, 2023
e95e316
pallet-beefy: add stubs for reporting invalid fork votes
acatangiu Jul 5, 2023
6651b32
sc-consensus-beefy: fisherman reports invalid votes and justifications
acatangiu Jul 5, 2023
7f988ef
don't check GRANDPA finality
Lederstrumpf Jul 20, 2023
2ab4f5b
change primitive: vote -> commitment
Lederstrumpf Jul 20, 2023
06260f0
add check_signed_commitment/report_invalid_payload
Lederstrumpf Jul 27, 2023
0642a81
update comments
Lederstrumpf Aug 2, 2023
c6c36e3
add dummy for report of invalid fork commitments
Lederstrumpf Aug 2, 2023
6078b41
account for #14471
Lederstrumpf Aug 1, 2023
5da5631
account for #14373
Lederstrumpf Aug 7, 2023
98db7cf
EquivocationOffence.{offender->offenders}
Lederstrumpf Aug 7, 2023
1a45cbe
EquivocationProof->VoteEquivocationProof
Lederstrumpf Aug 7, 2023
4bd78eb
Invalid{""->Vote}EquivocationProof
Lederstrumpf Aug 7, 2023
f4496c9
check_{""->vote}_equivocation_proof
Lederstrumpf Aug 7, 2023
61f9a45
InvalidForkCommitmentProof->ForkEquivocationProof
Lederstrumpf Aug 7, 2023
53a1a88
renames across submit_report_...
Lederstrumpf Aug 7, 2023
7e0ec77
convert EquivocationEvidenceFor to enum (minimal)
Lederstrumpf Aug 7, 2023
e8b97b3
handle ForkEquivocationProof enum variant
Lederstrumpf Aug 7, 2023
d5ceb23
reduce find_mmr_root_digest trait constraint
Lederstrumpf Aug 8, 2023
3b274fa
fix fork equiv. call interfaces (vecs of sigs)
Lederstrumpf Aug 8, 2023
8701d7f
check proof's payload against correct header's
Lederstrumpf Aug 8, 2023
7c2cdfd
rm superfluous report_fork_equiv.correct_header
Lederstrumpf Aug 8, 2023
98eb692
remove duplic. in check_{signed_commitment, proof}
Lederstrumpf Aug 8, 2023
91ce777
update outdated comments
Lederstrumpf Aug 8, 2023
3c3fc1c
remove report_invalid_payload
Lederstrumpf Aug 8, 2023
f2a9745
.+report.+{""->_vote}_equivocations
Lederstrumpf Aug 8, 2023
faea8d9
move correct_header hash check into primitives
Lederstrumpf Aug 9, 2023
c3df631
create_beefy_worker: only push block if at genesis
Lederstrumpf Aug 9, 2023
f1f2bb0
create_beefy_worker: opt. instantiate with TestApi
Lederstrumpf Aug 9, 2023
b0ed4ae
push to reported_fork_equivocations
Lederstrumpf Aug 9, 2023
113076c
add generate_fork_equivocation_proof_vote to tests
Lederstrumpf Aug 9, 2023
772e3b8
test: Alice snitches on Bob's vote equivocation
Lederstrumpf Aug 9, 2023
7d21f52
store reference to key_store in fisherman
Lederstrumpf Aug 10, 2023
6646665
test: Alice doesn't snitch *own* vote equivocation
Lederstrumpf Aug 10, 2023
c97c963
un-stub submit_unsigned_fork_equivocation_report
Lederstrumpf Aug 10, 2023
e4a39b2
Merge remote-tracking branch 'upstream/master' into rhmb/beefy-slashi…
Lederstrumpf Aug 17, 2023
10540ec
Alice reports Bob & Charlie's signed commitment
Aug 24, 2023
50cd76e
Merge remote-tracking branch 'upstream/master' into rhmb/beefy-slashi…
Aug 24, 2023
809784b
cleanup
Lederstrumpf Aug 24, 2023
37ec6c9
fmt
Lederstrumpf Aug 24, 2023
4c2e0ba
fixup! cleanup
Lederstrumpf Aug 24, 2023
3b655a1
remove superfluous None check
Lederstrumpf Aug 24, 2023
a36a01d
Merge branch 'master' into rhmb/beefy-slashing-fisherman
Lederstrumpf Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pallet-beefy: add stubs for reporting invalid fork votes
Signed-off-by: Adrian Catangiu <[email protected]>
  • Loading branch information
acatangiu authored and Lederstrumpf committed Aug 7, 2023
commit e95e316250c2d1a86313f58cdc6475fafd61c13f
1 change: 1 addition & 0 deletions frame/beefy/src/equivocation.rs
Original file line number Diff line number Diff line change
@@ -125,6 +125,7 @@ where
pub struct EquivocationReportSystem<T, R, P, L>(sp_std::marker::PhantomData<(T, R, P, L)>);

/// Equivocation evidence convenience alias.
// TODO: use an enum that takes either `EquivocationProof` or `InvalidForkVoteProof`
pub type EquivocationEvidenceFor<T> = (
EquivocationProof<
BlockNumberFor<T>,
63 changes: 63 additions & 0 deletions frame/beefy/src/lib.rs
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ const LOG_TARGET: &str = "runtime::beefy";
pub mod pallet {
use super::*;
use frame_system::pallet_prelude::BlockNumberFor;
use sp_consensus_beefy::InvalidForkVoteProof;

#[pallet::config]
pub trait Config: frame_system::Config {
@@ -111,6 +112,8 @@ pub mod pallet {
/// Defines methods to publish, check and process an equivocation offence.
type EquivocationReportSystem: OffenceReportSystem<
Option<Self::AccountId>,
// TODO: make below an enum that takes either `EquivocationProof` or
// `InvalidForkVoteProof`
EquivocationEvidenceFor<Self>,
>;
}
@@ -265,6 +268,66 @@ pub mod pallet {
)?;
Ok(Pays::No.into())
}

/// Report voter voting on invalid fork. This method will verify the
/// invalid fork proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence
/// will be reported.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))]
pub fn report_invalid_fork_vote(
origin: OriginFor<T>,
invalid_fork_proof: Box<
InvalidForkVoteProof<
BlockNumberFor<T>,
T::BeefyId,
<T::BeefyId as RuntimeAppPublic>::Signature,
>,
>,
key_owner_proof: T::KeyOwnerProof,
) -> DispatchResultWithPostInfo {
let reporter = ensure_signed(origin)?;

// TODO:
// T::EquivocationReportSystem::process_evidence(
// Some(reporter),
// (*invalid_fork_proof, key_owner_proof),
// )?;
// Waive the fee since the report is valid and beneficial
Ok(Pays::No.into())
}

/// Report voter voting on invalid fork. This method will verify the
/// invalid fork proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence
/// will be reported.
///
/// This extrinsic must be called unsigned and it is expected that only
/// block authors will call it (validated in `ValidateUnsigned`), as such
/// if the block author is defined it will be defined as the equivocation
/// reporter.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))]
pub fn report_invalid_fork_vote_unsigned(
origin: OriginFor<T>,
invalid_fork_proof: Box<
InvalidForkVoteProof<
BlockNumberFor<T>,
T::BeefyId,
<T::BeefyId as RuntimeAppPublic>::Signature,
>,
>,
key_owner_proof: T::KeyOwnerProof,
) -> DispatchResultWithPostInfo {
ensure_none(origin)?;

// TODO:
// T::EquivocationReportSystem::process_evidence(
// None,
// (*invalid_fork_proof, key_owner_proof),
// )?;
Ok(Pays::No.into())
}
}

#[pallet::validate_unsigned]