ethereum / go-verkle

A go implementation of Verkle trees
The Unlicense
207 stars 62 forks source link

Question about leaf marker #440

Closed acolytec3 closed 1 month ago

acolytec3 commented 1 month ago

I was talking with @kevaundray recently regarding the leaf marker and how it's implemented around here in go-verkle (and I believe similarly in rust-verkle). If I understand this code + @kevaundray 's explanation correctly, both libraries always include the leaf marker (i.e. a 1 on the 129th bit of the v^lower value that's used when updating the c1 or c2 commitment corresponding to the half of a leaf node's values array) once a value has been written to (regardless of what that value is, as long as it's "touched"). The EIP seems to say that this leaf marker should only be set when a leaf value contains 0 to demonstrate that it's a leaf value that's been touched since theoretically a leaf value that hasn't been touched also contains a value of 0. Am I understanding the go-verkle code correctly here? Just wanted to clarify since it seems different that it's different than the EIP and my JS implementation only uses the leaf marker when the written value is 0 so we would produce different commitments than go-verkle when the value is non-zero.

acolytec3 commented 1 month ago

cc @gabrocheleau

gballet commented 1 month ago

The python code says that the leaf marker is always set, as soon as the leaf is written to: https://github.com/ethereum/EIPs/blob/f93b530c60dc7a88e5b811f9cbdf865ecc1b9b97/EIPS/eip-6800.md?plain=1#L60

The line you refer only says that writing a 0 is not the same thing as a leaf missing from the tree, which is a behavior that differs from the MPT one.