Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

pallet-mmr: Change runtime API and RPC API to work with block numbers instead of leaf indices #12339

Closed

Description

@acatangiu

Issue

This issue was triggered by a good observation made by @serban300 in #12324 (comment):

Current pallet-mmr APIs work with leaf indices, leaving the burden of translating block numbers to leaf indices to the users of the pallet.

Light clients might have an easier experience dealing only with block numbers, and avoiding managing leaf indices and the conversion from block numbers => leaf indices.

Suggested solution

pallet-mmr could expose APIs based on block numbers and internally map those to leaf indices.

Implications

  • Breaking API change, both for Runtime API and RPC API.
  • Pallet currently only deployed on Rococo so breaking change only for that. Kusama and Polkadot will directly deploy new API.

Feedback requests

cc @vgeddes and @seunlanlege as current (light-client) users of this pallet

Activity

  1. added
    I7-refactorCode needs refactoring.
    Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.
    Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.
    on Sep 23, 2022
  2. moved this to Need for Kusama 🗒 in BEEFYon Sep 23, 2022
  3. Szegoo commented on Sep 24, 2022

    @Szegoo
    Contributor

    I will give this a try.

  4. acatangiu commented on Sep 26, 2022

    @acatangiu
    ContributorAuthor

    As shown in #12345 there is also the option to change only RPC API to use block numbers, while leaving existing Runtime API unchanged.

  5. seunlanlege commented on Sep 27, 2022

    @seunlanlege
    Contributor

    And while this change is harmless, it's actually unneccessary. As light clients need to be aware of the leaf_index which they can use to derive the leaf_postion which is needed when verifying mmr proofs with the ckb-merkle-mountain-range lib

  6. vgeddes commented on Sep 27, 2022

    @vgeddes
    Contributor

    I'm in favour of the change. It does simplify our offchain relayers that call mmr_generateProof. They have needed to manually calculate the leaf indices. To compute the correct leaf indices on Kusama and Polkadot, they will need to know the block height when MMR leafs started being generated, and this is extra configuration and deployment hassle.

    Our system also requires the MMR leaf index for a block. But since the output of mmr_generateProof(blockNumber) includes the leaf index we're happy. And we'd rather rely on that instead of calculating our own leaf indices.

  7. acatangiu commented on Sep 28, 2022

    @acatangiu
    ContributorAuthor

    Seeing how pallet-mmr has only been deployed on Rococo so far, I'm leaning heavily to just break the API without backwards compatibility if that's acceptable to you.

  8. vgeddes commented on Sep 28, 2022

    @vgeddes
    Contributor

    sounds fine with us 👍

  9. Szegoo commented on Sep 28, 2022

    @Szegoo
    Contributor

    So is the final decision to have this implemented? If so should #12345 also change the runtime API? Initially, I didn't change the runtime API in the PR, but I don't actually see a reason why we wouldn't change that also.

  10. acatangiu commented on Sep 28, 2022

    @acatangiu
    ContributorAuthor

    Yes, decision is to implement full breaking change. Let's change Runtime API too in #12345

  11. moved this from Draft to Open in Parity Roadmapon Oct 5, 2022
  12. Repository owner moved this from Need for Kusama 🗒 to Done ✅ in BEEFYon Oct 13, 2022
  13. Repository owner moved this from Open to Closed in Parity Roadmapon Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    D2-breaksapiI7-refactorCode needs refactoring.U2-some_time_soonIssue is worth doing soon.Z2-mediumCan be fixed by a coder with good Rust knowledge but little knowledge of the codebase.Z6-mentorAn easy task where a mentor is available. Please indicate in the issue who the mentor could be.

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions