feat: render registry state as TOML via configToml() - #491
Merged
topocount merged 1 commit intoAug 5, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a TOML-rendering API to SnapchainConfigRegistry, allowing clients to fetch a canonical, merge-ready TOML fragment for Snapchain node configuration directly via eth_call, with optional pagination to avoid RPC gas caps as validator-set history grows.
Changes:
- Introduces
configToml()as the canonical getter to render validator sets plus the[gossip]table. - Adds paginated rendering via
validatorSetsToml(start, end)and a standalonepeersToml(). - Implements low-allocation TOML rendering helpers (including an assembly key-line writer and single-pass join) to keep large outputs within typical
eth_calllimits.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/SnapchainConfigRegistry.sol | Implements TOML rendering entrypoints and optimized helpers for validator set / peer-string output. |
| src/interfaces/ISnapchainConfigRegistry.sol | Extends the public interface with TOML rendering functions and associated API documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
from
August 4, 2026 21:50
a2b2cb3 to
59dd349
Compare
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
from
August 4, 2026 21:57
59dd349 to
2df05ab
Compare
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
2 times, most recently
from
August 4, 2026 22:10
3fdd301 to
6727503
Compare
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
from
August 4, 2026 22:13
6727503 to
ac22c2f
Compare
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
from
August 5, 2026 20:55
ac22c2f to
0f1a964
Compare
Adds the rendering layer: configToml() as the canonical getter, plus validatorSetsToml(start, end) and peersToml() underneath it. Assembly is two-level. Each validator set is built on its own and the entries are joined into the result exactly once, through a helper that sizes the output up front and mcopy's each part in. A flat one-concat-per-line loop would be quadratic in output bytes and the EVM's quadratic memory term compounds it; today's ten entries would still work either way, but at around a hundred the difference is the getter working versus exceeding every public eth_call gas cap. Since the list grows by one entry per shard per rotation, that is a few years out, and it is not fixable after deployment without a migration. Pagination is the second half of the same insurance. Each rendered block carries its own trailing blank line rather than sitting between separators, which is what makes any split compose back into exactly the unpaginated document. Key lines are written directly into a pre-sized buffer in assembly. The straightforward version -- allocate a string per key, fill it with 64 bounds-checked single-byte writes, then concat it in -- costs roughly 3.5x more across the whole document, which at scale is the difference between 11M and 3M gas for the same output bytes. That is measured, not estimated: the accompanying gas guard failed at 10M before this and passes at 3.2M after, with the golden output unchanged.
topocount
force-pushed
the
kjs/neyn-13020-c3-config-toml-renderer
branch
from
August 5, 2026 21:08
0f1a964 to
2e9a31a
Compare
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.
Motivation
Describe why this issue should be fixed and link to any relevant design docs, issues or other relevant items.
Change Summary
Describe the changes being made in 1-2 concise sentences.
Merge Checklist
Choose all relevant options below by adding an
xnow or at any time before submitting for reviewAdditional Context
If this is a relatively large or complex change, provide more details here that will help reviewers.
Stack created with GitHub Stacks CLI • Give Feedback 💬
PR-Codex overview
This PR introduces TOML rendering functionality to the
SnapchainConfigRegistrycontract, allowing the registry to output its configuration in TOML format. This includes methods for rendering validator sets and gossip peer lists.Detailed summary
configToml()to render the entire registry as TOML.validatorSetsToml(uint256 start, uint256 end)for rendering a range of validator sets as TOML.peersToml()to render gossip peer lists as TOML._rangeToml(),_validatorSetToml(),_peersToml(),_join(), and_writeKeyLine().