Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Polkadot 0.9.26 #146

Merged
merged 20 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 201 additions & 35 deletions pallets/subbridge/src/chainbridge.rs

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions pallets/subbridge/src/fungible_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ impl<
);

// Deposit asset into temporary account, then forward through other bridges
let temporary_account =
MultiLocation::new(0, X1(GeneralKey(b"bridge_transfer".to_vec().try_into().expect("less than length limit; qed"))))
.into_account();
let temporary_account = MultiLocation::new(
0,
X1(GeneralKey(
b"bridge_transfer"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
)
.into_account();
if NativeChecker::is_native_asset(what) {
NativeAdapter::deposit_asset(
what,
Expand Down
8 changes: 7 additions & 1 deletion pallets/subbridge/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ mod subbridge_v3_migration_common {
T: chainbridge::Config + xcmbridge::Config + xtransfer::Config,
{
// Remove old chainbridge::BridgeFee storage
let _ = frame_support::migration::clear_storage_prefix(b"ChainBridge", b"BridgeFee", &[], None, None);
let _ = frame_support::migration::clear_storage_prefix(
b"ChainBridge",
b"BridgeFee",
&[],
None,
None,
);

// Create new storage items of fee setting in pallet ChainBridge
chainbridge::BridgeFee::<T>::insert(0, 300_000_000_000_000);
Expand Down
2 changes: 2 additions & 0 deletions pallets/subbridge/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl Config for XcmConfig {
}
parameter_types! {
pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;
pub const BridgeEventLimit: u32 = 1024;
}
pub type LocalOriginToLocation = SignedToAccountId32<Origin, AccountId, RelayNetwork>;

Expand Down Expand Up @@ -368,6 +369,7 @@ impl chainbridge::Config for Runtime {
>,
>;
type AssetsRegistry = AssetsRegistry;
type BridgeEventLimit = BridgeEventLimit;
}

impl xtransfer::Config for Runtime {
Expand Down
1 change: 0 additions & 1 deletion pallets/subbridge/src/xcmbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub mod pallet {
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::storage_version(STORAGE_VERSION)]
// TODO: remove when we Vec get replaced by BoundedVec
#[pallet::without_storage_info]
h4x3rotab marked this conversation as resolved.
Show resolved Hide resolved
pub struct Pallet<T>(_);

Expand Down
127 changes: 104 additions & 23 deletions pallets/subbridge/src/xtransfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,16 @@ pub mod pallet {
// use it as sender, asset will be withdrawn from this account.
// TODO: Handle the sitution when forwarding failed. Maybe need to have something like `AssesTrap`
// and `AssetsClaim`.
let temporary_account =
MultiLocation::new(0, X1(GeneralKey(b"bridge_transfer".to_vec().try_into().expect("less than length limit; qed")))).into_account();
let temporary_account = MultiLocation::new(
0,
X1(GeneralKey(
b"bridge_transfer"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
)
.into_account();
Self::do_transfer(
temporary_account.into(),
what.clone(),
Expand All @@ -177,13 +185,11 @@ pub mod pallet {
ENDOWED_BALANCE,
};
use crate::traits::*;
use crate::xcmbridge::Error as XcmbridgeError;
use crate::xtransfer::Error as XTransferError;

use frame_support::{assert_noop, assert_ok};
use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::{AccountIdConversion, ConstU32};
use sp_runtime::{AccountId32, bounded_vec, WeakBoundedVec};
use sp_runtime::{bounded_vec, AccountId32, WeakBoundedVec};

use assets_registry::{
AccountId32Conversion, AssetProperties, ExtractReserveLocation, IntoResourceId,
Expand All @@ -200,8 +206,15 @@ pub mod pallet {
fn test_transfer_unregistered_assets_to_parachain_should_failed() {
TestNet::reset();

let unregistered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"unregistered".to_vec().try_into().expect("less than length limit; qed"))));
let unregistered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"unregistered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);

ParaA::execute_with(|| {
// To parachains via Xcm(according to the dest)
Expand Down Expand Up @@ -230,8 +243,15 @@ pub mod pallet {
fn test_transfer_unregistered_assets_to_solochain_should_failed() {
TestNet::reset();

let unregistered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"unregistered".to_vec().try_into().expect("less than length limit; qed"))));
let unregistered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"unregistered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);

ParaA::execute_with(|| {
// To solo chains via Chainbridge(according to the dest)
Expand All @@ -242,9 +262,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -258,8 +288,15 @@ pub mod pallet {
fn test_transfer_by_chainbridge_without_enabled_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand All @@ -281,9 +318,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -297,8 +344,15 @@ pub mod pallet {
fn test_transfer_by_chainbridge_without_feeset_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand Down Expand Up @@ -329,9 +383,19 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(b"recipient".to_vec().try_into().expect("less than length limit; qed"))
GeneralKey(
b"recipient"
.to_vec()
.try_into()
.expect("less than length limit; qed")
)
)
)),
None,
Expand All @@ -345,8 +409,15 @@ pub mod pallet {
fn test_transfer_assets_to_local_should_failed() {
TestNet::reset();

let registered_asset_location =
MultiLocation::new(0, X1(GeneralKey(b"registered".to_vec().try_into().expect("less than length limit; qed"))));
let registered_asset_location = MultiLocation::new(
0,
X1(GeneralKey(
b"registered"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
)),
);
ParaA::execute_with(|| {
// Register asset
assert_ok!(AssetsRegistry::force_register_asset(
Expand Down Expand Up @@ -401,7 +472,12 @@ pub mod pallet {
Box::new(MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed")
),
GeneralIndex(0),
GeneralKey(recipient.clone())
)
Expand Down Expand Up @@ -435,7 +511,12 @@ pub mod pallet {
let dest = MultiLocation::new(
0,
X3(
GeneralKey(b"cb".to_vec().try_into().expect("less than length limit; qed")),
GeneralKey(
b"cb"
.to_vec()
.try_into()
.expect("less than length limit; qed"),
),
GeneralIndex(0),
GeneralKey(recipient.clone()),
),
Expand Down
2 changes: 2 additions & 0 deletions runtime/khala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ impl pallet_collator_selection::Config for Runtime {
parameter_types! {
pub const BridgeChainId: u8 = 1;
pub const ProposalLifetime: BlockNumber = 50400; // ~7 days
pub const BridgeEventLimit: u32 = 1024;
}

impl chainbridge::Config for Runtime {
Expand All @@ -1462,6 +1463,7 @@ impl chainbridge::Config for Runtime {
>,
>;
type AssetsRegistry = AssetsRegistry;
type BridgeEventLimit = BridgeEventLimit;
}

impl xtransfer::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions runtime/phala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ impl assets_registry::Config for Runtime {
parameter_types! {
pub const BridgeChainId: u8 = 3;
pub const ProposalLifetime: BlockNumber = 50400; // ~7 days
pub const BridgeEventLimit: u32 = 1024;
}

impl chainbridge::Config for Runtime {
Expand All @@ -1297,6 +1298,7 @@ impl chainbridge::Config for Runtime {
>,
>;
type AssetsRegistry = AssetsRegistry;
type BridgeEventLimit = BridgeEventLimit;
}

impl xtransfer::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions runtime/rhala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,7 @@ impl pallet_collator_selection::Config for Runtime {
parameter_types! {
pub const BridgeChainId: u8 = 1;
pub const ProposalLifetime: BlockNumber = 50400; // ~7 days
pub const BridgeEventLimit: u32 = 1024;
}

impl chainbridge::Config for Runtime {
Expand All @@ -1460,6 +1461,7 @@ impl chainbridge::Config for Runtime {
>,
>;
type AssetsRegistry = AssetsRegistry;
type BridgeEventLimit = BridgeEventLimit;
}

impl xtransfer::Config for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions runtime/thala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,7 @@ impl pallet_collator_selection::Config for Runtime {
parameter_types! {
pub const BridgeChainId: u8 = 1;
pub const ProposalLifetime: BlockNumber = 50400; // ~7 days
pub const BridgeEventLimit: u32 = 1024;
}

impl chainbridge::Config for Runtime {
Expand All @@ -1469,6 +1470,7 @@ impl chainbridge::Config for Runtime {
>,
>;
type AssetsRegistry = AssetsRegistry;
type BridgeEventLimit = BridgeEventLimit;
}

impl xtransfer::Config for Runtime {
Expand Down