refactor(clob): split the epoch-service god-object into focused modules (M4)#10
Merged
Conversation
…es (M4)
`clob.rs` had grown to ~1.4k lines holding config parsing, the transport
trait + HTTP impl, every wire type, all pool/finality state, the proposer
driver, the verifier, and the axum surface in one `impl Clob`. Audit M4.
Split into a `clob/` module, one cohesive concern per file:
- config.rs — `ClobConfig` + `SURPLUS_CLOB_*` parsing
- net.rs — the `ClobNet` transport trait + the HTTP peer-list impl
- wire.rs — the JSON wire types (order / cancel / proposal / attestation)
- pool.rs — admission, the settled/cancelled finality sets + journal,
the epoch snapshot, prune/evict (all shared-state mutation)
- driver.rs — proposer side: match → H3 pre-sim → quorum → submit, the
on-chain client, and membership reconciliation
- peer.rs — verifier side: `attest` + `status`
- http.rs — the axum router, handlers, env boot, and background loops
- mod.rs — the `Clob` struct, constructors, shared accessors, re-exports
Pure move: zero behavior change. Cross-module `Clob` methods were bumped
from private to `pub(crate)`/`pub(super)` where a sibling now calls them
(snapshot, prune_filled, is_cancelled, load_finality, evict); nothing else
changed. The public surface (`crate::clob::{router, start_from_env,
attest_deadline, Clob, ClobConfig, Wire*, ClobNet, cancel_digest, …}`) is
re-exported unchanged, so mesh.rs and the integration tests are untouched.
A typed `Attester` newtype for the `(Address, String)` operator tuples was
deliberately left out: it ripples into mesh.rs and two test fixtures and
would obscure this move-only diff — a follow-up if it earns its keep.
Verified: builds clean (default + chain,mesh); 13 operator unit + 4
clob_e2e + 1 mesh_clob + matcher/settlement suites green; and both anvil
e2e proofs — happy-path batch settle and the H3 pre-sim adversarial grief —
pass byte-for-byte against the refactored binary.
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.
Closes the last reasoned-deferred audit item (M4). Pure structural refactor —
zero behavior change.
Why
operator/src/clob.rshad grown to ~1.4k lines holding, in oneimpl Clob:config parsing, the transport trait + its HTTP impl, every wire type, all
pool/finality state, the proposer driver, the verifier, and the axum surface.
One file, seven unrelated concerns.
What
Split into a
clob/module, one cohesive concern per file:config.rsClobConfig+SURPLUS_CLOB_*parsingnet.rsClobNettransport trait + HTTP peer-list implwire.rspool.rsdriver.rspeer.rsattest+statushttp.rsmod.rsClobstruct, constructors, shared accessors, re-exportsIt's a move: the only non-mechanical change is bumping the handful of
Clobmethods a sibling module now calls from private to
pub(crate)/pub(super)(
snapshot,prune_filled,is_cancelled,load_finality,evict). Thepublic surface (
crate::clob::{router, start_from_env, attest_deadline, Clob, ClobConfig, Wire*, ClobNet, HttpNet, cancel_digest, …}) is re-exportedunchanged, so
mesh.rsand the integration tests didn't move a line.A typed
Attesternewtype for the(Address, String)operator tuples wasdeliberately left out — it ripples into
mesh.rsand two test fixtures andwould bury this move-only diff. A follow-up if it earns its keep.
Verification
chain,mesh).clob_e2e+ 1mesh_clob+ the matcher /settlement suites.
the happy-path batch settle, and the H3 pre-sim adversarial grief
(
bookNonceunchanged, doomed buy evicted, seller's order survives).🤖 Generated with Claude Code