mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 20:21:06 +00:00
babe: enable equivocation reporting on all runtimes (#1330)
* enable BABE equivocation reporting on all runtimes * runtime: fix parachains mock test runtime * cargo update -p sp-io Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Generated
+154
-136
File diff suppressed because it is too large
Load Diff
@@ -196,7 +196,7 @@ macro_rules! new_full_start {
|
|||||||
grandpa::block_import_with_authority_set_hard_forks(
|
grandpa::block_import_with_authority_set_hard_forks(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
&(client.clone() as Arc<_>),
|
&(client.clone() as Arc<_>),
|
||||||
select_chain,
|
select_chain.clone(),
|
||||||
grandpa_hard_forks,
|
grandpa_hard_forks,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -214,6 +214,7 @@ macro_rules! new_full_start {
|
|||||||
Some(Box::new(justification_import)),
|
Some(Box::new(justification_import)),
|
||||||
None,
|
None,
|
||||||
client,
|
client,
|
||||||
|
select_chain,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
@@ -517,14 +518,18 @@ macro_rules! new_light {
|
|||||||
client,
|
client,
|
||||||
backend,
|
backend,
|
||||||
fetcher,
|
fetcher,
|
||||||
_select_chain,
|
mut select_chain,
|
||||||
_,
|
_,
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
| {
|
| {
|
||||||
|
let select_chain = select_chain.take()
|
||||||
|
.ok_or_else(|| service::Error::SelectChainRequired)?;
|
||||||
|
|
||||||
let fetch_checker = fetcher
|
let fetch_checker = fetcher
|
||||||
.map(|fetcher| fetcher.checker().clone())
|
.map(|fetcher| fetcher.checker().clone())
|
||||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||||
|
|
||||||
let grandpa_block_import = grandpa::light_block_import(
|
let grandpa_block_import = grandpa::light_block_import(
|
||||||
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
|
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
|
||||||
)?;
|
)?;
|
||||||
@@ -546,6 +551,7 @@ macro_rules! new_light {
|
|||||||
None,
|
None,
|
||||||
Some(Box::new(finality_proof_import)),
|
Some(Box::new(finality_proof_import)),
|
||||||
client,
|
client,
|
||||||
|
select_chain,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
|
|||||||
@@ -1834,6 +1834,20 @@ mod tests {
|
|||||||
|
|
||||||
// session module is the trigger
|
// session module is the trigger
|
||||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||||
|
|
||||||
|
type KeyOwnerProofSystem = ();
|
||||||
|
|
||||||
|
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::Proof;
|
||||||
|
|
||||||
|
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::IdentificationTuple;
|
||||||
|
|
||||||
|
type HandleEquivocation = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
|
|||||||
@@ -169,6 +169,21 @@ impl babe::Trait for Runtime {
|
|||||||
|
|
||||||
// session module is the trigger
|
// session module is the trigger
|
||||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||||
|
|
||||||
|
type KeyOwnerProofSystem = Historical;
|
||||||
|
|
||||||
|
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::Proof;
|
||||||
|
|
||||||
|
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::IdentificationTuple;
|
||||||
|
|
||||||
|
type HandleEquivocation =
|
||||||
|
babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -913,7 +928,7 @@ construct_runtime! {
|
|||||||
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Storage},
|
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Storage},
|
||||||
|
|
||||||
// Must be before session.
|
// Must be before session.
|
||||||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp), ValidateUnsigned},
|
||||||
|
|
||||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||||
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
@@ -1170,6 +1185,29 @@ sp_api::impl_runtime_apis! {
|
|||||||
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
||||||
Babe::current_epoch_start()
|
Babe::current_epoch_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_key_ownership_proof(
|
||||||
|
_slot_number: babe_primitives::SlotNumber,
|
||||||
|
authority_id: babe_primitives::AuthorityId,
|
||||||
|
) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
|
||||||
|
use codec::Encode;
|
||||||
|
|
||||||
|
Historical::prove((babe_primitives::KEY_TYPE, authority_id))
|
||||||
|
.map(|p| p.encode())
|
||||||
|
.map(babe_primitives::OpaqueKeyOwnershipProof::new)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit_report_equivocation_unsigned_extrinsic(
|
||||||
|
equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
|
||||||
|
key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
|
||||||
|
) -> Option<()> {
|
||||||
|
let key_owner_proof = key_owner_proof.decode()?;
|
||||||
|
|
||||||
|
Babe::submit_unsigned_equivocation_report(
|
||||||
|
equivocation_proof,
|
||||||
|
key_owner_proof,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
||||||
|
|||||||
@@ -200,6 +200,21 @@ impl babe::Trait for Runtime {
|
|||||||
|
|
||||||
// session module is the trigger
|
// session module is the trigger
|
||||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||||
|
|
||||||
|
type KeyOwnerProofSystem = Historical;
|
||||||
|
|
||||||
|
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::Proof;
|
||||||
|
|
||||||
|
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::IdentificationTuple;
|
||||||
|
|
||||||
|
type HandleEquivocation =
|
||||||
|
babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -919,7 +934,7 @@ construct_runtime! {
|
|||||||
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
|
Scheduler: scheduler::{Module, Call, Storage, Event<T>},
|
||||||
|
|
||||||
// Must be before session.
|
// Must be before session.
|
||||||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp), ValidateUnsigned},
|
||||||
|
|
||||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||||
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
@@ -1171,6 +1186,29 @@ sp_api::impl_runtime_apis! {
|
|||||||
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
||||||
Babe::current_epoch_start()
|
Babe::current_epoch_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_key_ownership_proof(
|
||||||
|
_slot_number: babe_primitives::SlotNumber,
|
||||||
|
authority_id: babe_primitives::AuthorityId,
|
||||||
|
) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
|
||||||
|
use codec::Encode;
|
||||||
|
|
||||||
|
Historical::prove((babe_primitives::KEY_TYPE, authority_id))
|
||||||
|
.map(|p| p.encode())
|
||||||
|
.map(babe_primitives::OpaqueKeyOwnershipProof::new)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit_report_equivocation_unsigned_extrinsic(
|
||||||
|
equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
|
||||||
|
key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
|
||||||
|
) -> Option<()> {
|
||||||
|
let key_owner_proof = key_owner_proof.decode()?;
|
||||||
|
|
||||||
|
Babe::submit_unsigned_equivocation_report(
|
||||||
|
equivocation_proof,
|
||||||
|
key_owner_proof,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
||||||
|
|||||||
@@ -175,6 +175,20 @@ impl babe::Trait for Runtime {
|
|||||||
|
|
||||||
// session module is the trigger
|
// session module is the trigger
|
||||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||||
|
|
||||||
|
type KeyOwnerProofSystem = ();
|
||||||
|
|
||||||
|
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::Proof;
|
||||||
|
|
||||||
|
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::IdentificationTuple;
|
||||||
|
|
||||||
|
type HandleEquivocation = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -704,6 +718,20 @@ sp_api::impl_runtime_apis! {
|
|||||||
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
||||||
Babe::current_epoch_start()
|
Babe::current_epoch_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_key_ownership_proof(
|
||||||
|
_slot_number: babe_primitives::SlotNumber,
|
||||||
|
_authority_id: babe_primitives::AuthorityId,
|
||||||
|
) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit_report_equivocation_unsigned_extrinsic(
|
||||||
|
_equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
|
||||||
|
_key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
|
||||||
|
) -> Option<()> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sp_session::SessionKeys<Block> for Runtime {
|
impl sp_session::SessionKeys<Block> for Runtime {
|
||||||
|
|||||||
@@ -159,6 +159,21 @@ impl babe::Trait for Runtime {
|
|||||||
|
|
||||||
// session module is the trigger
|
// session module is the trigger
|
||||||
type EpochChangeTrigger = babe::ExternalTrigger;
|
type EpochChangeTrigger = babe::ExternalTrigger;
|
||||||
|
|
||||||
|
type KeyOwnerProofSystem = Historical;
|
||||||
|
|
||||||
|
type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::Proof;
|
||||||
|
|
||||||
|
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
|
||||||
|
KeyTypeId,
|
||||||
|
babe::AuthorityId,
|
||||||
|
)>>::IdentificationTuple;
|
||||||
|
|
||||||
|
type HandleEquivocation =
|
||||||
|
babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -677,7 +692,7 @@ construct_runtime! {
|
|||||||
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Storage},
|
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Storage},
|
||||||
|
|
||||||
// Must be before session.
|
// Must be before session.
|
||||||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp), ValidateUnsigned},
|
||||||
|
|
||||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||||
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
Indices: indices::{Module, Call, Storage, Config<T>, Event<T>},
|
||||||
@@ -915,6 +930,29 @@ sp_api::impl_runtime_apis! {
|
|||||||
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
fn current_epoch_start() -> babe_primitives::SlotNumber {
|
||||||
Babe::current_epoch_start()
|
Babe::current_epoch_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn generate_key_ownership_proof(
|
||||||
|
_slot_number: babe_primitives::SlotNumber,
|
||||||
|
authority_id: babe_primitives::AuthorityId,
|
||||||
|
) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
|
||||||
|
use codec::Encode;
|
||||||
|
|
||||||
|
Historical::prove((babe_primitives::KEY_TYPE, authority_id))
|
||||||
|
.map(|p| p.encode())
|
||||||
|
.map(babe_primitives::OpaqueKeyOwnershipProof::new)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit_report_equivocation_unsigned_extrinsic(
|
||||||
|
equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
|
||||||
|
key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
|
||||||
|
) -> Option<()> {
|
||||||
|
let key_owner_proof = key_owner_proof.decode()?;
|
||||||
|
|
||||||
|
Babe::submit_unsigned_equivocation_report(
|
||||||
|
equivocation_proof,
|
||||||
|
key_owner_proof,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ macro_rules! new_full_start {
|
|||||||
grandpa::block_import_with_authority_set_hard_forks(
|
grandpa::block_import_with_authority_set_hard_forks(
|
||||||
client.clone(),
|
client.clone(),
|
||||||
&(client.clone() as Arc<_>),
|
&(client.clone() as Arc<_>),
|
||||||
select_chain,
|
select_chain.clone(),
|
||||||
grandpa_hard_forks,
|
grandpa_hard_forks,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -210,6 +210,7 @@ macro_rules! new_full_start {
|
|||||||
Some(Box::new(justification_import)),
|
Some(Box::new(justification_import)),
|
||||||
None,
|
None,
|
||||||
client,
|
client,
|
||||||
|
select_chain,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
@@ -573,14 +574,18 @@ macro_rules! new_light {
|
|||||||
client,
|
client,
|
||||||
backend,
|
backend,
|
||||||
fetcher,
|
fetcher,
|
||||||
_select_chain,
|
mut select_chain,
|
||||||
_,
|
_,
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
| {
|
| {
|
||||||
|
let select_chain = select_chain.take()
|
||||||
|
.ok_or_else(|| service::Error::SelectChainRequired)?;
|
||||||
|
|
||||||
let fetch_checker = fetcher
|
let fetch_checker = fetcher
|
||||||
.map(|fetcher| fetcher.checker().clone())
|
.map(|fetcher| fetcher.checker().clone())
|
||||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||||
|
|
||||||
let grandpa_block_import = grandpa::light_block_import(
|
let grandpa_block_import = grandpa::light_block_import(
|
||||||
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
|
client.clone(), backend, &(client.clone() as Arc<_>), Arc::new(fetch_checker)
|
||||||
)?;
|
)?;
|
||||||
@@ -602,6 +607,7 @@ macro_rules! new_light {
|
|||||||
None,
|
None,
|
||||||
Some(Box::new(finality_proof_import)),
|
Some(Box::new(finality_proof_import)),
|
||||||
client,
|
client,
|
||||||
|
select_chain,
|
||||||
inherent_data_providers.clone(),
|
inherent_data_providers.clone(),
|
||||||
spawn_task_handle,
|
spawn_task_handle,
|
||||||
registry,
|
registry,
|
||||||
|
|||||||
Reference in New Issue
Block a user