mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 10:41:01 +00:00
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:
committed by
Bastian Köcher
parent
8a5b51a944
commit
ee655b1057
@@ -95,9 +95,9 @@ pub struct MessagePayload<SourceChainAccountId, TargetChainAccountPublic, Target
|
||||
}
|
||||
|
||||
/// The module configuration trait.
|
||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Config>::Event>;
|
||||
/// Id of the message. Whenever message is passed to the dispatch module, it emits
|
||||
/// event with this id + dispatch result. Could be e.g. (LaneId, MessageNonce) if
|
||||
/// it comes from message-lane module.
|
||||
@@ -113,7 +113,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
type Call: Parameter
|
||||
+ GetDispatchInfo
|
||||
+ Dispatchable<
|
||||
Origin = <Self as frame_system::Trait>::Origin,
|
||||
Origin = <Self as frame_system::Config>::Origin,
|
||||
PostInfo = frame_support::dispatch::PostDispatchInfo,
|
||||
>;
|
||||
/// A type which can be turned into an AccountId from a 256-bit hash.
|
||||
@@ -123,12 +123,12 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance = DefaultInstance> as CallDispatch {}
|
||||
trait Store for Module<T: Config<I>, I: Instance = DefaultInstance> as CallDispatch {}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I = DefaultInstance> where
|
||||
<T as Trait<I>>::MessageId
|
||||
<T as Config<I>>::MessageId
|
||||
{
|
||||
/// Message has been rejected by dispatcher because of spec version mismatch.
|
||||
/// Last two arguments are: expected and passed spec version.
|
||||
@@ -147,18 +147,18 @@ decl_event!(
|
||||
|
||||
decl_module! {
|
||||
/// Call Dispatch FRAME Pallet.
|
||||
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 {
|
||||
/// Deposit one of this module's events by using the default implementation.
|
||||
fn deposit_event() = default;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> MessageDispatch<T::MessageId> for Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> MessageDispatch<T::MessageId> for Module<T, I> {
|
||||
type Message = MessagePayload<
|
||||
T::SourceChainAccountId,
|
||||
T::TargetChainAccountPublic,
|
||||
T::TargetChainSignature,
|
||||
<T as Trait<I>>::Call,
|
||||
<T as Config<I>>::Call,
|
||||
>;
|
||||
|
||||
fn dispatch_weight(message: &Self::Message) -> Weight {
|
||||
@@ -168,7 +168,7 @@ impl<T: Trait<I>, I: Instance> MessageDispatch<T::MessageId> for Module<T, I> {
|
||||
fn dispatch(bridge: InstanceId, id: T::MessageId, message: Self::Message) {
|
||||
// verify spec version
|
||||
// (we want it to be the same, because otherwise we may decode Call improperly)
|
||||
let expected_version = <T as frame_system::Trait>::Version::get().spec_version;
|
||||
let expected_version = <T as frame_system::Config>::Version::get().spec_version;
|
||||
if message.spec_version != expected_version {
|
||||
frame_support::debug::trace!(
|
||||
"Message {:?}/{:?}: spec_version mismatch. Expected {:?}, got {:?}",
|
||||
@@ -384,7 +384,7 @@ mod tests {
|
||||
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 = Call;
|
||||
@@ -396,13 +396,6 @@ mod tests {
|
||||
type Header = Header;
|
||||
type Event = TestEvent;
|
||||
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 = ();
|
||||
@@ -410,9 +403,12 @@ mod tests {
|
||||
type OnKilledAccount = ();
|
||||
type BaseCallFilter = ();
|
||||
type SystemWeightInfo = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TestRuntime {
|
||||
impl Config for TestRuntime {
|
||||
type Event = TestEvent;
|
||||
type MessageId = MessageId;
|
||||
type SourceChainAccountId = AccountId;
|
||||
@@ -435,7 +431,7 @@ mod tests {
|
||||
fn prepare_message(
|
||||
origin: CallOrigin<AccountId, TestAccountPublic, TestSignature>,
|
||||
call: Call,
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Trait>::MessageId>>::Message {
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Config>::MessageId>>::Message {
|
||||
MessagePayload {
|
||||
spec_version: TEST_SPEC_VERSION,
|
||||
weight: TEST_WEIGHT,
|
||||
@@ -446,20 +442,20 @@ mod tests {
|
||||
|
||||
fn prepare_root_message(
|
||||
call: Call,
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Trait>::MessageId>>::Message {
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Config>::MessageId>>::Message {
|
||||
prepare_message(CallOrigin::SourceRoot, call)
|
||||
}
|
||||
|
||||
fn prepare_target_message(
|
||||
call: Call,
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Trait>::MessageId>>::Message {
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Config>::MessageId>>::Message {
|
||||
let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1));
|
||||
prepare_message(origin, call)
|
||||
}
|
||||
|
||||
fn prepare_source_message(
|
||||
call: Call,
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Trait>::MessageId>>::Message {
|
||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Config>::MessageId>>::Message {
|
||||
let origin = CallOrigin::SourceAccount(1);
|
||||
prepare_message(origin, call)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! So we are giving runtime opportunity to prepare environment and construct proof
|
||||
//! before invoking module calls.
|
||||
|
||||
use super::{BaseHeaderChain, Call, Instance, Module as CurrencyExchangeModule, Trait as CurrencyExchangeTrait};
|
||||
use super::{BaseHeaderChain, Call, Config as CurrencyExchangeConfig, Instance, Module as CurrencyExchangeModule};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use frame_benchmarking::{account, benchmarks_instance};
|
||||
@@ -29,7 +29,7 @@ const WORST_TX_SIZE_FACTOR: u32 = 1000;
|
||||
const WORST_PROOF_SIZE_FACTOR: u32 = 1000;
|
||||
|
||||
/// Module we're benchmarking here.
|
||||
pub struct Module<T: Trait<I>, I: Instance>(CurrencyExchangeModule<T, I>);
|
||||
pub struct Module<T: Config<I>, I: Instance>(CurrencyExchangeModule<T, I>);
|
||||
|
||||
/// Proof benchmarking parameters.
|
||||
pub struct ProofParams<Recipient> {
|
||||
@@ -45,12 +45,12 @@ pub struct ProofParams<Recipient> {
|
||||
pub proof_size_factor: u32,
|
||||
}
|
||||
|
||||
/// Trait that must be implemented by runtime.
|
||||
pub trait Trait<I: Instance>: CurrencyExchangeTrait<I> {
|
||||
/// Config that must be implemented by runtime.
|
||||
pub trait Config<I: Instance>: CurrencyExchangeConfig<I> {
|
||||
/// Prepare proof for importing exchange transaction.
|
||||
fn make_proof(
|
||||
proof_params: ProofParams<Self::AccountId>,
|
||||
) -> <<Self as CurrencyExchangeTrait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof;
|
||||
) -> <<Self as CurrencyExchangeConfig<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof;
|
||||
}
|
||||
|
||||
benchmarks_instance! {
|
||||
|
||||
@@ -35,7 +35,7 @@ pub trait OnTransactionSubmitted<AccountId> {
|
||||
}
|
||||
|
||||
/// The module configuration trait
|
||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||
/// Handler for transaction submission result.
|
||||
type OnTransactionSubmitted: OnTransactionSubmitted<Self::AccountId>;
|
||||
/// Represents the blockchain that we'll be exchanging currency with.
|
||||
@@ -61,7 +61,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait<I>, I: Instance> {
|
||||
pub enum Error for Module<T: Config<I>, I: Instance> {
|
||||
/// Invalid peer blockchain transaction provided.
|
||||
InvalidTransaction,
|
||||
/// Peer transaction has invalid amount.
|
||||
@@ -84,12 +84,12 @@ decl_error! {
|
||||
}
|
||||
|
||||
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 {
|
||||
/// Imports lock fund transaction of the peer blockchain.
|
||||
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||
pub fn import_peer_transaction(
|
||||
origin,
|
||||
proof: <<T as Trait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||
proof: <<T as Config<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||
) -> DispatchResult {
|
||||
let submitter = frame_system::ensure_signed(origin)?;
|
||||
|
||||
@@ -125,13 +125,13 @@ 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 {
|
||||
/// All transfers that have already been claimed.
|
||||
Transfers: map hasher(blake2_128_concat) <T::PeerMaybeLockFundsTransaction as MaybeLockFundsTransaction>::Id => ();
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
/// Returns true if currency exchange module is able to import given transaction proof in
|
||||
/// its current state.
|
||||
pub fn filter_transaction_proof(proof: &<T::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof) -> bool {
|
||||
@@ -149,7 +149,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> From<ExchangeError> for Error<T, I> {
|
||||
impl<T: Config<I>, I: Instance> From<ExchangeError> for Error<T, I> {
|
||||
fn from(error: ExchangeError) -> Self {
|
||||
match error {
|
||||
ExchangeError::InvalidTransaction => Error::InvalidTransaction,
|
||||
@@ -168,7 +168,7 @@ impl<AccountId> OnTransactionSubmitted<AccountId> for () {
|
||||
}
|
||||
|
||||
/// Exchange deposit details.
|
||||
struct DepositDetails<T: Trait<I>, I: Instance> {
|
||||
struct DepositDetails<T: Config<I>, I: Instance> {
|
||||
/// Transfer id.
|
||||
pub transfer_id: <T::PeerMaybeLockFundsTransaction as MaybeLockFundsTransaction>::Id,
|
||||
/// Transfer recipient.
|
||||
@@ -179,16 +179,16 @@ struct DepositDetails<T: Trait<I>, I: Instance> {
|
||||
|
||||
/// Verify and parse transaction proof, preparing everything required for importing
|
||||
/// this transaction proof.
|
||||
fn prepare_deposit_details<T: Trait<I>, I: Instance>(
|
||||
proof: &<<T as Trait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||
fn prepare_deposit_details<T: Config<I>, I: Instance>(
|
||||
proof: &<<T as Config<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||
) -> Result<DepositDetails<T, I>, Error<T, I>> {
|
||||
// ensure that transaction is included in finalized block that we know of
|
||||
let transaction = <T as Trait<I>>::PeerBlockchain::verify_transaction_inclusion_proof(proof)
|
||||
let transaction = <T as Config<I>>::PeerBlockchain::verify_transaction_inclusion_proof(proof)
|
||||
.ok_or(Error::<T, I>::UnfinalizedTransaction)?;
|
||||
|
||||
// parse transaction
|
||||
let transaction =
|
||||
<T as Trait<I>>::PeerMaybeLockFundsTransaction::parse(&transaction).map_err(Error::<T, I>::from)?;
|
||||
<T as Config<I>>::PeerMaybeLockFundsTransaction::parse(&transaction).map_err(Error::<T, I>::from)?;
|
||||
let transfer_id = transaction.id;
|
||||
ensure!(
|
||||
!Transfers::<T, I>::contains_key(&transfer_id),
|
||||
@@ -325,7 +325,7 @@ mod tests {
|
||||
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 = ();
|
||||
@@ -337,13 +337,6 @@ mod tests {
|
||||
type Header = Header;
|
||||
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 = ();
|
||||
@@ -351,9 +344,12 @@ mod tests {
|
||||
type OnKilledAccount = ();
|
||||
type BaseCallFilter = ();
|
||||
type SystemWeightInfo = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
impl Trait for TestRuntime {
|
||||
impl Config for TestRuntime {
|
||||
type OnTransactionSubmitted = DummyTransactionSubmissionHandler;
|
||||
type PeerBlockchain = DummyBlockchain;
|
||||
type PeerMaybeLockFundsTransaction = DummyTransaction;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ pub const WORST_MESSAGE_SIZE_FACTOR: u32 = 1000;
|
||||
const SEED: u32 = 0;
|
||||
|
||||
/// Module we're benchmarking here.
|
||||
pub struct Module<T: Trait<I>, I: crate::Instance>(crate::Module<T, I>);
|
||||
pub struct Module<T: Config<I>, I: crate::Instance>(crate::Module<T, I>);
|
||||
|
||||
/// Benchmark-specific message parameters.
|
||||
pub struct MessageParams<ThisAccountId> {
|
||||
@@ -44,7 +44,7 @@ pub struct MessageParams<ThisAccountId> {
|
||||
}
|
||||
|
||||
/// Trait that must be implemented by runtime.
|
||||
pub trait Trait<I: Instance>: crate::Trait<I> {
|
||||
pub trait Config<I: Instance>: crate::Config<I> {
|
||||
/// Create given account and give it enough balance for test purposes.
|
||||
fn endow_account(account: &Self::AccountId);
|
||||
/// Prepare message to send over lane.
|
||||
@@ -83,7 +83,7 @@ fn bench_lane_id() -> LaneId {
|
||||
*b"test"
|
||||
}
|
||||
|
||||
fn send_regular_message<T: Trait<I>, I: Instance>() {
|
||||
fn send_regular_message<T: Config<I>, I: Instance>() {
|
||||
let mut outbound_lane = crate::outbound_lane::<T, I>(bench_lane_id());
|
||||
outbound_lane.send_message(MessageData {
|
||||
payload: vec![],
|
||||
@@ -91,7 +91,7 @@ fn send_regular_message<T: Trait<I>, I: Instance>() {
|
||||
});
|
||||
}
|
||||
|
||||
fn confirm_message_delivery<T: Trait<I>, I: Instance>(nonce: MessageNonce) {
|
||||
fn confirm_message_delivery<T: Config<I>, I: Instance>(nonce: MessageNonce) {
|
||||
let mut outbound_lane = crate::outbound_lane::<T, I>(bench_lane_id());
|
||||
assert!(outbound_lane.confirm_delivery(nonce).is_some());
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ mod tests {
|
||||
fn fails_to_receive_messages_above_unrewarded_relayer_entries_limit_per_lane() {
|
||||
run_test(|| {
|
||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||
let max_nonce = <TestRuntime as crate::Trait>::MaxUnrewardedRelayerEntriesAtInboundLane::get();
|
||||
let max_nonce = <TestRuntime as crate::Config>::MaxUnrewardedRelayerEntriesAtInboundLane::get();
|
||||
for current_nonce in 1..max_nonce + 1 {
|
||||
assert!(lane.receive_message::<TestMessageDispatch>(
|
||||
TEST_RELAYER_A + current_nonce,
|
||||
@@ -315,7 +315,7 @@ mod tests {
|
||||
fn fails_to_receive_messages_above_unconfirmed_messages_limit_per_lane() {
|
||||
run_test(|| {
|
||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||
let max_nonce = <TestRuntime as crate::Trait>::MaxUnconfirmedMessagesAtInboundLane::get();
|
||||
let max_nonce = <TestRuntime as crate::Config>::MaxUnconfirmedMessagesAtInboundLane::get();
|
||||
for current_nonce in 1..=max_nonce {
|
||||
assert!(lane.receive_message::<TestMessageDispatch>(
|
||||
TEST_RELAYER_A,
|
||||
|
||||
@@ -69,11 +69,11 @@ const DELIVERY_OVERHEAD_WEIGHT: Weight = 0;
|
||||
const SINGLE_MESSAGE_DELIVERY_WEIGHT: Weight = 0;
|
||||
|
||||
/// The module configuration trait
|
||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||
// General types
|
||||
|
||||
/// They overarching event type.
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Config>::Event>;
|
||||
/// Maximal number of messages that may be pruned during maintenance. Maintenance occurs
|
||||
/// whenever new message is sent. The reason is that if you want to use lane, you should
|
||||
/// be ready to pay for its maintenance.
|
||||
@@ -133,17 +133,17 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
||||
type MessageDispatch: MessageDispatch<Self::InboundMessageFee, DispatchPayload = Self::InboundPayload>;
|
||||
}
|
||||
|
||||
/// Shortcut to messages proof type for Trait.
|
||||
/// Shortcut to messages proof type for Config.
|
||||
type MessagesProofOf<T, I> =
|
||||
<<T as Trait<I>>::SourceHeaderChain as SourceHeaderChain<<T as Trait<I>>::InboundMessageFee>>::MessagesProof;
|
||||
/// Shortcut to messages delivery proof type for Trait.
|
||||
type MessagesDeliveryProofOf<T, I> = <<T as Trait<I>>::TargetHeaderChain as TargetHeaderChain<
|
||||
<T as Trait<I>>::OutboundPayload,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<<T as Config<I>>::SourceHeaderChain as SourceHeaderChain<<T as Config<I>>::InboundMessageFee>>::MessagesProof;
|
||||
/// Shortcut to messages delivery proof type for Config.
|
||||
type MessagesDeliveryProofOf<T, I> = <<T as Config<I>>::TargetHeaderChain as TargetHeaderChain<
|
||||
<T as Config<I>>::OutboundPayload,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
>>::MessagesDeliveryProof;
|
||||
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait<I>, I: Instance> {
|
||||
pub enum Error for Module<T: Config<I>, I: Instance> {
|
||||
/// All pallet operations are halted.
|
||||
Halted,
|
||||
/// Message has been treated as invalid by chain verifier.
|
||||
@@ -162,7 +162,7 @@ decl_error! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait<I>, I: Instance = DefaultInstance> as MessageLane {
|
||||
trait Store for Module<T: Config<I>, I: Instance = DefaultInstance> as MessageLane {
|
||||
/// Optional pallet owner.
|
||||
///
|
||||
/// Pallet owner has a right to halt all pallet operations and then resume it. If it is
|
||||
@@ -192,7 +192,7 @@ decl_storage! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I = DefaultInstance> where
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Config>::AccountId,
|
||||
{
|
||||
/// Message has been accepted and is waiting to be delivered.
|
||||
MessageAccepted(LaneId, MessageNonce),
|
||||
@@ -204,7 +204,7 @@ decl_event!(
|
||||
);
|
||||
|
||||
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 {
|
||||
/// Deposit one of this module's events by using the default implementation.
|
||||
fn deposit_event() = default;
|
||||
|
||||
@@ -443,7 +443,7 @@ decl_module! {
|
||||
nonce,
|
||||
}).expect("message was just confirmed; we never prune unconfirmed messages; qed");
|
||||
|
||||
<T as Trait<I>>::MessageDeliveryAndDispatchPayment::pay_relayer_reward(
|
||||
<T as Config<I>>::MessageDeliveryAndDispatchPayment::pay_relayer_reward(
|
||||
&confirmation_relayer,
|
||||
&relayer,
|
||||
&message_data.fee,
|
||||
@@ -464,7 +464,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
impl<T: Config<I>, I: Instance> Module<T, I> {
|
||||
/// Get payload of given outbound message.
|
||||
pub fn outbound_message_payload(lane: LaneId, nonce: MessageNonce) -> Option<MessagePayload> {
|
||||
OutboundMessages::<T, I>::get(MessageKey { lane_id: lane, nonce }).map(|message_data| message_data.payload)
|
||||
@@ -521,7 +521,7 @@ pub mod storage_keys {
|
||||
use sp_core::storage::StorageKey;
|
||||
|
||||
/// Storage key of the outbound message in the runtime storage.
|
||||
pub fn message_key<T: Trait<I>, I: Instance>(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
pub fn message_key<T: Config<I>, I: Instance>(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
let message_key = MessageKey { lane_id: *lane, nonce };
|
||||
let raw_storage_key = OutboundMessages::<T, I>::storage_map_final_key(message_key);
|
||||
StorageKey(raw_storage_key)
|
||||
@@ -533,13 +533,13 @@ pub mod storage_keys {
|
||||
}
|
||||
|
||||
/// Storage key of the inbound message lane state in the runtime storage.
|
||||
pub fn inbound_lane_data_key<T: Trait<I>, I: Instance>(lane: &LaneId) -> StorageKey {
|
||||
pub fn inbound_lane_data_key<T: Config<I>, I: Instance>(lane: &LaneId) -> StorageKey {
|
||||
StorageKey(InboundLanes::<T, I>::storage_map_final_key(*lane))
|
||||
}
|
||||
}
|
||||
|
||||
/// Ensure that the origin is either root, or `ModuleOwner`.
|
||||
fn ensure_owner_or_root<T: Trait<I>, I: Instance>(origin: T::Origin) -> Result<(), BadOrigin> {
|
||||
fn ensure_owner_or_root<T: Config<I>, I: Instance>(origin: T::Origin) -> Result<(), BadOrigin> {
|
||||
match origin.into() {
|
||||
Ok(RawOrigin::Root) => Ok(()),
|
||||
Ok(RawOrigin::Signed(ref signer)) if Some(signer) == Module::<T, I>::module_owner().as_ref() => Ok(()),
|
||||
@@ -548,7 +548,7 @@ fn ensure_owner_or_root<T: Trait<I>, I: Instance>(origin: T::Origin) -> Result<(
|
||||
}
|
||||
|
||||
/// Ensure that the pallet is in operational mode (not halted).
|
||||
fn ensure_operational<T: Trait<I>, I: Instance>() -> Result<(), Error<T, I>> {
|
||||
fn ensure_operational<T: Config<I>, I: Instance>() -> Result<(), Error<T, I>> {
|
||||
if IsHalted::<I>::get() {
|
||||
Err(Error::<T, I>::Halted)
|
||||
} else {
|
||||
@@ -557,7 +557,7 @@ fn ensure_operational<T: Trait<I>, I: Instance>() -> Result<(), Error<T, I>> {
|
||||
}
|
||||
|
||||
/// Creates new inbound lane object, backed by runtime storage.
|
||||
fn inbound_lane<T: Trait<I>, I: Instance>(lane_id: LaneId) -> InboundLane<RuntimeInboundLaneStorage<T, I>> {
|
||||
fn inbound_lane<T: Config<I>, I: Instance>(lane_id: LaneId) -> InboundLane<RuntimeInboundLaneStorage<T, I>> {
|
||||
InboundLane::new(RuntimeInboundLaneStorage {
|
||||
lane_id,
|
||||
cached_data: RefCell::new(None),
|
||||
@@ -566,7 +566,7 @@ fn inbound_lane<T: Trait<I>, I: Instance>(lane_id: LaneId) -> InboundLane<Runtim
|
||||
}
|
||||
|
||||
/// Creates new outbound lane object, backed by runtime storage.
|
||||
fn outbound_lane<T: Trait<I>, I: Instance>(lane_id: LaneId) -> OutboundLane<RuntimeOutboundLaneStorage<T, I>> {
|
||||
fn outbound_lane<T: Config<I>, I: Instance>(lane_id: LaneId) -> OutboundLane<RuntimeOutboundLaneStorage<T, I>> {
|
||||
OutboundLane::new(RuntimeOutboundLaneStorage {
|
||||
lane_id,
|
||||
_phantom: Default::default(),
|
||||
@@ -574,13 +574,13 @@ fn outbound_lane<T: Trait<I>, I: Instance>(lane_id: LaneId) -> OutboundLane<Runt
|
||||
}
|
||||
|
||||
/// Runtime inbound lane storage.
|
||||
struct RuntimeInboundLaneStorage<T: Trait<I>, I = DefaultInstance> {
|
||||
struct RuntimeInboundLaneStorage<T: Config<I>, I = DefaultInstance> {
|
||||
lane_id: LaneId,
|
||||
cached_data: RefCell<Option<InboundLaneData<T::InboundRelayer>>>,
|
||||
_phantom: PhantomData<I>,
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> InboundLaneStorage for RuntimeInboundLaneStorage<T, I> {
|
||||
impl<T: Config<I>, I: Instance> InboundLaneStorage for RuntimeInboundLaneStorage<T, I> {
|
||||
type MessageFee = T::InboundMessageFee;
|
||||
type Relayer = T::InboundRelayer;
|
||||
|
||||
@@ -625,7 +625,7 @@ struct RuntimeOutboundLaneStorage<T, I = DefaultInstance> {
|
||||
_phantom: PhantomData<(T, I)>,
|
||||
}
|
||||
|
||||
impl<T: Trait<I>, I: Instance> OutboundLaneStorage for RuntimeOutboundLaneStorage<T, I> {
|
||||
impl<T: Config<I>, I: Instance> OutboundLaneStorage for RuntimeOutboundLaneStorage<T, I> {
|
||||
type MessageFee = T::OutboundMessageFee;
|
||||
|
||||
fn id(&self) -> LaneId {
|
||||
@@ -691,7 +691,7 @@ fn verify_and_decode_messages_proof<Chain: SourceHeaderChain<Fee>, Fee, Dispatch
|
||||
///
|
||||
/// This account stores all the fees paid by submitters. Relayers are able to claim these
|
||||
/// funds as at their convenience.
|
||||
fn relayer_fund_account_id<T: Trait<I>, I: Instance>() -> T::AccountId {
|
||||
fn relayer_fund_account_id<T: Config<I>, I: Instance>() -> T::AccountId {
|
||||
use sp_runtime::traits::Convert;
|
||||
let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID);
|
||||
T::AccountIdConverter::convert(encoded_id)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::Trait;
|
||||
use crate::Config;
|
||||
|
||||
use bp_message_lane::{
|
||||
source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, Sender, TargetHeaderChain},
|
||||
@@ -69,7 +69,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 = ();
|
||||
@@ -81,13 +81,6 @@ impl frame_system::Trait for TestRuntime {
|
||||
type Header = SubstrateHeader;
|
||||
type Event = TestEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type BlockExecutionWeight = ();
|
||||
type ExtrinsicBaseWeight = ();
|
||||
type MaximumExtrinsicWeight = MaximumBlockWeight;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type AccountData = ();
|
||||
@@ -95,6 +88,9 @@ impl frame_system::Trait for TestRuntime {
|
||||
type OnKilledAccount = ();
|
||||
type BaseCallFilter = ();
|
||||
type SystemWeightInfo = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -104,7 +100,7 @@ parameter_types! {
|
||||
pub const MaxMessagesInDeliveryTransaction: u64 = 128;
|
||||
}
|
||||
|
||||
impl Trait for TestRuntime {
|
||||
impl Config for TestRuntime {
|
||||
type Event = TestEvent;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||
|
||||
@@ -23,21 +23,21 @@ use frame_support::{decl_module, decl_storage};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// The module configuration trait.
|
||||
pub trait Trait: pallet_session::Trait {}
|
||||
pub trait Config: pallet_session::Config {}
|
||||
|
||||
decl_module! {
|
||||
/// Shift session manager pallet.
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {}
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as ShiftSessionManager {
|
||||
trait Store for Module<T: Config> as ShiftSessionManager {
|
||||
/// Validators of first two sessions.
|
||||
InitialValidators: Option<Vec<T::ValidatorId>>;
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
|
||||
impl<T: Config> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
|
||||
fn end_session(_: sp_staking::SessionIndex) {}
|
||||
fn start_session(_: sp_staking::SessionIndex) {}
|
||||
fn new_session(session_index: sp_staking::SessionIndex) -> Option<Vec<T::ValidatorId>> {
|
||||
@@ -61,7 +61,7 @@ impl<T: Trait> pallet_session::SessionManager<T::ValidatorId> for Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
/// Select validators for session.
|
||||
fn select_validators(
|
||||
session_index: sp_staking::SessionIndex,
|
||||
@@ -112,7 +112,7 @@ mod tests {
|
||||
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 = ();
|
||||
@@ -124,13 +124,6 @@ mod tests {
|
||||
type Header = Header;
|
||||
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 = ();
|
||||
@@ -138,6 +131,9 @@ mod tests {
|
||||
type OnKilledAccount = ();
|
||||
type BaseCallFilter = ();
|
||||
type SystemWeightInfo = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -145,9 +141,9 @@ mod tests {
|
||||
pub const Offset: u64 = 0;
|
||||
}
|
||||
|
||||
impl pallet_session::Trait for TestRuntime {
|
||||
impl pallet_session::Config for TestRuntime {
|
||||
type Event = ();
|
||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
||||
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||
type ValidatorIdOf = ConvertInto;
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
@@ -158,7 +154,7 @@ mod tests {
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl Trait for TestRuntime {}
|
||||
impl Config for TestRuntime {}
|
||||
|
||||
pub struct TestSessionHandler;
|
||||
impl pallet_session::SessionHandler<AccountId> for TestSessionHandler {
|
||||
|
||||
@@ -60,13 +60,13 @@ mod mock;
|
||||
mod fork_tests;
|
||||
|
||||
/// Block number of the bridged chain.
|
||||
pub(crate) type BridgedBlockNumber<T> = BlockNumberOf<<T as Trait>::BridgedChain>;
|
||||
pub(crate) type BridgedBlockNumber<T> = BlockNumberOf<<T as Config>::BridgedChain>;
|
||||
/// Block hash of the bridged chain.
|
||||
pub(crate) type BridgedBlockHash<T> = HashOf<<T as Trait>::BridgedChain>;
|
||||
pub(crate) type BridgedBlockHash<T> = HashOf<<T as Config>::BridgedChain>;
|
||||
/// Hasher of the bridged chain.
|
||||
pub(crate) type BridgedBlockHasher<T> = HasherOf<<T as Trait>::BridgedChain>;
|
||||
pub(crate) type BridgedBlockHasher<T> = HasherOf<<T as Config>::BridgedChain>;
|
||||
/// Header of the bridged chain.
|
||||
pub(crate) type BridgedHeader<T> = HeaderOf<<T as Trait>::BridgedChain>;
|
||||
pub(crate) type BridgedHeader<T> = HeaderOf<<T as Config>::BridgedChain>;
|
||||
|
||||
/// A convenience type identifying headers.
|
||||
#[derive(RuntimeDebug, PartialEq)]
|
||||
@@ -77,13 +77,13 @@ pub struct HeaderId<H: HeaderT> {
|
||||
pub hash: H::Hash,
|
||||
}
|
||||
|
||||
pub trait Trait: frame_system::Trait {
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Chain that we are bridging here.
|
||||
type BridgedChain: Chain;
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as SubstrateBridge {
|
||||
trait Store for Module<T: Config> as SubstrateBridge {
|
||||
/// The number of the highest block(s) we know of.
|
||||
BestHeight: BridgedBlockNumber<T>;
|
||||
/// Hash of the header at the highest known height.
|
||||
@@ -137,7 +137,7 @@ decl_storage! {
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// This header has failed basic verification.
|
||||
InvalidHeader,
|
||||
/// This header has not been finalized.
|
||||
@@ -156,7 +156,7 @@ decl_error! {
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
type Error = Error<T>;
|
||||
|
||||
/// Import a signed Substrate header into the runtime.
|
||||
@@ -277,7 +277,7 @@ decl_module! {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T> {
|
||||
impl<T: Config> Module<T> {
|
||||
/// Get the highest header(s) that the pallet knows of.
|
||||
pub fn best_headers() -> Vec<(BridgedBlockNumber<T>, BridgedBlockHash<T>)> {
|
||||
PalletStorage::<T>::new()
|
||||
@@ -353,7 +353,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
/// Ensure that the origin is either root, or `ModuleOwner`.
|
||||
fn ensure_owner_or_root<T: Trait>(origin: T::Origin) -> Result<(), BadOrigin> {
|
||||
fn ensure_owner_or_root<T: Config>(origin: T::Origin) -> Result<(), BadOrigin> {
|
||||
match origin.into() {
|
||||
Ok(RawOrigin::Root) => Ok(()),
|
||||
Ok(RawOrigin::Signed(ref signer)) if Some(signer) == <Module<T>>::module_owner().as_ref() => Ok(()),
|
||||
@@ -362,7 +362,7 @@ fn ensure_owner_or_root<T: Trait>(origin: T::Origin) -> Result<(), BadOrigin> {
|
||||
}
|
||||
|
||||
/// Ensure that the pallet is in operational mode (not halted).
|
||||
fn ensure_operational<T: Trait>() -> Result<(), Error<T>> {
|
||||
fn ensure_operational<T: Config>() -> Result<(), Error<T>> {
|
||||
if IsHalted::get() {
|
||||
Err(<Error<T>>::Halted)
|
||||
} else {
|
||||
@@ -372,7 +372,7 @@ fn ensure_operational<T: Trait>() -> Result<(), Error<T>> {
|
||||
|
||||
/// Since this writes to storage with no real checks this should only be used in functions that were
|
||||
/// called by a trusted origin.
|
||||
fn initialize_bridge<T: Trait>(init_params: InitializationData<BridgedHeader<T>>) {
|
||||
fn initialize_bridge<T: Config>(init_params: InitializationData<BridgedHeader<T>>) {
|
||||
let InitializationData {
|
||||
header,
|
||||
authority_list,
|
||||
@@ -488,7 +488,7 @@ impl<T> PalletStorage<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> BridgeStorage for PalletStorage<T> {
|
||||
impl<T: Config> BridgeStorage for PalletStorage<T> {
|
||||
type Header = BridgedHeader<T>;
|
||||
|
||||
fn write_header(&mut self, header: &ImportedHeader<BridgedHeader<T>>) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::Trait;
|
||||
use crate::Config;
|
||||
use bp_runtime::Chain;
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_runtime::{
|
||||
@@ -45,7 +45,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 = ();
|
||||
@@ -57,13 +57,6 @@ impl frame_system::Trait for TestRuntime {
|
||||
type Header = Header;
|
||||
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 = ();
|
||||
@@ -71,9 +64,12 @@ impl frame_system::Trait for TestRuntime {
|
||||
type OnKilledAccount = ();
|
||||
type BaseCallFilter = ();
|
||||
type SystemWeightInfo = ();
|
||||
type DbWeight = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
}
|
||||
|
||||
impl Trait for TestRuntime {
|
||||
impl Config for TestRuntime {
|
||||
type BridgedChain = TestBridgedChain;
|
||||
}
|
||||
|
||||
@@ -81,10 +77,10 @@ impl Trait for TestRuntime {
|
||||
pub struct TestBridgedChain;
|
||||
|
||||
impl Chain for TestBridgedChain {
|
||||
type BlockNumber = <TestRuntime as frame_system::Trait>::BlockNumber;
|
||||
type Hash = <TestRuntime as frame_system::Trait>::Hash;
|
||||
type Hasher = <TestRuntime as frame_system::Trait>::Hashing;
|
||||
type Header = <TestRuntime as frame_system::Trait>::Header;
|
||||
type BlockNumber = <TestRuntime as frame_system::Config>::BlockNumber;
|
||||
type Hash = <TestRuntime as frame_system::Config>::Hash;
|
||||
type Hasher = <TestRuntime as frame_system::Config>::Hashing;
|
||||
type Header = <TestRuntime as frame_system::Config>::Header;
|
||||
}
|
||||
|
||||
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
|
||||
|
||||
@@ -65,7 +65,7 @@ pub enum Error {
|
||||
StorageValueUnavailable,
|
||||
}
|
||||
|
||||
impl<T: crate::Trait> From<Error> for crate::Error<T> {
|
||||
impl<T: crate::Config> From<Error> for crate::Error<T> {
|
||||
fn from(error: Error) -> Self {
|
||||
match error {
|
||||
Error::StorageRootMismatch => crate::Error::StorageRootMismatch,
|
||||
|
||||
Reference in New Issue
Block a user