Update Substrate Dependency (#566)

* Update `sp-io` dependency

* Rename Trait to Config

* RustFmt

* Bump `sp-io` again

* Use new frame_system weight types in Rialto and Millau runtimes

* Update test Runtimes to use new weight types

* Bump `sp-io` again

* Update to not-the latest first.

* Update benchmarks.

* Another Trai.

* Move new weight types into runtime primitive crates

This allows us to check limits for extrinsics from other parts
of the codebase without pulling in the entire chain runtime.

* Remove leftover comments

* Move new functions to a better location

* Small formatting fixes

* Add actual documentation to new weight config types

* Decrease maximum block weight of Millau chain

* Decreease maximum block length of Millau chain

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
Hernando Castano
2020-12-16 04:52:53 -05:00
committed by Bastian Köcher
parent 8a5b51a944
commit ee655b1057
31 changed files with 328 additions and 293 deletions
+1 -1
View File
@@ -218,7 +218,7 @@ benchmarks_instance! {
}
}
fn initialize_bench<T: Trait<I>, I: Instance>(num_validators: usize) -> AuraHeader {
fn initialize_bench<T: Config<I>, I: Instance>(num_validators: usize) -> AuraHeader {
// Initialize storage with some initial header
let initial_header = build_genesis_header(&validator(0));
let initial_difficulty = initial_header.difficulty;
+9 -9
View File
@@ -370,7 +370,7 @@ impl<AccountId> OnHeadersSubmitted<AccountId> for () {
}
/// The module configuration trait.
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
pub trait Config<I = DefaultInstance>: frame_system::Config {
/// Aura configuration.
type AuraConfiguration: Get<AuraConfiguration>;
/// Validators configuration.
@@ -393,7 +393,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
}
decl_module! {
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {
pub struct Module<T: Config<I>, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {
/// Import single Aura header. Requires transaction to be **UNSIGNED**.
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
pub fn import_unsigned_header(origin, header: AuraHeader, receipts: Option<Vec<Receipt>>) {
@@ -457,7 +457,7 @@ decl_module! {
}
decl_storage! {
trait Store for Module<T: Trait<I>, I: Instance = DefaultInstance> as Bridge {
trait Store for Module<T: Config<I>, I: Instance = DefaultInstance> as Bridge {
/// Best known block.
BestBlock: (HeaderId, U256);
/// Best finalized block.
@@ -505,7 +505,7 @@ decl_storage! {
}
}
impl<T: Trait<I>, I: Instance> Module<T, I> {
impl<T: Config<I>, I: Instance> Module<T, I> {
/// Returns number and hash of the best block known to the bridge module.
/// The caller should only submit `import_header` transaction that makes
/// (or leads to making) other header the best one.
@@ -542,7 +542,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
}
}
impl<T: Trait<I>, I: Instance> frame_support::unsigned::ValidateUnsigned for Module<T, I> {
impl<T: Config<I>, I: Instance> frame_support::unsigned::ValidateUnsigned for Module<T, I> {
type Call = Call<T, I>;
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
@@ -584,7 +584,7 @@ impl<T: Trait<I>, I: Instance> frame_support::unsigned::ValidateUnsigned for Mod
#[derive(Default)]
pub struct BridgeStorage<T, I = DefaultInstance>(sp_std::marker::PhantomData<(T, I)>);
impl<T: Trait<I>, I: Instance> BridgeStorage<T, I> {
impl<T: Config<I>, I: Instance> BridgeStorage<T, I> {
/// Create new BridgeStorage.
pub fn new() -> Self {
BridgeStorage(sp_std::marker::PhantomData::<(T, I)>::default())
@@ -683,7 +683,7 @@ impl<T: Trait<I>, I: Instance> BridgeStorage<T, I> {
}
}
impl<T: Trait<I>, I: Instance> Storage for BridgeStorage<T, I> {
impl<T: Config<I>, I: Instance> Storage for BridgeStorage<T, I> {
type Submitter = T::AccountId;
fn best_block(&self) -> (HeaderId, U256) {
@@ -863,7 +863,7 @@ impl<T: Trait<I>, I: Instance> Storage for BridgeStorage<T, I> {
/// Initialize storage.
#[cfg(any(feature = "std", feature = "runtime-benchmarks"))]
pub(crate) fn initialize_storage<T: Trait<I>, I: Instance>(
pub(crate) fn initialize_storage<T: Config<I>, I: Instance>(
initial_header: &AuraHeader,
initial_difficulty: U256,
initial_validators: &[Address],
@@ -1263,7 +1263,7 @@ pub(crate) mod tests {
fn finality_votes_are_cached() {
run_test(TOTAL_VALIDATORS, |ctx| {
let mut storage = BridgeStorage::<TestRuntime>::new();
let interval = <TestRuntime as Trait>::FinalityVotesCachingInterval::get().unwrap();
let interval = <TestRuntime as Config>::FinalityVotesCachingInterval::get().unwrap();
// for all headers with number < interval, cache entry is not created
for i in 1..interval {
+6 -10
View File
@@ -18,7 +18,7 @@ pub use crate::test_utils::{insert_header, validator_utils::*, validators_change
pub use bp_eth_poa::signatures::secret_to_address;
use crate::validators::{ValidatorsConfiguration, ValidatorsSource};
use crate::{AuraConfiguration, ChainTime, GenesisConfig, PruningStrategy, Trait};
use crate::{AuraConfiguration, ChainTime, Config, GenesisConfig, PruningStrategy};
use bp_eth_poa::{Address, AuraHeader, H256, U256};
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use secp256k1::SecretKey;
@@ -44,7 +44,7 @@ parameter_types! {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
impl frame_system::Trait for TestRuntime {
impl frame_system::Config for TestRuntime {
type Origin = Origin;
type Index = u64;
type Call = ();
@@ -56,13 +56,6 @@ impl frame_system::Trait for TestRuntime {
type Header = SubstrateHeader;
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type BlockExecutionWeight = ();
type ExtrinsicBaseWeight = ();
type MaximumExtrinsicWeight = ();
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type PalletInfo = ();
type AccountData = ();
@@ -70,6 +63,9 @@ impl frame_system::Trait for TestRuntime {
type OnKilledAccount = ();
type BaseCallFilter = ();
type SystemWeightInfo = ();
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
}
parameter_types! {
@@ -78,7 +74,7 @@ parameter_types! {
pub TestValidatorsConfiguration: ValidatorsConfiguration = test_validators_config();
}
impl Trait for TestRuntime {
impl Config for TestRuntime {
type AuraConfiguration = TestAuraConfiguration;
type ValidatorsConfiguration = TestValidatorsConfiguration;
type FinalityVotesCachingInterval = TestFinalityVotesCachingInterval;
+3 -3
View File
@@ -27,7 +27,7 @@
use crate::finality::FinalityVotes;
use crate::validators::CHANGE_EVENT_HASH;
use crate::verification::calculate_score;
use crate::{HeaderToImport, Storage, Trait};
use crate::{Config, HeaderToImport, Storage};
use bp_eth_poa::{
rlp_encode,
@@ -73,7 +73,7 @@ impl HeaderBuilder {
}
/// Creates default header on top of parent with given hash.
pub fn with_parent_hash_on_runtime<T: Trait<I>, I: crate::Instance>(parent_hash: H256) -> Self {
pub fn with_parent_hash_on_runtime<T: Config<I>, I: crate::Instance>(parent_hash: H256) -> Self {
use crate::Headers;
use frame_support::StorageMap;
@@ -82,7 +82,7 @@ impl HeaderBuilder {
}
/// Creates default header on top of parent with given number. First parent is selected.
pub fn with_parent_number_on_runtime<T: Trait<I>, I: crate::Instance>(parent_number: u64) -> Self {
pub fn with_parent_number_on_runtime<T: Config<I>, I: crate::Instance>(parent_number: u64) -> Self {
use crate::HeadersByNumber;
use frame_support::StorageMap;