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

Fix nostd build of several crates #4060

Merged
merged 23 commits into from
Apr 17, 2024
Merged

Fix nostd build of several crates #4060

merged 23 commits into from
Apr 17, 2024

Conversation

ggwpez
Copy link
Member

@ggwpez ggwpez commented Apr 9, 2024

Preparation for #3935

Changes:

  • Add some default-features = false for the case that a crate and that dependency both support nostd builds.
  • Shuffle files around of some benchmarking-only crates. These conditionally disabled the cfg_attr for nostd and pulled in libstd. Example here. The actual logic is moved into a inner.rs to preserve nostd capability of the crate in case the benchmarking feature is disabled.
  • Add some use sp_std::vec where needed.
  • Remove some optional = true in cases where it was not optional.
  • Removed one superfluous cfg_attr(not(feature = "std"), no_std...

All in all this should be logical no-op.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Can be tried with v1.4 `zepter lint no-std default-features-of-nostd-dependencies-disabled --fix`

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
I dont know why this is needed, but otherwise it will not build with the error of
the pallet being unknown. Maybe the construct_runtime! syntax does not actually
support feature gates.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez ggwpez requested review from athei and a team as code owners April 9, 2024 22:10
@@ -36,7 +36,7 @@ pallet-nfts = { path = "../../../../../substrate/frame/nfts", default-features =
pallet-nfts-runtime-api = { path = "../../../../../substrate/frame/nfts/runtime-api", default-features = false }
pallet-proxy = { path = "../../../../../substrate/frame/proxy", default-features = false }
pallet-session = { path = "../../../../../substrate/frame/session", default-features = false }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false, optional = true }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false }
Copy link
Member Author

Choose a reason for hiding this comment

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

This should still be gated by the construct_runtime! feature gate. But i think that is not actually working, otherwise this change would not be needed 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

What?

Generally we don't need this anymore and the state migration should already have been finished.

Copy link
Member Author

@ggwpez ggwpez Apr 15, 2024

Choose a reason for hiding this comment

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

It is still deployed though, will double-check and remove it then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uhf, did we really genesis the asset-hub-rococo with state_version 0?
I just queried Core::version of the 1.1 runtime and it returns state_version=0...

Looks like it was copy&pasted from AHK. @cheme can you double-check please?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ouch https://github.com/polkadot-fellows/runtimes/blob/31ba26287ec752574244f0d690167f7ae8430c8b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs#L153 . (kusuma is fine).
Statemint on rococo (I guess it is now assethub, not sure) was migrated IIRC or was it only on westend cc @PierreBesson ?

Copy link
Member Author

@ggwpez ggwpez Apr 16, 2024

Choose a reason for hiding this comment

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

I meant it here for the Asset-hub-rococo:

#[cfg(feature = "state-trie-version-1")]

Not sure, since when i queried the runtime api it returned version 0. Maybe we can check with the RPC but the public node does not support it.
PS: Can you maybe create an issue to track the migration of the different runtimes? Or it already exists?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ggwpez ggwpez added R0-silent Changes should not be mentioned in any release notes T2-pallets This PR/Issue is related to a particular pallet. and removed R0-silent Changes should not be mentioned in any release notes labels Apr 9, 2024
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@@ -36,7 +36,7 @@ pallet-nfts = { path = "../../../../../substrate/frame/nfts", default-features =
pallet-nfts-runtime-api = { path = "../../../../../substrate/frame/nfts/runtime-api", default-features = false }
pallet-proxy = { path = "../../../../../substrate/frame/proxy", default-features = false }
pallet-session = { path = "../../../../../substrate/frame/session", default-features = false }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false, optional = true }
pallet-state-trie-migration = { path = "../../../../../substrate/frame/state-trie-migration", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

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

What?

Generally we don't need this anymore and the state migration should already have been finished.

substrate/frame/root-offences/Cargo.toml Outdated Show resolved Hide resolved
@@ -18,36 +18,9 @@
//! Supporting types for try-runtime, testing and dry-running commands.

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "try-runtime")]
Copy link
Member

Choose a reason for hiding this comment

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

