Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
44 changes: 22 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion integration-tests/bridges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cd
git clone https://github.com/integritee-network/parachain.git
cd parachain
git apply ./integration-tests/bridges/sudo-integritee.patch
cargo build --release
cargo build --release -p integritee-collator
cp ./target/release/integritee-collator ~/local_bridge_testing/bin/
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn assert_integritee_polkadot_tokens_minted(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
RuntimeEvent::Porteer(pallet_porteer::Event::MintedPortedTokens {
who, amount,
who, amount, source_nonce: _
}) => { who: *who == beneficiary, amount: *amount == ported_tokens_amount, },
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted { amount_in, ..}) => { amount_in: {
xcm_execution_fee = *amount_in;
Expand All @@ -227,7 +227,7 @@ fn assert_integritee_polkadot_tokens_minted(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
RuntimeEvent::Porteer(pallet_porteer::Event::MintedPortedTokens {
who, amount,
who, amount, source_nonce: _
}) => { who: *who == beneficiary, amount: *amount == ported_tokens_amount, },
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted { amount_in, ..}) => { amount_in: {
xcm_execution_fee = *amount_in;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn assert_integritee_kusama_tokens_minted(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
RuntimeEvent::Porteer(pallet_porteer::Event::MintedPortedTokens {
who, amount,
who, amount, source_nonce: _
}) => { who: *who == beneficiary, amount: *amount == ported_tokens_amount, },
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted { amount_in, ..}) => { amount_in: {
xcm_execution_fee = *amount_in;
Expand All @@ -228,7 +228,7 @@ fn assert_integritee_kusama_tokens_minted(
pallet_message_queue::Event::Processed { success: true, .. }
) => {},
RuntimeEvent::Porteer(pallet_porteer::Event::MintedPortedTokens {
who, amount,
who, amount, source_nonce: _
}) => { who: *who == beneficiary, amount: *amount == ported_tokens_amount, },
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::SwapCreditExecuted { amount_in, ..}) => { amount_in: {
xcm_execution_fee = *amount_in;
Expand Down
24 changes: 17 additions & 7 deletions polkadot-parachains/common/src/porteer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use crate::{AccountId, Balance};
use pallet_porteer::XcmFeeParams;
use parity_scale_codec::Encode;
use parity_scale_codec::{Compact, Encode};
use sp_std::vec;
use xcm::{
latest::{
Expand All @@ -39,13 +39,22 @@ pub const AHP_FEE: u128 = 3000000000000;
pub const IP_FEE: u128 = 1000000000000;

// hop1: [TEER], hop2: [KSM], hope: [DOT]. Each hop must include the fees of all subsequent hops (consider swapping)
pub const DEFAULT_XCM_FEES_IK_PERSPECTIVE: XcmFeeParams<Balance> =
XcmFeeParams { hop1: AHK_FEE, hop2: AHP_FEE, hop3: IP_FEE };
pub const DEFAULT_XCM_FEES_IK_PERSPECTIVE: XcmFeeParams<Balance> = XcmFeeParams {
local_equivalent_sum: 10_000_000_000_000u128,
hop1: AHK_FEE,
hop2: AHP_FEE,
hop3: IP_FEE,
};

// hop1: [TEER], hop2: [DOT], hope: [KSM]. Each hop must include the fees of all subsequent hops (consider swapping)
pub const DEFAULT_XCM_FEES_IP_PERSPECTIVE: XcmFeeParams<Balance> =
XcmFeeParams { hop1: AHP_FEE, hop2: AHK_FEE, hop3: IK_FEE };
pub const DEFAULT_XCM_FEES_IP_PERSPECTIVE: XcmFeeParams<Balance> = XcmFeeParams {
local_equivalent_sum: 10_000_000_000_000u128,
hop1: AHP_FEE,
hop2: AHK_FEE,
hop3: IK_FEE,
};

pub type PortTokensNonce = u64;
/// The porteer::mint call used by both runtimes.
///
/// We have tests in the runtimes that ensure that the
Expand All @@ -54,9 +63,10 @@ pub fn integritee_runtime_porteer_mint(
beneficiary: AccountId,
amount: Balance,
location: Option<Location>,
) -> ([u8; 2], AccountId, Balance, Option<Location>) {
nonce: PortTokensNonce,
) -> ([u8; 2], AccountId, Compact<Balance>, Option<Location>, Compact<PortTokensNonce>) {
// ([pallet_index, call_index], ...)
([56, 7], beneficiary, amount, location)
([56, 7], beneficiary, amount.into(), location, nonce.into())
}

pub const INTEGRITEE_KUSAMA_PARA_ID: u32 = 2015;
Expand Down
1 change: 1 addition & 0 deletions polkadot-parachains/integritee-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ impl pallet_porteer::Config for Runtime {
EnsureRoot<AccountId32>,
>;
type PortTokensToDestination = PortTokensToPolkadot;
type FeeCollectorAccount = TreasuryAccount;
type ForwardPortedTokensToDestinations = PortTokensToPolkadot;
type Location = Location;
type Fungible = Balances;
Expand Down
6 changes: 4 additions & 2 deletions polkadot-parachains/integritee-kusama/src/porteer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::ord_parameter_types;
use integritee_parachains_common::{
porteer::{
ah_sibling_xcm, ahp_cousin_location, ik_cousin_v5, ik_sibling_v5,
integritee_runtime_porteer_mint, ip_sibling_v5,
integritee_runtime_porteer_mint, ip_sibling_v5, PortTokensNonce,
},
xcm_helpers::{burn_asset_xcm, execute_local_and_remote_xcm, teleport_asset},
AccountId, Balance,
Expand Down Expand Up @@ -52,13 +52,15 @@ pub struct PortTokensToPolkadot;
impl PortTokens for PortTokensToPolkadot {
type AccountId = AccountId;
type Balance = Balance;
type Nonce = PortTokensNonce;
type Location = Location;
type Error = XcmError;

fn port_tokens(
who: Self::AccountId,
amount: Self::Balance,
location: Option<Self::Location>,
nonce: Self::Nonce,
) -> Result<(), Self::Error> {
let who_location = AccountIdToLocation::convert(who.clone());
let fees = Porteer::xcm_fee_config();
Expand All @@ -72,7 +74,7 @@ impl PortTokens for PortTokensToPolkadot {
burn_asset_xcm(who_location.clone(), ah_sibling_fee.clone().into(), local_fee);

let remote_xcm = ah_sibling_xcm(
integritee_runtime_porteer_mint(who.clone(), amount, location.clone()),
integritee_runtime_porteer_mint(who.clone(), amount, location.clone(), nonce),
ah_sibling_fee.into(),
ik_sibling_v5(),
ik_cousin_v5(),
Expand Down
3 changes: 2 additions & 1 deletion polkadot-parachains/integritee-kusama/src/tests/porteer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn integritee_kusama_porteer_mint_is_correct() {
let beneficiary = IntegriteePolkadotSovereignAccount::get();
let amount = 10;

let call = integritee_runtime_porteer_mint(beneficiary.clone(), amount, None);
let call = integritee_runtime_porteer_mint(beneficiary.clone(), amount, None, 0);

let decoded = RuntimeCall::decode(&mut call.encode().as_slice()).unwrap();

Expand All @@ -47,6 +47,7 @@ fn integritee_kusama_porteer_mint_is_correct() {
beneficiary,
amount,
forward_tokens_to_location: None,
source_nonce: 0,
})
)
}
1 change: 1 addition & 0 deletions polkadot-parachains/integritee-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ impl pallet_porteer::Config for Runtime {
EnsureRoot<AccountId32>,
>;
type PortTokensToDestination = PortTokensToKusama;
type FeeCollectorAccount = TreasuryAccount;
type ForwardPortedTokensToDestinations = PortTokensToKusama;
type Location = Location;
type Fungible = Balances;
Expand Down
6 changes: 4 additions & 2 deletions polkadot-parachains/integritee-polkadot/src/porteer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::ord_parameter_types;
use integritee_parachains_common::{
porteer::{
ah_sibling_xcm, ahk_cousin_location, ik_sibling_v5, integritee_runtime_porteer_mint,
ip_cousin_v5, ip_sibling_v5,
ip_cousin_v5, ip_sibling_v5, PortTokensNonce,
},
xcm_helpers::{burn_asset_xcm, execute_local_and_remote_xcm, teleport_asset},
AccountId, Balance,
Expand Down Expand Up @@ -52,13 +52,15 @@ pub struct PortTokensToKusama;
impl PortTokens for PortTokensToKusama {
type AccountId = AccountId;
type Balance = Balance;
type Nonce = PortTokensNonce;
type Location = Location;
type Error = XcmError;

fn port_tokens(
who: Self::AccountId,
amount: Self::Balance,
location: Option<Self::Location>,
nonce: Self::Nonce,
) -> Result<(), Self::Error> {
let who_location = AccountIdToLocation::convert(who.clone());
let fees = Porteer::xcm_fee_config();
Expand All @@ -72,7 +74,7 @@ impl PortTokens for PortTokensToKusama {
burn_asset_xcm(who_location.clone(), ah_sibling_fee.clone().into(), local_fee);

let remote_xcm = ah_sibling_xcm(
integritee_runtime_porteer_mint(who.clone(), amount, location.clone()),
integritee_runtime_porteer_mint(who.clone(), amount, location.clone(), nonce),
ah_sibling_fee.into(),
ip_sibling_v5(),
ip_cousin_v5(),
Expand Down
Loading
Loading