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

feat(mainnet): add XCM runtime APIs, config tests, and refactor to API mod [DON'T MERGE] #426

Closed
wants to merge 20 commits into from

Conversation

peterwht
Copy link
Collaborator

@peterwht peterwht commented Jan 12, 2025

DO NOT SQUASH MERGE -- REMOVE THIS MESSAGE BEFORE MERGE
Prereq: #425

This PR has various improvements to the mainnet runtime. Please review the individual commits:

test(mainnet): more configuration tests
refactor(mainnet): runtime APIs to apis module
feat(mainnet): add XCM runtime APIs

chungquantin and others added 18 commits January 3, 2025 12:24
Co-authored-by: Daanvdplas <daanvdplas@live.nl>
Co-authored-by: Daan van der Plas <93204684+Daanvdplas@users.noreply.github.com>
@peterwht peterwht requested a review from Daanvdplas January 12, 2025 19:06
@peterwht peterwht changed the title [DON'T MERGE] mainnet improvements feat,refactor,test(mainnet): various improvements [DON'T MERGE] Jan 12, 2025
@peterwht peterwht mentioned this pull request Jan 12, 2025
4 tasks
@peterwht peterwht changed the title feat,refactor,test(mainnet): various improvements [DON'T MERGE] feat(mainnet): add XCM runtime APIs, config tests, and refactor to API mod [DON'T MERGE] Jan 12, 2025
@peterwht peterwht requested a review from al3mart January 12, 2025 19:17
@peterwht
Copy link
Collaborator Author

[sc-2219]

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.

CI is failing

runtime/mainnet/src/lib.rs Outdated Show resolved Hide resolved
runtime/mainnet/src/lib.rs Show resolved Hide resolved
runtime/mainnet/src/lib.rs Outdated Show resolved Hide resolved
@@ -257,4 +267,71 @@ impl_runtime_apis! {
Default::default()
}
}

impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious to hear whether we want to add them to testnet and devnet as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see why not!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In follow up PRs, I think it would make sense. However, it seems a distraction right now. Our current mainnet runtime will be deployed as its own testnet. Which means our current testnet and devnet don't factor into the initial mainnet launch.

We do need to resolve what will happen to the current testnet and how the two testnets will live together (if at all)

Copy link
Collaborator

@Daanvdplas Daanvdplas Jan 15, 2025

Choose a reason for hiding this comment

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

That means that our current testnet becomes our devnet, and testnet should become a copy of mainnet?

Still believe that any feature on mainnet (thus testnet) should be on devnet

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider that certain things like spec name cannot be changed and that protocol id should be unique. Deploying the mainnet runtime as-is to Paseo may only make sense if it is going to be removed completely to make way for the Polkadot deployment rather than upgraded in place to become a testnet.

Copy link
Collaborator

@Daanvdplas Daanvdplas Jan 17, 2025

Choose a reason for hiding this comment

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

Fine to do it later, my view is that it only creates more work for later and it is a simple add now.

It is still unclear to me what the plan for this new testnet exactly is so getting that done would prevent further confusions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to address this myself in a different PR to get this closed one sorted.

Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

Overall pretty good!

Have left a few comments, but mainly things worth discussing rather than change requests.

@@ -16,6 +16,8 @@ use alloc::{borrow::Cow, vec::Vec};
use config::xcm::{RelayLocation, XcmOriginToTransactDispatchOrigin};
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim;
Copy link
Collaborator

@al3mart al3mart Jan 14, 2025

Choose a reason for hiding this comment

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

Looks like this is being deprecated and substituted by a new implementation.

For para chains StorageWeightReclaim in cumulus-primitives-storage-weight-reclaim is deprecated.
A new transaction extension StorageWeightReclaim in cumulus-pallet-weight-reclaim is introduced.
StorageWeightReclaim is meant to be used as a wrapping of the whole transaction extension pipeline, and will take into account all proof size accurately.

source

Let's see if this change is backported into 2412

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch. Hopefully they release the new release soon.

}
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
Copy link
Collaborator

@al3mart al3mart Jan 14, 2025

Choose a reason for hiding this comment

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

These dry_run api are delicate in the sense that if someone has access to a node can make the node work a lot for free.

While there are ways to rate-limit the requests to the node:

Ideally we should be capable of dropping a dry-run that is bigger than some threshold independently of spam. A weight-rate, instead of a requests one. However I'm not sure how could we do that from the top of my head.

These are very useful apis, that's for sure! Whether we are going to benefit from them from the start or not is questionable. Having native XCM support on ink! is a vote in favor for them.

My take would be keeping them for now and do some extra research on them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would these not be limited to RPCs only? If collators only expose P2P, is you concern then a non-issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Exactly, these apis are only accessible if one can reach out the node.

runtime/mainnet/src/apis.rs Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 14.20613% with 308 lines in your changes missing coverage. Please review.

Project coverage is 68.03%. Comparing base (e89b670) to head (ad7cee7).

