Skip to content

Commit

Permalink
Move CreateAssetDeposit around
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Mar 19, 2024
1 parent 115c3ff commit 853d17d
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 46 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ license.workspace = true
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }

# Local
system-parachains-constants = { path = "../../../constants", default-features = false }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" }

Expand All @@ -29,5 +32,6 @@ std = [
"frame-support/std",
"scale-info/std",
"sp-std/std",
"system-parachains-constants/std",
"xcm/std"
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use xcm::prelude::*;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

use system_parachains_constants::kusama::currency::UNITS;

/// `AssetHubKusama` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubKusama` chain.
Expand All @@ -48,6 +50,9 @@ frame_support::parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
/// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested.
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();

/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateForeignAssetDeposit: u128 = UNITS / 10;
}

fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec<Instruction<()>> {
Expand Down
8 changes: 8 additions & 0 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1764,4 +1764,12 @@ mod tests {
let parachain_tbf = TransactionByteFee::get();
assert_eq!(relay_tbf / 10, parachain_tbf);
}

#[test]
fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert_eq!(
bp_asset_hub_kusama::CreateForeignAssetDeposit::get(),
ForeignAssetsAssetDeposit::get()
);
}
}
19 changes: 3 additions & 16 deletions system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use asset_hub_kusama_runtime::{
xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
},
ForeignAssetsAssetDeposit,
use asset_hub_kusama_runtime::xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
};
use sp_core::H160;
use sp_std::prelude::*;
use xcm::prelude::*;
use xcm_builder::{ExporterFor, NetworkExportTable};

/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the
/// ForeignAssets AssetDeposit config on AssetHub.
#[test]
fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert!(
bp_bridge_hub_kusama::snowbridge::CreateAssetDeposit::get() >=
ForeignAssetsAssetDeposit::get()
);
}

#[test]
fn network_export_table_works() {
sp_io::TestExternalities::default().execute_with(|| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ license.workspace = true
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }

# Local
system-parachains-constants = { path = "../../../constants", default-features = false }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" }

Expand All @@ -29,5 +32,6 @@ std = [
"frame-support/std",
"scale-info/std",
"sp-std/std",
"system-parachains-constants/std",
"xcm/std"
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use xcm::prelude::*;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

use system_parachains_constants::polkadot::currency::UNITS;

/// `AssetHubPolkadot` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubPolkadot` chain.
Expand All @@ -48,6 +50,9 @@ frame_support::parameter_types! {
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
/// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested.
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();

/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateForeignAssetDeposit: u128 = 10 * UNITS;
}

fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec<Instruction<()>> {
Expand Down
8 changes: 8 additions & 0 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,4 +1721,12 @@ mod tests {
let parachain_tbf = TransactionByteFee::get();
assert_eq!(relay_tbf / 10, parachain_tbf);
}

#[test]
fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert_eq!(
bp_asset_hub_polkadot::CreateForeignAssetDeposit::get(),
ForeignAssetsAssetDeposit::get()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use asset_hub_polkadot_runtime::{
xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
},
ForeignAssetsAssetDeposit,
use asset_hub_polkadot_runtime::xcm_config::bridging::{
to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork},
SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId,
};
use sp_core::H160;
use sp_std::prelude::*;
use xcm::prelude::*;
use xcm_builder::{ExporterFor, NetworkExportTable};

/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the
/// ForeignAssets AssetDeposit config on AssetHub.
#[test]
fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() {
assert!(
bp_bridge_hub_polkadot::snowbridge::CreateAssetDeposit::get() >=
ForeignAssetsAssetDeposit::get()
);
}

#[test]
fn network_export_table_works() {
sp_io::TestExternalities::default().execute_with(|| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,13 @@ fn convert_from_udot_to_uksm(price_in_udot: Balance) -> Balance {
pub mod snowbridge {
use crate::Balance;
use frame_support::parameter_types;
use kusama_runtime_constants::currency::UNITS;
use snowbridge_core::{PricingParameters, Rewards, U256};
use sp_runtime::FixedU128;
use xcm::latest::NetworkId;

parameter_types! {
/// Should match the `ForeignAssets::create` index on Asset Hub.
pub const CreateAssetCall: [u8;2] = [53, 0];
/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateAssetDeposit: u128 = UNITS / 10;
/// The pallet index of the Ethereum inbound queue pallet in the Bridge Hub runtime.
pub const InboundQueuePalletInstance: u8 = 80;
/// Default pricing parameters used to calculate bridging fees. Initialized to unit values,
Expand Down
6 changes: 2 additions & 4 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ pub mod bridge_to_polkadot_config;
mod weights;
pub mod xcm_config;

use bp_bridge_hub_kusama::snowbridge::{
CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, Parameters,
};
use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters};
use bridge_hub_common::message_queue::{
AggregateMessageOrigin, NarrowOriginToSibling, ParaIdToSibling,
};
Expand Down Expand Up @@ -564,7 +562,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime {
type Helper = Runtime;
type MessageConverter = MessageToXcm<
CreateAssetCall,
CreateAssetDeposit,
bp_asset_hub_kusama::CreateForeignAssetDeposit,
InboundQueuePalletInstance,
AccountId,
Balance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,13 @@ fn convert_from_uksm_to_udot(price_in_uksm: Balance) -> Balance {
pub mod snowbridge {
use crate::Balance;
use frame_support::parameter_types;
use polkadot_runtime_constants::currency::UNITS;
use snowbridge_core::{PricingParameters, Rewards, U256};
use sp_runtime::FixedU128;
use xcm::latest::NetworkId;

parameter_types! {
/// Should match the `ForeignAssets::create` index on Asset Hub.
pub const CreateAssetCall: [u8;2] = [53, 0];
/// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub.
pub const CreateAssetDeposit: u128 = 10 * UNITS;
/// The pallet index of the Ethereum inbound queue pallet in the Bridge Hub runtime.
pub const InboundQueuePalletInstance: u8 = 80;
/// Default pricing parameters used to calculate bridging fees. Initialized to unit values,
Expand Down
6 changes: 2 additions & 4 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ pub mod bridge_to_kusama_config;
mod weights;
pub mod xcm_config;

use bp_bridge_hub_kusama::snowbridge::{
CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, Parameters,
};
use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters};
use bridge_hub_common::message_queue::{
AggregateMessageOrigin, NarrowOriginToSibling, ParaIdToSibling,
};
Expand Down Expand Up @@ -565,7 +563,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime {
type Helper = Runtime;
type MessageConverter = MessageToXcm<
CreateAssetCall,
CreateAssetDeposit,
bp_asset_hub_polkadot::CreateForeignAssetDeposit,
InboundQueuePalletInstance,
AccountId,
Balance,
Expand Down

0 comments on commit 853d17d

Please sign in to comment.