Skip to content

Commit

Permalink
calamari xcmp module configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Ferrell <[email protected]>
  • Loading branch information
ferrell-code committed Feb 2, 2024
1 parent bbe7334 commit a7ef2e0
Show file tree
Hide file tree
Showing 12 changed files with 657 additions and 350 deletions.
637 changes: 357 additions & 280 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ pallet-author-inherent = { git = "https://github.com/manta-network/nimbus.git",
# Polkadot dependencies
pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-cli = { git = 'https://github.com/paritytech/polkadot-sdk', branch = "release-polkadot-v1.6.0" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
polkadot-service = { git = 'https://github.com/paritytech/polkadot-sdk', branch = "release-polkadot-v1.6.0" }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.6.0", default-features = false }
Expand Down
7 changes: 7 additions & 0 deletions runtime/calamari/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-democracy = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-scheduler = { workspace = true }
Expand Down Expand Up @@ -84,8 +85,10 @@ pallet-author-inherent = { workspace = true }
# Polkadot dependencies
pallet-xcm = { workspace = true }
pallet-xcm-benchmarks = { workspace = true, optional = true }
parachains-common = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
Expand Down Expand Up @@ -185,6 +188,7 @@ runtime-benchmarks = [
"pallet-conviction-voting/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
'parachains-common/runtime-benchmarks',
]
try-runtime = [
'frame-try-runtime/try-runtime',
Expand Down Expand Up @@ -261,6 +265,7 @@ std = [
'frame-benchmarking/std',
'pallet-authorship/std',
'pallet-balances/std',
'pallet-message-queue/std',
'pallet-multisig/std',
'pallet-parachain-staking/std',
'substrate-fixed/std',
Expand Down Expand Up @@ -295,6 +300,8 @@ std = [
'xcm-builder/std',
'xcm-executor/std',
'polkadot-primitives/std',
'polkadot-runtime-common/std',
'parachains-common/std',
'manta-collator-selection/std',
'calamari-vesting/std',
'pallet-tx-pause/std',
Expand Down
57 changes: 5 additions & 52 deletions runtime/calamari/src/diff_tx_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use pallet_transaction_payment::Multiplier;
use runtime_common::MinimumMultiplier;
use sp_runtime::{
traits::{Saturating, Zero},
AccountId32, FixedPointNumber, MultiAddress, Perbill, Percent,
AccountId32, BuildStorage, FixedPointNumber, MultiAddress, Perbill, Percent,
};
use std::str::FromStr;
use xcm::prelude::*;
Expand Down Expand Up @@ -191,8 +191,8 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
Vec<(&'static str, &'static str, DispatchInfo, u32)>,
sp_io::TestExternalities,
) {
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.unwrap()
.into();

Expand Down Expand Up @@ -331,6 +331,8 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
let call = crate::RuntimeCall::Treasury(pallet_treasury::Call::spend {
amount: 8,
beneficiary: ALICE.into(),
asset_kind: Box::new(()),
valid_from: Some(0),
});
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push(("pallet_treasury", "spend", dispatch_info, call_len));
Expand Down Expand Up @@ -820,19 +822,6 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
9,
"Please update new extrinsic here."
);
// service_overweight
let call =
crate::RuntimeCall::XcmpQueue(cumulus_pallet_xcmp_queue::Call::service_overweight {
index: 1,
weight_limit: 64.into(),
});
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"cumulus_pallet_xcmp_queue",
"service_overweight",
dispatch_info,
call_len,
));

// suspend_xcm_execution
let call = crate::RuntimeCall::XcmpQueue(
Expand Down Expand Up @@ -892,42 +881,6 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
dispatch_info,
call_len,
));

// update_threshold_weight
let call = crate::RuntimeCall::XcmpQueue(
cumulus_pallet_xcmp_queue::Call::update_threshold_weight { new: 64.into() },
);
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"cumulus_pallet_xcmp_queue",
"update_threshold_weight",
dispatch_info,
call_len,
));