It makes no sense that this crate has a try-runtime feature.. This crate should only be activated if you use try-runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then it would enable the try-runtime feature of all dependencies by default?
I dont remember if this can cause issues with feature unification, but maybe it works since the crate would disabled otherwise.

Copy link
Member Author

@ggwpez ggwpez Apr 15, 2024

Choose a reason for hiding this comment

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

Okay actually this will make --workspace not compile anymore, since it enables all crates. You can check it with cargo tree --workspace and see that frame-system-benchmarking is enabled at the top-level @bkchr.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm yeah okay... 🦭

Maybe having the try_runtime types in frame-support not behind a feature would be a better solution.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have some traits with feature gated functions. Maybe that is an anti-pattern in itself... should probably be an extension trait that is only selectively required.

Copy link
Member

Choose a reason for hiding this comment

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

I mean the functions is fine, I would probably just not hide the traits etc in try_runtime.rs. But in the end this is all discussable and we can keep it like it is done right now.

Copy link
Member

Choose a reason for hiding this comment

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

Generally just don't like these inner.rs files.


#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "runtime-benchmarks")]
Copy link
Member

Choose a reason for hiding this comment

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

Same. This crate should only be activated when you are compiling runtime benchmarks.

Comment on lines 55 to 56
// NOTE that we put the actual code into another module to keep the no-std capability of this create
// even when the `experimental` feature is disabled.
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this comment. Also generally it doesn't make sense that the experimental feature disables everything of this crate.

What is the purpose of this feature then? Just don't use the crate if you don't want to use experimental stuff.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay i reverted the changes to the FRAME crate. Apparently it is not published anyway - so should not be needed for the umbrella crate until then.
Also increased the warning in the docs. I could not rename it since the name is used in some crate-access generation macros and repeated often in docs... can fix in the future once we start publishing.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
# This pallet will migrate the entire state, controlled through some account.
#
# This feature should be removed when the main-net will be migrated.
state-trie-version-1 = []
Copy link
Contributor

Choose a reason for hiding this comment

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

oh now I remembre, this is used for multiple network so the feature was needed to have one running V0 while another one was already migrated (likely westend/rococo a long time ago).
Sounds ok to remove it so migration got started everywhere. One point I am not sure is related to the account use as controller: currently it is hardcoded to :

pub const MigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));
	pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52"));

probably would need a different one per network, this is not really convenient.
Worst case, what can happen with this chain is some parachain moving to hybrid mode (both v0 and v1 in tree, if warpsync is not use by the parachain this should not be an issue) and not being able to migrate because no account to process the typescript driven migration.

Copy link
Member Author

@ggwpez ggwpez Apr 17, 2024

Choose a reason for hiding this comment

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

Okay thanks for the context. For Rococo it is probably fine, as it will be decommissioned soon anyway.
Just going to leave it as is, and hope that DevOps has the keys. Otherwise we do another upgrade or root call etc.

Choose a reason for hiding this comment

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

I confirm we have the key to 0x8458ed39dc4b6f6c7255f7bc42be50c2967db126357c999d44e12ca7ac80dc52 to be able to process the migration.

@ggwpez ggwpez added this pull request to the merge queue Apr 17, 2024
Merged via the queue into master with commit 7a2c9d4 Apr 17, 2024
132 of 135 checks passed
@ggwpez ggwpez deleted the oty-fix-nostd branch April 17, 2024 17:35
sandreim pushed a commit that referenced this pull request Apr 18, 2024
Preparation for #3935

Changes:
- Add some `default-features = false` for the case that a crate and that
dependency both support nostd builds.
- Shuffle files around of some benchmarking-only crates. These
conditionally disabled the `cfg_attr` for nostd and pulled in libstd.
Example [here](ggwpez/zepter#95). The actual
logic is moved into a `inner.rs` to preserve nostd capability of the
crate in case the benchmarking feature is disabled.
- Add some `use sp_std::vec` where needed.
- Remove some `optional = true` in cases where it was not optional.
- Removed one superfluous `cfg_attr(not(feature = "std"), no_std..`.

All in all this should be logical no-op.

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants