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

refactor(mainnet): xcm config #455

Merged
merged 39 commits into from
Feb 10, 2025

Conversation

al3mart
Copy link
Collaborator

@al3mart al3mart commented Jan 30, 2025

Extends xcm config module including:

  • pallet_message_queue
  • cumulus_pallet_xcm
  • cumulus_pallet_xcmp_queue

And adding configuration unit tests for:

  • xcm_executor
  • pallet_xcm

TODOs:


Notable configuration items are:

  • pallet_message_queue
type HeapSize = ConstU32<{ 64 * 1024 }>;
type IdleMaxServiceWeight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block;
type ServiceWeight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
  • cumulus_pallet_xcmp_queue
type ControllerOrigin = EnsureRoot<AccountId>;
type MaxActiveOutboundChannels = ConstU32<128>;
type MaxInboundSuspended = ConstU32<128>;
type MaxPageSize = ConstU32<{ 103 * 1024 }>;

PriceForSiblingDelivery is addressed in: #457

  • xcm_executor
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);

WaivedLocations are removed from FeeManager config in: #456

  • pallet_xcm
type AdminOrigin = EnsureRoot<AccountId>;
type ExecuteXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;

[sc-2205]

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 99.83444% with 1 line in your changes missing coverage. Please review.

Project coverage is 75.78%. Comparing base (702b7f2) to head (25cd9f9).

Files with missing lines Patch % Lines
runtime/mainnet/src/apis.rs 0.00% 1 Missing ⚠️
@@                         Coverage Diff                         @@
##           al3mart/refactor-mainnet-config     #455      +/-   ##
===================================================================
+ Coverage                            74.94%   75.78%   +0.84%     
===================================================================
  Files                                   83       83              
  Lines                                16550    17127     +577     
  Branches                             16550    17127     +577     
===================================================================
+ Hits                                 12403    12980     +577     
  Misses                                3884     3884              
  Partials                               263      263              
Files with missing lines Coverage Δ
runtime/mainnet/src/config/xcm.rs 100.00% <100.00%> (ø)
runtime/mainnet/src/lib.rs 66.23% <ø> (ø)
runtime/mainnet/src/apis.rs 0.00% <0.00%> (ø)

type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type MaxActiveOutboundChannels = ConstU32<128>;
type MaxInboundSuspended = ConstU32<128>;
type MaxPageSize = ConstU32<{ 103 * 1024 }>;
Copy link
Collaborator Author

@al3mart al3mart Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@al3mart al3mart marked this pull request as ready for review January 31, 2025 12:13
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch from 5b70d8c to 9333fe6 Compare January 31, 2025 13:29
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, left some comments.

will help with the PR that is blocking this PR as fast as I can

runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
@@ -34,6 +44,31 @@ parameter_types! {
pub const RelayNetwork: Option<NetworkId> = Some(Polkadot);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation = [GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
pub MessageQueueIdleServiceWeight: Weight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block;
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be the one from pallet treasury?

Copy link
Collaborator Author

@al3mart al3mart Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, needs changing with the rebase. I should have left a comment here in GH. The description of the base PR notes that there are relevant changes out of the base branch, and that it needs a rebase to include those.

Leaving the rebase to do last so I can address all at once. Treasury's account, for instance, is not only used here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you rebased pallet treasury into the base branch, can this not be immediately resolved?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I did amend this during the rebase. Looks like I rolled back the changed along the way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch from 9333fe6 to 5fa78c6 Compare February 4, 2025 13:08
Copy link
Collaborator

@peterwht peterwht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! Left a few tiny nitpicks and then good to approve (once the next PRs are merged in)

runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch from 7b7df0f to 95745b5 Compare February 5, 2025 01:39
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch from 95745b5 to 73926d9 Compare February 5, 2025 08:32
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-config branch from 809c784 to 9b1f3e2 Compare February 5, 2025 09:08
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch 3 times, most recently from d644888 to 1610f34 Compare February 5, 2025 13:00
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
@Daanvdplas
Copy link
Collaborator

FYI: I wanted to see if I could improve the integration tests changes but it couldn't compile locally.

@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch 3 times, most recently from 8700383 to d63b78b Compare February 6, 2025 16:35
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch 2 times, most recently from 475d40e to d9ec3db Compare February 7, 2025 11:36
@al3mart al3mart requested a review from Daanvdplas February 7, 2025 11:36
* refactor: integration tests mainnet xcm

* fix: remove unused ED

rebase

fmt

fmt
@al3mart al3mart force-pushed the al3mart/refactor-mainnet-xcm branch from d9ec3db to 8969363 Compare February 7, 2025 12:16
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looking really good! A few last things that need addressing but then good to go!

@@ -326,6 +327,18 @@ fn reserve_transfer_native_asset_from_para_to_system_para() {
let sender_balance_before = test.sender.balance;
let receiver_balance_before = test.receiver.balance;

let delivery_fees = PopNetworkPara::execute_with(|| {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move those to where it was initially positioned and check if the clones can be removed? I thought I did this but apparently made a mistake

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -34,6 +44,31 @@ parameter_types! {
pub const RelayNetwork: Option<NetworkId> = Some(Polkadot);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation = [GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())].into();
pub MessageQueueIdleServiceWeight: Weight = Perbill::from_percent(20) * RuntimeBlockWeights::get().max_block;
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you rebased pallet treasury into the base branch, can this not be immediately resolved?

runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
fn relay_as_relay_asset_reserve_fails() {
let relay_asset = Asset::from((AssetId::from(Parent), Fungibility::from(100u128)));
assert!(!TrustedReserves::contains(&relay_asset, &Parent.into()));
mod xcm_configuration {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since those tests do not belong to a pallet directly I would suggest to remove this submodule

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
mod xcm_executor_configuration {
use super::*;

mod reserves_config {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mod reserves_config {
mod reserves {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime/mainnet/src/config/xcm.rs Show resolved Hide resolved
}

#[test]
fn reserve_transfer_filter_only_allows_relay_asset_from_ah() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see this test refactored into two tests. One for the filter, one passing.

Moreover, like I have said elsewhere too, I find the tests that use the Location::Parent confusing. This should not be possible on our chain and thus causes confusion to me. Especially the passing test of an asset with location Location::Parent on line 972

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still don't get it why we are testing for parent location. Also the second test now contains logic that is not specific to that test which only confused or distracts from what actually needs to be tested.

Rule of thumb I learned, tests should be as specific and simple as it can be to reduce the amount work required, as well as maintaining it. In addition, you want the tests to be specific so that it is super clear what is tested and why.

@al3mart al3mart requested a review from Daanvdplas February 10, 2025 11:24
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final suggestion to simplify the unit tests then happy to approve!

runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/config/xcm.rs Outdated Show resolved Hide resolved
}

#[test]
fn reserve_transfer_filter_contains_parent_asset() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

@Daanvdplas Daanvdplas self-requested a review February 10, 2025 17:36
Copy link
Collaborator

@Daanvdplas Daanvdplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job and thanks for the patience!

Copy link
Collaborator

@peterwht peterwht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@al3mart al3mart merged commit cae5b19 into al3mart/refactor-mainnet-config Feb 10, 2025
15 checks passed
@al3mart al3mart deleted the al3mart/refactor-mainnet-xcm branch February 10, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants