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

Move all tests to use u32 as BlockNumber #1657

Closed
2 tasks done
gupnik opened this issue Sep 21, 2023 · 30 comments · Fixed by #4543
Closed
2 tasks done

Move all tests to use u32 as BlockNumber #1657

gupnik opened this issue Sep 21, 2023 · 30 comments · Fixed by #4543
Assignees
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T10-tests This PR/Issue is related to tests.

Comments

@gupnik
Copy link
Contributor

gupnik commented Sep 21, 2023

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

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

@gupnik gupnik added C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. I10-unconfirmed Issue might be valid, but it's not yet known. T10-tests This PR/Issue is related to tests. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. labels Sep 21, 2023
@kianenigma kianenigma removed the I10-unconfirmed Issue might be valid, but it's not yet known. label Sep 21, 2023
@philoniare
Copy link
Contributor

@gupnik I'd like to work on this one, could you please assign it to me?

@ggwpez
Copy link
Member

ggwpez commented Feb 6, 2024

@gupnik looking at this issue again: Why u32 and not u64?
It looks like our TestDefaultConfig uses u64 for BlockHashCount.

@kianenigma
Copy link
Contributor

@gupnik looking at this issue again: Why u32 and not u64? It looks like our TestDefaultConfig uses u64 for BlockHashCount.

I don't think there is any reasonable advantage to either. I suggest @philoniare to do whichever produces the smaller diff.

@philoniare
Copy link
Contributor

@gupnik looking at this issue again: Why u32 and not u64? It looks like our TestDefaultConfig uses u64 for BlockHashCount.

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 🙏

@gupnik
Copy link
Contributor Author

gupnik commented Feb 7, 2024

@gupnik looking at this issue again: Why u32 and not u64? It looks like our TestDefaultConfig uses u64 for BlockHashCount.

@ggwpez I think the discussion at that time was to make it use the same type as the relay, but yes fine to use either.

@philoniare
Copy link
Contributor

Ended up choosing the u64 as it had smaller diff

@xlc
Copy link
Contributor

xlc commented Feb 14, 2024

can we make it u32 😮‍💨 all relay and system parachains are using u32 and there is zero reason to use u64
let's correct the mistake, not make it even worse just because it had smaller diff

@gupnik
Copy link
Contributor Author

gupnik commented Feb 14, 2024

can we make it u32 😮‍💨 all relay and system parachains are using u32 and there is zero reason to use u64 let's correct the mistake, not make it even worse just because it had smaller diff

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?

@xlc
Copy link
Contributor

xlc commented Feb 14, 2024

it does. we had bad tests with AccountId = u64 because the type size is too small and causing unexpected behaviors.
yes the test environment doesn’t need to match to prod env but let’s don’t introduce unnecessary differences for no benefits. it can be different, only if it helps.

@gupnik
Copy link
Contributor Author

gupnik commented Feb 15, 2024

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.

let’s don’t introduce unnecessary differences for no benefits. it can be different, only if it helps.

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.

@philoniare
Copy link
Contributor

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

@philoniare philoniare removed their assignment Feb 15, 2024
@gupnik
Copy link
Contributor Author

gupnik commented Feb 15, 2024

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

@gupnik
Copy link
Contributor Author

gupnik commented Feb 19, 2024

As discussed, assigning this to you @Gilt0

@Gilt0
Copy link
Contributor

Gilt0 commented Feb 20, 2024

@gupnik Just to make sure I am on the right track

The command % grep -ri BlockNumber * | grep 'type BlockNumber = ' | grep -v u32 outputs

