Skip to content

Commit c394c29

Browse files
refactor: split block handler into C1–C4 with allCandidatesKnown and candidate cleanup
Split the monolithic PollResultPoller into four specialized block handlers: - C1 (ContractPoller): RPC multicall for non-deterministic generators only - C2 (CandidateConfirmer): API confirmation + candidate deletion after promotion - C3 (StatusUpdater): API status polling for open discrete orders + expiry - C4 (HistoricalBootstrap): one-time owner fetch at live sync start Add allCandidatesKnown boolean to conditionalOrderGenerator so C1 skips generators whose UIDs are already known. Unify backfill and live creation handlers to both use UID pre-computation for deterministic types.
1 parent 904a5f1 commit c394c29

5 files changed

Lines changed: 336 additions & 124 deletions

File tree

ponder.config.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
CoWShedFactoryContract,
66
FLASH_LOAN_ROUTER_ADDRESSES,
77
GPv2SettlementContract,
8-
ORDERBOOK_POLL_INTERVAL,
98
} from "./src/data";
109
import { ComposableCowAbi } from "./abis/ComposableCowAbi";
1110

@@ -39,14 +38,37 @@ export default createConfig({
3938
},
4039
},
4140
blocks: {
42-
// Fires every ORDERBOOK_POLL_INTERVAL blocks on each chain to check due orders
43-
// via getTradeableOrderWithSignature. Starts at "latest" — only runs at live sync.
44-
PollResultPoller: {
41+
// C1: Contract Poller — RPC multicall for non-deterministic generators
42+
ContractPoller: {
4543
chain: {
4644
mainnet: { startBlock: "latest" },
4745
gnosis: { startBlock: "latest" },
4846
},
49-
interval: ORDERBOOK_POLL_INTERVAL,
47+
interval: 1,
48+
},
49+
// C2: Candidate Confirmer — checks API for unconfirmed candidates
50+
CandidateConfirmer: {
51+
chain: {
52+
mainnet: { startBlock: "latest" },
53+
gnosis: { startBlock: "latest" },
54+
},
55+
interval: 1,
56+
},
57+
// C3: Status Updater — polls API for open discrete order status
58+
StatusUpdater: {
59+
chain: {
60+
mainnet: { startBlock: "latest" },
61+
gnosis: { startBlock: "latest" },
62+
},
63+
interval: 1,
64+
},
65+
// C4: Historical Bootstrap — one-time owner fetch for non-deterministic backfill orders
66+
HistoricalBootstrap: {
67+
chain: {
68+
mainnet: { startBlock: "latest", endBlock: "latest" },
69+
gnosis: { startBlock: "latest", endBlock: "latest" },
70+
},
71+
interval: 1,
5072
},
5173
},
5274
});

schema/tables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const conditionalOrderGenerator = onchainTable(
6767
decodedParams: t.json(), // null if unknown type or decode failed
6868
decodeError: t.text(), // "invalid_static_input" | null
6969
txHash: t.hex().notNull(), // FK → transaction.hash
70+
allCandidatesKnown: t.boolean().notNull().default(false),
7071
nextCheckBlock: t.bigint(), // block handler scheduling
7172
lastCheckBlock: t.bigint(),
7273
lastPollResult: t.text(),

0 commit comments

Comments
 (0)