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

chore: remove unused deps and add missing feats for all tomls #1223

Merged
merged 14 commits into from
Mar 3, 2023

Conversation

wischli
Copy link
Contributor

@wischli wischli commented Mar 2, 2023

Description

Result of fixing try-runtime in #1198 required for migration of pallet-block-rewards.

  • Removes unused deps with help of cargo-machete (though this tools creates many false positives, especially for optional deps, codec and scale-info)
  • Adds missing features std, runtime-benchmarks and try-runtime for all crates
    • Enables isolated compiling of any of our crates.
  • Adds try-runtime to development-runtime required in feat: impl block rewards #1198
  • Fixes try-runtime which wasn't working since try-runtime was made much stricter sometime between Polkadot v0.9.28 and v0.9.32. Basically, each of our pallets requires at least having
try-runtime = [ "frame-support/try-runtime" ]
  • See Shawns comment for details.
  • Normalizes apostrophes used in tomls to " instead of mixed '/"
  • Adds patch to PureStake/Frontier, thanks @NunoAlexandre !

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

# Find all child directories containing Cargo.toml files
dirs=$(find . -name Cargo.toml -print0 | xargs -0 -n1 dirname | sort -u)

# Execute the command "subalfred check" on each directory
for dir in $dirs; do
    subalfred check features $dir
done

# Check unused deps
# NOTE: creates false positives
cargo-machete
# cargo-machete --fix
cargo run --release --features=try-runtime try-runtime --chain=development --no-spec-check-panic --execution=native on-runtime-upgrade live --uri=wss://fullnode.parachain.centrifuge.io:443

Checklist:

  • I have added Rust doc comments to structs, enums, traits and functions
  • I have made corresponding changes to the documentation
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I rebased on the latest main branch

@wischli wischli added D0-ready Pull request can be merged without special precaution and notification. I6-refactoring Code needs refactoring. labels Mar 2, 2023
lemunozm
lemunozm previously approved these changes Mar 3, 2023
Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

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

LGTM! Awesome work @wischli! 🙌🏻

mustermeiszer
mustermeiszer previously approved these changes Mar 3, 2023
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

Great clean up, love it!!

Just one minor question regarding a change in the lock.

The other comments are just nit picks that can also be cleaned up on the same run.

But see no blockers.

Comment on lines 2 to 9
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
description = "FRAME pallet template for defining custom runtime logic."
edition = "2018"
homepage = "https://substrate.dev"
license = "Unlicense"
name = "pallet-investments"
readme = "README.md"
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should tackle this in a follow up and actually insert the right info. My technical debt, sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-randomness-collective-flip/try-runtime",
"pallet-restricted-tokens/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-society/try-runtime",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we even have pallet-staking as a deps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I will run cargo-machete an all crates and remove unused deps!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -22,7 +22,7 @@ column_width = 160
# Indent based on tables and arrays of tables and their subtables, subtables out of order are not indented.
indent_tables = false
# The substring that is used for indentation, should be tabs or spaces (but technically can be anything).
indent_string = ' '
indent_string = " "
Copy link
Collaborator

Choose a reason for hiding this comment

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

🥳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, this does not change anything. There is no taplo enforcement on the type of apostrophe used 😓

"orml-asset-registry/runtime-benchmarks",
"orml-tokens/runtime-benchmarks",
"orml-xtokens/runtime-benchmarks",
"pallet-babe/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.

Babe and grandpa can also be removerd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pallets/connectors/Cargo.toml Show resolved Hide resolved
Cargo.lock Outdated
@@ -13132,7 +13134,7 @@ version = "1.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
dependencies = [
"cfg-if 1.0.0",
"cfg-if 0.1.10",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you know what caused the downgrade of the version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very likely due to the patching for PureStake/frontier. Should be reverted once I remove the patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved after removing the patch as expected.

@wischli wischli dismissed stale reviews from mustermeiszer and lemunozm via 9761390 March 3, 2023 12:59
@wischli wischli changed the title chore: add missing features in all tomls chore: remove unused deps and add missing feats for all tomls Mar 3, 2023
mustermeiszer
mustermeiszer previously approved these changes Mar 3, 2023
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

Thanks for changing Investments cargo already ❤️

Reverting patch looks good. Good to go from my side

NunoAlexandre
NunoAlexandre previously approved these changes Mar 3, 2023
Copy link
Contributor

@NunoAlexandre NunoAlexandre left a comment

Choose a reason for hiding this comment

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

Awesome sauce 🌶️

@wischli wischli dismissed stale reviews from NunoAlexandre and mustermeiszer via 887de3f March 3, 2023 13:41
Copy link
Contributor

@NunoAlexandre NunoAlexandre left a comment

Choose a reason for hiding this comment

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

Re-approving

@mustermeiszer
Copy link
Collaborator

Re-approve

@mikiquantum mikiquantum merged commit c291287 into main Mar 3, 2023
@mikiquantum mikiquantum deleted the chore/add-missing-toml-feats branch March 3, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D0-ready Pull request can be merged without special precaution and notification. I6-refactoring Code needs refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants