Skip to content

Commit

Permalink
polkadot version upgrade from v1.2.0 to v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy Li authored and Freddy Li committed May 17, 2024
1 parent 5bb313b commit 4721ddf
Show file tree
Hide file tree
Showing 53 changed files with 4,757 additions and 3,437 deletions.
4,745 changes: 2,708 additions & 2,037 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ members = [
"substrate-node/standalone/runtime",
"parachain-info",
"bridge-forwarder",
"xcm-bridge"
"xcm-bridge",
"xcm-mock-message-queue"
]

exclude = [
Expand Down
18 changes: 9 additions & 9 deletions access-segregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde", "decode"] }

# Substrate
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

[dev-dependencies]
# Substrate
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }

[features]
default = ["std"]
Expand Down
3 changes: 2 additions & 1 deletion access-segregator/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<2>;
type RuntimeTask = ();
}

parameter_types! {
Expand All @@ -83,7 +84,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type RuntimeFreezeReason = ();
}

parameter_types! {
Expand Down
24 changes: 12 additions & 12 deletions basic-fee-handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ codec = { package = "parity-scale-codec", version = "3.6.1", default-features =
scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde", "decode"] }

# Substrate
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

# Polkadot
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

# Local
sygma-traits = { path = "../traits", default-features = false }
sygma-access-segregator = { path = "../access-segregator", default-features = false }

[dev-dependencies]
# Substrate
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }

[features]
default = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions basic-fee-handler/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use frame_system::RawOrigin as SystemOrigin;

use sp_std::vec;
use sygma_traits::DomainID;
use xcm::latest::prelude::*;
use xcm::v4::prelude::*;

#[benchmarks]
mod benchmarks {
Expand All @@ -19,7 +19,7 @@ mod benchmarks {
#[benchmark]
fn set_fee() {
let dest_domain_id: DomainID = 1;
let native_location: MultiLocation = MultiLocation::here();
let native_location: Location = Location::here();
let fee = 1_000_000_000_000u128; // 1 with 12 decimals

#[extrinsic_call]
Expand Down
60 changes: 39 additions & 21 deletions basic-fee-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub mod pallet {
use frame_system::pallet_prelude::*;
use sp_std::boxed::Box;
use sygma_traits::{DomainID, FeeHandler};
use xcm::latest::{AssetId, MultiAsset};
use xcm::opaque::v4::Asset;
use xcm::v4::AssetId;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

Expand Down Expand Up @@ -96,7 +97,7 @@ pub mod pallet {
}

impl<T: Config> FeeHandler for Pallet<T> {
fn get_fee(domain: DomainID, asset: MultiAsset) -> Option<u128> {
fn get_fee(domain: DomainID, asset: Asset) -> Option<u128> {
AssetFees::<T>::get((domain, &asset.id))
}
}
Expand All @@ -112,61 +113,75 @@ pub mod pallet {
use frame_support::{assert_noop, assert_ok};
use sp_std::boxed::Box;
use sygma_traits::DomainID;
use xcm::latest::{prelude::*, MultiLocation};
use xcm::opaque::v4::Junctions::Here;
use xcm::opaque::v4::Location;
use xcm::v4::prelude::*;

#[test]
fn set_get_fee() {
new_test_ext().execute_with(|| {
let dest_domain_id: DomainID = 0;
let another_dest_domain_id: DomainID = 1;
let asset_id_a = Concrete(MultiLocation::new(1, Here));
let asset_id_a = AssetId(Location::new(1, Here));
let amount_a = 100u128;

let asset_id_b = Concrete(MultiLocation::new(2, Here));
let asset_id_b = AssetId(Location::new(2, Here));
let amount_b = 101u128;

// set fee 100 with assetId asset_id_a for one domain
assert_ok!(BasicFeeHandler::set_fee(
Origin::root(),
dest_domain_id,
Box::new(asset_id_a),
Box::new(asset_id_a.clone()),
amount_a
));
// set fee 200 with assetId asset_id_a for another domain
assert_ok!(BasicFeeHandler::set_fee(
Origin::root(),
another_dest_domain_id,
Box::new(asset_id_a),
Box::new(asset_id_a.clone()),
amount_a * 2
));
assert_eq!(AssetFees::<Test>::get((dest_domain_id, asset_id_a)).unwrap(), amount_a);
assert_eq!(
AssetFees::<Test>::get((another_dest_domain_id, asset_id_a)).unwrap(),
AssetFees::<Test>::get((dest_domain_id, asset_id_a.clone())).unwrap(),
amount_a
);
assert_eq!(
AssetFees::<Test>::get((another_dest_domain_id, asset_id_a.clone())).unwrap(),
amount_a * 2
);

// set fee 101 with assetId asset_id_b
assert_ok!(BasicFeeHandler::set_fee(
Origin::root(),
dest_domain_id,
Box::new(asset_id_b),
Box::new(asset_id_b.clone()),
amount_b
));
assert_eq!(AssetFees::<Test>::get((dest_domain_id, asset_id_b)).unwrap(), amount_b);
assert_eq!(
AssetFees::<Test>::get((dest_domain_id, asset_id_b.clone())).unwrap(),
amount_b
);

// fee of asset_id_a should not be equal to amount_b
assert_ne!(AssetFees::<Test>::get((dest_domain_id, asset_id_a)).unwrap(), amount_b);
assert_ne!(
AssetFees::<Test>::get((dest_domain_id, asset_id_a.clone())).unwrap(),
amount_b
);

// fee of asset_id_b should not be equal to amount_a
assert_ne!(AssetFees::<Test>::get((dest_domain_id, asset_id_b)).unwrap(), amount_a);
assert_ne!(
AssetFees::<Test>::get((dest_domain_id, asset_id_b.clone())).unwrap(),
amount_a
);

// permission test: unauthorized account should not be able to set fee
let unauthorized_account = Origin::from(Some(ALICE));
assert_noop!(
BasicFeeHandler::set_fee(
unauthorized_account,
dest_domain_id,
Box::new(asset_id_a),
Box::new(asset_id_a.clone()),
amount_a
),
basic_fee_handler::Error::<Test>::AccessDenied
Expand All @@ -175,12 +190,12 @@ pub mod pallet {
assert_events(vec![
Event::BasicFeeHandler(BasicFeeHandlerEvent::FeeSet {
domain: dest_domain_id,
asset: asset_id_a,
asset: asset_id_a.clone(),
amount: amount_a,
}),
Event::BasicFeeHandler(BasicFeeHandlerEvent::FeeSet {
domain: another_dest_domain_id,
asset: asset_id_a,
asset: asset_id_a.clone(),
amount: amount_a * 2,
}),
Event::BasicFeeHandler(BasicFeeHandlerEvent::FeeSet {
Expand All @@ -196,19 +211,19 @@ pub mod pallet {
fn access_control() {
new_test_ext().execute_with(|| {
let dest_domain_id: DomainID = 0;
let asset_id = Concrete(MultiLocation::new(0, Here));
let asset_id = AssetId(Location::new(0, Here));

assert_ok!(BasicFeeHandler::set_fee(
Origin::root(),
dest_domain_id,
Box::new(asset_id),
Box::new(asset_id.clone()),
100
),);
assert_noop!(
BasicFeeHandler::set_fee(
Some(ALICE).into(),
dest_domain_id,
Box::new(asset_id),
Box::new(asset_id.clone()),
200
),
basic_fee_handler::Error::<Test>::AccessDenied
Expand All @@ -234,10 +249,13 @@ pub mod pallet {
assert_ok!(BasicFeeHandler::set_fee(
Some(ALICE).into(),
dest_domain_id,
Box::new(asset_id),
Box::new(asset_id.clone()),
200
),);
assert_eq!(AssetFees::<Test>::get((dest_domain_id, asset_id)).unwrap(), 200);
assert_eq!(
AssetFees::<Test>::get((dest_domain_id, asset_id.clone())).unwrap(),
200
);
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion basic-fee-handler/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = ConstU32<2>;
type RuntimeTask = ();
}

parameter_types! {
Expand All @@ -84,7 +85,7 @@ impl pallet_balances::Config for Test {
type FreezeIdentifier = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type MaxHolds = ();
type RuntimeFreezeReason = ();
}

parameter_types! {
Expand Down
40 changes: 20 additions & 20 deletions bridge-forwarder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ scale-info = { version = "2.5.0", default-features = false, features = ["derive"
hex-literal = { version = "0.3", default-features = false }

# Substrate
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

# Polkadot
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

# Cumulus
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }
cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0", default-features = false }

# Local
sygma-traits = { path = "../traits", default-features = false }

[dev-dependencies]
# Substrate
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }

# Polkadot
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.2.0" }
polkadot-parachain-primitives = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.7.0" }

# Local
sygma-traits = { path = "../traits" }
Expand Down
Loading

0 comments on commit 4721ddf

Please sign in to comment.