Bump Substrate/Polkadot/Cumulus refs (aka Weights v1.5) (#1597)

* update Substrate + Polkadot + Cumulus refs

* Origin -> RuntimeOrigin

* weights v1.5

* update refs once again + `cargo test -p pallet-bridge-grandpa` works

* started work on `cargo test -p pallet-bridge-messages`

* cargo test -p pallet-bridge-relayers

* cargo test -p pallet-bridge-parachains

* cargo test -p millau-runtime

* cargo test -p bridge-runtime-common

* cargo test -p rialto-runtime

* cargo test -p rialto-parachain-runtime

* cargo test -p millau-bridge-node

* cargo test -p rialto-bridge-node

* cargo test -p rialto-parachain-collator

* cargo test -p messages-relay

* cargo test -p parachains-relay

* cargo test -p substrate-relay

* cargo test --all

* cargo check -p millau-runtime --locked --features runtime-benchmarks

* fix remaining test

* fmt

* try to allow clippy failure temporarily

* Revert "try to allow clippy failure temporarily"

This reverts commit d1b6593580f07e0dbeecb7ab0aa92cee98888ed3.

* use min_by

* Revert "use min_by"

This reverts commit 33042f49ed37e8dd0505370289e17f03bf1a56ee.

* Revert "Revert "use min_by""

This reverts commit 1d2204f0b14dc81e5650bb574dedb5fa78c7097d.

* trigger CI

* Revert "trigger CI"

This reverts commit 259d91b5606743bba9d043c69f07eac6c8700ef5.

* new day, new clippy warning

* more clippy issues
This commit is contained in:
Svyatoslav Nikolsky
2022-10-20 10:27:23 +03:00
committed by Bastian Köcher
parent 9e1847d12a
commit a3dc2d2748
66 changed files with 991 additions and 893 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ fixed-hash = { version = "0.7.0", default-features = false }
hash256-std-hasher = { version = "0.15.2", default-features = false }
impl-codec = { version = "0.6", default-features = false }
impl-serde = { version = "0.3.1", optional = true }
parity-util-mem = { version = "0.11", default-features = false, features = ["primitive-types"] }
parity-util-mem = { version = "0.12", default-features = false, features = ["primitive-types"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true, features = ["derive"] }
+11 -25
View File
@@ -25,7 +25,8 @@ use bp_messages::{
};
use bp_runtime::{decl_bridge_runtime_apis, Chain};
use frame_support::{
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
dispatch::DispatchClass,
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight},
Parameter, RuntimeDebug,
};
use frame_system::limits;
@@ -56,11 +57,8 @@ pub const TX_EXTRA_BYTES: u32 = 103;
/// Maximum weight of single Millau block.
///
/// This represents 0.5 seconds of compute assuming a target block time of six seconds.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;
/// Represents the average portion of a block's weight that will be used by an
/// `on_initialize()` runtime call.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_div(2);
/// Represents the portion of a block that will be used by Normal extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
@@ -77,21 +75,22 @@ pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 128;
/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH`
/// bytes is delivered. The message must have dispatch weight set to zero. The result then must be
/// rounded up to account possible future runtime upgrades.
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = Weight::from_ref_time(1_500_000_000);
/// Increase of delivery transaction weight on Millau chain with every additional message byte.
///
/// This value is a result of
/// `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The result then
/// must be rounded up to account possible future runtime upgrades.
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000;
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = Weight::from_ref_time(25_000);
/// Maximal weight of single message delivery confirmation transaction on Millau chain.
///
/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof`
/// weight formula computation for the case when single message is confirmed. The result then must
/// be rounded up to account possible future runtime upgrades.
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000;
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight =
Weight::from_ref_time(2_000_000_000);
/// Weight of pay-dispatch-fee operation for inbound messages at Millau chain.
///
@@ -100,7 +99,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
/// chain. Don't put too much reserve there, because it is used to **decrease**
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
/// transactions cheaper.
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = Weight::from_ref_time(700_000_000);
/// The target length of a session (how often authorities change) on Millau measured in of number of
/// blocks.
@@ -227,21 +226,8 @@ impl sp_runtime::traits::Hash for BlakeTwoAndKeccak256 {
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(2 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub BlockWeights: limits::BlockWeights = 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();
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}
/// Name of the With-Millau GRANDPA pallet instance that is deployed at bridged chains.
@@ -23,7 +23,8 @@ use bp_messages::{
};
use bp_runtime::{decl_bridge_runtime_apis, Chain};
use frame_support::{
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
dispatch::DispatchClass,
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight},
Parameter, RuntimeDebug,
};
use frame_system::limits;
@@ -53,11 +54,8 @@ pub const TX_EXTRA_BYTES: u32 = 104;
/// Maximal weight of single RialtoParachain block.
///
/// This represents two seconds of compute assuming a target block time of six seconds.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
/// Represents the average portion of a block's weight that will be used by an
/// `on_initialize()` runtime call.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2);
/// Represents the portion of a block that will be used by Normal extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
@@ -74,7 +72,7 @@ pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 1024;
/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH`
/// bytes is delivered. The message must have dispatch weight set to zero. The result then must be
/// rounded up to account possible future runtime upgrades.
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = Weight::from_ref_time(1_500_000_000);
/// Increase of delivery transaction weight on RialtoParachain chain with every additional message
/// byte.
@@ -82,14 +80,15 @@ pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
/// This value is a result of
/// `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The result then
/// must be rounded up to account possible future runtime upgrades.
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000;
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = Weight::from_ref_time(25_000);
/// Maximal weight of single message delivery confirmation transaction on RialtoParachain chain.
///
/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof`
/// weight formula computation for the case when single message is confirmed. The result then must
/// be rounded up to account possible future runtime upgrades.
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000;
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight =
Weight::from_ref_time(2_000_000_000);
/// Weight of pay-dispatch-fee operation for inbound messages at Rialto chain.
///
@@ -98,7 +97,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
/// chain. Don't put too much reserve there, because it is used to **decrease**
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
/// transactions cheaper.
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = Weight::from_ref_time(600_000_000);
/// Block number type used in Rialto.
pub type BlockNumber = u32;
@@ -164,21 +163,8 @@ impl Chain for RialtoParachain {
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub BlockWeights: limits::BlockWeights = 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();
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}
/// Name of the With-Rialto-Parachain messages pallet instance that is deployed at bridged chains.
+11 -25
View File
@@ -23,7 +23,8 @@ use bp_messages::{
};
use bp_runtime::{decl_bridge_runtime_apis, Chain};
use frame_support::{
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
dispatch::DispatchClass,
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, Weight},
Parameter, RuntimeDebug,
};
use frame_system::limits;
@@ -47,11 +48,8 @@ pub const TX_EXTRA_BYTES: u32 = 104;
/// Maximal weight of single Rialto block.
///
/// This represents two seconds of compute assuming a target block time of six seconds.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
/// Represents the average portion of a block's weight that will be used by an
/// `on_initialize()` runtime call.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2);
/// Represents the portion of a block that will be used by Normal extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
@@ -68,21 +66,22 @@ pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 1024;
/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH`
/// bytes is delivered. The message must have dispatch weight set to zero. The result then must be
/// rounded up to account possible future runtime upgrades.
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = Weight::from_ref_time(1_500_000_000);
/// Increase of delivery transaction weight on Rialto chain with every additional message byte.
///
/// This value is a result of
/// `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The result then
/// must be rounded up to account possible future runtime upgrades.
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000;
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = Weight::from_ref_time(25_000);
/// Maximal weight of single message delivery confirmation transaction on Rialto chain.
///
/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof`
/// weight formula computation for the case when single message is confirmed. The result then must
/// be rounded up to account possible future runtime upgrades.
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000;
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight =
Weight::from_ref_time(2_000_000_000);
/// Weight of pay-dispatch-fee operation for inbound messages at Rialto chain.
///
@@ -91,7 +90,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
/// chain. Don't put too much reserve there, because it is used to **decrease**
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
/// transactions cheaper.
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 700_000_000;
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = Weight::from_ref_time(700_000_000);
/// The target length of a session (how often authorities change) on Rialto measured in of number of
/// blocks.
@@ -193,21 +192,8 @@ impl Chain for Rialto {
frame_support::parameter_types! {
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub BlockWeights: limits::BlockWeights = 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();
pub BlockWeights: limits::BlockWeights =
limits::BlockWeights::with_sensible_defaults(MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO);
}
/// Name of the With-Rialto GRANDPA pallet instance that is deployed at bridged chains.
+5 -2
View File
@@ -33,12 +33,15 @@ pub type Westend = PolkadotLike;
pub enum Call {}
impl sp_runtime::traits::Dispatchable for Call {
type Origin = ();
type RuntimeOrigin = ();
type Config = ();
type Info = ();
type PostInfo = ();
fn dispatch(self, _origin: Self::Origin) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> {
fn dispatch(
self,
_origin: Self::RuntimeOrigin,
) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> {
unimplemented!("The Call is not expected to be dispatched.")
}
}
@@ -212,7 +212,7 @@ impl<SenderOrigin, Balance, Payload> MessagesBridge<SenderOrigin, Balance, Paylo
_message: Payload,
_delivery_and_dispatch_fee: Balance,
) -> Result<SendMessageArtifacts, Self::Error> {
Ok(SendMessageArtifacts { nonce: 0, weight: 0 })
Ok(SendMessageArtifacts { nonce: 0, weight: Weight::from_ref_time(0) })
}
}
@@ -233,10 +233,11 @@ pub trait OnDeliveryConfirmed {
fn on_messages_delivered(_lane: &LaneId, _messages: &DeliveredMessages) -> Weight;
}
#[allow(clippy::let_and_return)]
#[impl_trait_for_tuples::impl_for_tuples(30)]
impl OnDeliveryConfirmed for Tuple {
fn on_messages_delivered(lane: &LaneId, messages: &DeliveredMessages) -> Weight {
let mut total_weight: Weight = 0;
let mut total_weight = Weight::from_ref_time(0);
for_tuples!(
#(
total_weight = total_weight.saturating_add(Tuple::on_messages_delivered(lane, messages));
@@ -254,7 +255,7 @@ pub trait OnMessageAccepted {
impl OnMessageAccepted for () {
fn on_messages_accepted(_lane: &LaneId, _message: &MessageNonce) -> Weight {
0
Weight::from_ref_time(0)
}
}
@@ -167,7 +167,7 @@ impl<AccountId, Fee> MessageDispatch<AccountId, Fee> for ForbidInboundMessages {
) -> MessageDispatchResult {
MessageDispatchResult {
dispatch_result: false,
unspent_weight: 0,
unspent_weight: Weight::from_ref_time(0),
dispatch_fee_paid_during_dispatch: false,
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
parity-util-mem = { version = "0.11.0", optional = true }
parity-util-mem = { version = "0.12.0", optional = true }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0", optional = true, features = ["derive"] }
+9 -7
View File
@@ -20,11 +20,11 @@ use bp_messages::MessageNonce;
use bp_runtime::{Chain, EncodedOrDecodedCall};
use codec::Compact;
use frame_support::{
dispatch::Dispatchable,
dispatch::{DispatchClass, Dispatchable},
parameter_types,
weights::{
constants::{BlockExecutionWeight, WEIGHT_PER_SECOND},
DispatchClass, Weight,
Weight,
},
Blake2_128Concat, RuntimeDebug, StorageHasher, Twox128,
};
@@ -73,7 +73,8 @@ const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// All Polkadot-like chains allow 2 seconds of compute with a 6-second average block time.
///
/// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.set_proof_size(1_000).saturating_mul(2);
/// All Polkadot-like chains assume that an on-initialize consumes 1 percent of the weight on
/// average, hence a single extrinsic will not be allowed to consume more than
@@ -134,7 +135,8 @@ pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 8192;
/// This value is a result of `pallet_bridge_messages::Pallet::receive_messages_delivery_proof`
/// weight formula computation for the case when single message is confirmed. The result then must
/// be rounded up to account possible future runtime upgrades.
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000;
pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight =
Weight::from_ref_time(2_000_000_000);
/// Increase of delivery transaction weight on Polkadot-like chain with every additional message
/// byte.
@@ -142,7 +144,7 @@ pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000
/// This value is a result of
/// `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The result then
/// must be rounded up to account possible future runtime upgrades.
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000;
pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = Weight::from_ref_time(25_000);
/// Maximal number of bytes, included in the signed Polkadot-like transaction apart from the encoded
/// call itself.
@@ -156,7 +158,7 @@ pub const TX_EXTRA_BYTES: u32 = 256;
/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH`
/// bytes is delivered. The message must have dispatch weight set to zero. The result then must be
/// rounded up to account possible future runtime upgrades.
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = Weight::from_ref_time(1_500_000_000);
/// Weight of pay-dispatch-fee operation for inbound messages at Polkadot-like chain.
///
@@ -165,7 +167,7 @@ pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_500_000_000;
/// chain. Don't put too much reserve there, because it is used to **decrease**
/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery
/// transactions cheaper.
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = Weight::from_ref_time(600_000_000);
/// Re-export `time_units` to make usage easier.
pub use time_units::*;
+3 -3
View File
@@ -403,7 +403,7 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
}
/// Ensure that the origin is either root, or `PalletOwner`.
fn ensure_owner_or_root(origin: T::Origin) -> Result<(), BadOrigin> {
fn ensure_owner_or_root(origin: T::RuntimeOrigin) -> Result<(), BadOrigin> {
match origin.into() {
Ok(RawOrigin::Root) => Ok(()),
Ok(RawOrigin::Signed(ref signer))
@@ -422,7 +422,7 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
}
/// Change the owner of the module.
fn set_owner(origin: T::Origin, maybe_owner: Option<T::AccountId>) -> DispatchResult {
fn set_owner(origin: T::RuntimeOrigin, maybe_owner: Option<T::AccountId>) -> DispatchResult {
Self::ensure_owner_or_root(origin)?;
match maybe_owner {
Some(owner) => {
@@ -440,7 +440,7 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
/// Halt or resume all/some module operations.
fn set_operating_mode(
origin: T::Origin,
origin: T::RuntimeOrigin,
operating_mode: Self::OperatingMode,
) -> DispatchResult {
Self::ensure_owner_or_root(origin)?;
+9 -9
View File
@@ -228,16 +228,16 @@ macro_rules! generate_owned_bridge_module_tests {
PalletOwner::<TestRuntime>::put(1);
// The root should be able to change the owner.
assert_ok!(Pallet::<TestRuntime>::set_owner(Origin::root(), Some(2)));
assert_ok!(Pallet::<TestRuntime>::set_owner(RuntimeOrigin::root(), Some(2)));
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(2));
// The owner should be able to change the owner.
assert_ok!(Pallet::<TestRuntime>::set_owner(Origin::signed(2), Some(3)));
assert_ok!(Pallet::<TestRuntime>::set_owner(RuntimeOrigin::signed(2), Some(3)));
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(3));
// Other users shouldn't be able to change the owner.
assert_noop!(
Pallet::<TestRuntime>::set_owner(Origin::signed(1), Some(4)),
Pallet::<TestRuntime>::set_owner(RuntimeOrigin::signed(1), Some(4)),
DispatchError::BadOrigin
);
assert_eq!(PalletOwner::<TestRuntime>::get(), Some(3));
@@ -252,26 +252,26 @@ macro_rules! generate_owned_bridge_module_tests {
// The root should be able to halt the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::root(),
RuntimeOrigin::root(),
$halted_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $halted_operating_mode);
// The root should be able to resume the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::root(),
RuntimeOrigin::root(),
$normal_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $normal_operating_mode);
// The owner should be able to halt the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::signed(1),
RuntimeOrigin::signed(1),
$halted_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $halted_operating_mode);
// The owner should be able to resume the pallet.
assert_ok!(Pallet::<TestRuntime>::set_operating_mode(
Origin::signed(1),
RuntimeOrigin::signed(1),
$normal_operating_mode
));
assert_eq!(PalletOperatingMode::<TestRuntime>::get(), $normal_operating_mode);
@@ -279,7 +279,7 @@ macro_rules! generate_owned_bridge_module_tests {
// Other users shouldn't be able to halt the pallet.
assert_noop!(
Pallet::<TestRuntime>::set_operating_mode(
Origin::signed(2),
RuntimeOrigin::signed(2),
$halted_operating_mode
),
DispatchError::BadOrigin
@@ -289,7 +289,7 @@ macro_rules! generate_owned_bridge_module_tests {
PalletOperatingMode::<TestRuntime>::put($halted_operating_mode);
assert_noop!(
Pallet::<TestRuntime>::set_operating_mode(
Origin::signed(2),
RuntimeOrigin::signed(2),
$normal_operating_mode
),
DispatchError::BadOrigin