substrate
substrate copied to clipboard
Proposal: Flatten `AllPallets` and similar types
Currently, all of the types generated via this macro are nested. For example, you have:
type AllPallets = (System, (Balances, Babe));
As far as I know, the main advantage of this is that we can use recursive implementations in some places. For example, PalletsInfoAccess
introduced in https://github.com/paritytech/substrate/pull/10053/files is only implemented for (T1, T2)
, and there's no need to generate the code for longer tuples.
In fact, if we use only nested tuples, you can probably get away with impl_trait_for_tuple(2)
for most items that are implemented for all pallets, such as OnInitialize
etc.
The problem is: certain traits like OnInitialize
are perfectly comprehensible both for T
, and (T1, T2, T3)
, and (T1, (T2, T3))
. But, certain traits like PalletInfoAccess
are only comprehensible on individual items, i.e. T
, but not on tuples.
And then you have an unfortunate scenario where you want to assert where T: PalletInfoAccess
, and you know that each T
does indeed implement PalletInfoAccess
, but if demonstrated as a nested tuple, this does not work.
You can see a concrete example of this in what I am trying to do here: https://github.com/paritytech/substrate/pull/10174/files#diff-1c449417be9803cb427eed15d51557931141d47d0047561407f1651d319f7103R183
Lastly, in general, arguing about a flat array of tuples rather then nested is generally easier.
- [x] measure how slower it is to bump impl_trait_for_tuples to 100 instead of 30.
bot rebase
Rebased
/cmd queue -c fmt $
@kianenigma Could not find start of command (" $ ")
/cmd queue -c fmt
@kianenigma Could not find start of command (" $ ")
/cmd queue -c fmt $ 1
@kianenigma https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726286 was started for your command "$PIPELINE_SCRIPTS_DIR/fmt.sh" 1
. Check out https://gitlab.parity.io/parity/mirrors/substrate/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.
Comment /cmd cancel 11-58e217d0-cfd8-4c51-94b8-464e4f4538b4
to cancel this command or /cmd cancel
to cancel all commands in this pull request.
@kianenigma Command "$PIPELINE_SCRIPTS_DIR/fmt.sh" 1
has finished. Result: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726286 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1726286/artifacts/download.
bot rebase
Rebased
The CI pipeline was cancelled due to failure one of the required jobs. The job name - test-linux-stable The job logs - https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/1740275
bot merge
This pull request has been mentioned on Polkadot Forum. There might be relevant details there:
https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-41-v0-9-42/2828/1