Skip to content

refactor: rename block handlers to semantic namespaced names (COW-1000)#83

Open
lgahdl wants to merge 3 commits into
developfrom
luizhatem/cow-1000-f7-rename-c1-c5-block-handlers-to-semantic-names-with
Open

refactor: rename block handlers to semantic namespaced names (COW-1000)#83
lgahdl wants to merge 3 commits into
developfrom
luizhatem/cow-1000-f7-rename-c1-c5-block-handlers-to-semantic-names-with

Conversation

@lgahdl
Copy link
Copy Markdown
Contributor

@lgahdl lgahdl commented Jun 1, 2026

Summary

  • Renames all 5 Ponder block-handler entries from opaque C1–C5 shorthand to composableCow.* names that match their responsibility (OrderDiscoveryPoller, CandidateConfirmer, OrderStatusTracker, OwnerBackfill, CancellationWatcher)
  • Updates ponder.config.ts block keys and ponder.on() call names in blockHandler.ts
  • Updates section header comments, log prefixes ([COW:C1][COW:OrderDiscoveryPoller]), and all in-file cross-references to old names

Test plan

  • pnpm typecheck — passes
  • pnpm test — 19/19 passing
  • Handler names in config match ponder.on() names exactly

🤖 Generated with Claude Code

Renames all five Ponder block-handler entries from opaque C1–C5 shorthand
to self-documenting composableCow.* names that match their responsibility.
Updates ponder.config.ts keys, ponder.on() call names, section headers,
log prefixes, and all in-file cross-references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 1, 2026

COW-1000

…ot-namespace conflict)

Ponder 0.16.x treats dots in block interval names as namespace separators,
causing ponder.on('composableCow.OrderDiscoveryPoller:block') to fail validation.
Block intervals must use simple names without dots.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lgahdl lgahdl changed the base branch from main to develop June 2, 2026 13:52
@lgahdl
Copy link
Copy Markdown
Contributor Author

lgahdl commented Jun 2, 2026

The handler rename is consistent throughout ponder.config.ts and blockHandler.ts, but docs/deployment.md still uses the old names in the Debug / Performance Flags table (this file is untouched by both this PR and #85):

  • DISABLE_POLL_RESULT_CHECK description reads: "Disables the C1 ContractPoller block handler"
  • DISABLE_DETERMINISTIC_CANCEL_SWEEP description reads: "Disables the C5 DeterministicCancellationSweeper"
  • MAX_GENERATORS_PER_BLOCK_<chainId> description reads: "how many generators C1 and C5 will touch"

These should be updated to OrderDiscoveryPoller, CancellationWatcher, and OrderDiscoveryPoller and CancellationWatcher respectively to match the rename.

@lgahdl
Copy link
Copy Markdown
Contributor Author

lgahdl commented Jun 2, 2026

Code review — block handler rename (COW-1000)

Ponder app fingerprint / schema drop risk

Ponder 0.16.x tracks block sources by name in its internal _ponder_sync tables. Renaming all five block handler entries (ContractPoller → OrderDiscoveryPoller, CandidateConfirmer unchanged, StatusUpdater → OrderStatusTracker, HistoricalBootstrap → OwnerBackfill, DeterministicCancellationSweeper → CancellationWatcher) will look to Ponder like five sources were removed and five new ones were added. On a fresh deploy against an existing database Ponder will treat the old named sources as gone and start the new ones from their configured startBlock ("latest"). Since all five handlers use startBlock: "latest", no historical re-index is triggered — live block processing just resumes under the new names. No schema drop is required for this rename. Worth verifying in staging before the mainnet deploy regardless.

Name consistency

ponder.config.ts and blockHandler.ts are fully aligned:

  • OrderDiscoveryPoller:block
  • CandidateConfirmer:block ✓ (no rename here)
  • OrderStatusTracker:block
  • OwnerBackfill:block
  • CancellationWatcher:block

Leftover old names

src/constants.ts still references the old identifiers in JSDoc comments (lines 22, 50, 55, 70, 76, 78). These are comments only and do not affect runtime, but they will drift from the log output the handlers now emit. Recommend a follow-up pass to update the JSDoc to use the new names; it's a small doc hygiene item, not a blocker.

Overall: PR is operationally safe. No schema changes, no logic changes, no orphaned ponder.on(...) registrations. Good to merge after confirming the staging deploy succeeds.

@lgahdl
Copy link
Copy Markdown
Contributor Author

lgahdl commented Jun 2, 2026

Documentation / CI review

docs/deployment.md — Debug/Performance Flags table still uses old names. Must fix before merge.

Lines 33–35 of docs/deployment.md still read:

  • DISABLE_POLL_RESULT_CHECK — "Disables the C1 ContractPoller block handler."
  • DISABLE_DETERMINISTIC_CANCEL_SWEEP — "Disables the C5 DeterministicCancellationSweeper."
  • MAX_GENERATORS_PER_BLOCK_<chainId> — "how many generators C1 and C5 will touch…"

This PR renames those handlers to OrderDiscoveryPoller and CancellationWatcher. The table descriptions need to be updated to match, otherwise ops will grep for C1/C5 in the codebase and find nothing.

docs/api-reference.md — one stale reference.
Line 129: candidateDiscreteOrder.creationDate — "Block timestamp at C1 discovery." Should say OrderDiscoveryPoller.

Breaking change / schema drop notice missing from PR body.
The rename changes the Ponder block handler keys in ponder.config.ts (e.g. ContractPollerOrderDiscoveryPoller). Ponder tracks block handler progress by name in its internal checkpoint. Renaming a handler key on an existing deployment causes Ponder to treat it as a new handler and re-run it from startBlock — for handlers with startBlock: "latest" this is harmless (they fire once at the next live block), but it is worth calling out in the PR body so operators know no schema drop is required, but the first restart will re-run all five handlers' initial blocks.

CLAUDE.md / agent_docs not affected. The code-patterns.md timeout label example ([COW:Cx]) is the only spot that references old shorthand — worth a follow-on update but not a merge blocker.

…-1000)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@yvesfracari yvesfracari left a comment

