-
Notifications
You must be signed in to change notification settings - Fork 2.6k
BEEFY: generate historical proofs #11230
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -399,6 +399,17 @@ sp_api::decl_runtime_apis! { | |
/// Generate MMR proof for a leaf under given index. | ||
fn generate_proof(leaf_index: LeafIndex) -> Result<(EncodableOpaqueLeaf, Proof<Hash>), Error>; | ||
|
||
/// Generate a historical MMR proof for a leaf with given index. | ||
/// | ||
/// This function may be used to generate proofs using MMR state at some earlier | ||
/// point. To do that, you shall provide historical value of the `leaves_count`. | ||
/// The proof generated by this function may be verified by clients that only have | ||
/// some old MMR root (corresponding to the `leaves_count`). | ||
fn generate_historical_proof( | ||
leaf_index: LeafIndex, | ||
leaves_count: LeafIndex, | ||
) -> Result<(EncodableOpaqueLeaf, Proof<Hash>), Error>; | ||
Comment on lines
+408
to
+411
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to directly add this with support for multiple leaves at once? (see #10635) Would the light client benefit for generating historical proofs in a batch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah - I think it makes sense to add support for proving several leaves, even though we'll only be using this API to prove single leaf now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then let's probably defer this PR until #10635 is merged to reuse primitives from there && etc |
||
|
||
/// Verify MMR proof against on-chain MMR. | ||
/// | ||
/// Note this function will use on-chain MMR root hash and check if the proof | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it makes sense to add an explicit error in case
leaves_count > Self::mmr_leaves()