Unverified Commit 0409d123 authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

companion: Babe remove inherent (#2438)

parent cb0570d8
Pipeline #124383 canceled with stages
in 5 minutes and 21 seconds
This diff is collapsed.
......@@ -25,6 +25,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
[dev-dependencies]
......
......@@ -17,8 +17,9 @@
use crate::{Client, FullBackend};
use polkadot_test_runtime::{GetLastTimestamp, UncheckedExtrinsic};
use polkadot_primitives::v1::Block;
use sp_runtime::generic::BlockId;
use sp_runtime::{generic::BlockId, Digest, DigestItem};
use sp_api::ProvideRuntimeApi;
use sp_consensus_babe::{BABE_ENGINE_ID, digests::{PreDigest, SecondaryPlainPreDigest}};
use sc_block_builder::{BlockBuilderProvider, BlockBuilder};
use sp_state_machine::BasicExternalities;
use parity_scale_codec::{Encode, Decode};
......@@ -52,10 +53,6 @@ impl InitPolkadotBlockBuilder for Client {
&self,
at: &BlockId<Block>,
) -> BlockBuilder<Block, Client, FullBackend> {
let mut block_builder = self.new_block_at(at, Default::default(), false)
.expect("Creates new block builder for test runtime");
let mut inherent_data = sp_inherents::InherentData::new();
let last_timestamp = self
.runtime_api()
.get_last_timestamp(&at)
......@@ -67,6 +64,29 @@ impl InitPolkadotBlockBuilder for Client {
let timestamp = last_timestamp + minimum_period;
// `SlotDuration` is a storage parameter type that requires externalities to access the value.
let slot_duration = BasicExternalities::new_empty()
.execute_with(|| polkadot_test_runtime::SlotDuration::get());
let slot = (timestamp / slot_duration).into();
let digest = Digest {
logs: vec![
DigestItem::PreRuntime(
BABE_ENGINE_ID,
PreDigest::SecondaryPlain(SecondaryPlainPreDigest {
slot,
authority_index: 42,
}).encode()
),
],
};
let mut block_builder = self.new_block_at(at, digest, false)
.expect("Creates new block builder for test runtime");
let mut inherent_data = sp_inherents::InherentData::new();
inherent_data
.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Put timestamp inherent data");
......
......@@ -980,7 +980,7 @@ construct_runtime! {
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Storage} = 32,
// Must be before session.
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned} = 1,
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned} = 1,
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent} = 2,
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>} = 3,
......
......@@ -985,7 +985,7 @@ construct_runtime! {
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>} = 1,
// Must be before session.
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned} = 2,
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned} = 2,
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent} = 3,
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>} = 4,
......
......@@ -168,7 +168,7 @@ construct_runtime! {
System: frame_system::{Module, Call, Storage, Config, Event<T>},
// Must be before session.
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned},
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
......
......@@ -491,7 +491,7 @@ construct_runtime! {
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Storage},
// Must be before session.
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent},
Babe: pallet_babe::{Module, Call, Storage, Config},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>},
......
......@@ -690,7 +690,7 @@ construct_runtime! {
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Storage} = 25,
// Must be before session.
Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned} = 1,
Babe: pallet_babe::{Module, Call, Storage, Config, ValidateUnsigned} = 1,
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent} = 2,
Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>} = 3,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment