mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-16 07:15:41 +00:00
Aura consensus for parachains (#371)
* Update polkadot * Migrate all uses of MQC heads to merkle proofs * Mass rename `relay_parent_storage_root` * Restore parachain-system tests * Update polkadot and libp2p swarm for testing * Collapse match into an if let Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Start with something * Update Substrate & Polkadot * Start to make it compile * Make it compile * Begin with something * Yep * I'm a hacker * Bring back the builder * Make it work in some way * Compile * Parachains use their own "slot" * Adds cumulus-pallet-aura * Wrap AuRa import queue to disable equivocation checking by default * Pass slot duration * Check the seal when validating a block * Adds missing file * Try to make the seal working * Fix it * Some fixes * Bring in the latest features to cleanup the code * Update and make it compile * Improve the import * Start fixing * More work * Fix fix fix * Make everything compile * Small cleanups * Rename and more docs * Docs * Fixes fixes fixes * Update rococo-parachains/src/chain_spec.rs * Update client/consensus/aura/src/lib.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/aura/src/lib.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update primitives/parachain-inherent/Cargo.toml Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update primitives/parachain-inherent/Cargo.toml * Update primitives/parachain-inherent/Cargo.toml * Update primitives/parachain-inherent/Cargo.toml Co-authored-by: Sergei Shulepov <sergei@parity.io> Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -52,6 +52,7 @@ pub use pallet_timestamp::Call as TimestampCall;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
|
||||
// XCM imports
|
||||
use polkadot_parachain::primitives::Sibling;
|
||||
@@ -71,7 +72,9 @@ use frame_support::traits::Contains;
|
||||
pub type SessionHandlers = ();
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {}
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
}
|
||||
}
|
||||
|
||||
/// This runtime version.
|
||||
@@ -85,7 +88,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
transaction_version: 1,
|
||||
};
|
||||
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 12000;
|
||||
|
||||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||
|
||||
@@ -248,6 +251,8 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
pub const RocLocation: MultiLocation = X1(Parent);
|
||||
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
|
||||
@@ -419,14 +424,8 @@ impl pallet_assets::Config for Runtime {
|
||||
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encode_call() {
|
||||
let hash = hex_literal::hex!["0af9fef6f950ca3ac8ac4766200454b1039ffb7b2d0827fffd5e47bd43761437"].into();
|
||||
let call = Call::ParachainSystem(cumulus_pallet_parachain_system::Call::authorize_upgrade(hash));
|
||||
assert_eq!(
|
||||
hex::encode(codec::Encode::encode(&call)),
|
||||
"14030af9fef6f950ca3ac8ac4766200454b1039ffb7b2d0827fffd5e47bd43761437",
|
||||
);
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
construct_runtime! {
|
||||
@@ -447,6 +446,9 @@ construct_runtime! {
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
|
||||
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 31,
|
||||
|
||||
Aura: pallet_aura::{Pallet, Config<T>},
|
||||
AuraExt: cumulus_pallet_aura_ext::{Pallet, Config},
|
||||
|
||||
// XCM helpers.
|
||||
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
|
||||
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,
|
||||
@@ -496,7 +498,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
Executive::execute_block(block)
|
||||
Executive::execute_block(block);
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
@@ -556,6 +558,19 @@ impl_runtime_apis! {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block!(Runtime, Executive);
|
||||
cumulus_pallet_parachain_system::register_validate_block!(
|
||||
Runtime,
|
||||
cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user