mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 00:31:02 +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
@@ -318,8 +318,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||||||
task_manager
|
task_manager
|
||||||
.spawn_essential_handle()
|
.spawn_essential_handle()
|
||||||
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
||||||
} else {
|
|
||||||
sc_finality_grandpa::setup_disabled_grandpa(network)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network_starter.start_network();
|
network_starter.start_network();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
|||||||
pub mod rialto_messages;
|
pub mod rialto_messages;
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
|
use frame_system::limits;
|
||||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||||
use sp_api::impl_runtime_apis;
|
use sp_api::impl_runtime_apis;
|
||||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
@@ -50,7 +51,7 @@ use sp_version::RuntimeVersion;
|
|||||||
pub use frame_support::{
|
pub use frame_support::{
|
||||||
construct_runtime, parameter_types,
|
construct_runtime, parameter_types,
|
||||||
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
||||||
weights::{IdentityFee, RuntimeDbWeight, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight},
|
||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,19 +150,17 @@ pub fn native_version() -> NativeVersion {
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: BlockNumber = 250;
|
pub const BlockHashCount: BlockNumber = 250;
|
||||||
pub const MaximumBlockWeight: Weight = bp_millau::MAXIMUM_BLOCK_WEIGHT;
|
|
||||||
pub const ExtrinsicBaseWeight: Weight = 10_000_000;
|
|
||||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(bp_millau::AVAILABLE_BLOCK_RATIO);
|
|
||||||
pub MaximumExtrinsicWeight: Weight = bp_millau::MAXIMUM_EXTRINSIC_WEIGHT;
|
|
||||||
pub const MaximumBlockLength: u32 = bp_millau::MAXIMUM_BLOCK_SIZE;
|
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||||
read: 60_000_000, // ~0.06 ms = ~60 µs
|
read: 60_000_000, // ~0.06 ms = ~60 µs
|
||||||
write: 200_000_000, // ~0.2 ms = 200 µs
|
write: 200_000_000, // ~0.2 ms = 200 µs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub RuntimeBlockLength: limits::BlockLength = bp_millau::runtime_block_length();
|
||||||
|
pub RuntimeBlockWeights: limits::BlockWeights = bp_millau::runtime_block_weights();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for Runtime {
|
impl frame_system::Config for Runtime {
|
||||||
/// The basic call filter to use in dispatchable.
|
/// The basic call filter to use in dispatchable.
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
/// The identifier used to distinguish between accounts.
|
/// The identifier used to distinguish between accounts.
|
||||||
@@ -186,24 +185,6 @@ impl frame_system::Trait for Runtime {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
/// Maximum weight of each block.
|
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
/// The weight of database operations that the runtime can invoke.
|
|
||||||
type DbWeight = DbWeight;
|
|
||||||
/// The weight of the overhead invoked on the block import process, independent of the
|
|
||||||
/// extrinsics included in that block.
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
/// The base weight of any extrinsic processed by the runtime, independent of the
|
|
||||||
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
|
|
||||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
|
||||||
/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,
|
|
||||||
/// idependent of the logic of that extrinsics. (Roughly max block weight - average on
|
|
||||||
/// initialize cost).
|
|
||||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
|
||||||
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
/// Portion of the block weight that is available to all normal transactions.
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
/// Version of the runtime.
|
/// Version of the runtime.
|
||||||
type Version = Version;
|
type Version = Version;
|
||||||
/// Provides information about the pallet setup in the runtime.
|
/// Provides information about the pallet setup in the runtime.
|
||||||
@@ -217,12 +198,18 @@ impl frame_system::Trait for Runtime {
|
|||||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||||
/// Weight information for the extrinsics of this pallet.
|
/// Weight information for the extrinsics of this pallet.
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
/// Block and extrinsics weights: base values and limits.
|
||||||
|
type BlockWeights = RuntimeBlockWeights;
|
||||||
|
/// The maximum length of a block (in bytes).
|
||||||
|
type BlockLength = RuntimeBlockLength;
|
||||||
|
/// The weight of database operations that the runtime can invoke.
|
||||||
|
type DbWeight = DbWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_aura::Trait for Runtime {
|
impl pallet_aura::Config for Runtime {
|
||||||
type AuthorityId = AuraId;
|
type AuthorityId = AuraId;
|
||||||
}
|
}
|
||||||
impl pallet_bridge_call_dispatch::Trait for Runtime {
|
impl pallet_bridge_call_dispatch::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
@@ -232,7 +219,7 @@ impl pallet_bridge_call_dispatch::Trait for Runtime {
|
|||||||
type AccountIdConverter = bp_millau::AccountIdConverter;
|
type AccountIdConverter = bp_millau::AccountIdConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_grandpa::Trait for Runtime {
|
impl pallet_grandpa::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type KeyOwnerProofSystem = ();
|
type KeyOwnerProofSystem = ();
|
||||||
@@ -248,7 +235,7 @@ parameter_types! {
|
|||||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_timestamp::Trait for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
/// A timestamp: milliseconds since the unix epoch.
|
/// A timestamp: milliseconds since the unix epoch.
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
@@ -264,7 +251,7 @@ parameter_types! {
|
|||||||
pub const MaxLocks: u32 = 50;
|
pub const MaxLocks: u32 = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_balances::Trait for Runtime {
|
impl pallet_balances::Config for Runtime {
|
||||||
/// The type for recording an account's balance.
|
/// The type for recording an account's balance.
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
/// The ubiquitous event type.
|
/// The ubiquitous event type.
|
||||||
@@ -282,14 +269,14 @@ parameter_types! {
|
|||||||
pub const TransactionByteFee: Balance = 1;
|
pub const TransactionByteFee: Balance = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_transaction_payment::Trait for Runtime {
|
impl pallet_transaction_payment::Config for Runtime {
|
||||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||||
type TransactionByteFee = TransactionByteFee;
|
type TransactionByteFee = TransactionByteFee;
|
||||||
type WeightToFee = IdentityFee<Balance>;
|
type WeightToFee = IdentityFee<Balance>;
|
||||||
type FeeMultiplierUpdate = ();
|
type FeeMultiplierUpdate = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_sudo::Trait for Runtime {
|
impl pallet_sudo::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
}
|
}
|
||||||
@@ -300,9 +287,9 @@ parameter_types! {
|
|||||||
pub const Offset: BlockNumber = 0;
|
pub const Offset: BlockNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_session::Trait for Runtime {
|
impl pallet_session::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||||
type ValidatorIdOf = ();
|
type ValidatorIdOf = ();
|
||||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
@@ -314,11 +301,11 @@ impl pallet_session::Trait for Runtime {
|
|||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_substrate_bridge::Trait for Runtime {
|
impl pallet_substrate_bridge::Config for Runtime {
|
||||||
type BridgedChain = bp_rialto::Rialto;
|
type BridgedChain = bp_rialto::Rialto;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_shift_session_manager::Trait for Runtime {}
|
impl pallet_shift_session_manager::Config for Runtime {}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
||||||
@@ -330,7 +317,7 @@ parameter_types! {
|
|||||||
bp_millau::MAX_MESSAGES_IN_DELIVERY_TRANSACTION;
|
bp_millau::MAX_MESSAGES_IN_DELIVERY_TRANSACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_message_lane::Trait for Runtime {
|
impl pallet_message_lane::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||||
|
|||||||
@@ -89,12 +89,12 @@ impl MessageBridge for WithRialtoMessageBridge {
|
|||||||
type BridgedChain = Rialto;
|
type BridgedChain = Rialto;
|
||||||
|
|
||||||
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
||||||
bp_rialto::MAXIMUM_EXTRINSIC_SIZE
|
bp_rialto::max_extrinsic_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||||
let upper_limit = bp_rialto::MAXIMUM_EXTRINSIC_WEIGHT / 2;
|
let upper_limit = bp_rialto::max_extrinsic_weight() / 2;
|
||||||
|
|
||||||
// given Rialto chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
// given Rialto chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
||||||
// the minimal weight of the message may be computed as message.length()
|
// the minimal weight of the message may be computed as message.length()
|
||||||
@@ -116,12 +116,12 @@ impl MessageBridge for WithRialtoMessageBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_this_balance(weight: Weight) -> bp_millau::Balance {
|
fn this_weight_to_this_balance(weight: Weight) -> bp_millau::Balance {
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_rialto::Balance {
|
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_rialto::Balance {
|
||||||
// we're using the same weights in both chains now
|
// we're using the same weights in both chains now
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight) as _
|
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_balance_to_bridged_balance(this_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
fn this_balance_to_bridged_balance(this_balance: bp_millau::Balance) -> bp_rialto::Balance {
|
||||||
|
|||||||
@@ -317,8 +317,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||||||
task_manager
|
task_manager
|
||||||
.spawn_essential_handle()
|
.spawn_essential_handle()
|
||||||
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
|
||||||
} else {
|
|
||||||
sc_finality_grandpa::setup_disabled_grandpa(network)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
network_starter.start_network();
|
network_starter.start_network();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ impl MaybeLockFundsTransaction for EthTransaction {
|
|||||||
|
|
||||||
/// Prepares everything required to bench claim of funds locked by given transaction.
|
/// Prepares everything required to bench claim of funds locked by given transaction.
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Trait<I>, I: frame_support::traits::Instance>(
|
pub(crate) fn prepare_environment_for_claim<T: pallet_bridge_eth_poa::Config<I>, I: frame_support::traits::Instance>(
|
||||||
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
transactions: &[(RawTransaction, RawTransactionReceipt)],
|
||||||
) -> bp_eth_poa::H256 {
|
) -> bp_eth_poa::H256 {
|
||||||
use bp_eth_poa::compute_merkle_root;
|
use bp_eth_poa::compute_merkle_root;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ pub mod millau_messages;
|
|||||||
pub mod rialto_poa;
|
pub mod rialto_poa;
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
|
use frame_system::limits;
|
||||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
|
||||||
use sp_api::impl_runtime_apis;
|
use sp_api::impl_runtime_apis;
|
||||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
@@ -56,7 +57,7 @@ use sp_version::RuntimeVersion;
|
|||||||
pub use frame_support::{
|
pub use frame_support::{
|
||||||
construct_runtime, parameter_types,
|
construct_runtime, parameter_types,
|
||||||
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness},
|
||||||
weights::{IdentityFee, RuntimeDbWeight, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight},
|
||||||
StorageValue,
|
StorageValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,19 +158,17 @@ pub fn native_version() -> NativeVersion {
|
|||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const BlockHashCount: BlockNumber = 250;
|
pub const BlockHashCount: BlockNumber = 250;
|
||||||
pub const MaximumBlockWeight: Weight = bp_rialto::MAXIMUM_BLOCK_WEIGHT;
|
|
||||||
pub const ExtrinsicBaseWeight: Weight = 10_000_000;
|
|
||||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(bp_rialto::AVAILABLE_BLOCK_RATIO);
|
|
||||||
pub MaximumExtrinsicWeight: Weight = bp_rialto::MAXIMUM_EXTRINSIC_WEIGHT;
|
|
||||||
pub const MaximumBlockLength: u32 = bp_rialto::MAXIMUM_BLOCK_SIZE;
|
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||||
read: 60_000_000, // ~0.06 ms = ~60 µs
|
read: 60_000_000, // ~0.06 ms = ~60 µs
|
||||||
write: 200_000_000, // ~0.2 ms = 200 µs
|
write: 200_000_000, // ~0.2 ms = 200 µs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub RuntimeBlockLength: limits::BlockLength = bp_rialto::runtime_block_length();
|
||||||
|
pub RuntimeBlockWeights: limits::BlockWeights = bp_rialto::runtime_block_weights();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for Runtime {
|
impl frame_system::Config for Runtime {
|
||||||
/// The basic call filter to use in dispatchable.
|
/// The basic call filter to use in dispatchable.
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
/// The identifier used to distinguish between accounts.
|
/// The identifier used to distinguish between accounts.
|
||||||
@@ -194,24 +193,6 @@ impl frame_system::Trait for Runtime {
|
|||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
/// Maximum weight of each block.
|
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
/// The weight of database operations that the runtime can invoke.
|
|
||||||
type DbWeight = DbWeight;
|
|
||||||
/// The weight of the overhead invoked on the block import process, independent of the
|
|
||||||
/// extrinsics included in that block.
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
/// The base weight of any extrinsic processed by the runtime, independent of the
|
|
||||||
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
|
|
||||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
|
||||||
/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,
|
|
||||||
/// idependent of the logic of that extrinsics. (Roughly max block weight - average on
|
|
||||||
/// initialize cost).
|
|
||||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
|
||||||
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
/// Portion of the block weight that is available to all normal transactions.
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
/// Version of the runtime.
|
/// Version of the runtime.
|
||||||
type Version = Version;
|
type Version = Version;
|
||||||
/// Provides information about the pallet setup in the runtime.
|
/// Provides information about the pallet setup in the runtime.
|
||||||
@@ -225,14 +206,20 @@ impl frame_system::Trait for Runtime {
|
|||||||
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||||
/// Weight information for the extrinsics of this pallet.
|
/// Weight information for the extrinsics of this pallet.
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
/// Block and extrinsics weights: base values and limits.
|
||||||
|
type BlockWeights = RuntimeBlockWeights;
|
||||||
|
/// The maximum length of a block (in bytes).
|
||||||
|
type BlockLength = RuntimeBlockLength;
|
||||||
|
/// The weight of database operations that the runtime can invoke.
|
||||||
|
type DbWeight = DbWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_aura::Trait for Runtime {
|
impl pallet_aura::Config for Runtime {
|
||||||
type AuthorityId = AuraId;
|
type AuthorityId = AuraId;
|
||||||
}
|
}
|
||||||
|
|
||||||
type RialtoPoA = pallet_bridge_eth_poa::Instance1;
|
type RialtoPoA = pallet_bridge_eth_poa::Instance1;
|
||||||
impl pallet_bridge_eth_poa::Trait<RialtoPoA> for Runtime {
|
impl pallet_bridge_eth_poa::Config<RialtoPoA> for Runtime {
|
||||||
type AuraConfiguration = rialto_poa::BridgeAuraConfiguration;
|
type AuraConfiguration = rialto_poa::BridgeAuraConfiguration;
|
||||||
type FinalityVotesCachingInterval = rialto_poa::FinalityVotesCachingInterval;
|
type FinalityVotesCachingInterval = rialto_poa::FinalityVotesCachingInterval;
|
||||||
type ValidatorsConfiguration = rialto_poa::BridgeValidatorsConfiguration;
|
type ValidatorsConfiguration = rialto_poa::BridgeValidatorsConfiguration;
|
||||||
@@ -242,7 +229,7 @@ impl pallet_bridge_eth_poa::Trait<RialtoPoA> for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Kovan = pallet_bridge_eth_poa::Instance2;
|
type Kovan = pallet_bridge_eth_poa::Instance2;
|
||||||
impl pallet_bridge_eth_poa::Trait<Kovan> for Runtime {
|
impl pallet_bridge_eth_poa::Config<Kovan> for Runtime {
|
||||||
type AuraConfiguration = kovan::BridgeAuraConfiguration;
|
type AuraConfiguration = kovan::BridgeAuraConfiguration;
|
||||||
type FinalityVotesCachingInterval = kovan::FinalityVotesCachingInterval;
|
type FinalityVotesCachingInterval = kovan::FinalityVotesCachingInterval;
|
||||||
type ValidatorsConfiguration = kovan::BridgeValidatorsConfiguration;
|
type ValidatorsConfiguration = kovan::BridgeValidatorsConfiguration;
|
||||||
@@ -252,7 +239,7 @@ impl pallet_bridge_eth_poa::Trait<Kovan> for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RialtoCurrencyExchange = pallet_bridge_currency_exchange::Instance1;
|
type RialtoCurrencyExchange = pallet_bridge_currency_exchange::Instance1;
|
||||||
impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime {
|
impl pallet_bridge_currency_exchange::Config<RialtoCurrencyExchange> for Runtime {
|
||||||
type OnTransactionSubmitted = ();
|
type OnTransactionSubmitted = ();
|
||||||
type PeerBlockchain = rialto_poa::RialtoBlockchain;
|
type PeerBlockchain = rialto_poa::RialtoBlockchain;
|
||||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||||
@@ -263,7 +250,7 @@ impl pallet_bridge_currency_exchange::Trait<RialtoCurrencyExchange> for Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KovanCurrencyExchange = pallet_bridge_currency_exchange::Instance2;
|
type KovanCurrencyExchange = pallet_bridge_currency_exchange::Instance2;
|
||||||
impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
|
impl pallet_bridge_currency_exchange::Config<KovanCurrencyExchange> for Runtime {
|
||||||
type OnTransactionSubmitted = ();
|
type OnTransactionSubmitted = ();
|
||||||
type PeerBlockchain = kovan::KovanBlockchain;
|
type PeerBlockchain = kovan::KovanBlockchain;
|
||||||
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
type PeerMaybeLockFundsTransaction = exchange::EthTransaction;
|
||||||
@@ -273,7 +260,7 @@ impl pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange> for Runtime {
|
|||||||
type DepositInto = DepositInto;
|
type DepositInto = DepositInto;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_bridge_call_dispatch::Trait for Runtime {
|
impl pallet_bridge_call_dispatch::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce);
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
@@ -340,7 +327,7 @@ impl bp_currency_exchange::DepositInto for DepositInto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_grandpa::Trait for Runtime {
|
impl pallet_grandpa::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
type KeyOwnerProofSystem = ();
|
type KeyOwnerProofSystem = ();
|
||||||
@@ -356,7 +343,7 @@ parameter_types! {
|
|||||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_timestamp::Trait for Runtime {
|
impl pallet_timestamp::Config for Runtime {
|
||||||
/// A timestamp: milliseconds since the unix epoch.
|
/// A timestamp: milliseconds since the unix epoch.
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
@@ -372,7 +359,7 @@ parameter_types! {
|
|||||||
pub const MaxLocks: u32 = 50;
|
pub const MaxLocks: u32 = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_balances::Trait for Runtime {
|
impl pallet_balances::Config for Runtime {
|
||||||
/// The type for recording an account's balance.
|
/// The type for recording an account's balance.
|
||||||
type Balance = Balance;
|
type Balance = Balance;
|
||||||
/// The ubiquitous event type.
|
/// The ubiquitous event type.
|
||||||
@@ -390,14 +377,14 @@ parameter_types! {
|
|||||||
pub const TransactionByteFee: Balance = 1;
|
pub const TransactionByteFee: Balance = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_transaction_payment::Trait for Runtime {
|
impl pallet_transaction_payment::Config for Runtime {
|
||||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||||
type TransactionByteFee = TransactionByteFee;
|
type TransactionByteFee = TransactionByteFee;
|
||||||
type WeightToFee = IdentityFee<Balance>;
|
type WeightToFee = IdentityFee<Balance>;
|
||||||
type FeeMultiplierUpdate = ();
|
type FeeMultiplierUpdate = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_sudo::Trait for Runtime {
|
impl pallet_sudo::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
}
|
}
|
||||||
@@ -407,9 +394,9 @@ parameter_types! {
|
|||||||
pub const Offset: BlockNumber = 0;
|
pub const Offset: BlockNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_session::Trait for Runtime {
|
impl pallet_session::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||||
type ValidatorIdOf = ();
|
type ValidatorIdOf = ();
|
||||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
@@ -421,11 +408,11 @@ impl pallet_session::Trait for Runtime {
|
|||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_substrate_bridge::Trait for Runtime {
|
impl pallet_substrate_bridge::Config for Runtime {
|
||||||
type BridgedChain = bp_millau::Millau;
|
type BridgedChain = bp_millau::Millau;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_shift_session_manager::Trait for Runtime {}
|
impl pallet_shift_session_manager::Config for Runtime {}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8;
|
||||||
@@ -438,7 +425,7 @@ parameter_types! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type WithMillauMessageLaneInstance = pallet_message_lane::DefaultInstance;
|
pub(crate) type WithMillauMessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||||
impl pallet_message_lane::Trait for Runtime {
|
impl pallet_message_lane::Config for Runtime {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||||
@@ -777,18 +764,18 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_bridge_currency_exchange::benchmarking::{
|
use pallet_bridge_currency_exchange::benchmarking::{
|
||||||
Module as BridgeCurrencyExchangeBench,
|
Module as BridgeCurrencyExchangeBench,
|
||||||
Trait as BridgeCurrencyExchangeTrait,
|
Config as BridgeCurrencyExchangeConfig,
|
||||||
ProofParams as BridgeCurrencyExchangeProofParams,
|
ProofParams as BridgeCurrencyExchangeProofParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl BridgeCurrencyExchangeTrait<KovanCurrencyExchange> for Runtime {
|
impl BridgeCurrencyExchangeConfig<KovanCurrencyExchange> for Runtime {
|
||||||
fn make_proof(
|
fn make_proof(
|
||||||
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
proof_params: BridgeCurrencyExchangeProofParams<AccountId>,
|
||||||
) -> crate::exchange::EthereumTransactionInclusionProof {
|
) -> crate::exchange::EthereumTransactionInclusionProof {
|
||||||
use bp_currency_exchange::DepositInto;
|
use bp_currency_exchange::DepositInto;
|
||||||
|
|
||||||
if proof_params.recipient_exists {
|
if proof_params.recipient_exists {
|
||||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||||
proof_params.recipient.clone(),
|
proof_params.recipient.clone(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
).unwrap();
|
).unwrap();
|
||||||
@@ -817,11 +804,11 @@ impl_runtime_apis! {
|
|||||||
|
|
||||||
use pallet_message_lane::benchmarking::{
|
use pallet_message_lane::benchmarking::{
|
||||||
Module as MessageLaneBench,
|
Module as MessageLaneBench,
|
||||||
Trait as MessageLaneTrait,
|
Config as MessageLaneConfig,
|
||||||
MessageParams as MessageLaneMessageParams,
|
MessageParams as MessageLaneMessageParams,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl MessageLaneTrait<WithMillauMessageLaneInstance> for Runtime {
|
impl MessageLaneConfig<WithMillauMessageLaneInstance> for Runtime {
|
||||||
fn endow_account(account: &Self::AccountId) {
|
fn endow_account(account: &Self::AccountId) {
|
||||||
pallet_balances::Module::<Runtime>::make_free_balance_be(
|
pallet_balances::Module::<Runtime>::make_free_balance_be(
|
||||||
account,
|
account,
|
||||||
@@ -923,7 +910,7 @@ mod tests {
|
|||||||
let initial_amount =
|
let initial_amount =
|
||||||
<pallet_balances::Module<Runtime> as Currency<AccountId>>::free_balance(&existing_account);
|
<pallet_balances::Module<Runtime> as Currency<AccountId>>::free_balance(&existing_account);
|
||||||
let additional_amount = 10_000;
|
let additional_amount = 10_000;
|
||||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||||
existing_account.clone(),
|
existing_account.clone(),
|
||||||
additional_amount,
|
additional_amount,
|
||||||
)
|
)
|
||||||
@@ -942,7 +929,7 @@ mod tests {
|
|||||||
let initial_amount = 0;
|
let initial_amount = 0;
|
||||||
let additional_amount = ExistentialDeposit::get() + 10_000;
|
let additional_amount = ExistentialDeposit::get() + 10_000;
|
||||||
let new_account: AccountId = [42u8; 32].into();
|
let new_account: AccountId = [42u8; 32].into();
|
||||||
<Runtime as pallet_bridge_currency_exchange::Trait<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
<Runtime as pallet_bridge_currency_exchange::Config<KovanCurrencyExchange>>::DepositInto::deposit_into(
|
||||||
new_account.clone(),
|
new_account.clone(),
|
||||||
additional_amount,
|
additional_amount,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,12 +89,12 @@ impl MessageBridge for WithMillauMessageBridge {
|
|||||||
type BridgedChain = Millau;
|
type BridgedChain = Millau;
|
||||||
|
|
||||||
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
fn maximal_extrinsic_size_on_target_chain() -> u32 {
|
||||||
bp_millau::MAXIMUM_EXTRINSIC_SIZE
|
bp_millau::max_extrinsic_size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
fn weight_limits_of_message_on_bridged_chain(message_payload: &[u8]) -> RangeInclusive<Weight> {
|
||||||
// we don't want to relay too large messages + keep reserve for future upgrades
|
// we don't want to relay too large messages + keep reserve for future upgrades
|
||||||
let upper_limit = bp_millau::MAXIMUM_EXTRINSIC_WEIGHT / 2;
|
let upper_limit = bp_millau::max_extrinsic_weight() / 2;
|
||||||
|
|
||||||
// given Millau chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
// given Millau chain parameters (`TransactionByteFee`, `WeightToFee`, `FeeMultiplierUpdate`),
|
||||||
// the minimal weight of the message may be computed as message.length()
|
// the minimal weight of the message may be computed as message.length()
|
||||||
@@ -116,12 +116,12 @@ impl MessageBridge for WithMillauMessageBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance {
|
fn this_weight_to_this_balance(weight: Weight) -> bp_rialto::Balance {
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight)
|
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance {
|
fn bridged_weight_to_bridged_balance(weight: Weight) -> bp_millau::Balance {
|
||||||
// we're using the same weights in both chains now
|
// we're using the same weights in both chains now
|
||||||
<crate::Runtime as pallet_transaction_payment::Trait>::WeightToFee::calc(&weight) as _
|
<crate::Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&weight) as _
|
||||||
}
|
}
|
||||||
|
|
||||||
fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
fn this_balance_to_bridged_balance(this_balance: bp_rialto::Balance) -> bp_millau::Balance {
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ pub mod source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The maximal size of extrinsic at Substrate-based chain depends on the
|
// The maximal size of extrinsic at Substrate-based chain depends on the
|
||||||
// `frame_system::Trait::MaximumBlockLength` and `frame_system::Trait::AvailableBlockRatio`
|
// `frame_system::Config::MaximumBlockLength` and `frame_system::Config::AvailableBlockRatio`
|
||||||
// constants. This check is here to be sure that the lane won't stuck because message is too
|
// constants. This check is here to be sure that the lane won't stuck because message is too
|
||||||
// large to fit into delivery transaction.
|
// large to fit into delivery transaction.
|
||||||
//
|
//
|
||||||
@@ -261,10 +261,10 @@ pub mod source {
|
|||||||
proof: FromBridgedChainMessagesDeliveryProof<B>,
|
proof: FromBridgedChainMessagesDeliveryProof<B>,
|
||||||
) -> Result<ParsedMessagesDeliveryProofFromBridgedChain<B>, &'static str>
|
) -> Result<ParsedMessagesDeliveryProofFromBridgedChain<B>, &'static str>
|
||||||
where
|
where
|
||||||
ThisRuntime: pallet_substrate_bridge::Trait,
|
ThisRuntime: pallet_substrate_bridge::Config,
|
||||||
ThisRuntime: pallet_message_lane::Trait<MessageLaneInstanceOf<BridgedChain<B>>>,
|
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||||
HashOf<BridgedChain<B>>:
|
HashOf<BridgedChain<B>>:
|
||||||
Into<bp_runtime::HashOf<<ThisRuntime as pallet_substrate_bridge::Trait>::BridgedChain>>,
|
Into<bp_runtime::HashOf<<ThisRuntime as pallet_substrate_bridge::Config>::BridgedChain>>,
|
||||||
{
|
{
|
||||||
let (bridged_header_hash, bridged_storage_proof, lane) = proof;
|
let (bridged_header_hash, bridged_storage_proof, lane) = proof;
|
||||||
pallet_substrate_bridge::Module::<ThisRuntime>::parse_finalized_storage_proof(
|
pallet_substrate_bridge::Module::<ThisRuntime>::parse_finalized_storage_proof(
|
||||||
@@ -359,7 +359,7 @@ pub mod target {
|
|||||||
for FromBridgedChainMessageDispatch<B, ThisRuntime, ThisCallDispatchInstance>
|
for FromBridgedChainMessageDispatch<B, ThisRuntime, ThisCallDispatchInstance>
|
||||||
where
|
where
|
||||||
ThisCallDispatchInstance: frame_support::traits::Instance,
|
ThisCallDispatchInstance: frame_support::traits::Instance,
|
||||||
ThisRuntime: pallet_bridge_call_dispatch::Trait<ThisCallDispatchInstance>,
|
ThisRuntime: pallet_bridge_call_dispatch::Config<ThisCallDispatchInstance>,
|
||||||
pallet_bridge_call_dispatch::Module<ThisRuntime, ThisCallDispatchInstance>:
|
pallet_bridge_call_dispatch::Module<ThisRuntime, ThisCallDispatchInstance>:
|
||||||
bp_message_dispatch::MessageDispatch<
|
bp_message_dispatch::MessageDispatch<
|
||||||
(LaneId, MessageNonce),
|
(LaneId, MessageNonce),
|
||||||
@@ -396,10 +396,10 @@ pub mod target {
|
|||||||
max_messages: MessageNonce,
|
max_messages: MessageNonce,
|
||||||
) -> Result<ProvedMessages<Message<BalanceOf<BridgedChain<B>>>>, &'static str>
|
) -> Result<ProvedMessages<Message<BalanceOf<BridgedChain<B>>>>, &'static str>
|
||||||
where
|
where
|
||||||
ThisRuntime: pallet_substrate_bridge::Trait,
|
ThisRuntime: pallet_substrate_bridge::Config,
|
||||||
ThisRuntime: pallet_message_lane::Trait<MessageLaneInstanceOf<BridgedChain<B>>>,
|
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||||
HashOf<BridgedChain<B>>:
|
HashOf<BridgedChain<B>>:
|
||||||
Into<bp_runtime::HashOf<<ThisRuntime as pallet_substrate_bridge::Trait>::BridgedChain>>,
|
Into<bp_runtime::HashOf<<ThisRuntime as pallet_substrate_bridge::Config>::BridgedChain>>,
|
||||||
{
|
{
|
||||||
verify_messages_proof_with_parser::<B, _, _>(
|
verify_messages_proof_with_parser::<B, _, _>(
|
||||||
proof,
|
proof,
|
||||||
@@ -459,7 +459,7 @@ pub mod target {
|
|||||||
where
|
where
|
||||||
H: Hasher,
|
H: Hasher,
|
||||||
B: MessageBridge,
|
B: MessageBridge,
|
||||||
ThisRuntime: pallet_message_lane::Trait<MessageLaneInstanceOf<BridgedChain<B>>>,
|
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||||
{
|
{
|
||||||
fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option<Vec<u8>> {
|
fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option<Vec<u8>> {
|
||||||
let storage_outbound_lane_data_key = pallet_message_lane::storage_keys::outbound_lane_data_key::<
|
let storage_outbound_lane_data_key = pallet_message_lane::storage_keys::outbound_lane_data_key::<
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ pub struct MessagePayload<SourceChainAccountId, TargetChainAccountPublic, Target
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The module configuration trait.
|
/// The module configuration trait.
|
||||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||||
/// The overarching event type.
|
/// 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
|
/// 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
|
/// event with this id + dispatch result. Could be e.g. (LaneId, MessageNonce) if
|
||||||
/// it comes from message-lane module.
|
/// it comes from message-lane module.
|
||||||
@@ -113,7 +113,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
|||||||
type Call: Parameter
|
type Call: Parameter
|
||||||
+ GetDispatchInfo
|
+ GetDispatchInfo
|
||||||
+ Dispatchable<
|
+ Dispatchable<
|
||||||
Origin = <Self as frame_system::Trait>::Origin,
|
Origin = <Self as frame_system::Config>::Origin,
|
||||||
PostInfo = frame_support::dispatch::PostDispatchInfo,
|
PostInfo = frame_support::dispatch::PostDispatchInfo,
|
||||||
>;
|
>;
|
||||||
/// A type which can be turned into an AccountId from a 256-bit hash.
|
/// 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! {
|
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!(
|
decl_event!(
|
||||||
pub enum Event<T, I = DefaultInstance> where
|
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.
|
/// Message has been rejected by dispatcher because of spec version mismatch.
|
||||||
/// Last two arguments are: expected and passed spec version.
|
/// Last two arguments are: expected and passed spec version.
|
||||||
@@ -147,18 +147,18 @@ decl_event!(
|
|||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
/// Call Dispatch FRAME Pallet.
|
/// 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.
|
/// Deposit one of this module's events by using the default implementation.
|
||||||
fn deposit_event() = default;
|
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<
|
type Message = MessagePayload<
|
||||||
T::SourceChainAccountId,
|
T::SourceChainAccountId,
|
||||||
T::TargetChainAccountPublic,
|
T::TargetChainAccountPublic,
|
||||||
T::TargetChainSignature,
|
T::TargetChainSignature,
|
||||||
<T as Trait<I>>::Call,
|
<T as Config<I>>::Call,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
fn dispatch_weight(message: &Self::Message) -> Weight {
|
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) {
|
fn dispatch(bridge: InstanceId, id: T::MessageId, message: Self::Message) {
|
||||||
// verify spec version
|
// verify spec version
|
||||||
// (we want it to be the same, because otherwise we may decode Call improperly)
|
// (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 {
|
if message.spec_version != expected_version {
|
||||||
frame_support::debug::trace!(
|
frame_support::debug::trace!(
|
||||||
"Message {:?}/{:?}: spec_version mismatch. Expected {:?}, got {:?}",
|
"Message {:?}/{:?}: spec_version mismatch. Expected {:?}, got {:?}",
|
||||||
@@ -384,7 +384,7 @@ mod tests {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = Call;
|
type Call = Call;
|
||||||
@@ -396,13 +396,6 @@ mod tests {
|
|||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = TestEvent;
|
type Event = TestEvent;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = ();
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -410,9 +403,12 @@ mod tests {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
|
type DbWeight = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type Event = TestEvent;
|
type Event = TestEvent;
|
||||||
type MessageId = MessageId;
|
type MessageId = MessageId;
|
||||||
type SourceChainAccountId = AccountId;
|
type SourceChainAccountId = AccountId;
|
||||||
@@ -435,7 +431,7 @@ mod tests {
|
|||||||
fn prepare_message(
|
fn prepare_message(
|
||||||
origin: CallOrigin<AccountId, TestAccountPublic, TestSignature>,
|
origin: CallOrigin<AccountId, TestAccountPublic, TestSignature>,
|
||||||
call: Call,
|
call: Call,
|
||||||
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Trait>::MessageId>>::Message {
|
) -> <Module<TestRuntime> as MessageDispatch<<TestRuntime as Config>::MessageId>>::Message {
|
||||||
MessagePayload {
|
MessagePayload {
|
||||||
spec_version: TEST_SPEC_VERSION,
|
spec_version: TEST_SPEC_VERSION,
|
||||||
weight: TEST_WEIGHT,
|
weight: TEST_WEIGHT,
|
||||||
@@ -446,20 +442,20 @@ mod tests {
|
|||||||
|
|
||||||
fn prepare_root_message(
|
fn prepare_root_message(
|
||||||
call: Call,
|
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)
|
prepare_message(CallOrigin::SourceRoot, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_target_message(
|
fn prepare_target_message(
|
||||||
call: Call,
|
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));
|
let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1));
|
||||||
prepare_message(origin, call)
|
prepare_message(origin, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_source_message(
|
fn prepare_source_message(
|
||||||
call: Call,
|
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);
|
let origin = CallOrigin::SourceAccount(1);
|
||||||
prepare_message(origin, call)
|
prepare_message(origin, call)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
//! So we are giving runtime opportunity to prepare environment and construct proof
|
//! So we are giving runtime opportunity to prepare environment and construct proof
|
||||||
//! before invoking module calls.
|
//! 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 sp_std::prelude::*;
|
||||||
|
|
||||||
use frame_benchmarking::{account, benchmarks_instance};
|
use frame_benchmarking::{account, benchmarks_instance};
|
||||||
@@ -29,7 +29,7 @@ const WORST_TX_SIZE_FACTOR: u32 = 1000;
|
|||||||
const WORST_PROOF_SIZE_FACTOR: u32 = 1000;
|
const WORST_PROOF_SIZE_FACTOR: u32 = 1000;
|
||||||
|
|
||||||
/// Module we're benchmarking here.
|
/// 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.
|
/// Proof benchmarking parameters.
|
||||||
pub struct ProofParams<Recipient> {
|
pub struct ProofParams<Recipient> {
|
||||||
@@ -45,12 +45,12 @@ pub struct ProofParams<Recipient> {
|
|||||||
pub proof_size_factor: u32,
|
pub proof_size_factor: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait that must be implemented by runtime.
|
/// Config that must be implemented by runtime.
|
||||||
pub trait Trait<I: Instance>: CurrencyExchangeTrait<I> {
|
pub trait Config<I: Instance>: CurrencyExchangeConfig<I> {
|
||||||
/// Prepare proof for importing exchange transaction.
|
/// Prepare proof for importing exchange transaction.
|
||||||
fn make_proof(
|
fn make_proof(
|
||||||
proof_params: ProofParams<Self::AccountId>,
|
proof_params: ProofParams<Self::AccountId>,
|
||||||
) -> <<Self as CurrencyExchangeTrait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof;
|
) -> <<Self as CurrencyExchangeConfig<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof;
|
||||||
}
|
}
|
||||||
|
|
||||||
benchmarks_instance! {
|
benchmarks_instance! {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub trait OnTransactionSubmitted<AccountId> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The module configuration trait
|
/// 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.
|
/// Handler for transaction submission result.
|
||||||
type OnTransactionSubmitted: OnTransactionSubmitted<Self::AccountId>;
|
type OnTransactionSubmitted: OnTransactionSubmitted<Self::AccountId>;
|
||||||
/// Represents the blockchain that we'll be exchanging currency with.
|
/// Represents the blockchain that we'll be exchanging currency with.
|
||||||
@@ -61,7 +61,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_error! {
|
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.
|
/// Invalid peer blockchain transaction provided.
|
||||||
InvalidTransaction,
|
InvalidTransaction,
|
||||||
/// Peer transaction has invalid amount.
|
/// Peer transaction has invalid amount.
|
||||||
@@ -84,12 +84,12 @@ decl_error! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
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.
|
/// Imports lock fund transaction of the peer blockchain.
|
||||||
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
||||||
pub fn import_peer_transaction(
|
pub fn import_peer_transaction(
|
||||||
origin,
|
origin,
|
||||||
proof: <<T as Trait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
proof: <<T as Config<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
let submitter = frame_system::ensure_signed(origin)?;
|
let submitter = frame_system::ensure_signed(origin)?;
|
||||||
|
|
||||||
@@ -125,13 +125,13 @@ decl_module! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
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.
|
/// All transfers that have already been claimed.
|
||||||
Transfers: map hasher(blake2_128_concat) <T::PeerMaybeLockFundsTransaction as MaybeLockFundsTransaction>::Id => ();
|
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
|
/// Returns true if currency exchange module is able to import given transaction proof in
|
||||||
/// its current state.
|
/// its current state.
|
||||||
pub fn filter_transaction_proof(proof: &<T::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof) -> bool {
|
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 {
|
fn from(error: ExchangeError) -> Self {
|
||||||
match error {
|
match error {
|
||||||
ExchangeError::InvalidTransaction => Error::InvalidTransaction,
|
ExchangeError::InvalidTransaction => Error::InvalidTransaction,
|
||||||
@@ -168,7 +168,7 @@ impl<AccountId> OnTransactionSubmitted<AccountId> for () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Exchange deposit details.
|
/// Exchange deposit details.
|
||||||
struct DepositDetails<T: Trait<I>, I: Instance> {
|
struct DepositDetails<T: Config<I>, I: Instance> {
|
||||||
/// Transfer id.
|
/// Transfer id.
|
||||||
pub transfer_id: <T::PeerMaybeLockFundsTransaction as MaybeLockFundsTransaction>::Id,
|
pub transfer_id: <T::PeerMaybeLockFundsTransaction as MaybeLockFundsTransaction>::Id,
|
||||||
/// Transfer recipient.
|
/// Transfer recipient.
|
||||||
@@ -179,16 +179,16 @@ struct DepositDetails<T: Trait<I>, I: Instance> {
|
|||||||
|
|
||||||
/// Verify and parse transaction proof, preparing everything required for importing
|
/// Verify and parse transaction proof, preparing everything required for importing
|
||||||
/// this transaction proof.
|
/// this transaction proof.
|
||||||
fn prepare_deposit_details<T: Trait<I>, I: Instance>(
|
fn prepare_deposit_details<T: Config<I>, I: Instance>(
|
||||||
proof: &<<T as Trait<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
proof: &<<T as Config<I>>::PeerBlockchain as BaseHeaderChain>::TransactionInclusionProof,
|
||||||
) -> Result<DepositDetails<T, I>, Error<T, I>> {
|
) -> Result<DepositDetails<T, I>, Error<T, I>> {
|
||||||
// ensure that transaction is included in finalized block that we know of
|
// 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)?;
|
.ok_or(Error::<T, I>::UnfinalizedTransaction)?;
|
||||||
|
|
||||||
// parse transaction
|
// parse transaction
|
||||||
let 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;
|
let transfer_id = transaction.id;
|
||||||
ensure!(
|
ensure!(
|
||||||
!Transfers::<T, I>::contains_key(&transfer_id),
|
!Transfers::<T, I>::contains_key(&transfer_id),
|
||||||
@@ -325,7 +325,7 @@ mod tests {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = ();
|
type Call = ();
|
||||||
@@ -337,13 +337,6 @@ mod tests {
|
|||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = ();
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -351,9 +344,12 @@ mod tests {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
|
type DbWeight = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type OnTransactionSubmitted = DummyTransactionSubmissionHandler;
|
type OnTransactionSubmitted = DummyTransactionSubmissionHandler;
|
||||||
type PeerBlockchain = DummyBlockchain;
|
type PeerBlockchain = DummyBlockchain;
|
||||||
type PeerMaybeLockFundsTransaction = DummyTransaction;
|
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
|
// Initialize storage with some initial header
|
||||||
let initial_header = build_genesis_header(&validator(0));
|
let initial_header = build_genesis_header(&validator(0));
|
||||||
let initial_difficulty = initial_header.difficulty;
|
let initial_difficulty = initial_header.difficulty;
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ impl<AccountId> OnHeadersSubmitted<AccountId> for () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The module configuration trait.
|
/// The module configuration trait.
|
||||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||||
/// Aura configuration.
|
/// Aura configuration.
|
||||||
type AuraConfiguration: Get<AuraConfiguration>;
|
type AuraConfiguration: Get<AuraConfiguration>;
|
||||||
/// Validators configuration.
|
/// Validators configuration.
|
||||||
@@ -393,7 +393,7 @@ pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
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**.
|
/// Import single Aura header. Requires transaction to be **UNSIGNED**.
|
||||||
#[weight = 0] // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
|
#[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>>) {
|
pub fn import_unsigned_header(origin, header: AuraHeader, receipts: Option<Vec<Receipt>>) {
|
||||||
@@ -457,7 +457,7 @@ decl_module! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
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.
|
/// Best known block.
|
||||||
BestBlock: (HeaderId, U256);
|
BestBlock: (HeaderId, U256);
|
||||||
/// Best finalized block.
|
/// 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.
|
/// Returns number and hash of the best block known to the bridge module.
|
||||||
/// The caller should only submit `import_header` transaction that makes
|
/// The caller should only submit `import_header` transaction that makes
|
||||||
/// (or leads to making) other header the best one.
|
/// (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>;
|
type Call = Call<T, I>;
|
||||||
|
|
||||||
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
|
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)]
|
#[derive(Default)]
|
||||||
pub struct BridgeStorage<T, I = DefaultInstance>(sp_std::marker::PhantomData<(T, I)>);
|
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.
|
/// Create new BridgeStorage.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
BridgeStorage(sp_std::marker::PhantomData::<(T, I)>::default())
|
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;
|
type Submitter = T::AccountId;
|
||||||
|
|
||||||
fn best_block(&self) -> (HeaderId, U256) {
|
fn best_block(&self) -> (HeaderId, U256) {
|
||||||
@@ -863,7 +863,7 @@ impl<T: Trait<I>, I: Instance> Storage for BridgeStorage<T, I> {
|
|||||||
|
|
||||||
/// Initialize storage.
|
/// Initialize storage.
|
||||||
#[cfg(any(feature = "std", feature = "runtime-benchmarks"))]
|
#[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_header: &AuraHeader,
|
||||||
initial_difficulty: U256,
|
initial_difficulty: U256,
|
||||||
initial_validators: &[Address],
|
initial_validators: &[Address],
|
||||||
@@ -1263,7 +1263,7 @@ pub(crate) mod tests {
|
|||||||
fn finality_votes_are_cached() {
|
fn finality_votes_are_cached() {
|
||||||
run_test(TOTAL_VALIDATORS, |ctx| {
|
run_test(TOTAL_VALIDATORS, |ctx| {
|
||||||
let mut storage = BridgeStorage::<TestRuntime>::new();
|
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 all headers with number < interval, cache entry is not created
|
||||||
for i in 1..interval {
|
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;
|
pub use bp_eth_poa::signatures::secret_to_address;
|
||||||
|
|
||||||
use crate::validators::{ValidatorsConfiguration, ValidatorsSource};
|
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 bp_eth_poa::{Address, AuraHeader, H256, U256};
|
||||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||||
use secp256k1::SecretKey;
|
use secp256k1::SecretKey;
|
||||||
@@ -44,7 +44,7 @@ parameter_types! {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = ();
|
type Call = ();
|
||||||
@@ -56,13 +56,6 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type Header = SubstrateHeader;
|
type Header = SubstrateHeader;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = ();
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -70,6 +63,9 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
|
type DbWeight = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -78,7 +74,7 @@ parameter_types! {
|
|||||||
pub TestValidatorsConfiguration: ValidatorsConfiguration = test_validators_config();
|
pub TestValidatorsConfiguration: ValidatorsConfiguration = test_validators_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type AuraConfiguration = TestAuraConfiguration;
|
type AuraConfiguration = TestAuraConfiguration;
|
||||||
type ValidatorsConfiguration = TestValidatorsConfiguration;
|
type ValidatorsConfiguration = TestValidatorsConfiguration;
|
||||||
type FinalityVotesCachingInterval = TestFinalityVotesCachingInterval;
|
type FinalityVotesCachingInterval = TestFinalityVotesCachingInterval;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
use crate::finality::FinalityVotes;
|
use crate::finality::FinalityVotes;
|
||||||
use crate::validators::CHANGE_EVENT_HASH;
|
use crate::validators::CHANGE_EVENT_HASH;
|
||||||
use crate::verification::calculate_score;
|
use crate::verification::calculate_score;
|
||||||
use crate::{HeaderToImport, Storage, Trait};
|
use crate::{Config, HeaderToImport, Storage};
|
||||||
|
|
||||||
use bp_eth_poa::{
|
use bp_eth_poa::{
|
||||||
rlp_encode,
|
rlp_encode,
|
||||||
@@ -73,7 +73,7 @@ impl HeaderBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates default header on top of parent with given hash.
|
/// 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 crate::Headers;
|
||||||
use frame_support::StorageMap;
|
use frame_support::StorageMap;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ impl HeaderBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates default header on top of parent with given number. First parent is selected.
|
/// 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 crate::HeadersByNumber;
|
||||||
use frame_support::StorageMap;
|
use frame_support::StorageMap;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub const WORST_MESSAGE_SIZE_FACTOR: u32 = 1000;
|
|||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
/// Module we're benchmarking here.
|
/// 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.
|
/// Benchmark-specific message parameters.
|
||||||
pub struct MessageParams<ThisAccountId> {
|
pub struct MessageParams<ThisAccountId> {
|
||||||
@@ -44,7 +44,7 @@ pub struct MessageParams<ThisAccountId> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Trait that must be implemented by runtime.
|
/// 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.
|
/// Create given account and give it enough balance for test purposes.
|
||||||
fn endow_account(account: &Self::AccountId);
|
fn endow_account(account: &Self::AccountId);
|
||||||
/// Prepare message to send over lane.
|
/// Prepare message to send over lane.
|
||||||
@@ -83,7 +83,7 @@ fn bench_lane_id() -> LaneId {
|
|||||||
*b"test"
|
*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());
|
let mut outbound_lane = crate::outbound_lane::<T, I>(bench_lane_id());
|
||||||
outbound_lane.send_message(MessageData {
|
outbound_lane.send_message(MessageData {
|
||||||
payload: vec![],
|
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());
|
let mut outbound_lane = crate::outbound_lane::<T, I>(bench_lane_id());
|
||||||
assert!(outbound_lane.confirm_delivery(nonce).is_some());
|
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() {
|
fn fails_to_receive_messages_above_unrewarded_relayer_entries_limit_per_lane() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
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 {
|
for current_nonce in 1..max_nonce + 1 {
|
||||||
assert!(lane.receive_message::<TestMessageDispatch>(
|
assert!(lane.receive_message::<TestMessageDispatch>(
|
||||||
TEST_RELAYER_A + current_nonce,
|
TEST_RELAYER_A + current_nonce,
|
||||||
@@ -315,7 +315,7 @@ mod tests {
|
|||||||
fn fails_to_receive_messages_above_unconfirmed_messages_limit_per_lane() {
|
fn fails_to_receive_messages_above_unconfirmed_messages_limit_per_lane() {
|
||||||
run_test(|| {
|
run_test(|| {
|
||||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
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 {
|
for current_nonce in 1..=max_nonce {
|
||||||
assert!(lane.receive_message::<TestMessageDispatch>(
|
assert!(lane.receive_message::<TestMessageDispatch>(
|
||||||
TEST_RELAYER_A,
|
TEST_RELAYER_A,
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ const DELIVERY_OVERHEAD_WEIGHT: Weight = 0;
|
|||||||
const SINGLE_MESSAGE_DELIVERY_WEIGHT: Weight = 0;
|
const SINGLE_MESSAGE_DELIVERY_WEIGHT: Weight = 0;
|
||||||
|
|
||||||
/// The module configuration trait
|
/// The module configuration trait
|
||||||
pub trait Trait<I = DefaultInstance>: frame_system::Trait {
|
pub trait Config<I = DefaultInstance>: frame_system::Config {
|
||||||
// General types
|
// General types
|
||||||
|
|
||||||
/// They overarching event type.
|
/// 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
|
/// 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
|
/// whenever new message is sent. The reason is that if you want to use lane, you should
|
||||||
/// be ready to pay for its maintenance.
|
/// 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>;
|
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> =
|
type MessagesProofOf<T, I> =
|
||||||
<<T as Trait<I>>::SourceHeaderChain as SourceHeaderChain<<T as Trait<I>>::InboundMessageFee>>::MessagesProof;
|
<<T as Config<I>>::SourceHeaderChain as SourceHeaderChain<<T as Config<I>>::InboundMessageFee>>::MessagesProof;
|
||||||
/// Shortcut to messages delivery proof type for Trait.
|
/// Shortcut to messages delivery proof type for Config.
|
||||||
type MessagesDeliveryProofOf<T, I> = <<T as Trait<I>>::TargetHeaderChain as TargetHeaderChain<
|
type MessagesDeliveryProofOf<T, I> = <<T as Config<I>>::TargetHeaderChain as TargetHeaderChain<
|
||||||
<T as Trait<I>>::OutboundPayload,
|
<T as Config<I>>::OutboundPayload,
|
||||||
<T as frame_system::Trait>::AccountId,
|
<T as frame_system::Config>::AccountId,
|
||||||
>>::MessagesDeliveryProof;
|
>>::MessagesDeliveryProof;
|
||||||
|
|
||||||
decl_error! {
|
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.
|
/// All pallet operations are halted.
|
||||||
Halted,
|
Halted,
|
||||||
/// Message has been treated as invalid by chain verifier.
|
/// Message has been treated as invalid by chain verifier.
|
||||||
@@ -162,7 +162,7 @@ decl_error! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
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.
|
/// Optional pallet owner.
|
||||||
///
|
///
|
||||||
/// Pallet owner has a right to halt all pallet operations and then resume it. If it is
|
/// 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!(
|
decl_event!(
|
||||||
pub enum Event<T, I = DefaultInstance> where
|
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.
|
/// Message has been accepted and is waiting to be delivered.
|
||||||
MessageAccepted(LaneId, MessageNonce),
|
MessageAccepted(LaneId, MessageNonce),
|
||||||
@@ -204,7 +204,7 @@ decl_event!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
decl_module! {
|
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.
|
/// Deposit one of this module's events by using the default implementation.
|
||||||
fn deposit_event() = default;
|
fn deposit_event() = default;
|
||||||
|
|
||||||
@@ -443,7 +443,7 @@ decl_module! {
|
|||||||
nonce,
|
nonce,
|
||||||
}).expect("message was just confirmed; we never prune unconfirmed messages; qed");
|
}).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,
|
&confirmation_relayer,
|
||||||
&relayer,
|
&relayer,
|
||||||
&message_data.fee,
|
&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.
|
/// Get payload of given outbound message.
|
||||||
pub fn outbound_message_payload(lane: LaneId, nonce: MessageNonce) -> Option<MessagePayload> {
|
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)
|
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;
|
use sp_core::storage::StorageKey;
|
||||||
|
|
||||||
/// Storage key of the outbound message in the runtime storage.
|
/// 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 message_key = MessageKey { lane_id: *lane, nonce };
|
||||||
let raw_storage_key = OutboundMessages::<T, I>::storage_map_final_key(message_key);
|
let raw_storage_key = OutboundMessages::<T, I>::storage_map_final_key(message_key);
|
||||||
StorageKey(raw_storage_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.
|
/// 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))
|
StorageKey(InboundLanes::<T, I>::storage_map_final_key(*lane))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure that the origin is either root, or `ModuleOwner`.
|
/// 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() {
|
match origin.into() {
|
||||||
Ok(RawOrigin::Root) => Ok(()),
|
Ok(RawOrigin::Root) => Ok(()),
|
||||||
Ok(RawOrigin::Signed(ref signer)) if Some(signer) == Module::<T, I>::module_owner().as_ref() => 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).
|
/// 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() {
|
if IsHalted::<I>::get() {
|
||||||
Err(Error::<T, I>::Halted)
|
Err(Error::<T, I>::Halted)
|
||||||
} else {
|
} 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.
|
/// 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 {
|
InboundLane::new(RuntimeInboundLaneStorage {
|
||||||
lane_id,
|
lane_id,
|
||||||
cached_data: RefCell::new(None),
|
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.
|
/// 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 {
|
OutboundLane::new(RuntimeOutboundLaneStorage {
|
||||||
lane_id,
|
lane_id,
|
||||||
_phantom: Default::default(),
|
_phantom: Default::default(),
|
||||||
@@ -574,13 +574,13 @@ fn outbound_lane<T: Trait<I>, I: Instance>(lane_id: LaneId) -> OutboundLane<Runt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Runtime inbound lane storage.
|
/// Runtime inbound lane storage.
|
||||||
struct RuntimeInboundLaneStorage<T: Trait<I>, I = DefaultInstance> {
|
struct RuntimeInboundLaneStorage<T: Config<I>, I = DefaultInstance> {
|
||||||
lane_id: LaneId,
|
lane_id: LaneId,
|
||||||
cached_data: RefCell<Option<InboundLaneData<T::InboundRelayer>>>,
|
cached_data: RefCell<Option<InboundLaneData<T::InboundRelayer>>>,
|
||||||
_phantom: PhantomData<I>,
|
_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 MessageFee = T::InboundMessageFee;
|
||||||
type Relayer = T::InboundRelayer;
|
type Relayer = T::InboundRelayer;
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ struct RuntimeOutboundLaneStorage<T, I = DefaultInstance> {
|
|||||||
_phantom: PhantomData<(T, I)>,
|
_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;
|
type MessageFee = T::OutboundMessageFee;
|
||||||
|
|
||||||
fn id(&self) -> LaneId {
|
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
|
/// This account stores all the fees paid by submitters. Relayers are able to claim these
|
||||||
/// funds as at their convenience.
|
/// 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;
|
use sp_runtime::traits::Convert;
|
||||||
let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID);
|
let encoded_id = bp_runtime::derive_relayer_fund_account_id(bp_runtime::NO_INSTANCE_ID);
|
||||||
T::AccountIdConverter::convert(encoded_id)
|
T::AccountIdConverter::convert(encoded_id)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// 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/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::Trait;
|
use crate::Config;
|
||||||
|
|
||||||
use bp_message_lane::{
|
use bp_message_lane::{
|
||||||
source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, Sender, TargetHeaderChain},
|
source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, Sender, TargetHeaderChain},
|
||||||
@@ -69,7 +69,7 @@ parameter_types! {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = ();
|
type Call = ();
|
||||||
@@ -81,13 +81,6 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type Header = SubstrateHeader;
|
type Header = SubstrateHeader;
|
||||||
type Event = TestEvent;
|
type Event = TestEvent;
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = MaximumBlockWeight;
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -95,6 +88,9 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
|
type DbWeight = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -104,7 +100,7 @@ parameter_types! {
|
|||||||
pub const MaxMessagesInDeliveryTransaction: u64 = 128;
|
pub const MaxMessagesInDeliveryTransaction: u64 = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type Event = TestEvent;
|
type Event = TestEvent;
|
||||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||||
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
|
||||||
|
|||||||
@@ -23,21 +23,21 @@ use frame_support::{decl_module, decl_storage};
|
|||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// The module configuration trait.
|
/// The module configuration trait.
|
||||||
pub trait Trait: pallet_session::Trait {}
|
pub trait Config: pallet_session::Config {}
|
||||||
|
|
||||||
decl_module! {
|
decl_module! {
|
||||||
/// Shift session manager pallet.
|
/// 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! {
|
decl_storage! {
|
||||||
trait Store for Module<T: Trait> as ShiftSessionManager {
|
trait Store for Module<T: Config> as ShiftSessionManager {
|
||||||
/// Validators of first two sessions.
|
/// Validators of first two sessions.
|
||||||
InitialValidators: Option<Vec<T::ValidatorId>>;
|
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 end_session(_: sp_staking::SessionIndex) {}
|
||||||
fn start_session(_: sp_staking::SessionIndex) {}
|
fn start_session(_: sp_staking::SessionIndex) {}
|
||||||
fn new_session(session_index: sp_staking::SessionIndex) -> Option<Vec<T::ValidatorId>> {
|
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.
|
/// Select validators for session.
|
||||||
fn select_validators(
|
fn select_validators(
|
||||||
session_index: sp_staking::SessionIndex,
|
session_index: sp_staking::SessionIndex,
|
||||||
@@ -112,7 +112,7 @@ mod tests {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = ();
|
type Call = ();
|
||||||
@@ -124,13 +124,6 @@ mod tests {
|
|||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = ();
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -138,6 +131,9 @@ mod tests {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
|
type DbWeight = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -145,9 +141,9 @@ mod tests {
|
|||||||
pub const Offset: u64 = 0;
|
pub const Offset: u64 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_session::Trait for TestRuntime {
|
impl pallet_session::Config for TestRuntime {
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
type ValidatorId = <Self as frame_system::Config>::AccountId;
|
||||||
type ValidatorIdOf = ConvertInto;
|
type ValidatorIdOf = ConvertInto;
|
||||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||||
@@ -158,7 +154,7 @@ mod tests {
|
|||||||
type WeightInfo = ();
|
type WeightInfo = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {}
|
impl Config for TestRuntime {}
|
||||||
|
|
||||||
pub struct TestSessionHandler;
|
pub struct TestSessionHandler;
|
||||||
impl pallet_session::SessionHandler<AccountId> for TestSessionHandler {
|
impl pallet_session::SessionHandler<AccountId> for TestSessionHandler {
|
||||||
|
|||||||
@@ -60,13 +60,13 @@ mod mock;
|
|||||||
mod fork_tests;
|
mod fork_tests;
|
||||||
|
|
||||||
/// Block number of the bridged chain.
|
/// 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.
|
/// 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.
|
/// 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.
|
/// 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.
|
/// A convenience type identifying headers.
|
||||||
#[derive(RuntimeDebug, PartialEq)]
|
#[derive(RuntimeDebug, PartialEq)]
|
||||||
@@ -77,13 +77,13 @@ pub struct HeaderId<H: HeaderT> {
|
|||||||
pub hash: H::Hash,
|
pub hash: H::Hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Trait: frame_system::Trait {
|
pub trait Config: frame_system::Config {
|
||||||
/// Chain that we are bridging here.
|
/// Chain that we are bridging here.
|
||||||
type BridgedChain: Chain;
|
type BridgedChain: Chain;
|
||||||
}
|
}
|
||||||
|
|
||||||
decl_storage! {
|
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.
|
/// The number of the highest block(s) we know of.
|
||||||
BestHeight: BridgedBlockNumber<T>;
|
BestHeight: BridgedBlockNumber<T>;
|
||||||
/// Hash of the header at the highest known height.
|
/// Hash of the header at the highest known height.
|
||||||
@@ -137,7 +137,7 @@ decl_storage! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_error! {
|
decl_error! {
|
||||||
pub enum Error for Module<T: Trait> {
|
pub enum Error for Module<T: Config> {
|
||||||
/// This header has failed basic verification.
|
/// This header has failed basic verification.
|
||||||
InvalidHeader,
|
InvalidHeader,
|
||||||
/// This header has not been finalized.
|
/// This header has not been finalized.
|
||||||
@@ -156,7 +156,7 @@ decl_error! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
decl_module! {
|
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>;
|
type Error = Error<T>;
|
||||||
|
|
||||||
/// Import a signed Substrate header into the runtime.
|
/// 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.
|
/// Get the highest header(s) that the pallet knows of.
|
||||||
pub fn best_headers() -> Vec<(BridgedBlockNumber<T>, BridgedBlockHash<T>)> {
|
pub fn best_headers() -> Vec<(BridgedBlockNumber<T>, BridgedBlockHash<T>)> {
|
||||||
PalletStorage::<T>::new()
|
PalletStorage::<T>::new()
|
||||||
@@ -353,7 +353,7 @@ impl<T: Trait> Module<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Ensure that the origin is either root, or `ModuleOwner`.
|
/// 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() {
|
match origin.into() {
|
||||||
Ok(RawOrigin::Root) => Ok(()),
|
Ok(RawOrigin::Root) => Ok(()),
|
||||||
Ok(RawOrigin::Signed(ref signer)) if Some(signer) == <Module<T>>::module_owner().as_ref() => 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).
|
/// 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() {
|
if IsHalted::get() {
|
||||||
Err(<Error<T>>::Halted)
|
Err(<Error<T>>::Halted)
|
||||||
} else {
|
} 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
|
/// Since this writes to storage with no real checks this should only be used in functions that were
|
||||||
/// called by a trusted origin.
|
/// 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 {
|
let InitializationData {
|
||||||
header,
|
header,
|
||||||
authority_list,
|
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>;
|
type Header = BridgedHeader<T>;
|
||||||
|
|
||||||
fn write_header(&mut self, header: &ImportedHeader<BridgedHeader<T>>) {
|
fn write_header(&mut self, header: &ImportedHeader<BridgedHeader<T>>) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
use crate::Trait;
|
use crate::Config;
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -45,7 +45,7 @@ parameter_types! {
|
|||||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl frame_system::Trait for TestRuntime {
|
impl frame_system::Config for TestRuntime {
|
||||||
type Origin = Origin;
|
type Origin = Origin;
|
||||||
type Index = u64;
|
type Index = u64;
|
||||||
type Call = ();
|
type Call = ();
|
||||||
@@ -57,13 +57,6 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type BlockHashCount = BlockHashCount;
|
type BlockHashCount = BlockHashCount;
|
||||||
type MaximumBlockWeight = MaximumBlockWeight;
|
|
||||||
type DbWeight = ();
|
|
||||||
type BlockExecutionWeight = ();
|
|
||||||
type ExtrinsicBaseWeight = ();
|
|
||||||
type MaximumExtrinsicWeight = ();
|
|
||||||
type AvailableBlockRatio = AvailableBlockRatio;
|
|
||||||
type MaximumBlockLength = MaximumBlockLength;
|
|
||||||
type Version = ();
|
type Version = ();
|
||||||
type PalletInfo = ();
|
type PalletInfo = ();
|
||||||
type AccountData = ();
|
type AccountData = ();
|
||||||
@@ -71,9 +64,12 @@ impl frame_system::Trait for TestRuntime {
|
|||||||
type OnKilledAccount = ();
|
type OnKilledAccount = ();
|
||||||
type BaseCallFilter = ();
|
type BaseCallFilter = ();
|
||||||
type SystemWeightInfo = ();
|
type SystemWeightInfo = ();
|
||||||
|
type DbWeight = ();
|
||||||
|
type BlockWeights = ();
|
||||||
|
type BlockLength = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for TestRuntime {
|
impl Config for TestRuntime {
|
||||||
type BridgedChain = TestBridgedChain;
|
type BridgedChain = TestBridgedChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,10 +77,10 @@ impl Trait for TestRuntime {
|
|||||||
pub struct TestBridgedChain;
|
pub struct TestBridgedChain;
|
||||||
|
|
||||||
impl Chain for TestBridgedChain {
|
impl Chain for TestBridgedChain {
|
||||||
type BlockNumber = <TestRuntime as frame_system::Trait>::BlockNumber;
|
type BlockNumber = <TestRuntime as frame_system::Config>::BlockNumber;
|
||||||
type Hash = <TestRuntime as frame_system::Trait>::Hash;
|
type Hash = <TestRuntime as frame_system::Config>::Hash;
|
||||||
type Hasher = <TestRuntime as frame_system::Trait>::Hashing;
|
type Hasher = <TestRuntime as frame_system::Config>::Hashing;
|
||||||
type Header = <TestRuntime as frame_system::Trait>::Header;
|
type Header = <TestRuntime as frame_system::Config>::Header;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
|
pub fn run_test<T>(test: impl FnOnce() -> T) -> T {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ pub enum Error {
|
|||||||
StorageValueUnavailable,
|
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 {
|
fn from(error: Error) -> Self {
|
||||||
match error {
|
match error {
|
||||||
Error::StorageRootMismatch => crate::Error::StorageRootMismatch,
|
Error::StorageRootMismatch => crate::Error::StorageRootMismatch,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
|||||||
# Substrate Based Dependencies
|
# Substrate Based Dependencies
|
||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
|
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
@@ -36,6 +37,7 @@ std = [
|
|||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"fixed-hash/std",
|
"fixed-hash/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
|
"frame-system/std",
|
||||||
"hash256-std-hasher/std",
|
"hash256-std-hasher/std",
|
||||||
"impl-codec/std",
|
"impl-codec/std",
|
||||||
"impl-serde",
|
"impl-serde",
|
||||||
|
|||||||
@@ -24,11 +24,14 @@ mod millau_hash;
|
|||||||
|
|
||||||
use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState};
|
use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{weights::Weight, RuntimeDebug};
|
use frame_support::{
|
||||||
|
weights::{constants::WEIGHT_PER_MILLIS, DispatchClass, Weight},
|
||||||
|
RuntimeDebug,
|
||||||
|
};
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{IdentifyAccount, Verify},
|
traits::{IdentifyAccount, Verify},
|
||||||
MultiSignature, MultiSigner,
|
MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_trie::{trie_types::Layout, TrieConfiguration};
|
use sp_trie::{trie_types::Layout, TrieConfiguration};
|
||||||
@@ -68,23 +71,25 @@ impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maximal weight of single Millau block.
|
/// Maximum weight of single Millau block.
|
||||||
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 10_000_000_000;
|
///
|
||||||
/// Portion of block reserved for regular transactions.
|
/// This represents 0.1 seconds of compute assuming a target block time of six seconds.
|
||||||
pub const AVAILABLE_BLOCK_RATIO: u32 = 75;
|
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 10 * WEIGHT_PER_MILLIS;
|
||||||
/// Maximal weight of single Millau extrinsic (65% of maximum block weight = 75% for regular
|
|
||||||
/// transactions minus 10% for initialization).
|
/// Represents the average portion of a block's weight that will be used by an
|
||||||
pub const MAXIMUM_EXTRINSIC_WEIGHT: Weight = MAXIMUM_BLOCK_WEIGHT / 100 * (AVAILABLE_BLOCK_RATIO as Weight - 10);
|
/// `on_initialize()` runtime call.
|
||||||
/// Maximal size of Millau block.
|
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||||
pub const MAXIMUM_BLOCK_SIZE: u32 = 2 * 1024 * 1024;
|
|
||||||
/// Maximal size of single normal Millau extrinsic (75% of maximal block size).
|
/// Represents the portion of a block that will be used by Normal extrinsics.
|
||||||
pub const MAXIMUM_EXTRINSIC_SIZE: u32 = MAXIMUM_BLOCK_SIZE / 100 * AVAILABLE_BLOCK_RATIO;
|
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
|
|
||||||
// TODO: may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78
|
// TODO: may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78
|
||||||
/// Maximal number of messages in single delivery transaction.
|
/// Maximal number of messages in single delivery transaction.
|
||||||
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 1024;
|
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 1024;
|
||||||
|
|
||||||
/// Maximal number of unrewarded relayer entries at inbound lane.
|
/// Maximal number of unrewarded relayer entries at inbound lane.
|
||||||
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 1024;
|
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 1024;
|
||||||
|
|
||||||
/// Maximal number of unconfirmed messages at inbound lane.
|
/// Maximal number of unconfirmed messages at inbound lane.
|
||||||
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024;
|
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024;
|
||||||
|
|
||||||
@@ -155,6 +160,44 @@ impl sp_runtime::traits::Convert<sp_core::H256, AccountId> for AccountIdConverte
|
|||||||
hash.to_fixed_bytes().into()
|
hash.to_fixed_bytes().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a struct which defines the weight limits and values used during extrinsic execution.
|
||||||
|
pub fn runtime_block_weights() -> frame_system::limits::BlockWeights {
|
||||||
|
frame_system::limits::BlockWeights::builder()
|
||||||
|
// Allowance for Normal class
|
||||||
|
.for_class(DispatchClass::Normal, |weights| {
|
||||||
|
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
})
|
||||||
|
// Allowance for Operational class
|
||||||
|
.for_class(DispatchClass::Operational, |weights| {
|
||||||
|
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
// Extra reserved space for Operational class
|
||||||
|
weights.reserved = Some(MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
})
|
||||||
|
// By default Mandatory class is not limited at all.
|
||||||
|
// This parameter is used to derive maximal size of a single extrinsic.
|
||||||
|
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
|
||||||
|
.build_or_panic()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the maximum weight (compute time) that a Normal extrinsic on the Millau chain can use.
|
||||||
|
pub fn max_extrinsic_weight() -> Weight {
|
||||||
|
runtime_block_weights()
|
||||||
|
.get(DispatchClass::Normal)
|
||||||
|
.max_extrinsic
|
||||||
|
.unwrap_or(Weight::MAX)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a struct which tracks the length in bytes for each extrinsic class in a Millau block.
|
||||||
|
pub fn runtime_block_length() -> frame_system::limits::BlockLength {
|
||||||
|
frame_system::limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the maximum length in bytes that a Normal extrinsic on the Millau chain requires.
|
||||||
|
pub fn max_extrinsic_size() -> u32 {
|
||||||
|
*runtime_block_length().max.get(DispatchClass::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about Millau headers from the Bridge Pallet instance.
|
/// API for querying information about Millau headers from the Bridge Pallet instance.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use parity_util_mem::MallocSizeOf;
|
|||||||
use sp_runtime::traits::CheckEqual;
|
use sp_runtime::traits::CheckEqual;
|
||||||
|
|
||||||
// `sp_core::H512` can't be used, because it doesn't implement `CheckEqual`, which is required
|
// `sp_core::H512` can't be used, because it doesn't implement `CheckEqual`, which is required
|
||||||
// by `frame_system::Trait::Hash`.
|
// by `frame_system::Config::Hash`.
|
||||||
|
|
||||||
fixed_hash::construct_fixed_hash! {
|
fixed_hash::construct_fixed_hash! {
|
||||||
/// Hash type used in Millau chain.
|
/// Hash type used in Millau chain.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ bp-runtime = { path = "../runtime", default-features = false }
|
|||||||
# Substrate Based Dependencies
|
# Substrate Based Dependencies
|
||||||
|
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
|
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
|
||||||
@@ -27,6 +28,7 @@ std = [
|
|||||||
"bp-message-lane/std",
|
"bp-message-lane/std",
|
||||||
"bp-runtime/std",
|
"bp-runtime/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
|
"frame-system/std",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
|
|||||||
@@ -22,31 +22,36 @@
|
|||||||
|
|
||||||
use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState};
|
use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState};
|
||||||
use bp_runtime::Chain;
|
use bp_runtime::Chain;
|
||||||
use frame_support::{weights::Weight, RuntimeDebug};
|
use frame_support::{
|
||||||
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight},
|
||||||
|
RuntimeDebug,
|
||||||
|
};
|
||||||
use sp_core::Hasher as HasherT;
|
use sp_core::Hasher as HasherT;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
traits::{BlakeTwo256, Convert, IdentifyAccount, Verify},
|
||||||
MultiSignature, MultiSigner,
|
MultiSignature, MultiSigner, Perbill,
|
||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// Maximal weight of single Rialto block.
|
/// Maximal weight of single Rialto block.
|
||||||
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2_000_000_000_000;
|
///
|
||||||
/// Portion of block reserved for regular transactions.
|
/// This represents two seconds of compute assuming a target block time of six seconds.
|
||||||
pub const AVAILABLE_BLOCK_RATIO: u32 = 75;
|
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
|
||||||
/// Maximal weight of single Rialto extrinsic (65% of maximum block weight = 75% for regular
|
|
||||||
/// transactions minus 10% for initialization).
|
/// Represents the average portion of a block's weight that will be used by an
|
||||||
pub const MAXIMUM_EXTRINSIC_WEIGHT: Weight = MAXIMUM_BLOCK_WEIGHT / 100 * (AVAILABLE_BLOCK_RATIO as Weight - 10);
|
/// `on_initialize()` runtime call.
|
||||||
/// Maximal size of Rialto block.
|
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||||
pub const MAXIMUM_BLOCK_SIZE: u32 = 5 * 1024 * 1024;
|
|
||||||
/// Maximal size of single normal Rialto extrinsic (75% of maximal block size).
|
/// Represents the portion of a block that will be used by Normal extrinsics.
|
||||||
pub const MAXIMUM_EXTRINSIC_SIZE: u32 = MAXIMUM_BLOCK_SIZE / 100 * AVAILABLE_BLOCK_RATIO;
|
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||||
|
|
||||||
// TODO: may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78
|
// TODO: may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78
|
||||||
/// Maximal number of messages in single delivery transaction.
|
/// Maximal number of messages in single delivery transaction.
|
||||||
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 128;
|
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 128;
|
||||||
|
|
||||||
/// Maximal number of unrewarded relayer entries at inbound lane.
|
/// Maximal number of unrewarded relayer entries at inbound lane.
|
||||||
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 128;
|
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 128;
|
||||||
|
|
||||||
/// Maximal number of unconfirmed messages at inbound lane.
|
/// Maximal number of unconfirmed messages at inbound lane.
|
||||||
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128;
|
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128;
|
||||||
|
|
||||||
@@ -131,6 +136,43 @@ pub fn derive_account_from_millau_id(id: bp_runtime::SourceAccount<AccountId>) -
|
|||||||
AccountIdConverter::convert(encoded_id)
|
AccountIdConverter::convert(encoded_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a struct which defines the weight limits and values used during extrinsic execution.
|
||||||
|
pub fn runtime_block_weights() -> frame_system::limits::BlockWeights {
|
||||||
|
frame_system::limits::BlockWeights::builder()
|
||||||
|
// Allowance for Normal class
|
||||||
|
.for_class(DispatchClass::Normal, |weights| {
|
||||||
|
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
})
|
||||||
|
// Allowance for Operational class
|
||||||
|
.for_class(DispatchClass::Operational, |weights| {
|
||||||
|
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
// Extra reserved space for Operational class
|
||||||
|
weights.reserved = Some(MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
|
||||||
|
})
|
||||||
|
// By default Mandatory class is not limited at all.
|
||||||
|
// This parameter is used to derive maximal size of a single extrinsic.
|
||||||
|
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
|
||||||
|
.build_or_panic()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the maximum weight (compute time) that a Normal extrinsic on the Millau chain can use.
|
||||||
|
pub fn max_extrinsic_weight() -> Weight {
|
||||||
|
runtime_block_weights()
|
||||||
|
.get(DispatchClass::Normal)
|
||||||
|
.max_extrinsic
|
||||||
|
.unwrap_or(Weight::MAX)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get a struct which tracks the length in bytes for each extrinsic class in a Millau block.
|
||||||
|
pub fn runtime_block_length() -> frame_system::limits::BlockLength {
|
||||||
|
frame_system::limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the maximum length in bytes that a Normal extrinsic on the Millau chain requires.
|
||||||
|
pub fn max_extrinsic_size() -> u32 {
|
||||||
|
*runtime_block_length().max.get(DispatchClass::Normal)
|
||||||
|
}
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about Rialto headers from the Bridge Pallet instance.
|
/// API for querying information about Rialto headers from the Bridge Pallet instance.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub trait Chain: ChainBase {
|
|||||||
type Call: Dispatchable + Debug;
|
type Call: Dispatchable + Debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Substrate-based chain with `frame_system::Trait::AccountData` set to
|
/// Substrate-based chain with `frame_system::Config::AccountData` set to
|
||||||
/// the `pallet_balances::AccountData<NativeBalance>`.
|
/// the `pallet_balances::AccountData<NativeBalance>`.
|
||||||
pub trait ChainWithBalances: Chain {
|
pub trait ChainWithBalances: Chain {
|
||||||
/// Balance of an account in native tokens.
|
/// Balance of an account in native tokens.
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ pub fn run(
|
|||||||
max_messages_in_single_batch: bp_rialto::MAX_MESSAGES_IN_DELIVERY_TRANSACTION,
|
max_messages_in_single_batch: bp_rialto::MAX_MESSAGES_IN_DELIVERY_TRANSACTION,
|
||||||
// TODO: subtract base weight of delivery from this when it'll be known
|
// TODO: subtract base weight of delivery from this when it'll be known
|
||||||
// https://github.com/paritytech/parity-bridges-common/issues/78
|
// https://github.com/paritytech/parity-bridges-common/issues/78
|
||||||
max_messages_weight_in_single_batch: bp_rialto::MAXIMUM_EXTRINSIC_WEIGHT,
|
max_messages_weight_in_single_batch: bp_rialto::max_extrinsic_weight(),
|
||||||
// 2/3 is reserved for proofs and tx overhead
|
// 2/3 is reserved for proofs and tx overhead
|
||||||
max_messages_size_in_single_batch: bp_rialto::MAXIMUM_EXTRINSIC_SIZE as usize / 3,
|
max_messages_size_in_single_batch: bp_rialto::max_extrinsic_size() as usize / 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MillauSourceClient::new(millau_client, lane.clone(), lane_id, RIALTO_BRIDGE_INSTANCE),
|
MillauSourceClient::new(millau_client, lane.clone(), lane_id, RIALTO_BRIDGE_INSTANCE),
|
||||||
|
|||||||
@@ -132,9 +132,9 @@ pub fn run(
|
|||||||
max_messages_in_single_batch: bp_millau::MAX_MESSAGES_IN_DELIVERY_TRANSACTION,
|
max_messages_in_single_batch: bp_millau::MAX_MESSAGES_IN_DELIVERY_TRANSACTION,
|
||||||
// TODO: subtract base weight of delivery from this when it'll be known
|
// TODO: subtract base weight of delivery from this when it'll be known
|
||||||
// https://github.com/paritytech/parity-bridges-common/issues/78
|
// https://github.com/paritytech/parity-bridges-common/issues/78
|
||||||
max_messages_weight_in_single_batch: bp_millau::MAXIMUM_EXTRINSIC_WEIGHT,
|
max_messages_weight_in_single_batch: bp_millau::max_extrinsic_weight(),
|
||||||
// 2/3 is reserved for proofs and tx overhead
|
// 2/3 is reserved for proofs and tx overhead
|
||||||
max_messages_size_in_single_batch: bp_millau::MAXIMUM_EXTRINSIC_SIZE as usize / 3,
|
max_messages_size_in_single_batch: bp_millau::max_extrinsic_size() as usize / 3,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RialtoSourceClient::new(rialto_client, lane.clone(), lane_id, MILLAU_BRIDGE_INSTANCE),
|
RialtoSourceClient::new(rialto_client, lane.clone(), lane_id, MILLAU_BRIDGE_INSTANCE),
|
||||||
|
|||||||
Reference in New Issue
Block a user