mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
companion: Babe remove inherent (#2438)
This commit is contained in:
committed by
GitHub
parent
b28e1b4e74
commit
8734cf62b2
Generated
+142
-140
File diff suppressed because it is too large
Load Diff
@@ -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, ×tamp)
|
||||
.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,
|
||||
|
||||
Reference in New Issue
Block a user