Skip to content

feat(p2p): carry the accept-interval key through the legacy config mapping - #47

Merged
bdchatham merged 1 commit into
mainfrom
fix/p2p-accept-interval
Aug 11, 2026
Merged

feat(p2p): carry the accept-interval key through the legacy config mapping#47
bdchatham merged 1 commit into
mainfrom
fix/p2p-accept-interval

Conversation

@bdchatham

Copy link
Copy Markdown
Collaborator

Companion to sei-protocol/sei-chain#3899, which adds a p2p accept-interval key so the router's inbound accept rate can be configured instead of being pinned to its compiled-in default of 1 accept/second.

Why this repo has to change too

WriteConfigToDir regenerates config.toml wholesale from the legacy structs:

tm := cfg.toLegacyTendermint()
if err := atomicWriteTOML(configPath, tm); err != nil { ... }

A key with no corresponding field on legacyP2P is therefore silently dropped on the next write — not preserved, not rejected. Without this change, seictl and sei-k8s-controller would strip accept-interval from any node config they write, reverting that node to 1 accept/s with no diagnostic. The sei-chain change alone does not survive contact with a fleet managed by this library.

Change

Five sites, following DialInterval exactly, per the contract in CLAUDE.md:

Site Field
config.go — unified P2PConfig AcceptInterval Duration \toml:"accept_interval"``
legacy.golegacyP2P AcceptInterval Duration \toml:"accept-interval"``
defaults.gobaseDefaults() Dur(10 * time.Millisecond)
legacy.gotoLegacyTendermint() mapping
legacy.gofromLegacy() mapping

Note the deliberate tag asymmetry, matching every neighbouring key: underscore in the unified schema (accept_interval), hyphen in the legacy file (accept-interval).

The default matches the one sei-chain#3899 sets, so a node written by this library and a node relying on seid's own defaults agree rather than silently diverging.

No enrichments.go entry — DialInterval has none either, so that layer is curated rather than exhaustive. Happy to add one if you'd rather it be surfaced in the field registry.

Tests

Extended TestWriteReadRoundTrip per CLAUDE.md ("Every new field should be exercised in at least one round-trip test"), using the testing package only, per the repo's no-assertion-library rule.

Verified it discriminates rather than merely passing — with the toLegacyTendermint mapping removed it fails as:

--- FAIL: TestWriteReadRoundTrip (0.04s)
    config_test.go:365: p2p.accept_interval: got 0s, want 25ms

which is precisely the silent-drop failure mode this guards. Full suite green with the mapping in place:

go test ./... -count=1
ok  	github.com/sei-protocol/sei-config	0.629s

make vet is clean. make lint reports 6 pre-existing lll violations (config_test.go:38/55/93/118/126, migrate.go:189) that reproduce identically on unmodified origin/main; none are lines this PR adds.

Sequencing

This should land before anything starts writing accept-interval into node configs, otherwise the key is written and then stripped on the next reconcile. Consumers (seid, seictl, sei-k8s-controller) pick it up on the next release + dependency bump; I have not touched version.json, since releases here appear to be their own chore: release commits.

🤖 Generated with Claude Code

…pping

WriteConfigToDir regenerates config.toml wholesale from the legacy structs,
so any config.toml key with no corresponding field on legacyP2P is silently
dropped on the next write rather than preserved. sei-chain is adding a p2p
accept-interval key to make the router's inbound accept rate configurable
(sei-protocol/sei-chain#3899); without a matching field here, seictl and
sei-k8s-controller would strip that key from any node they write, silently
reverting the node to the compiled-in 1 accept/s.

Add AcceptInterval alongside DialInterval across all five sites the
contract requires: the unified P2PConfig (accept_interval), legacyP2P
(accept-interval), baseDefaults, toLegacyTendermint and fromLegacy.

The default matches the one sei-chain#3899 sets, so a node written by this
library and a node using seid's own defaults agree.

Verified the round-trip assertion discriminates rather than merely passing:
removing the toLegacyTendermint mapping fails it with "got 0s, want 25ms",
which is the silent-drop failure mode this guards.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Schema and mapping-only change with a round-trip test; affects P2P tuning defaults but no auth, data, or security-sensitive logic.

Overview
Adds P2P accept_interval so inbound accept rate can flow through this library’s config model and into config.toml as accept-interval, aligned with sei-chain’s new knob (companion to sei-chain#3899).

The field is wired like DialInterval: unified P2PConfig, legacyP2P, toLegacyTendermint / fromLegacy, and baseDefaults() set to 10ms so defaults match seid. Without the legacy mapping, WriteConfigToDir would regenerate config.toml and drop the key, pushing nodes back toward a 1 accept/s effective rate.

TestWriteReadRoundTrip now asserts a non-default 25ms survives write/read, guarding that silent-drop behavior.

Reviewed by Cursor Bugbot for commit e7392ca. Bugbot is set up for automated code reviews on this repo. Configure here.

@bdchatham
bdchatham merged commit aa7c61c into main Aug 11, 2026
3 checks passed
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.

1 participant