0

I see from the RFC (https://github.com/polkadot-fellows/RFCs/blob/main/text/0078-merkleized-metadata.md#inclusion-in-an-extrinsic) that it's possible to not provide the hash when crafting a polkadot tx, expecially this part:

The signing side should control whether it wants to add the metadata hash or if it wants to omit it. To accomplish this it is required to add one extra byte to the extrinsic itself. If this byte is 0 the metadata hash is not required and if the byte is 1 the metadata hash is added using V1 of the MetadataDigest.

However i cannot find where this byte is supposed to be in the signing payload, is there some documentation or example for this? The only thing I can find is this (https://spec.polkadot.network/id-extrinsics#defn-extrinsic-signature) but no mention of the metadata hash

New contributor
dierreh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

2 Answers 2

0

The change is being implemented in this pull request.

A signed extension can add data to the extrinsic. This means that the data is part of the actual extrinsic and thus, increases the size of the extrinsic. There should be put data that only one side knows and the other can not reconstruct. Then signed extensions also can add data that is only added to the data that will get signed. This has the advantage that the data will not increase the size of the extrinsic, but still will be checked to be correct. It requires that both sides are aware of the data.

When it now comes to the metadata hash signed extension, the so called mode will be put into the extrinsic and the metadata hash itself will be added to the signed data only. The mode controls if the metadata hash should be added to the signed data or not. If mode == 0 is passed, the metadata hash should be omitted. This basically means that the signed extension does not adds any data to the signing process. If mode == 1 is passed, the metadata hash should be added to the signed data.

2
  • Thanks for your answer. So do i need to change my crafter + signer to add this mode=0 or can i keep them as they are for now?
    – dierreh
    May 15 at 22:39
  • Yes you need to add mode=0.
    – bkchr
    2 days ago
1

The change is not yet implemented. It is coming up in #4274.

From what i understood: The metadata hash can be optionally appended at the end. This keeps backwards compatibility with existing signers who would just not append the hash.

It does this by creating a specific type: EncodeNoneToEmpty, that does not encode anything if there is no hash present.

2
  • Thanks for your answer, from what i got from @bkchr comment, it seems that the backward compatibility is not assured, are you sure it's optional? I don't understand the code base well enough to be sure of that
    – dierreh
    May 16 at 8:17
  • If you don't use the signed extension in your runtime, nothing changes for you. However, if the signed extension is added you need to pass at least mode = 0 to make it work as before.
    – bkchr
    2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.