-
Notifications
You must be signed in to change notification settings - Fork 587
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
BlockHeaderInnerLiteView::block_merkle_root should include entire previous epoch #2711
Comments
CC @SkidanovAlex |
I believe |
@SkidanovAlex I don't understand the format of our merkle tree then. Could you please give example of merkle tree and how it is updated when one block is added to it? Suppose we have 4 blocks B0, B1, B2, B3. I would expect the merkle tree to look like this:
How do we update it when block B4 is added? |
This is not true. The merkle root include every block up to the previous block of the current head. |
@nearmax we always maintain the path for the next leaf. In this case what we maintain in |
I am not sure what do you mean. Also when you say "this is not true" what "this" is referring to? |
@nearmax I was referring to
I didn't refresh the page so didn't see the two comments above. |
@nearmax the way I understand the tree, the progression of the hashes is the following:
etc In short, it is like a regular merkle tree of all the blocks, but the nodes that have only one child are collapsed. E.g. instead of
we get
(node I guess documenting it wouldn't hurt :) |
Do I understand correctly that |
@SkidanovAlex you are absolutely right and offered a much better explanation than I did :) It almost makes me wonder who actually implemented this :)
It is signed by validators since it is part of |
As per spec, it is part of |
So the virtual merkle tree grows endlessly, since we do not reset it between the epochs? Does this mean that the proofs for this tree will become longer and longer as the time passes? (For instances in @SkidanovAlex 's example the proof for B0 went from 0 nodes to 1 to 2). |
Correct. It grows endlessly with logarithmic speed. UPDATE: couple changes above |
Yes. I have considered this when I implemented it. But given at the amount of blocks is bounded by u64, the log of which is 64. I think it should be fine :) |
Yeah, I am mostly concerned with feasibility of verifying long merkle paths in Eth and other blockchains. But it seems like it will take 10 years to get path to be 29 nodes long, which will cost < 100k Eth gas for proof verification. Which should be fine. |
Currently
BlockHeaderInnerLiteView::block_merkle_root
includes merkle tree built from the headers in the current epoch up until the current block. This creates the following issue:LightClientBlockView
from the node and provides information of its last known node (X);Unfortunately, the merkle root of the headers references in Y only includes blocks form epoch E+1. The merkle root of the headers of block X does not include blocks from X+1 to the last block in epoch E. As the result the light client cannot verify transaction outcomes for these blocks.
Potential solutions:
The text was updated successfully, but these errors were encountered: