Support variable size PMMR (optional size_file) #2733
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces a big chunk of #1260 by implementing an optional
size_file
alongside thedata_file
. Thesize_file
can be thought of as an index into thedata_file
allowing random access by position across elements with variable size.How does this work?
To read an entry at position
n
we first read the size_entry at positionn
then use this to readsize
bytes at the givenoffset
. This allows us to do efficient random access into the data_file via two reads (one insize_file
one indata_file
).The
size_file
itself is simply implemented as a fixed sizedata_file
containingsize_entries
.Each
size_entry
consists of -offset
(u64, 8 bytes)size
(u16, 2 bytes)The size_file will add an additional 10 bytes of data for each kernel in the kernel MMR.
But this will (eventually) allow us to save 8 bytes of
lock_height
on most kernels and 8 bytes offee
on all coinbase kernels.Currently Implemented
1.0.x
and1.1.x
nodes).Future Direction
lock_height
onHeightLocked
kernelsfee
on non-coinbase kernelsEventually aim is to support "relative kernels" which will in turn allow "relative lock_heights" to be implemented.
This will require us to store a related kernel excess commitment alongside some kernels (kernel
K1
is relative to kernelK2
) and we cannot currently do this with fixed size kernels in the kernel MMR as we have nowhere to store this relationship.TODO -