alliance/src/mock.rs:type BlockNumber = u64;
authority-discovery/src/lib.rs: pub type BlockNumber = u64;
democracy/src/migrations/unlock_and_unreserve_all_funds.rs:             type BlockNumber = BlockNumberFor<Test>;
election-provider-multi-phase/src/lib.rs:       type BlockNumber = BlockNumberFor<T>;
election-provider-multi-phase/src/mock.rs:pub(crate) type BlockNumber = u64;
election-provider-multi-phase/src/mock.rs:      type BlockNumber = BlockNumber;
election-provider-multi-phase/src/mock.rs:      type BlockNumber = BlockNumber;
election-provider-support/src/onchain.rs:       type BlockNumber = frame_system::pallet_prelude::BlockNumberFor<T::System>;
election-provider-support/src/onchain.rs:       type BlockNumber = u64;
election-provider-support/src/onchain.rs:                       type BlockNumber = BlockNumber;
election-provider-support/src/lib.rs://!         type BlockNumber = BlockNumber;
election-provider-support/src/lib.rs://!         type BlockNumber = BlockNumber;
election-provider-support/src/lib.rs:   type BlockNumber = BlockNumber;
fast-unstake/src/mock.rs:pub type BlockNumber = u64;
fast-unstake/src/mock.rs:       type BlockNumber = BlockNumber;
merkle-mountain-range/src/tests.rs:type BlockNumber = frame_system::pallet_prelude::BlockNumberFor<Test>;
nomination-pools/benchmarking/src/mock.rs:type BlockNumber = u64;
nomination-pools/test-staking/src/mock.rs:type BlockNumber = u64;
nomination-pools/src/mock.rs:pub type BlockNumber = u64;
root-offences/src/mock.rs:type BlockNumber = u64;
safe-mode/src/lib.rs:   type BlockNumber = BlockNumberFor<T>;
staking/src/mock.rs:pub(crate) type BlockNumber = u64;
staking/src/pallet/impls.rs:    type BlockNumber = BlockNumberFor<T>;
support/test/compile_pass/src/lib.rs:pub type BlockNumber = u64;
support/test/tests/construct_runtime_ui/use_undefined_part.rs:pub type BlockNumber = u64;
support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs:pub type BlockNumber = u64;
support/test/tests/construct_runtime_ui/exclude_undefined_part.rs:pub type BlockNumber = u64;
support/test/tests/composite_enum.rs:pub type BlockNumber = u64;
support/test/tests/issue2219.rs:pub type BlockNumber = u64;
support/test/tests/construct_runtime.rs:pub type BlockNumber = u64;
support/test/tests/runtime_metadata.rs:pub type BlockNumber = u64;
support/procedural/src/lib.rs:///     type BlockNumber = u64;
support/procedural/src/lib.rs:///     type BlockNumber = <TestDefaultConfig as DefaultConfig>::BlockNumber;
system/src/lib.rs:      type BlockNumber = BlockNumberFor<T>;
tips/src/migrations/unreserve_deposits.rs:              type BlockNumber = BlockNumberFor<Test>;
utility/src/tests.rs:type BlockNumber = u64;

In cases where u64 appears I change to u32?
And in less straight forward definitions (eg type BlockNumber = BlockNumberFor<T>;) I dig a little further to ensure that u32 is indeed used - I can get inspiration from pull request #3285 by @philoniare?

Thank you

@xlc
Copy link
Contributor

xlc commented Feb 20, 2024

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

@philoniare
Copy link
Contributor

Yep @Gilt0, you can just perform the reverse operation on my PR. Please note that you'll need to update the BlockHashCount whenever necessary as well

@Gilt0
Copy link
Contributor

Gilt0 commented Feb 21, 2024

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

Are you suggesting that I create a pull request for each pallet? Or can I make only one?
In any case, I was planning on fixing one pallet at time, build, then move on to the next one if it is successful.

Thank you for your help 🤗

@Gilt0
Copy link
Contributor

Gilt0 commented Feb 21, 2024

Yep @Gilt0, you can just perform the reverse operation on my PR. Please note that you'll need to update the BlockHashCount whenever necessary as well

Duely noted thank you 🤗

@xlc
Copy link
Contributor

xlc commented Feb 21, 2024

One PR for each chunk of work, which could be one big pallet or a few small pallets

@gupnik
Copy link
Contributor Author

gupnik commented Feb 23, 2024

Thanks @Gilt0!

(i) Please let me know if I can change the hash codes in the failing tests of merkle-mountain-range pallet

Let's do this in a separate PR.

@Gilt0
Copy link
Contributor

Gilt0 commented Feb 25, 2024

Thanks @Gilt0!

(i) Please let me know if I can change the hash codes in the failing tests of merkle-mountain-range pallet

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?

@gupnik
Copy link
Contributor Author

gupnik commented Feb 25, 2024

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?

@Gilt0
Copy link
Contributor

Gilt0 commented Feb 27, 2024

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

