Skip to content

feat: render registry state as TOML via configToml() - #491

Merged
topocount merged 1 commit into
kjs/neyn-13019-c2-snapchain-config-registryfrom
kjs/neyn-13020-c3-config-toml-renderer
Aug 5, 2026
Merged

feat: render registry state as TOML via configToml()#491
topocount merged 1 commit into
kjs/neyn-13019-c2-snapchain-config-registryfrom
kjs/neyn-13020-c3-config-toml-renderer

Conversation

@topocount

@topocount topocount commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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 x now or at any time before submitting for review

Additional Context

If this is a relatively large or complex change, provide more details here that will help reviewers.


Stack created with GitHub Stacks CLIGive Feedback 💬


PR-Codex overview

This PR introduces TOML rendering functionality to the SnapchainConfigRegistry contract, allowing the registry to output its configuration in TOML format. This includes methods for rendering validator sets and gossip peer lists.

Detailed summary

  • Added configToml() to render the entire registry as TOML.
  • Introduced validatorSetsToml(uint256 start, uint256 end) for rendering a range of validator sets as TOML.
  • Created peersToml() to render gossip peer lists as TOML.
  • Implemented helper functions for TOML rendering, including _rangeToml(), _validatorSetToml(), _peersToml(), _join(), and _writeKeyLine().
  • Added constants for hex symbol alignment and key line length.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copilot AI lite review requested due to automatic review settings August 4, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 standalone peersToml().
  • Implements low-allocation TOML rendering helpers (including an assembly key-line writer and single-pass join) to keep large outputs within typical eth_call limits.

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
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch from a2b2cb3 to 59dd349 Compare August 4, 2026 21:50
@topocount
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch from 59dd349 to 2df05ab Compare August 4, 2026 21:57
@topocount
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch 2 times, most recently from 3fdd301 to 6727503 Compare August 4, 2026 22:10
@topocount
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch from 6727503 to ac22c2f Compare August 4, 2026 22:13
@topocount
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch from ac22c2f to 0f1a964 Compare August 5, 2026 20:55
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
topocount force-pushed the kjs/neyn-13020-c3-config-toml-renderer branch from 0f1a964 to 2e9a31a Compare August 5, 2026 21:08
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Coverage after merging kjs/neyn-13020-c3-config-toml-renderer into kjs/neyn-13019-c2-snapchain-config-registry will be

81.11%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Bundler.sol100%100%100%100%
   BundlerV1.sol100%100%100%100%
   FnameResolver.sol100%100%100%100%
   IdGateway.sol100%100%100%100%
   IdRegistry.sol100%100%100%100%
   KeyGateway.sol100%100%100%100%
   KeyRegistry.sol100%100%100%100%
   RecoveryProxy.sol100%100%100%100%
   SnapchainConfigRegistry.sol0%0%0%0%136, 139, 149–150, 156, 159, 159–160, 166–170, 172, 182–183, 189–190, 196–197, 207, 212–215, 217, 223, 228–229, 229, 231–232, 234, 240–242, 242, 244–245, 250–253, 255–256, 258, 264, 267, 269, 271, 277, 280, 282, 284, 300–301, 301, 303–306, 308, 308, 310, 319, 322–323, 326–328, 331–334, 337, 355–356, 370, 373–375, 378–382, 384, 386, 388, 401, 403, 406–408, 412–418, 422–424, 441, 447–448, 454–455, 457–460, 489–491, 493–496, 496, 498–499, 502, 516, 519–520, 522–524, 531, 534–535, 535, 537–539, 539, 551, 554–555, 555, 557–558, 558–560, 560, 572, 575–577, 577, 579–581, 581–582, 585, 585
   StorageRegistry.sol100%100%100%100%
   TierRegistry.sol100%100%100%100%
src/abstract
   EIP712.sol100%100%100%100%
   Guardians.sol100%100%100%100%
   Migration.sol100%100%100%100%
   Nonces.sol100%100%100%100%
   Signatures.sol100%100%100%100%
src/validators
   SignedKeyRequestValidator.sol100%100%100%100%

@topocount
topocount merged commit add4a40 into main Aug 5, 2026
6 of 8 checks passed
@topocount
topocount deleted the kjs/neyn-13020-c3-config-toml-renderer branch August 5, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants