Skip to content

Commit

Permalink
Millau, Rialto: accept equivocation reports (#2614) (#2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 authored and bkchr committed Apr 10, 2024
1 parent d4952b2 commit 08f1580
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 10 deletions.
4 changes: 4 additions & 0 deletions bridges/bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-beefy-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = ["historical"]}
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
Expand Down Expand Up @@ -100,6 +102,7 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-aura/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-beefy/std",
"pallet-beefy-mmr/std",
Expand All @@ -109,6 +112,7 @@ std = [
"pallet-bridge-relayers/std",
"pallet-grandpa/std",
"pallet-mmr/std",
"pallet-offences/std",
"pallet-session/std",
"pallet-shift-session-manager/std",
"pallet-sudo/std",
Expand Down
43 changes: 40 additions & 3 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, IdentityLookup, Keccak256, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, Perquintill,
ApplyExtrinsicResult, FixedPointNumber, KeyTypeId, Perquintill,
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
Expand Down Expand Up @@ -249,8 +249,9 @@ impl pallet_grandpa::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = ConstU32<10>;
type MaxSetIdSessionEntries = ConstU64<0>;
type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type EquivocationReportSystem =
pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
type MaxNominators = ConstU32<256>;
}

Expand Down Expand Up @@ -377,6 +378,7 @@ parameter_types! {
pub const Period: BlockNumber = bp_millau::SESSION_LENGTH;
pub const Offset: BlockNumber = 0;
pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs";
pub ReportLongevity: u64 = Period::get() * 10;
}

impl pallet_session::Config for Runtime {
Expand All @@ -392,6 +394,37 @@ impl pallet_session::Config for Runtime {
type WeightInfo = ();
}

impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = RuntimeCall;
}

impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type EventHandler = ();
}

pub struct FullIdentificationOf;
impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
fn convert(_: AccountId) -> Option<()> {
Some(())
}
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = ();
type FullIdentificationOf = FullIdentificationOf;
}

impl pallet_offences::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = ();
}

impl pallet_bridge_relayers::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Reward = Balance;
Expand Down Expand Up @@ -582,6 +615,10 @@ construct_runtime!(
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>},

// Consensus support.
Authorship: pallet_authorship::{Pallet, Storage},
Offences: pallet_offences::{Pallet, Storage, Event},
Historical: pallet_session::historical::{Pallet},

Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config<T>, Event},
ShiftSessionManager: pallet_shift_session_manager::{Pallet},
Expand Down
4 changes: 4 additions & 0 deletions bridges/bin/rialto/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-authority-discovery = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-babe = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-beefy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-beefy-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-mmr = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-offences = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false, features = ["historical"]}
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
Expand Down Expand Up @@ -94,6 +96,7 @@ std = [
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
"pallet-babe/std",
"pallet-balances/std",
"pallet-beefy/std",
Expand All @@ -105,6 +108,7 @@ std = [
"pallet-grandpa/std",
"pallet-message-queue/std",
"pallet-mmr/std",
"pallet-offences/std",
"pallet-xcm/std",
"pallet-session/std",
"pallet-shift-session-manager/std",
Expand Down
37 changes: 34 additions & 3 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, Block as BlockT, Keccak256, NumberFor, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, Perquintill,
ApplyExtrinsicResult, FixedPointNumber, KeyTypeId, Perquintill,
};
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
#[cfg(feature = "std")]
Expand Down Expand Up @@ -219,6 +219,7 @@ pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
parameter_types! {
pub const EpochDuration: u64 = bp_rialto::EPOCH_DURATION_IN_SLOTS as u64;
pub const ExpectedBlockTime: bp_rialto::Moment = bp_rialto::time_units::MILLISECS_PER_BLOCK;
pub ReportLongevity: u64 = EpochDuration::get() * 10;
}

impl pallet_babe::Config for Runtime {
Expand Down Expand Up @@ -257,8 +258,9 @@ impl pallet_grandpa::Config for Runtime {
type WeightInfo = ();
type MaxAuthorities = ConstU32<10>;
type MaxSetIdSessionEntries = ConstU64<0>;
type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
type KeyOwnerProof = <Historical as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type EquivocationReportSystem =
pallet_grandpa::EquivocationReportSystem<Self, Offences, Historical, ReportLongevity>;
type MaxNominators = ConstU32<256>;
}

Expand Down Expand Up @@ -383,6 +385,29 @@ impl pallet_session::Config for Runtime {
type WeightInfo = ();
}

impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
type EventHandler = ();
}

pub struct FullIdentificationOf;
impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
fn convert(_: AccountId) -> Option<()> {
Some(())
}
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = ();
type FullIdentificationOf = FullIdentificationOf;
}

impl pallet_offences::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = ();
}

impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = ConstU32<10>;
}
Expand Down Expand Up @@ -469,6 +494,12 @@ construct_runtime!(
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>},

// Consensus support.
// Authorship must be before session in order to note author in the correct session and era
// for im-online.
Authorship: pallet_authorship::{Pallet, Storage},
Offences: pallet_offences::{Pallet, Storage, Event},
Historical: pallet_session::historical::{Pallet},

AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config<T>, Event},
Expand Down
5 changes: 3 additions & 2 deletions bridges/relays/client-millau/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use relay_substrate_client::{
ChainWithTransactions, ChainWithUtilityPallet, Error as SubstrateError,
FullRuntimeUtilityPallet, NonceOf, SignParam, UnderlyingChainProvider, UnsignedTransaction,
};
use sp_core::{storage::StorageKey, Pair, Void};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
use sp_session::MembershipProof;
use std::time::Duration;

/// Millau header id.
Expand Down Expand Up @@ -70,7 +71,7 @@ impl ChainWithGrandpa for Millau {
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
MILLAU_SYNCED_HEADERS_GRANDPA_INFO_METHOD;

type KeyOwnerProof = Void;
type KeyOwnerProof = MembershipProof;
}

impl ChainWithBalances for Millau {
Expand Down
5 changes: 3 additions & 2 deletions bridges/relays/client-rialto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use relay_substrate_client::{
ChainWithTransactions, Error as SubstrateError, NonceOf, RelayChain, SignParam,
UnderlyingChainProvider, UnsignedTransaction,
};
use sp_core::{storage::StorageKey, Pair, Void};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount};
use sp_session::MembershipProof;
use std::time::Duration;

/// Rialto header id.
Expand Down Expand Up @@ -55,7 +56,7 @@ impl ChainWithGrandpa for Rialto {
const SYNCED_HEADERS_GRANDPA_INFO_METHOD: &'static str =
RIALTO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;

type KeyOwnerProof = Void;
type KeyOwnerProof = MembershipProof;
}

impl RelayChain for Rialto {
Expand Down

0 comments on commit 08f1580

Please sign in to comment.