@Gilt0
Copy link
Contributor

Gilt0 commented Mar 5, 2024

@gupnik

I hope this message will find you well.

Here is the result of this first straight forward pass of changes, using the grep command.

grep -ri 'MockBlock<Test>' * | awk -F/ '{print $1}' | sort -u
asset-conversion                    DONE
asset-rate                          DONE
assets                              DONE
atomic-swap                         DONE
aura                                DONE
authorship                          DONE
babe                                DONE -- Aliased type Header = generic::Header<u32, BlakeTwo256> instead of sourcing from sp_runtime::testing
balances                            DONE
beefy                               DONE
beefy-mmr                           NOT DONE -- Hashes to be modified for tests to be validated
benchmarking                        DONE -- ignored pov/src/benchmarking.rs, pov/src/tests.rs, src/baseline.rs (no tests depend on it)
bounties                            DONE
broker                              DONE
child-bounties                      DONE
contracts                           NOT DONE -- WASM code to be updated
conviction-voting                   DONE
core-fellowship                     DONE
examples                            NOTHING TO DO -- Tests are not triggered
glutton                             DONE 
grandpa                             NOT DONE -- Tests fail
identity                            DONE
indices                             DONE
insecure-randomness-collective-flip DONE
lottery                             DONE
membership                          DONE
message-queue                       DONE
nft-fractionalization               DONE
nfts                                DONE
nis                                 DONE
node-authorization                  DONE
paged-list                          DONE                       
preimage                            DONE
proxy                               DONE
ranked-collective                   DONE -- PollStatus::Completed(*when, *succeeded) => PollStatus::Completed(*when as u32, *succeeded) -- there may be a loss of data with the conversion but it is better this way?
recovery                            DONE
referenda                           NOT DONE -- test referendum_status_v0 needs some further work as there is a hardcoded hex value to updated
remark                              DONE
safe-mode                           NOT DONE -- I have errors like trait `From<RawOrigin<u32>>` is not implemented for `mock::RuntimeOrigin
salary                              DONE
sassafras                           DONE -- using a lot of 'epoch_length as u32' as Slot is mainly defined as u64 and I do not want to touch to primitives in this PR
scheduler                           NOT DONE -- two tests fails: `migration_to_v4_works` and `test_migrate_origin`
scored-pool                         DONE
session                             DONE
society                             NOT DONE - requires modification outside of test files (in society/src/migrations.rs)
statement                           DONE
sudo                                DONE
support                             NOTHING TO DO -- tests do not use MockBlock
system                              NOT DONE -- will have its own PR
timestamp                           DONE
transaction-storage                 DONE
treasury                            DONE
tx-pause                            DONE
uniques                             DONE
vesting                             NOT DONE -- trait `sp_runtime::traits::Convert<u32, u64>` is not implemented for `sp_runtime::traits::Identity
whitelist                           DONE

To summarize, they all went pretty smoothly except for (including the first pass above)

  • safe-mode
  • election-provider-multi-phase
  • merkle-mountain-range
  • beefy-mmr
  • contracts
  • grandpa
  • referenda
  • safe-mode
  • scheduler
  • society
  • system
  • vesting
  • system

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

@gupnik
Copy link
Contributor Author

gupnik commented Mar 6, 2024

Thanks @Gilt0 ! Will go through the PR soon and looking forward to the subsequent ones.

serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 26, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Mar 27, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* 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>
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* 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>
bkchr pushed a commit that referenced this issue Apr 10, 2024
* 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>
@bkchr
Copy link
Member

bkchr commented May 24, 2024

@bkontur I think we can close this with #4543? As there is no real need to move all tests to u32 or u64.

github-merge-queue bot pushed a commit that referenced this issue May 24, 2024
…{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>
TomaszWaszczyk pushed a commit to TomaszWaszczyk/polkadot-sdk that referenced this issue May 27, 2024
* 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>
TomaszWaszczyk pushed a commit to TomaszWaszczyk/polkadot-sdk that referenced this issue May 27, 2024
…{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>
hitchhooker pushed a commit to ibp-network/polkadot-sdk that referenced this issue Jun 5, 2024
…{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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T10-tests This PR/Issue is related to tests.
Projects
Status: Done
7 participants