Hi everyone, Rupam here. This week I completed adding tests which were left in the PR which implements the function to calculate the roots of all fields of a block body. This is a part of the implementation of the compute_merkle_proof
function from CL specs. With this, the PR got merged and right now I am working on another PR which implements a function to calculate the merkle proof of the execution payload field of a block body.
According to what rkapka said:
execution_payload
is a field of BeaconBlockBody
, which itself is a field of BeaconBlock
This means that the merkle trie will look something like this:
P
is the execution_payload
field, F
is the root of the block body and L
is the root of the block.
So in this case the merkle proof will consist of the following nodes: C --> D --> G --> K
We already have a function fieldtrie.ProofFromMerkleLayers
that is able to generate a proof for a simple trie. So it is able to produce a proof of P
if the trie's root is F
(the proof will be C --> D
) and a proof of F
if the trie's root is L
(the proof will be G --> K
).
What we can do is call this function twice to obtain a combined proof
First of all, we need roots of all fields of the block body. That way we can construct a proof of execution_payload with respect to the block body. Note that this proof does not contain the root of the block body, but this is very easy to get - we just need to call HashTreeRoot
on the body.
We then take the root of the body plus roots of all other fields of the block and construct a proof of the block's root. Lastly, we combine these two proofs into one. Each proof is just a slice of bytes that we combine into one slice.
This PR should ideally implement the changes that Capella and Deneb have brought forward once it gets completed.