Choose a reason for hiding this comment

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

This PR applies the suggestions but didn't answer other questions of Anxo with my take bellow them:

  1. The flashloan orders flow aren't well documented. Shouldn't we have different handlers for composable cow and aave flash loan orders?

Flash loan orders are not handle by block handlers, we monitor directly events for it. However, we need to improve the documentation about it. The blockhandlers that have specific composable cow logic should mention it to make sure we separate what is generic (e.g. order status change that is valid for any kind of order)

  1. We have around 11% unknown types. Are they really unknown?

Doing a quick search, no they are not unknown and we could identify (at least the main ones), example: (1, 2, 3)

  1. Why is orderbook_cache retained vs dropped?

I think that is only to not check order API twice between deployments for orders that are already on its final state. Would double check if we're documenting this properly.

  1. TWAP nParts upper bound.

Nice catch. He mention that UI only accept TWAPs with 365 parts. On contracts side they are validated to be lower than uint32.max, what is a really giant number of rows to insert into the DB. In addition, this validation happens after the conditional order is emitted, on the query / execution path. This means that the nParts upper bound on the contract perspective is actually uint256.max. Looking at the code I don't find any kind of guard against it. This means that someone could use it of a DDoS attack.

WRT this PR I would only address points 1 and 3 here. The others are big enough to be executed alone.

Comment thread docs/deployment.md
| `DISABLE_POLL_RESULT_CHECK` | No | Disables the C1 ContractPoller block handler. Skips RPC multicalls for non-deterministic generators. Saves RPC calls during initial sync at the cost of not detecting poll results until re-enabled. |
| `DISABLE_DETERMINISTIC_CANCEL_SWEEP` | No | Disables the C5 DeterministicCancellationSweeper. Skips periodic `singleOrders()` reads on deterministic generators. While disabled, on-chain `ComposableCoW.remove()` calls on TWAP/StopLoss/CirclesBackingOrder generators will not be detected and those generators stay `Active`. |
| `MAX_GENERATORS_PER_BLOCK_<chainId>` | No | Per-block cap on how many generators C1 and C5 will touch on the given chain (e.g. `MAX_GENERATORS_PER_BLOCK_1=200`, `MAX_GENERATORS_PER_BLOCK_100=400`). Default is 200. Excess generators defer to the next block, prioritized by oldest `lastCheckBlock` first. |
| `DISABLE_POLL_RESULT_CHECK` | No | Disables the OrderDiscoveryPoller block handler. Skips RPC multicalls for non-deterministic generators. Saves RPC calls during initial sync at the cost of not detecting poll results until re-enabled. |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: would use inline code format to make it clear it is talking a about a code component

Suggested change
| `DISABLE_POLL_RESULT_CHECK` | No | Disables the OrderDiscoveryPoller block handler. Skips RPC multicalls for non-deterministic generators. Saves RPC calls during initial sync at the cost of not detecting poll results until re-enabled. |
| `DISABLE_POLL_RESULT_CHECK` | No | Disables the `OrderDiscoveryPoller` block handler. Skips RPC multicalls for non-deterministic generators. Saves RPC calls during initial sync at the cost of not detecting poll results until re-enabled. |

Comment thread ponder.config.ts
ACTIVE_CHAINS.map((c) => [c.name, { startBlock: "latest" as const }]),
),
// OrderStatusTracker — polls API for open discrete order status.
"OrderStatusTracker": {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit:

Suggested change
"OrderStatusTracker": {
OrderStatusTracker: {

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