Files with missing lines Patch % Lines
runtime/mainnet/src/apis.rs 0.00% 308 Missing ⚠️
@@                       Coverage Diff                        @@
##           peterwht/chore-polkadot-2412     #426      +/-   ##
================================================================
- Coverage                         68.31%   68.03%   -0.28%     
================================================================
  Files                                70       71       +1     
  Lines                             11777    11899     +122     
  Branches                          11777    11899     +122     
================================================================
+ Hits                               8045     8096      +51     
- Misses                             3480     3551      +71     
  Partials                            252      252              
Files with missing lines Coverage Δ
runtime/mainnet/src/lib.rs 73.98% <100.00%> (+52.53%) ⬆️
runtime/mainnet/src/apis.rs 0.00% <0.00%> (ø)

@peterwht peterwht force-pushed the peterwht/chore-polkadot-2412 branch from 029a3a9 to 937ca11 Compare January 17, 2025 02:50
Cargo.toml Show resolved Hide resolved
Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

I believe the changes look great. Happy to proceed once CI is happy too.

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Seems the transaction payment pallet is missing from define_benchmarks! along with the inclusion of the new transaction extension benchmarks across the various runtimes.

tokio = { version = "1.36", features = [ "macros", "rt-multi-thread", "time" ] }
tracing-subscriber = { version = "0.3.18", default-features = false }

# Build
substrate-build-script-utils = "11.0.0"
substrate-wasm-builder = "24.0.1"
substrate-build-script-utils = { git = "https://github.com/r0gue-io/polkadot-sdk", branch = "stable2412" }
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
substrate-build-script-utils = { git = "https://github.com/r0gue-io/polkadot-sdk", branch = "stable2412" }
substrate-build-script-utils = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2412" }

Suggest a quick find and replace and see if it builds and everything works. Some fixes are already pushed there ahead of the first patch release due next week. Can then get rid of the fork and switch back to the crates.io versions separately with next release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in #425

paseo-runtime-constants = { git = "https://github.com/paseo-network/runtimes/", tag = "v1.3.3", default-features = false }
westend-runtime = { version = "18.0.1", default-features = false }
westend-runtime-constants = { version = "17.0.0", default-features = false }
asset-hub-paseo-runtime = { git = "https://github.com/paseo-network/runtimes", default-features = false, tag = "v1.3.3" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest we remove these other runtimes as a follow up PR. I dont see them being used anytime soon due to the lag between a SDK release and runtime release.

@@ -60,74 +60,9 @@ paseo = [
"asset-hub-paseo-runtime",
"paseo-runtime",
"paseo-runtime-constants",
"std",
]
runtime-benchmarks = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Justification here is that none of these features are used/required to run integration tests. These were included historically to work around build issues when trying to use a single command to run all tests/benchmarks in the repo. Can be revisited again separately.

};
use polkadot_primitives::{AssignmentId, Balance, ValidatorId, LOWEST_PUBLIC_ID};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_beefy::test_utils::Keyring;
Copy link
Collaborator

Choose a reason for hiding this comment

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

No change required, but single usage imports seem unnecessary to me, provided the usage doesnt cause a line wrap. Based on the level of indentation below, I assume this would be the case.

I simply prefer as little code as possible, less to write, less to review.

config.prometheus_registry(),
task_manager.spawn_essential_handle(),
client.clone(),
// TOOD: double check
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can more insight be provided here? Not sure we should be reviewing/approving/merging if there are todos.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved in #425, dependent on this convo: #425 (comment)

primitives/src/lib.rs Show resolved Hide resolved
runtime/devnet/src/config/api/versioning.rs Show resolved Hide resolved
@@ -186,15 +187,15 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("pop"),
impl_name: create_runtime_str!("pop"),
spec_name: Cow::Borrowed("pop"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

No action required, but as there is an import for Cow, could have just been Cow::Borrowed imported to avoid the duplication here. I figure you may prefer it having an explicit prefix tho.

@@ -166,6 +169,7 @@ runtime-benchmarks = [
"pallet-scheduler/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont see that this has been added to define_benchmarks in any of the runtimes. Likewise there is no addition of the benchmarks for transaction extensions (frame_system_extensions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was an intentional decision (should have been documented). Our define_benchmarks! in all of our runtimes does not include every pallet. I will create an issue to resolve this in a separate PR once the 2412 uplift is merged

@@ -984,7 +988,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench; in the benchmarks trait implementation. Closest I could place the comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

resolved in #447

Base automatically changed from peterwht/chore-polkadot-2412 to chore-upgrade-pop-net-to-stable2412/sc-1940 January 21, 2025 14:59
Base automatically changed from chore-upgrade-pop-net-to-stable2412/sc-1940 to main January 21, 2025 20:45
@peterwht
Copy link
Collaborator Author

superseded by #447

@peterwht peterwht closed this Jan 22, 2025
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.

6 participants