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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ rustup --version
cargo --version

case $TARGET in
build-node)
cargo build --release "$@"
;;
build-node)
cargo build --release "$@"
;;

build-runtime)
export RUSTC_VERSION=$RUST_TOOLCHAIN
Expand Down
16 changes: 15 additions & 1 deletion libs/mock-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.0.1"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }

[dev-dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
Expand All @@ -20,3 +20,17 @@ scale-info = { version = "2.3.0", features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

[features]
default = ["std"]
std = [
"frame-support/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]
6 changes: 5 additions & 1 deletion libs/traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f

[dev-dependencies]
cfg-mocks = { path = "../mocks" }
cfg-types = { path = "../types", default-features = true }
cfg-types = { path = "../types" }
mock-builder = { path = "../../libs/mock-builder" }

[features]
Expand All @@ -31,6 +31,9 @@ runtime-benchmarks = [
"cfg-primitives/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"cfg-mocks/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"mock-builder/runtime-benchmarks",
]
std = [
"codec/std",
Expand All @@ -45,4 +48,5 @@ try-runtime = [
"frame-support/try-runtime",
"cfg-primitives/try-runtime",
"sp-runtime/try-runtime",
"mock-builder/try-runtime",
]
16 changes: 11 additions & 5 deletions pallets/anchors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-
pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }

[dev-dependencies]
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

cfg-mocks = { path = "../../libs/mocks" }

Expand All @@ -46,17 +46,23 @@ runtime-benchmarks = [
"pallet-timestamp/runtime-benchmarks",
"cfg-utils/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"cfg-mocks/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
]
try-runtime = [
"cfg-utils/try-runtime",
"cfg-traits/try-runtime",
"cfg-mocks/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-aura/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-randomness-collective-flip/try-runtime",
"sp-runtime/try-runtime",
]
std = [
Expand Down
6 changes: 5 additions & 1 deletion pallets/bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pallet-authorship = { git = "https://github.com/paritytech/substrate", branch =
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-fees = { path = "../fees" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
runtime-common = { path = "../../runtime/common" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
Expand All @@ -41,7 +40,10 @@ runtime-benchmarks = [
"chainbridge/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"cfg-primitives/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
]
std = [
"codec/std",
Expand All @@ -58,5 +60,7 @@ try-runtime = [
"cfg-traits/try-runtime",
"frame-support/try-runtime",
"chainbridge/try-runtime",
"cfg-types/try-runtime",
"cfg-primitives/try-runtime",
"frame-system/try-runtime",
]
7 changes: 7 additions & 0 deletions pallets/claims/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ try-runtime = [
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
runtime-benchmarks = [
"cfg-primitives/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
]
4 changes: 0 additions & 4 deletions pallets/connectors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ sp-io = { git = "https://github.com/paritytech/substrate", default-features = tr
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }

# Local crates
runtime-common = { path = "../../runtime/common", default-features = true }

[features]
default = ["std"]
runtime-benchmarks = [
Expand Down Expand Up @@ -89,7 +86,6 @@ std = [
"orml-tokens/std",
"orml-traits/std",
"pallet-balances/std",
"runtime-common/std",
"xcm/std",
"pallet-ethereum/std",
"xcm-primitives/std",
Expand Down
10 changes: 6 additions & 4 deletions pallets/crowdloan-reward/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
cfg-traits = { path = "../../libs/traits", default_features = false }

[dev-dependencies]
cfg-types = { path = "../../libs/types", default_features = true }
pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
cfg-types = { path = "../../libs/types" }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
serde = { version = "1.0.119" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

[features]
default = ["std"]
Expand All @@ -44,6 +44,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
]
std = [
"codec/std",
Expand All @@ -58,6 +59,7 @@ std = [
"sp-runtime/std",
]
try-runtime = [
"cfg-types/try-runtime",
"cfg-traits/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
Expand Down
23 changes: 12 additions & 11 deletions pallets/investments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.38" }

[dev-dependencies]
cfg-test-utils = { path = "../../libs/test-utils", default-features = true }
cfg-types = { path = "../../libs/types", default-features = true }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-restricted-tokens = { path = "../../pallets/restricted-tokens", default-features = true }
runtime-common = { path = "../../runtime/common", default-features = true }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
cfg-test-utils = { path = "../../libs/test-utils" }
cfg-types = { path = "../../libs/types" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-restricted-tokens = { path = "../../pallets/restricted-tokens" }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking",
"frame-system/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"cfg-test-utils/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"cfg-primitives/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
]
std = [
"cfg-primitives/std",
Expand All @@ -64,6 +64,7 @@ std = [
"serde/std",
]
try-runtime = [
"cfg-test-utils/try-runtime",
"cfg-primitives/try-runtime",
"cfg-traits/try-runtime",
"frame-support/try-runtime",
Expand Down
5 changes: 4 additions & 1 deletion pallets/migration/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ benchmarks! {
assert_eq!(vesting_info, storage_vesting_info);
}
}

migrate_proxy_proxies{
let n in 1 .. <T as Config>::MigrationMaxProxies::get();

Expand Down Expand Up @@ -189,7 +190,9 @@ fn inject_total_issuance() {
}

fn inject_system_accounts() {
let accounts = test_data::system_account::SYSTEM_ACCOUNT;
// 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();
Comment on lines +193 to +195
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.


for account in accounts {
storage::unhashed::put_raw(&account.key[..], &account.value[..]);
Expand Down
1 change: 1 addition & 0 deletions pallets/migration/src/test_data/system_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24009,6 +24009,7 @@ pub const SYSTEM_ACCOUNT: [AccountKeyValue; 1715] = [
},
];

#[derive(Clone)]
pub struct AccountKeyValue {
pub key: [u8; 80],
pub value: [u8; 80],
Expand Down
28 changes: 15 additions & 13 deletions pallets/nft-sales/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,34 @@ pallet-uniques = { git = "https://github.com/paritytech/substrate", default-feat

[dev-dependencies]
# Substrate crates & pallets
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.38" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

# Orml crates
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.38" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.38" }

# Local crates
cfg-primitives = { path = "../../libs/primitives", default-features = true }
cfg-types = { path = "../../libs/types", default-features = true }
cfg-primitives = { path = "../../libs/primitives" }
cfg-types = { path = "../../libs/types" }

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking",
"pallet-balances",
"pallet-uniques",
"cfg-types",
"cfg-primitives",
"orml-tokens",
"pallet-balances/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"cfg-primitives/runtime-benchmarks",
"orml-traits",
"orml-tokens/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
]
std = [
"codec/std",
Expand Down
5 changes: 4 additions & 1 deletion pallets/nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ cfg-mocks = { path = "../../libs/mocks" }
[features]
default = ["std"]
runtime-benchmarks = [
"chainbridge/runtime-benchmarks",
"frame-benchmarking",
"chainbridge/runtime-benchmarks",
"cfg-primitives/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"cfg-types/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"cfg-mocks/runtime-benchmarks",
"pallet-anchors/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
]
std = [
"codec/std",
Expand Down
2 changes: 1 addition & 1 deletion pallets/permissions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bitflags = "1.3"
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking",
"cfg-types",
"cfg-types/runtime-benchmarks",
"cfg-traits/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
Expand Down
4 changes: 3 additions & 1 deletion pallets/pool-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ use frame_support::{
};
use frame_system::EnsureSigned;
use orml_traits::{asset_registry::AssetMetadata, parameter_type_with_key};
#[cfg(feature = "runtime-benchmarks")]
use pallet_pool_system::benchmarking::create_pool;
use pallet_pool_system::{
benchmarking::create_pool,
pool_types::{PoolChanges, PoolDetails, ScheduledUpdateDetails},
tranches::TrancheInput,
};
Expand Down Expand Up @@ -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 🤔

create_pool::<T>(tranche_inputs.len() as u32, admin)?;
Ok(())
}
Expand Down
Loading