-
Notifications
You must be signed in to change notification settings - Fork 827
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
Move all tests to use u32 as BlockNumber #1657
Comments
@gupnik I'd like to work on this one, could you please assign it to me? |
@gupnik looking at this issue again: Why |
I don't think there is any reasonable advantage to either. I suggest @philoniare to do whichever produces the smaller diff. |
Got it, will do. Appreciate the guidance 🙏 |
Ended up choosing the u64 as it had smaller diff |
can we make it u32 😮💨 all relay and system parachains are using u32 and there is zero reason to use u64 |
Yeah, I initially thought the same but does it really matter? The framework accepts any type with certain constraints and it should be acceptable to add any type for tests that satisfies those constraints? |
it does. we had bad tests with AccountId = u64 because the type size is too small and causing unexpected behaviors. |
It makes sense when the type size used in test env is smaller than the prod one. However, it's the opposite here and its difficult to imagine a missing scenario in this case.
Yeah, agreed to this one. @philoniare We might need to go back to u32 ones. Hopefully, it won't be that difficult now that you are already familiar with the process. |
@gupnik I'll unassign myself on this one. My old macbook is unable to handle a workspace level build, so I've been using the CI tests as a feedback loop, which results in a pretty bad dev experience. I'd rather focus on individual pallet level tickets that I can build locally. |
Understandable. Thanks for looking into it! You might choose to do it in separate PRs with a few pallets at a time, if you would still want to take it to completion. |
As discussed, assigning this to you @Gilt0 |
@gupnik Just to make sure I am on the right track The command
In cases where u64 appears I change to u32? Thank you |
if possible, fix it one pallet at a time. unless the fix is trivial that only requires search and replace. otherwise it is going to take very long time to review and you will keep having merge conflicts |
Yep @Gilt0, you can just perform the reverse operation on my PR. Please note that you'll need to update the |
Are you suggesting that I create a pull request for each pallet? Or can I make only one? Thank you for your help 🤗 |
Duely noted thank you 🤗 |
One PR for each chunk of work, which could be one big pallet or a few small pallets |
@Gilt0 You are on the right track 👍 |
@gupnik @xlc @philoniare Thank you! |
FYI I will modify these pallets
And following @xlc 's advice, I will create pull requests according to his logic. |
FYI Using the list above I managed to change some files - see below for my notes.
I did not touch In The tests in Finally, I have also tried to look for
If I am not mistaken, Therefore: |
Thanks @Gilt0!
Let's do this in a separate PR. |
You're welcome, thank you for the guidance. Here is a pull request I created on my fork: Gilt0#1 Not sure how to share it with you otherwise as the PR cannot be merged unless all test pass, right? |
Shall we first remove changes in merkle-mountain-range, try to fix all tests in #3437 and get it merged? We can then come back to it in the second PR? |
@gupnik Noted, thanks for the pointer, it makes a lot of sense. I was busy these past two days, but I shall get back into it tomorrow at the latest. |
I hope this message will find you well. Here is the result of this first straight forward pass of changes, using the grep command.
To summarize, they all went pretty smoothly except for (including the first pass above)
Therefore, if you can, have a look at the current PR and let me know if anything is not good for you (I'll switch it to not draft). From now on, I will work on the pallets above, starting a PR for each of them. I'll probably be constantly working on two or three at a time. If you are ok, I will allow myself with questions on the pallet for each respective PR. Thank you again for this learning opportunity. I look forward to completely resolving this issue with your help. 😃 |
Thanks @Gilt0 ! Will go through the PR soon and looking forward to the subsequent ones. |
* add utlity pallet to the Millau runtime * RefundRelayerForMessagesDeliveryFromParachain prototype * done with RefundRelayerForMessagesDeliveryFromParachain::post_dispatch * parse calls * check batch for obsolete headers/messages * fmt * shorten generic arg names + add parachain id generic arg * check lane_id * impl all state read functions * fix typos from review * renamed extension + reference issue from TODO * tests for pre-dispaytch * renamed extension source file * tests for post-dispatch * abstract fee calculation * clippy * actually fix clippy * Update bin/runtime-common/src/refund_relayer_extension.rs Co-authored-by: Adrian Catangiu <adrian@parity.io> * Update bin/runtime-common/src/refund_relayer_extension.rs Co-authored-by: Adrian Catangiu <adrian@parity.io> * Update bin/runtime-common/src/refund_relayer_extension.rs Co-authored-by: Adrian Catangiu <adrian@parity.io> * Update bin/runtime-common/src/refund_relayer_extension.rs Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Adrian Catangiu <adrian@parity.io>
…{MockBlock, MockBlockU32, MockBlockU128}` (#4543) While doing some migration/rebase I came in to the situation, where I needed to change `mocking::MockBlock` to `mocking::MockBlockU32`: ``` #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = frame_system::mocking::MockBlockU32<TestRuntime>; type AccountData = pallet_balances::AccountData<ThisChainBalance>; } ``` But actual `TestDefaultConfig` for `frame_system` is using `ConstU64` for `type BlockHashCount = frame_support::traits::ConstU64<10>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/system/src/lib.rs#L303). Because of this, it force me to specify and add override for `type BlockHashCount = ConstU32<10>`. This PR tries to fix this with `TestBlockHashCount` implementation for `TestDefaultConfig` which supports `u32`, `u64` and `u128` as a `BlockNumber`. ### How to simulate error Just by removing `type BlockHashCount = ConstU32<250>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/multisig/src/tests.rs#L44) ``` :~/parity/olkadot-sdk$ cargo test -p pallet-multisig Compiling pallet-multisig v28.0.0 (/home/bparity/parity/aaa/polkadot-sdk/substrate/frame/multisig) error[E0277]: the trait bound `ConstU64<10>: frame_support::traits::Get<u32>` is not satisfied --> substrate/frame/multisig/src/tests.rs:41:1 | 41 | #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `frame_support::traits::Get<u32>` is not implemented for `ConstU64<10>` | = help: the following other types implement trait `frame_support::traits::Get<T>`: <ConstU64<T> as frame_support::traits::Get<u64>> <ConstU64<T> as frame_support::traits::Get<std::option::Option<u64>>> note: required by a bound in `frame_system::Config::BlockHashCount` --> /home/bparity/parity/aaa/polkadot-sdk/substrate/frame/system/src/lib.rs:535:24 | 535 | type BlockHashCount: Get<BlockNumberFor<Self>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Config::BlockHashCount` = note: this error originates in the attribute macro `derive_impl` which comes from the expansion of the macro `frame_support::macro_magic::forward_tokens_verbatim` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. error: could not compile `pallet-multisig` (lib test) due to 1 previous error ``` ## For reviewers: (If there is a better solution, please let me know!) The first commit contains actual attempt to fix the problem: 3c5499e. The second commit is just removal of `BlockHashCount` from all other places where not needed by default. Closes: #1657 --------- Co-authored-by: Bastian Köcher <git@kchr.de>
…{MockBlock, MockBlockU32, MockBlockU128}` (paritytech#4543) While doing some migration/rebase I came in to the situation, where I needed to change `mocking::MockBlock` to `mocking::MockBlockU32`: ``` #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = frame_system::mocking::MockBlockU32<TestRuntime>; type AccountData = pallet_balances::AccountData<ThisChainBalance>; } ``` But actual `TestDefaultConfig` for `frame_system` is using `ConstU64` for `type BlockHashCount = frame_support::traits::ConstU64<10>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/system/src/lib.rs#L303). Because of this, it force me to specify and add override for `type BlockHashCount = ConstU32<10>`. This PR tries to fix this with `TestBlockHashCount` implementation for `TestDefaultConfig` which supports `u32`, `u64` and `u128` as a `BlockNumber`. ### How to simulate error Just by removing `type BlockHashCount = ConstU32<250>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/multisig/src/tests.rs#L44) ``` :~/parity/olkadot-sdk$ cargo test -p pallet-multisig Compiling pallet-multisig v28.0.0 (/home/bparity/parity/aaa/polkadot-sdk/substrate/frame/multisig) error[E0277]: the trait bound `ConstU64<10>: frame_support::traits::Get<u32>` is not satisfied --> substrate/frame/multisig/src/tests.rs:41:1 | 41 | #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `frame_support::traits::Get<u32>` is not implemented for `ConstU64<10>` | = help: the following other types implement trait `frame_support::traits::Get<T>`: <ConstU64<T> as frame_support::traits::Get<u64>> <ConstU64<T> as frame_support::traits::Get<std::option::Option<u64>>> note: required by a bound in `frame_system::Config::BlockHashCount` --> /home/bparity/parity/aaa/polkadot-sdk/substrate/frame/system/src/lib.rs:535:24 | 535 | type BlockHashCount: Get<BlockNumberFor<Self>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Config::BlockHashCount` = note: this error originates in the attribute macro `derive_impl` which comes from the expansion of the macro `frame_support::macro_magic::forward_tokens_verbatim` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. error: could not compile `pallet-multisig` (lib test) due to 1 previous error ``` ## For reviewers: (If there is a better solution, please let me know!) The first commit contains actual attempt to fix the problem: paritytech@3c5499e. The second commit is just removal of `BlockHashCount` from all other places where not needed by default. Closes: paritytech#1657 --------- Co-authored-by: Bastian Köcher <git@kchr.de>
…{MockBlock, MockBlockU32, MockBlockU128}` (paritytech#4543) While doing some migration/rebase I came in to the situation, where I needed to change `mocking::MockBlock` to `mocking::MockBlockU32`: ``` #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = frame_system::mocking::MockBlockU32<TestRuntime>; type AccountData = pallet_balances::AccountData<ThisChainBalance>; } ``` But actual `TestDefaultConfig` for `frame_system` is using `ConstU64` for `type BlockHashCount = frame_support::traits::ConstU64<10>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/system/src/lib.rs#L303). Because of this, it force me to specify and add override for `type BlockHashCount = ConstU32<10>`. This PR tries to fix this with `TestBlockHashCount` implementation for `TestDefaultConfig` which supports `u32`, `u64` and `u128` as a `BlockNumber`. ### How to simulate error Just by removing `type BlockHashCount = ConstU32<250>;` [here](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/multisig/src/tests.rs#L44) ``` :~/parity/olkadot-sdk$ cargo test -p pallet-multisig Compiling pallet-multisig v28.0.0 (/home/bparity/parity/aaa/polkadot-sdk/substrate/frame/multisig) error[E0277]: the trait bound `ConstU64<10>: frame_support::traits::Get<u32>` is not satisfied --> substrate/frame/multisig/src/tests.rs:41:1 | 41 | #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `frame_support::traits::Get<u32>` is not implemented for `ConstU64<10>` | = help: the following other types implement trait `frame_support::traits::Get<T>`: <ConstU64<T> as frame_support::traits::Get<u64>> <ConstU64<T> as frame_support::traits::Get<std::option::Option<u64>>> note: required by a bound in `frame_system::Config::BlockHashCount` --> /home/bparity/parity/aaa/polkadot-sdk/substrate/frame/system/src/lib.rs:535:24 | 535 | type BlockHashCount: Get<BlockNumberFor<Self>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Config::BlockHashCount` = note: this error originates in the attribute macro `derive_impl` which comes from the expansion of the macro `frame_support::macro_magic::forward_tokens_verbatim` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0277`. error: could not compile `pallet-multisig` (lib test) due to 1 previous error ``` ## For reviewers: (If there is a better solution, please let me know!) The first commit contains actual attempt to fix the problem: paritytech@3c5499e. The second commit is just removal of `BlockHashCount` from all other places where not needed by default. Closes: paritytech#1657 --------- Co-authored-by: Bastian Köcher <git@kchr.de>
Is there an existing issue?
Experiencing problems? Have you tried our Stack Exchange first?
Description of bug
As we expand the usage of
derive-impl
being tracked in #171, it seems that we would need to maintain two default configs to support both u32 and u64 BlockNumber types.Since there's no apparent reason to use different types for tests, it might be better to move them to use u32.
Steps to reproduce
No response
The text was updated successfully, but these errors were encountered: