Skip to content

Auto-generate the GetWeight impl for the XCM Instruction enum #12279

Description

@franciscoaguirre

Part of the same issues #2766 wants to fix.

The XcmWeightInfo trait is already auto-generated from the Instruction enum by the XcmWeightInfoTrait derive macro (polkadot/xcm/procedural/src/weight_info.rs). However, the dispatch glue that maps each variant to its trait method is not. This is manually written and has to be updated in v3, v4 and v5 whenever any variant of the enum changes.

We should extend the existing proc macro so the same derive that emits the XcmWeightInfo trait also emits the GetWeight impl we need. Then remove the manually written impls.

Tip

The Builder pattern macro in xcm-procedural is a good example of how to turn variant names into method names within a proc macro. Its structure can be mirrored.

Metadata

Metadata

Assignees

Labels

C1-mentorA task where a mentor is available. Please indicate in the issue who the mentor could be.C2-good-first-issueA task for a first time contributor to become familiar with the Polkadot-SDK.T6-XCMThis PR/Issue is related to XCM.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions