Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AURA offence report system #1766

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion substrate/bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ pub fn new_partial(
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;

let import_queue =
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _, _>(ImportQueueParams {
block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(),
select_chain: select_chain.clone(),
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

Expand All @@ -129,6 +130,7 @@ pub fn new_partial(
registry: config.prometheus_registry(),
check_for_equivocation: Default::default(),
telemetry: telemetry.as_ref().map(|x| x.handle()),
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()),
compatibility_mode: Default::default(),
})?;

Expand Down
56 changes: 35 additions & 21 deletions substrate/bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,21 @@ impl frame_system::Config for Runtime {
impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type WeightInfo = pallet_aura::default_weights::SubstrateWeight<0>;
type MaxAuthorities = ConstU32<32>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;

type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
#[cfg(feature = "experimental")]
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
}

impl pallet_grandpa::Config for Runtime {
type RuntimeEvent = RuntimeEvent;

type WeightInfo = ();
type MaxAuthorities = ConstU32<32>;
type MaxNominators = ConstU32<0>;
type MaxSetIdSessionEntries = ConstU64<0>;

type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
}
Expand Down Expand Up @@ -408,6 +408,18 @@ impl_runtime_apis! {
}
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
}

fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
}
}

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
Expand All @@ -416,17 +428,22 @@ impl_runtime_apis! {
fn authorities() -> Vec<AuraId> {
Aura::authorities().into_inner()
}
}

impl sp_session::SessionKeys<Block> for Runtime {
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
opaque::SessionKeys::generate(seed)
fn generate_key_ownership_proof(
_slot: sp_consensus_aura::Slot,
_authority_id: AuraId,
) -> Option<sp_consensus_aura::OpaqueKeyOwnershipProof> {
None
}

fn decode_session_keys(
encoded: Vec<u8>,
) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {
opaque::SessionKeys::decode_into_raw_public_keys(&encoded)
fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: sp_consensus_aura::EquivocationProof<
<Block as BlockT>::Header,
AuraId,
>,
_key_owner_proof: sp_consensus_aura::OpaqueKeyOwnershipProof,
) -> Option<()> {
None
}
}

Expand All @@ -439,6 +456,13 @@ impl_runtime_apis! {
Grandpa::current_set_id()
}

fn generate_key_ownership_proof(
_set_id: sp_consensus_grandpa::SetId,
_authority_id: GrandpaId,
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
None
}

fn submit_report_equivocation_unsigned_extrinsic(
_equivocation_proof: sp_consensus_grandpa::EquivocationProof<
<Block as BlockT>::Hash,
Expand All @@ -448,16 +472,6 @@ impl_runtime_apis! {
) -> Option<()> {
None
}

fn generate_key_ownership_proof(
_set_id: sp_consensus_grandpa::SetId,
_authority_id: GrandpaId,
) -> Option<sp_consensus_grandpa::OpaqueKeyOwnershipProof> {
// NOTE: this is the only implementation possible since we've
// defined our key owner proof type as a bottom type (i.e. a type
// with no values).
None
}
}

impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
Expand Down
1 change: 1 addition & 0 deletions substrate/client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sc-client-api = { path = "../../api" }
sc-consensus = { path = "../common" }
sc-consensus-slots = { path = "../slots" }
sc-telemetry = { path = "../../telemetry" }
sc-transaction-pool-api = { path = "../../transaction-pool/api" }
sp-api = { path = "../../../primitives/api" }
sp-application-crypto = { path = "../../../primitives/application-crypto" }
sp-block-builder = { path = "../../../primitives/block-builder" }
Expand Down
Loading
Loading