// update_weight_restrict_decay
let call = crate::RuntimeCall::XcmpQueue(
cumulus_pallet_xcmp_queue::Call::update_weight_restrict_decay { new: 64.into() },
);
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"cumulus_pallet_xcmp_queue",
"update_weight_restrict_decay",
dispatch_info,
call_len,
));

// update_xcmp_max_individual_weight
let call = crate::RuntimeCall::XcmpQueue(
cumulus_pallet_xcmp_queue::Call::update_xcmp_max_individual_weight { new: 64.into() },
);
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"cumulus_pallet_xcmp_queue",
"update_xcmp_max_individual_weight",
dispatch_info,
call_len,
));
}

// orml_xtokens
Expand Down
9 changes: 5 additions & 4 deletions runtime/calamari/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod multiplier_tests {
use manta_primitives::constants::time::DAYS;
use pallet_transaction_payment::Multiplier;
use runtime_common::MinimumMultiplier;
use sp_runtime::BuildStorage;

fn fetch_kma_price() -> Result<f32, &'static str> {
let body = reqwest::blocking::get(
Expand Down Expand Up @@ -89,8 +90,8 @@ mod multiplier_tests {
..Default::default()
};

let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.unwrap()
.into();
// set the minimum
Expand Down Expand Up @@ -160,8 +161,8 @@ mod multiplier_tests {
let mut multiplier = Multiplier::from_u32(1);
let mut blocks = 0;

let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.unwrap()
.into();

Expand Down
20 changes: 16 additions & 4 deletions runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT},
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, IdentityLookup},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Percent, Permill,
};
Expand All @@ -45,8 +45,10 @@ use frame_support::{
dispatch::DispatchClass,
parameter_types,
traits::{
fungible::HoldConsideration, ConstU128, ConstU32, ConstU8, Contains, Currency,
EitherOfDiverse, IsInVec, LinearStoragePrice, NeverEnsureOrigin, PrivilegeCmp,
fungible::HoldConsideration,
tokens::{PayFromAccount, UnityAssetBalanceConversion},
ConstBool, ConstU128, ConstU32, ConstU8, Contains, Currency, EitherOfDiverse, IsInVec,
LinearStoragePrice, NeverEnsureOrigin, PrivilegeCmp,
},
weights::{ConstantMultiplier, Weight},
PalletId,
Expand Down Expand Up @@ -669,6 +671,7 @@ parameter_types! {
pub SpendPeriod: BlockNumber = prod_or_fast!(6 * DAYS, 2 * MINUTES, "CALAMARI_SPEND_PERIOD");
pub const Burn: Permill = Permill::from_percent(0);
pub const TreasuryPalletId: PalletId = TREASURY_PALLET_ID;
pub const PayoutSpendPeriod: BlockNumber = 30 * DAYS;
}

type EnsureRootOrThreeFifthsCouncil = EitherOfDiverse<
Expand Down Expand Up @@ -700,6 +703,12 @@ impl pallet_treasury::Config for Runtime {
// Expects an implementation of `EnsureOrigin` with a `Success` generic,
// which is the the maximum amount that this origin is allowed to spend at a time.
type SpendOrigin = NeverEnsureOrigin<Balance>;
type Beneficiary = AccountId;
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = PayoutSpendPeriod;
type AssetKind = ();
}

impl pallet_aura_style_filter::Config for Runtime {
Expand Down Expand Up @@ -820,7 +829,8 @@ parameter_types! {
// So anything more than 3.5MB doesn't make sense here
pub const PreimageMaxSize: u32 = 3584 * 1024;
pub const PreimageBaseDeposit: Balance = 1 * KMA;
pub const PreimageHoldReason: RuntimeHoldReason = RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
pub const PreimageHoldReason: RuntimeHoldReason =
RuntimeHoldReason::Preimage(pallet_preimage::HoldReason::Preimage);
}

impl pallet_preimage::Config for Runtime {
Expand Down Expand Up @@ -870,6 +880,7 @@ impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
}

parameter_types! {
Expand Down Expand Up @@ -1026,6 +1037,7 @@ construct_runtime!(
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 32,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 33,
XTokens: orml_xtokens::{Pallet, Call, Event<T>, Storage} = 34,
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 35,

// Handy utilities.
Utility: pallet_utility::{Pallet, Call, Event} = 40,
Expand Down
2 changes: 0 additions & 2 deletions runtime/calamari/src/migrations/sudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use frame_support::{
pallet_prelude::Weight,
traits::{Get, OnRuntimeUpgrade},
};
use sp_runtime::DispatchError;
use sp_std::vec::Vec;

pub struct RemoveSudo<T>(PhantomData<T>);
impl<T: frame_system::Config> OnRuntimeUpgrade for RemoveSudo<T> {
Expand Down
38 changes: 38 additions & 0 deletions runtime/calamari/src/weights/frame_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub trait WeightInfo {
fn set_storage(i: u32, ) -> Weight;
fn kill_storage(i: u32, ) -> Weight;
fn kill_prefix(p: u32, ) -> Weight;
fn authorize_upgrade() -> Weight;
fn apply_authorized_upgrade() -> Weight;
}

/// Weights for frame_system using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -116,6 +118,24 @@ impl<T: frame_system::Config> frame_system::WeightInfo for SubstrateWeight<T> {
.saturating_add(Weight::from_parts(1_158_786, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[0, 1000]`.
fn authorize_upgrade() -> Weight {
// Minimum execution time: 17_856 nanoseconds.
Weight::from_parts(18_373_000, 0)
// Standard Error: 1_613
.saturating_add(Weight::from_parts(1_158_786, 0))
.saturating_add(T::DbWeight::get().writes((1_u64)))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[0, 1000]`.
fn apply_authorized_upgrade() -> Weight {
// Minimum execution time: 17_856 nanoseconds.
Weight::from_parts(18_373_000, 0)
// Standard Error: 1_613
.saturating_add(Weight::from_parts(1_158_786, 0))
.saturating_add(T::DbWeight::get().writes((1_u64)))
}
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -178,4 +198,22 @@ impl WeightInfo for () {
.saturating_add(Weight::from_parts(1_158_786, 0).saturating_mul(p.into()))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into())))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[0, 1000]`.
fn authorize_upgrade() -> Weight {
// Minimum execution time: 17_856 nanoseconds.
Weight::from_parts(18_373_000, 0)
// Standard Error: 1_613
.saturating_add(Weight::from_parts(1_158_786, 0))
.saturating_add(RocksDbWeight::get().writes((1_u64)))
}
// Storage: Skipped Metadata (r:0 w:0)
/// The range of component `p` is `[0, 1000]`.
fn apply_authorized_upgrade() -> Weight {
// Minimum execution time: 17_856 nanoseconds.
Weight::from_parts(18_373_000, 0)
// Standard Error: 1_613
.saturating_add(Weight::from_parts(1_158_786, 0))
.saturating_add(RocksDbWeight::get().writes((1_u64)))
}
}
23 changes: 23 additions & 0 deletions runtime/calamari/src/weights/pallet_preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub trait WeightInfo {
fn unrequest_preimage() -> Weight;
fn unrequest_unnoted_preimage() -> Weight;
fn unrequest_multi_referenced_preimage() -> Weight;
fn ensure_updated(s: u32, ) -> Weight;
}

/// Weights for pallet_preimage using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -215,6 +216,17 @@ impl<T: frame_system::Config> pallet_preimage::WeightInfo for SubstrateWeight<T>
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: Preimage StatusFor (r:1 w:1)
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
fn ensure_updated(_s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `140`
// Estimated: `3556`
// Minimum execution time: 9_631_000 picoseconds.
Weight::from_parts(9_884_000, 3556)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -372,4 +384,15 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: Preimage StatusFor (r:1 w:1)
/// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen)
fn ensure_updated(_s: u32) -> Weight {
// Proof Size summary in bytes:
// Measured: `140`
// Estimated: `3556`
// Minimum execution time: 9_631_000 picoseconds.
Weight::from_parts(9_884_000, 3556)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
Loading

0 comments on commit a7ef2e0

Please sign in to comment.