Skip to content

Commit

Permalink
chore: update to polkadot 0.9.29
Browse files Browse the repository at this point in the history
Includes refactor to opaque weights (weights v1.5)
  • Loading branch information
Theodore Bugnet committed Oct 12, 2022
1 parent fa42905 commit b9abb0d
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 135 deletions.
116 changes: 36 additions & 80 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sc-informant = { git = "https://github.com/paritytech//substrate", branch = "pol
sc-keystore = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-network = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-network-gossip = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-network-common = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-offchain = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-rpc = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
sc-rpc-api = { git = "https://github.com/paritytech//substrate", branch = "polkadot-v0.9.29" }
Expand Down
2 changes: 1 addition & 1 deletion crates/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Contains<Call> for BaseFilter {
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1_000_000);
frame_system::limits::BlockWeights::simple_max(Weight::from_ref_time(1_000_000 as u64));
}
impl frame_system::Config for Test {
type BaseCallFilter = BaseFilter;
Expand Down
5 changes: 2 additions & 3 deletions parachain/runtime/runtime-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "r
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29", default-features = false }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29", default-features = false }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29", default-features = false }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29", default-features = false }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.29", default-features = false }

# Parachain dependencies
Expand Down Expand Up @@ -121,8 +122,6 @@ orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-libra
orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "44fda4432b71f49ee59a650cf4775db895ab97af", default-features = false }
orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "44fda4432b71f49ee59a650cf4775db895ab97af", default-features = false }

xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "ab5cd6c5fabe6ddda52ed6803ee1bf54c258fefe" }

[dev-dependencies]
hex = '0.4.2'
mocktopus = '0.7.0'
Expand Down Expand Up @@ -199,7 +198,7 @@ std = [
"interlay-runtime-parachain/std",
"testnet-kintsugi-runtime-parachain/std",
"testnet-interlay-runtime-parachain/std",

"btc-relay/std",
"currency/std",
"security/std",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
use crate::relaychain::kusama_test_net::*;
use codec::Encode;
use frame_support::{assert_ok, weights::WeightToFee};
use frame_support::{
assert_ok,
weights::{Weight as FrameWeight, WeightToFee},
};
use orml_traits::MultiCurrency;
use primitives::{
CurrencyId::{ForeignAsset, Token},
CustomMetadata,
};
use sp_runtime::{FixedPointNumber, FixedU128};
use xcm::latest::prelude::*;
use xcm::latest::{prelude::*, Weight};
use xcm_builder::ParentIsPreset;
use xcm_emulator::{TestExt, XcmExecutor};
use xcm_executor::traits::Convert;
use xcm_simulator::{TestExt, XcmExecutor};

mod fees {
use super::*;

// N * unit_weight * (weight/10^12) * token_per_second
fn weight_calculation(instruction_count: u32, unit_weight: Weight, per_second: u128) -> u128 {
let weight = unit_weight.saturating_mul(instruction_count as u64);
let weight_ratio = FixedU128::saturating_from_rational(weight as u128, WEIGHT_PER_SECOND as u128);
let weight_ratio = FixedU128::saturating_from_rational(weight as u128, WEIGHT_PER_SECOND.ref_time() as u128);
weight_ratio.saturating_mul_int(per_second)
}

Expand Down Expand Up @@ -229,7 +232,7 @@ fn transfer_to_relay_chain() {
});

KusamaNet::execute_with(|| {
let used_weight = 298_368_000; // the actual weight of the sent message
let used_weight = FrameWeight::from_ref_time(298_368_000); // the actual weight of the sent message
let fee =
<kusama_runtime::Runtime as pallet_transaction_payment::Config>::WeightToFee::weight_to_fee(&used_weight);
assert_eq!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub use primitives::{
TokenSymbol::{KINT, KSM},
};
use sp_runtime::traits::AccountIdConversion;
use xcm_emulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain};
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain};

pub const KINTSUGI_PARA_ID: u32 = 2092;
pub const SIBLING_PARA_ID: u32 = 2001;
Expand All @@ -23,7 +23,6 @@ decl_test_relay_chain! {
decl_test_parachain! {
pub struct Kintsugi {
Runtime = Runtime,
Origin = Origin,
XcmpMessageHandler = kintsugi_runtime_parachain::XcmpQueue,
DmpMessageHandler = kintsugi_runtime_parachain::DmpQueue,
new_ext = para_ext(KINTSUGI_PARA_ID),
Expand All @@ -33,7 +32,6 @@ decl_test_parachain! {
decl_test_parachain! {
pub struct Sibling {
Runtime = testnet_kintsugi_runtime_parachain::Runtime,
Origin = testnet_kintsugi_runtime_parachain::Origin,
XcmpMessageHandler = testnet_kintsugi_runtime_parachain::XcmpQueue,
DmpMessageHandler = testnet_kintsugi_runtime_parachain::DmpQueue,
new_ext = para_ext(SIBLING_PARA_ID),
Expand Down Expand Up @@ -66,7 +64,7 @@ fn default_parachains_host_configuration() -> HostConfiguration<BlockNumber> {
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024,
ump_service_total_weight: 4 * 1_000_000_000,
ump_service_total_weight: Weight::from_ref_time(4 * 1_000_000_000 as u64),
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 5_000_000_000_000,
Expand Down
Loading

0 comments on commit b9abb0d

Please sign in to comment.