feat(nds): update registry arity to 2 - #1190
Open
emturner wants to merge 3 commits into
Open
Conversation
A database proof never ships on its own: its database sits in a registry slot, so what goes over the wire is the registry proof wrapping it. Checking database proofs against the same MAXIMUM_PROOF_SIZE as registry proofs therefore admits database proofs that no longer fit once wrapped.
|
Benchmark results for revision dad9179:
Full results
Compare the results above with those for the default branch. |
|
Durable storage space metrics for revision dad9179, at pull request
Full reportThese figures are for catching a regression before it merges. Compare them with |
emturner
force-pushed
the
emturner@tzx-211
branch
from
August 28, 2026 14:04
5462988 to
7756659
Compare
emturner
marked this pull request as draft
August 28, 2026 14:05
emturner
force-pushed
the
emturner@tzx-211
branch
from
August 28, 2026 14:15
7756659 to
4258111
Compare
`value_open` overestimates - as it does not take into account that consecutive pages often share parent nodes, as they can descend the same way down a significant portion of the tree. The logic to calculate this properly is somewhat fiddly, and therefore it's more straightforward to cap the overall value directly - with a known constant. Additionally, stop charging the terminal search-path node's blinded data child when the operation opens the value: `avl_path_node` charges that child as one blinded subtree, but a proof that opens the value carries the `Bytes` subtree there instead, which `value_open` already charges in full. The 33 bytes were being paid twice.
Arity = 2 is optimal for a proof-size perspective.
emturner
force-pushed
the
emturner@tzx-211
branch
from
August 28, 2026 14:15
4258111 to
a0fddd8
Compare
emturner
marked this pull request as ready for review
August 28, 2026 14:15
emturner
enabled auto-merge
August 28, 2026 14:16
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1190 +/- ##
==========================================
+ Coverage 89.85% 89.88% +0.03%
==========================================
Files 152 153 +1
Lines 32554 32731 +177
Branches 32554 32731 +177
==========================================
+ Hits 29250 29420 +170
- Misses 2290 2296 +6
- Partials 1014 1015 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Ensure registry is included in database proof size limit, and update arity of vector to 2.
Why
Bundling these three changes together keeps the net effect on the number of keys/values we support in proofs (as reported by
proof_size.rs) visible in one place. As the bounds are now tighter and more accurate, the overall effect is to raise confidence in the figures.Impact on database sizes
A database proof never ships on its own, so it is now measured against
DATABASE_MAX_PROOF_SIZE(15288 B) rather than the full 16 KiBMAXIMUM_PROOF_SIZE: the difference is the registry envelope that wraps it (1096 B for the deepest registryregistry_resizeadmits).Against that reservation, the binding operation gets 677 B cheaper to model — 644 B from capping
value_openatMAX_PROOF_LENGTH, and 33 B from no longer charging the terminal search-path node's blinded data child when the value is opened. The arity change takes a further 546 B off the envelope itself. That leaves 419 B unpaid, so the binding operation loses one level of AVL depth; because minimal AVL node counts are Fibonacci, a level is roughly 1.6x the number of keys:The reduction is a correction rather than a loss of capability. The
beforecolumn was measured two ways that both overstated it: against a ceiling that ignored the registry wrapper the proof has to fit inside, and with avalue_openthat charged every touched page a full root-to-leaf branch of blinded siblings.MAX_PROOF_LENGTH(4097 B) is the worst case actually derivable for a three-page read or write over a 64 MiB leaf, sharing included.For the record, d=34 now clears its ceiling by 5 bytes, and reaching d=35 would need another 324 B — out of the 1096 B envelope, or out of the 329 B per search-path level, which is dominated by the 255-byte key leaf.
How
Tighten the bounds, by taking into account the true maximum size of
Byteproofs, include the registry proof in the database proof-size limit, and reduce the arity of the registry.Manually Testing
Regressions
Updated due to arity change of
Vector.Tasks for the Author