5

I want to run an experiment to see how big are PoVs for my parachain blocks.

I figured I can leverage the same API that is used during syncing execute_block for the blocks I am interested in and collect the key-value pairs along with the merkle-proof similar to what a collator does during parachain block creation.

Is that possible to do in Substrate?

1 Answer 1

4

It is possible to collect a witness for having an runtime API handle at hand. The key methods are record_proof and extract_proof.

Assuming you have a Client instance at hand, you can do the following:

let mut runtime_api = client.runtime_api();
runtime_api.record_proof(); 
runtime_api.execute_block(at, block);
let witness = runtime_api
    .extract_proof()
    .unwrap("proof is always present if called after `record_proof`");

Currently, Cumulus' PoV consists of the witness and the block part. The block part can be obtained by just SCALE encoding the block, i.e.

block.encode()

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.