Skip to content

Add mmr_generateAncestryProof rpc call #9295

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

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Lederstrumpf
Copy link
Contributor

Description

Adds generateAncestryProof to the mmr RPC. An RPC method for generating ancestry proofs is required for cross-chain slashing by cross-chain fishermen Snowfork/snowbridge#1493.
Consequently, this PR also adds the mmr runtime api method generate_ancestry_proof. While such a method was already exposed by the beefy-mmr runtime api, this PR opts for moving it to the mmr runtime api instead due to the following considerations:

  1. Invoking beefy-mmr's generate_proof method via RPC would require adding the offchain-db extension to the beefy-rpc, which is a more invasive change with boilerplate that's not needed since the mmr RPC already uses the offchain-db extension for generating leaf proofs.
  2. Since the ancestry proofs are for MMR, it is more natural to expose the method directly on the mmr runtime api - the beefy-mmr pallet's generate_proof method is merely a wrapper around the mmr pallet's generate_ancestry_proof method.

Some other misc. changes documented under Review Notes.

Integration

The integration is the same as for the beefy-mmr runtime api's generate_proof method, except that the optional at specifier is removed for the method here since the method is idempotent wrt. the block height invoked at, so long as at >= best_known_block_number. Removing the specifier reduces likelihood of spurious errors from incorrect usage. I can revert the at specifier removal however if desired for compatibility.

For example use, see Snowfork/snowbridge#1493.

Review Notes

  • Adds generate_ancestry_proof method to mmr runtime api (Lederstrumpf@682eb4a)
  • Adds mmr_generateAncestryProof rpc method (Lederstrumpf@5d0eac9, Lederstrumpf@5d0eac9f1f)
  • Adds new InvalidEquivocationProofSessionMember error to beefy pallet (Lederstrumpf@682eb4a141) (note: this change is unrelated to the PR's main purpose, but helps implementers with more granular error reporting. I'm open to removing this change).
  • Deprecates pallet_beefy::generate_ancestry_proof::generate_ancestry_proof and pallet_beefy::AncestryHelper::generate_proof. Deprecation penciled in for September 2025 - I'm open to change this date or undo the deprecation. (Lederstrumpf@6619169ecd)
  • Removes at specifier for pallet_mmr::generate_ancestry_proof (Lederstrumpf@bcadda2) (as mentioned in the Integration section, fine to undo)

PR can be tested using Snowfork/snowbridge#1493.

already exists for beefy runtime, but this is a layered onion that's
begging for a peeling.
Block height at which the proof is generated is irrelevant to the proof
content, so long as `at` >= `best_known_block_number`. Removing the
specifier reduces likelihood of spurious errors from incorrect usage.
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.

1 participant