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 individual crate compilation issues & add script for running all tests #1444

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

lemunozm
Copy link
Contributor

@lemunozm lemunozm commented Jul 6, 2023

Description

Fixes #1441

Changes and Descriptions

  • Fixed all compilation issues running all crates isolated 🎉. Now you can run without errors each crate as:

    cargo test -p <crate> -F <feature1,feature2,...>
  • Added script to run all workspace crate tests with all feature combinations.

    To run the script for all crates:

    ./scripts/tests.sh

    To run the script for all crates from the selected one in the workspace list (used mainly to recover the script execution point after a crate failure):

    ./scripts/tests.sh <from-crate>

@lemunozm lemunozm added I3-annoyance The code behaves as expected, but "expected" is an issue. crcl-protocol Circle protocol related. dependencies Pull requests that update a dependency file. labels Jul 6, 2023
@lemunozm lemunozm self-assigned this Jul 6, 2023
Copy link
Contributor Author

@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.

A couple of "relevant" fixes comes with this PR:

Comment on lines +43 to +47
# There is a bug in the frontier repo that adds pallet-ethereum without a try-runtime dependency
# for this crate which makes our compilation fail with the i_know_what_i_am_doing error.
# It seem fixed in 0.9.39, and this dependency can be removed from this file safely.
fp-self-contained = { git = "https://github.com/PureStake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.38" }

Copy link
Contributor Author

@lemunozm lemunozm Jul 6, 2023

Choose a reason for hiding this comment

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

I'm pretty sure this was the issue that happened in #1406 (not tested yet), so it would unlock that PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

That could very well be it. But I tried using my fork of frontier fixing all the cargo features and the issue still persisted 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you added "fp-self-contained/try-runtime" too to your try?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but I ran subalfred on the whole repo to make sure I wasn't missing any feature anywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, but before this PR I also run subalfred for all crates, and everything went "well" 😆, and things weren't well. I guess we can not trust 100% in subalfred. Some things are not checked.

Comment on lines +193 to +195
// We need to put the array into the stack (with a vec) to avoid stack overflow
// here
let accounts = test_data::system_account::SYSTEM_ACCOUNT.to_vec();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows us to remove the stack limit increment in the CI scripts

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this pallet all-together. We will not use it again.

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 to know!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lemunozm
Copy link
Contributor Author

lemunozm commented Jul 6, 2023

It would be great to add this script as a CI job, but it surely exceeds the maximum size available and will take considerably more time than other jobs. Any idea @gpmayorga? My suggestion is to clean artifacts after testing each crate (which will take even more time to run all crates) and create a weekend job for it.

scripts/tests.sh Outdated
go=1
fi

cargo install cargo-workspaces
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have this as part of a setup script? Having this here means that every time we want to run this (locally) we will have cargo checking for updates and trying to update this crate, which will slow this process even further. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Make sense. What's the setup script you're referring?

Copy link
Contributor

@NunoAlexandre NunoAlexandre Jul 6, 2023

Choose a reason for hiding this comment

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

It doesn't exist atm, but we could create one or adapt the current install-toolchain to be more general-purpose and install tools we need for development

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I understand. By now, f you agree, I can print a message if the command is not found instead of fetching every time if it exists. I do not want to add things into install_toolchain.sh because it affects all CI job time/space. Only the required job should fetch its required tools, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can prepare a good script in another PR, with taplo, subalfred, cargo-workspaces, ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's fine :)

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.

LGTM but it would be nice to have another reviewer 👍🏻

@lemunozm
Copy link
Contributor Author

lemunozm commented Jul 6, 2023

Thanks Nuno! I think other review is even required 🤣

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.

LGTM!

@@ -222,6 +223,7 @@ impl<
_currency: <T as pallet_pool_registry::Config>::CurrencyId,
_max_reserve: <T as pallet_pool_registry::Config>::Balance,
) -> DispatchResult {
#[cfg(feature = "runtime-benchmarks")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure the only code paths for this can be thru the runtime-benchmarks feature? I'm a little concerned about having the mocks behave differently between benches and tests...

Copy link
Contributor Author

@lemunozm lemunozm Jul 6, 2023

Choose a reason for hiding this comment

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

Good point! It's true that it's used in tests even when runtime-benchmarks is not enabled, so in that case, you're not creating a pool. Anyways, it is compiling and passing with and without runtime-benchmarks feature, so I suppose it should behave as expected.

Looking more deeply creating a pool seems to doesn't matter for the testing, but yes for the benchmarks because it adds a lot of weight to the call, so makes sense to only call create_pool() on benchmaking. Although real benchmarks will not use mocks, so actually, I think you could even remove that line 🤔

Copy link
Contributor

@branan branan left a comment

Choose a reason for hiding this comment

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

One question / minor concern, but it's not a blocker. Leaving my approval so merging isn't blocked on the discussion

Copy link
Contributor

@wischli wischli left a comment

Choose a reason for hiding this comment

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

LGTM!

@lemunozm lemunozm enabled auto-merge (squash) July 6, 2023 21:27
Copy link
Contributor

@mikiquantum mikiquantum left a comment

Choose a reason for hiding this comment

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

I would remove the migrations pallet, but in any case I am not blocking this pr 👍

Comment on lines +193 to +195
// We need to put the array into the stack (with a vec) to avoid stack overflow
// here
let accounts = test_data::system_account::SYSTEM_ACCOUNT.to_vec();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove this pallet all-together. We will not use it again.

@lemunozm lemunozm merged commit 33f3aea into main Jul 7, 2023
@lemunozm lemunozm deleted the fix-compilation-issues branch July 10, 2023 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crcl-protocol Circle protocol related. dependencies Pull requests that update a dependency file. I3-annoyance The code behaves as expected, but "expected" is an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Script to check and test all crates separately
6 participants