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

Metadata: Retain a subset of metadata pallets #879

Merged
merged 32 commits into from
Apr 4, 2023
Merged

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Mar 23, 2023

This PR strips the metadata to include only some provided pallets.

Metadata size with single pallet

The No Generics means that the extrinsic types were stripped of the generic type parameters.
Those generics where not needed and include nested type IDs that are unnecessarily increasing
the final metadata size. (Relies on paritytech/scale-info#176).

No Generics With Generics Pallet
244K 244K Alliance.scale
240K 240K AllianceMotion.scale
8,0K 240K AssetTxPayment.scale
32K 244K Assets.scale
12K 12K Auctions.scale
8,0K 240K AuthorityDiscovery.scale
8,0K 240K Authorship.scale
16K 244K Babe.scale
16K 244K Balances.scale
16K 244K Bounties.scale
16K 240K ChildBounties.scale
12K 12K Claims.scale
16K 16K Configuration.scale
28K 252K Contracts.scale
16K 240K ConvictionVoting.scale
16K 240K CoreFellowship.scale
240K 240K Council.scale
16K 16K Crowdloan.scale
248K 248K Democracy.scale
8,0K 8,0K Dmp.scale
20K 248K ElectionProviderMultiPhase.scale
16K 244K Elections.scale
12K 240K FastUnstake.scale
8,0K 240K Glutton.scale
12K 240K Grandpa.scale
8,0K 240K Historical.scale
16K 16K Hrmp.scale
20K 244K Identity.scale
12K 240K ImOnline.scale
12K 240K Indices.scale
8,0K 8,0K Initializer.scale
240K 240K Lottery.scale
12K 240K MessageQueue.scale
8,0K 240K Mmr.scale
240K 240K Multisig.scale
44K 252K Nfts.scale
20K 248K Nis.scale
28K 248K NominationPools.scale
8,0K 240K Offences.scale
12K 12K ParaInclusion.scale
12K 12K ParaInherent.scale
12K 12K ParaScheduler.scale
8,0K 8,0K ParaSessionInfo.scale
8,0K 8,0K ParachainsOrigin.scale
20K 20K Paras.scale
12K 12K ParasDisputes.scale
8,0K 8,0K ParasShared.scale
16K 16K PhragmenElection.scale
8,0K 240K Pov.scale
12K 240K Preimage.scale
240K 240K Proxy.scale
8,0K 240K RandomnessCollectiveFlip.scale
12K 240K RankedCollective.scale
248K 248K RankedPolls.scale
244K 244K Recovery.scale
248K 248K Referenda.scale
12K 12K Registrar.scale
8,0K 240K Remark.scale
8,0K 240K RootTesting.scale
12K 240K Salary.scale
240K 240K Scheduler.scale
12K 240K Session.scale
12K 12K Slots.scale
20K 244K Society.scale
36K 252K Staking.scale
12K 240K StateTrieMigration.scale
240K 240K Sudo.scale
312K 312K System.scale
240K 240K TechnicalCommittee.scale
12K 240K TechnicalMembership.scale
8,0K 240K Timestamp.scale
16K 240K Tips.scale
8,0K 240K TransactionPayment.scale
12K 240K TransactionStorage.scale
12K 240K Treasury.scale
12K 12K Ump.scale
28K 244K Uniques.scale
240K 240K Utility.scale
12K 240K Vesting.scale
12K 244K VoterList.scale
240K 240K Whitelist.scale
36K 36K XcmPallet.scale
468K 468K polkadot_metadata.scale

Closes #629.

// CC @paritytech/subxt-team

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv self-assigned this Mar 23, 2023
metadata/src/retain.rs Outdated Show resolved Hide resolved
metadata/src/lib.rs Outdated Show resolved Hide resolved
lexnv added 12 commits March 24, 2023 16:22
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This reverts commit 725a2e5.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
cli/src/commands/metadata.rs Outdated Show resolved Hide resolved
metadata/src/lib.rs Outdated Show resolved Hide resolved
metadata/src/retain.rs Outdated Show resolved Hide resolved
metadata/src/retain.rs Outdated Show resolved Hide resolved
lexnv and others added 3 commits March 28, 2023 13:14
Co-authored-by: James Wilson <james@jsdw.me>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
cli/src/commands/utils.rs Outdated Show resolved Hide resolved
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@jsdw
Copy link
Collaborator

jsdw commented Mar 29, 2023

Awesome; looks like removing those generic types had a really notable impact! (allets like Sudo and MultiSig I guess depend on RuntimeCall for the inner stuff which depends on types from all other pallets, so it makes sense that they are still big :))

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

Looks great; happy to see this merge :)

@niklasad1 niklasad1 self-requested a review March 31, 2023 15:28
cli/src/commands/utils.rs Outdated Show resolved Hide resolved
metadata/src/retain.rs Outdated Show resolved Hide resolved
metadata/src/retain.rs Outdated Show resolved Hide resolved
metadata/src/retain.rs Outdated Show resolved Hide resolved
@jsdw jsdw self-requested a review April 4, 2023 11:08
@jsdw
Copy link
Collaborator

jsdw commented Apr 4, 2023

Instead of trying to strip type params out of the extrinsic type (whose effect is primarily to remove the reference to the RuntimeCall type), I now strip the RuntimeCall type variants to only include those for pallets we want to keep. This keeps the size fairly uniformly small across all pallets now (below based on artifacts/polkadot.metadata):

pallet size
System 64233
Scheduler 13027
Preimage 9102
Babe 14074
Timestamp 7879
Indices 10815
Balances 14605
TransactionPayment 8060
Authorship 8461
Staking 35015
Offences 7783
Historical 6555
Session 10574
Grandpa 11876
ImOnline 10598
AuthorityDiscovery 6563
Democracy 23583
Council 16705
TechnicalCommittee 16749
PhragmenElection 15828
TechnicalMembership 8984
Treasury 11710
Claims 11536
Vesting 11809
Utility 13546
Identity 21004
Proxy 16162
Multisig 16092
Bounties 13829
ChildBounties 14950
Tips 13978
ElectionProviderMultiPhase 18513
VoterList 12627
NominationPools 23233
FastUnstake 10442
ParachainsOrigin 6561
Configuration 14857
ParasShared 7399
ParaInclusion 12255
ParaInherent 11830
ParaScheduler 9923
Paras 17175
Initializer 8226
Dmp 7453
Ump 11275
Hrmp 15863
ParaSessionInfo 8246
ParasDisputes 9899
Registrar 12484
Slots 9715
Auctions 11495
Crowdloan 14214
XcmPallet 36657

cli/src/utils.rs Outdated Show resolved Hide resolved
cli/src/utils.rs Outdated Show resolved Hide resolved
cli/src/utils.rs Outdated Show resolved Hide resolved
@jsdw jsdw merged commit 8a7c172 into master Apr 4, 2023
@jsdw jsdw deleted the lexnv/stirp_metadata branch April 4, 2023 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI Tool: Strip metadata to only include certain pallets
3 participants