Skip to content

Commit

Permalink
fix-wip(system-parachains/bridge-hubs): fulfill values on mock weight…
Browse files Browse the repository at this point in the history
…s + fees parameters + test parameters

Note: Weight-related fixes should be adjusted accordingly again once actual benchmarks are executed.
  • Loading branch information
pandres95 committed Oct 25, 2024
1 parent cc5b8cf commit abb0eaf
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 75 deletions.
18 changes: 18 additions & 0 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 @@ -56,6 +56,7 @@ cumulus-pallet-xcm = { version = "0.17.0", default-features = false }
cumulus-pallet-xcmp-queue = { version = "0.17.0", default-features = false }
cumulus-primitives-aura = { version = "0.15.0", default-features = false }
cumulus-primitives-core = { version = "0.16.0", default-features = false }
cumulus-primitives-storage-weight-reclaim = { version = "8.0.0", default-features = false }
cumulus-primitives-utility = { version = "0.17.0", default-features = false }
emulated-integration-tests-common = { version = "14.0.0" }
encointer-balances-tx-payment = { version = "~14.1.0", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ frame_support::parameter_types! {

/// Transaction fee that is paid at the Kusama BridgeHub for delivering single inbound message.
/// (initially was calculated by test `BridgeHubKusama::can_calculate_fee_for_complex_message_delivery_transaction` + `33%`)
pub const BridgeHubKusamaBaseDeliveryFeeInKsms: u128 = 3_140_827_287;
pub const BridgeHubKusamaBaseDeliveryFeeInKsms: u128 = 3_142_112_953;

/// Transaction fee that is paid at the Kusama BridgeHub for delivering single outbound message confirmation.
/// (initially was calculated by test `BridgeHubKusama::can_calculate_fee_for_complex_message_confirmation_transaction` + `33%`)
pub const BridgeHubKusamaBaseConfirmationFeeInKsms: u128 = 574_592_739;
pub const BridgeHubKusamaBaseConfirmationFeeInKsms: u128 = 575_036_072;
}

/// Compute the total estimated fee that needs to be paid in KSMs by the sender when sending
Expand Down

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

30 changes: 17 additions & 13 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use frame_support::{
traits::{tokens::imbalance::ResolveTo, ConstU32, Contains, Equals, Everything, Nothing},
};
use frame_system::EnsureRoot;
use pallet_collator_selection::StakingPotAccountId;
use pallet_xcm::XcmPassthrough;
use parachains_common::xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, ParentRelayOrSiblingParachains,
Expand All @@ -36,13 +37,14 @@ use sp_runtime::traits::AccountIdConversion;
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
FungibleAdapter, HashedDescription, IsConcrete, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowHrmpNotificationsFromRelayChain,
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents,
};
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
Expand All @@ -57,8 +59,8 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
pub const GovernanceLocation: Location = Location::parent();
pub const FellowshipLocation: Location = Location::parent();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(kusama_runtime_constants::TREASURY_PALLET_ID)).into();
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(kusama_runtime_constants::TREASURY_PALLET_ID)).into();
// Test [`crate::tests::treasury_pallet_account_not_none`] ensures that the result of location
// conversion is not `None`.
pub RelayTreasuryPalletAccount: AccountId =
Expand Down Expand Up @@ -149,6 +151,8 @@ pub type Barrier = TrailingSetTopicAsId<
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentRelayOrSiblingParachains>,
// HRMP notifications from the relay chain are OK.
AllowHrmpNotificationsFromRelayChain,
),
UniversalLocation,
ConstU32<8>,
Expand All @@ -173,7 +177,6 @@ pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type XcmRecorder = ();
type AssetTransactor = FungibleTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
// BridgeHub does not recognize a reserve location for any asset. Users must teleport KSM
Expand All @@ -192,16 +195,16 @@ impl xcm_executor::Config for XcmConfig {
KsmRelayLocation,
AccountId,
Balances,
ResolveTo<StakingPot, Balances>,
ResolveTo<StakingPotAccountId<Runtime>, Balances>,
>;
type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
type AssetLocker = ();
type AssetExchanger = ();
type AssetClaims = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type AssetLocker = ();
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
SendXcmFeeToAccount<Self::AssetTransactor, RelayTreasuryPalletAccount>,
Expand All @@ -215,6 +218,7 @@ impl xcm_executor::Config for XcmConfig {
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = PolkadotXcm;
}

/// Converts a local signed origin into an XCM `Location`.
Expand All @@ -232,9 +236,9 @@ pub type XcmRouter = WithUniqueTopic<(

impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmRouter = XcmRouter;
// We want to disallow users sending (arbitrary) XCMs from this chain.
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, ()>;
type XcmRouter = XcmRouter;
// Any local signed origin can execute XCM messages.
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalSignedOriginToLocation>;
type XcmExecuteFilter = Everything;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub const SIBLING_PARACHAIN_ID: u32 = 1000;
// Random para id of sibling chain used in tests.
pub const SIBLING_SYSTEM_PARACHAIN_ID: u32 = 1008;
// Random para id of bridged chain from different global consensus used in tests.
pub const BRIDGED_LOCATION_PARACHAIN_ID: u32 = 1075;
pub const BRIDGED_LOCATION_PARACHAIN_ID: u32 = 1000;

parameter_types! {
pub SiblingParachainLocation: Location = Location::new(1, [Parachain(SIBLING_PARACHAIN_ID)]);
Expand Down
2 changes: 2 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { features = ["bridging"], workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-storage-weight-reclaim = { workspace = true }
cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
parachain-info = { workspace = true }
Expand Down Expand Up @@ -152,6 +153,7 @@ std = [
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-storage-weight-reclaim/std",
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
"frame-executive/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
BridgeRejectObsoleteHeadersAndMessages,
bridge_to_kusama_config::OnBridgeHubPolkadotRefundBridgeHubKusamaMessages,
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

Expand Down
Loading

0 comments on commit abb0eaf

Please sign in to comment.