-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
fn generate_historical_proof( | ||
leaf_index: LeafIndex, | ||
leaves_count: LeafIndex, | ||
) -> Result<(EncodableOpaqueLeaf, Proof<Hash>), Error>; |
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.
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 comment
The 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 comment
The 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
/// Note this method can only be used from an off-chain context | ||
/// (Offchain Worker or Runtime API call), since it requires | ||
/// all the leaves to be present. | ||
/// It may return an error or panic if used incorrectly. |
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()
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Polkadot companion: paritytech/polkadot#5334
This PR adds new MMR RPC method -
mmr_generateHistoricalProof
. It is quite similar to the existingmmr_generateProof
method, but it has additional argument - number of MMR leaves. It may be used to generate proof using historical MMR state even using latest block state, where there are more leaves.Where it is useful:
mmr_generateProof(use-state-at-validator-set-change-block)
will obviously fail. We may usemmr_generateHistoricalProof(use-state-at-best-block, use-mmr-state-at-validator-set-change-block)
instead - this will generate us required proof;B
is known to the light client, then we can't simply generate some MMR-related proof using MMR state at blockB+10
. So e.g. to prove some storage (read: deliver message), we need to generate proof using MMR state at blockB
. If state is discarded, we'll need to importB+10
first => extra bridge cost.The
leaves_count
argument can easily be computed by the client by assuming that there's exactly one leaf per every block starting from some beginning block (where MMR pallet has been deployed). We may read number of MMR leaves at thebest_block
and then computeleaves_count_at_historical_block
asnumber_of_historical_block - (best_block_number - leaves_count_at_best_block)
.