@gzeoneth/gov-tracker 0.2.1-alpha.perf-sendroot.fa5e981 → 0.2.1-beta.33b5291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -80
- package/dist/abis.d.ts +3 -0
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +30 -2
- package/dist/abis.js.map +1 -1
- package/dist/calldata/index.d.ts +1 -1
- package/dist/calldata/index.d.ts.map +1 -1
- package/dist/calldata/index.js.map +1 -1
- package/dist/calldata/parameter-decoder.d.ts.map +1 -1
- package/dist/calldata/parameter-decoder.js +8 -1
- package/dist/calldata/parameter-decoder.js.map +1 -1
- package/dist/calldata/signature-lookup.d.ts +17 -2
- package/dist/calldata/signature-lookup.d.ts.map +1 -1
- package/dist/calldata/signature-lookup.js +20 -2
- package/dist/calldata/signature-lookup.js.map +1 -1
- package/dist/cli/cli.js +266 -27
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/lib/cli.d.ts +50 -2
- package/dist/cli/lib/cli.d.ts.map +1 -1
- package/dist/cli/lib/cli.js +378 -66
- package/dist/cli/lib/cli.js.map +1 -1
- package/dist/cli/lib/json-state.d.ts +23 -0
- package/dist/cli/lib/json-state.d.ts.map +1 -1
- package/dist/cli/lib/json-state.js +51 -4
- package/dist/cli/lib/json-state.js.map +1 -1
- package/dist/constants.d.ts +39 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +47 -2
- package/dist/constants.js.map +1 -1
- package/dist/data/bundled-cache.json +11807 -2559
- package/dist/deduplication.d.ts +132 -0
- package/dist/deduplication.d.ts.map +1 -0
- package/dist/deduplication.js +270 -0
- package/dist/deduplication.js.map +1 -0
- package/dist/discovery/governor-discovery.d.ts.map +1 -1
- package/dist/discovery/governor-discovery.js +52 -36
- package/dist/discovery/governor-discovery.js.map +1 -1
- package/dist/discovery/timelock-discovery.d.ts +15 -6
- package/dist/discovery/timelock-discovery.d.ts.map +1 -1
- package/dist/discovery/timelock-discovery.js +27 -11
- package/dist/discovery/timelock-discovery.js.map +1 -1
- package/dist/election/contracts.d.ts +8 -0
- package/dist/election/contracts.d.ts.map +1 -0
- package/dist/election/contracts.js +28 -0
- package/dist/election/contracts.js.map +1 -0
- package/dist/election/details.d.ts +15 -0
- package/dist/election/details.d.ts.map +1 -0
- package/dist/election/details.js +157 -0
- package/dist/election/details.js.map +1 -0
- package/dist/election/index.d.ts +11 -0
- package/dist/election/index.d.ts.map +1 -0
- package/dist/election/index.js +48 -0
- package/dist/election/index.js.map +1 -0
- package/dist/election/params.d.ts +13 -0
- package/dist/election/params.d.ts.map +1 -0
- package/dist/election/params.js +93 -0
- package/dist/election/params.js.map +1 -0
- package/dist/election/participants.d.ts +6 -0
- package/dist/election/participants.d.ts.map +1 -0
- package/dist/election/participants.js +102 -0
- package/dist/election/participants.js.map +1 -0
- package/dist/election/prepare.d.ts +10 -0
- package/dist/election/prepare.d.ts.map +1 -0
- package/dist/election/prepare.js +52 -0
- package/dist/election/prepare.js.map +1 -0
- package/dist/election/proposal-ids.d.ts +18 -0
- package/dist/election/proposal-ids.d.ts.map +1 -0
- package/dist/election/proposal-ids.js +77 -0
- package/dist/election/proposal-ids.js.map +1 -0
- package/dist/election/status.d.ts +15 -0
- package/dist/election/status.d.ts.map +1 -0
- package/dist/election/status.js +102 -0
- package/dist/election/status.js.map +1 -0
- package/dist/election/tracking.d.ts +28 -0
- package/dist/election/tracking.d.ts.map +1 -0
- package/dist/election/tracking.js +412 -0
- package/dist/election/tracking.js.map +1 -0
- package/dist/index.d.ts +30 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -9
- package/dist/index.js.map +1 -1
- package/dist/stages/builder.d.ts +4 -0
- package/dist/stages/builder.d.ts.map +1 -1
- package/dist/stages/builder.js +7 -0
- package/dist/stages/builder.js.map +1 -1
- package/dist/stages/l2-to-l1-message.d.ts +3 -1
- package/dist/stages/l2-to-l1-message.d.ts.map +1 -1
- package/dist/stages/l2-to-l1-message.js +6 -6
- package/dist/stages/l2-to-l1-message.js.map +1 -1
- package/dist/stages/proposal-created.d.ts +1 -0
- package/dist/stages/proposal-created.d.ts.map +1 -1
- package/dist/stages/proposal-created.js +1 -0
- package/dist/stages/proposal-created.js.map +1 -1
- package/dist/stages/proposal-queued.d.ts +1 -0
- package/dist/stages/proposal-queued.d.ts.map +1 -1
- package/dist/stages/proposal-queued.js +3 -1
- package/dist/stages/proposal-queued.js.map +1 -1
- package/dist/stages/retryables.js +2 -2
- package/dist/stages/retryables.js.map +1 -1
- package/dist/stages/timelock.d.ts +3 -1
- package/dist/stages/timelock.d.ts.map +1 -1
- package/dist/stages/timelock.js +10 -4
- package/dist/stages/timelock.js.map +1 -1
- package/dist/stages/utils.d.ts +7 -8
- package/dist/stages/utils.d.ts.map +1 -1
- package/dist/stages/utils.js +40 -27
- package/dist/stages/utils.js.map +1 -1
- package/dist/stages/voting.d.ts.map +1 -1
- package/dist/stages/voting.js +5 -4
- package/dist/stages/voting.js.map +1 -1
- package/dist/tracker/cache.d.ts +10 -6
- package/dist/tracker/cache.d.ts.map +1 -1
- package/dist/tracker/cache.js +39 -15
- package/dist/tracker/cache.js.map +1 -1
- package/dist/tracker/checkpoint-helpers.d.ts +63 -0
- package/dist/tracker/checkpoint-helpers.d.ts.map +1 -0
- package/dist/tracker/checkpoint-helpers.js +176 -0
- package/dist/tracker/checkpoint-helpers.js.map +1 -0
- package/dist/tracker/discovery.d.ts +40 -9
- package/dist/tracker/discovery.d.ts.map +1 -1
- package/dist/tracker/discovery.js +152 -15
- package/dist/tracker/discovery.js.map +1 -1
- package/dist/tracker/pipeline.d.ts.map +1 -1
- package/dist/tracker/pipeline.js +26 -11
- package/dist/tracker/pipeline.js.map +1 -1
- package/dist/tracker/query.d.ts +1 -0
- package/dist/tracker/query.d.ts.map +1 -1
- package/dist/tracker/query.js +14 -61
- package/dist/tracker/query.js.map +1 -1
- package/dist/tracker/state.d.ts +0 -10
- package/dist/tracker/state.d.ts.map +1 -1
- package/dist/tracker/state.js +1 -28
- package/dist/tracker/state.js.map +1 -1
- package/dist/tracker.d.ts +78 -4
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +300 -13
- package/dist/tracker.js.map +1 -1
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +4 -2
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/election.d.ts +143 -0
- package/dist/types/election.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/stages.d.ts +70 -1
- package/dist/types/stages.d.ts.map +1 -1
- package/dist/types/stages.js.map +1 -1
- package/dist/types/tracking.d.ts +34 -4
- package/dist/types/tracking.d.ts.map +1 -1
- package/dist/utils/block-cache.d.ts +50 -0
- package/dist/utils/block-cache.d.ts.map +1 -0
- package/dist/utils/block-cache.js +80 -0
- package/dist/utils/block-cache.js.map +1 -0
- package/dist/utils/formatters.d.ts +91 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +327 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/multicall.d.ts +52 -0
- package/dist/utils/multicall.d.ts.map +1 -0
- package/dist/utils/multicall.js +75 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/salt-computation.d.ts.map +1 -1
- package/dist/utils/salt-computation.js +33 -7
- package/dist/utils/salt-computation.js.map +1 -1
- package/dist/utils/sanitize.d.ts +28 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +52 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/stage-metadata.d.ts +0 -20
- package/dist/utils/stage-metadata.d.ts.map +1 -1
- package/dist/utils/stage-metadata.js +29 -44
- package/dist/utils/stage-metadata.js.map +1 -1
- package/dist/utils/timing.d.ts +13 -0
- package/dist/utils/timing.d.ts.map +1 -1
- package/dist/utils/timing.js +37 -1
- package/dist/utils/timing.js.map +1 -1
- package/package.json +10 -2
- package/dist/election.d.ts +0 -172
- package/dist/election.d.ts.map +0 -1
- package/dist/election.js +0 -467
- package/dist/election.js.map +0 -1
- package/dist/types/cross-chain.d.ts +0 -24
- package/dist/types/cross-chain.d.ts.map +0 -1
- package/dist/types/cross-chain.js +0 -6
- package/dist/types/cross-chain.js.map +0 -1
package/dist/tracker/state.js
CHANGED
|
@@ -32,7 +32,6 @@ exports.getL2ExecutionTxHash = getL2ExecutionTxHash;
|
|
|
32
32
|
exports.getOutboxExecutionTx = getOutboxExecutionTx;
|
|
33
33
|
exports.getL1ExecutionTxHash = getL1ExecutionTxHash;
|
|
34
34
|
exports.createCheckpoint = createCheckpoint;
|
|
35
|
-
exports.toResult = toResult;
|
|
36
35
|
const ethers_1 = require("ethers");
|
|
37
36
|
const logger_1 = require("../utils/logger");
|
|
38
37
|
const utils_1 = require("../stages/utils");
|
|
@@ -40,24 +39,10 @@ const governor_discovery_1 = require("../discovery/governor-discovery");
|
|
|
40
39
|
const constants_1 = require("../constants");
|
|
41
40
|
const { tracker: logTracker } = logger_1.loggers;
|
|
42
41
|
// State Creation
|
|
43
|
-
/**
|
|
44
|
-
* Create a new TrackingState.
|
|
45
|
-
*/
|
|
46
|
-
function getAddressForPath(input) {
|
|
47
|
-
switch (input.type) {
|
|
48
|
-
case "governor":
|
|
49
|
-
return input.governorAddress;
|
|
50
|
-
case "timelock":
|
|
51
|
-
return input.timelockAddress;
|
|
52
|
-
default:
|
|
53
|
-
return "";
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
42
|
function createTrackingState(options) {
|
|
57
43
|
// Initialize stages based on tracking path
|
|
58
44
|
const includeProposal = options.input.type === "governor";
|
|
59
|
-
const
|
|
60
|
-
const initialStages = (0, utils_1.initializeStagesForPath)(addressForPath, includeProposal);
|
|
45
|
+
const initialStages = (0, utils_1.initializeStagesForPath)(includeProposal);
|
|
61
46
|
let ctx = {
|
|
62
47
|
providers: options.providers,
|
|
63
48
|
chunkingConfig: options.chunkingConfig ?? constants_1.DEFAULT_CHUNKING_CONFIG,
|
|
@@ -255,16 +240,4 @@ async function emitProgress(ctx, s) {
|
|
|
255
240
|
isComplete: isComplete(ctx),
|
|
256
241
|
});
|
|
257
242
|
}
|
|
258
|
-
function toResult(ctx) {
|
|
259
|
-
return {
|
|
260
|
-
input: ctx.input,
|
|
261
|
-
stages: ctx.stages,
|
|
262
|
-
checkpoint: createCheckpoint(ctx),
|
|
263
|
-
isComplete: isComplete(ctx),
|
|
264
|
-
proposalType: getProposalType(ctx),
|
|
265
|
-
proposalData: getProposalData(ctx),
|
|
266
|
-
currentState: (0, exports.getProposalState)(ctx),
|
|
267
|
-
isElection: (0, exports.getIsElection)(ctx),
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
243
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/tracker/state.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/tracker/state.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA6FH,kDAsBC;AAwBD,4BAUC;AAMD,4CAGC;AAGD,8CAGC;AAGD,wCAEC;AAKD,gCAEC;AAiBD,gDAMC;AAED,wCAMC;AAED,oDAMC;AAOD,0CA8BC;AAED,0CAKC;AAUD,8CAMC;AAED,oDAGC;AAKD,oDAOC;AAED,oDAGC;AAID,4CAaC;AAxTD,mCAA2C;AAC3C,4CAA0C;AAmB1C,2CAKyB;AACzB,wEAAyF;AACzF,4CAAuD;AAEvD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,gBAAO,CAAC;AA4DxC,iBAAiB;AAEjB,SAAgB,mBAAmB,CAAC,OAAmC;IACrE,2CAA2C;IAC3C,MAAM,eAAe,GAAG,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,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,kBAAkB;QAClB,kBAAkB,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;QAC7C,UAAU,EAAE,EAAE,eAAe,EAAE;QAC/B,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE;KACvD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,GAAkB,EAAE,CAAe;IAC7D,IAAI,CAAC,GAAG,CAAC,UAAU;QAAE,OAAO;IAC5B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,GAAG,CAAC,UAAU,CAAC;QACnB,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,YAAY,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU;QAC7C,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM;QAC9B,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
package/dist/tracker.d.ts
CHANGED
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
* - tracker/execute.ts: Transaction preparation
|
|
13
13
|
*/
|
|
14
14
|
import { ethers } from "ethers";
|
|
15
|
-
import { TrackerOptions, TrackingResult, TrackedStage, TrackingCheckpoint, TrackerStats, ChunkingConfig, DiscoveryWatermarks, DiscoveryTargets, PrepareResult, PrepareOptions, ElectionCheckResult, TimelockLink } from "./types";
|
|
15
|
+
import { TrackerOptions, TrackingResult, TrackedStage, TrackingCheckpoint, TrackerStats, ChunkingConfig, DiscoveryWatermarks, DiscoveryTargets, PrepareResult, PrepareOptions, ElectionCheckResult, ElectionProposalStatus, TimelockLink } from "./types";
|
|
16
|
+
import type { SerializableNomineeDetails, SerializableMemberDetails } from "./types";
|
|
17
|
+
import { LoadedWatermarks } from "./tracker/discovery";
|
|
18
|
+
import { WatermarkHashes } from "./types";
|
|
16
19
|
import { DiscoveredProposal, DiscoveredTimelockOp } from "./tracker/discovery";
|
|
17
20
|
/**
|
|
18
21
|
* Extract TimelockLink from stages if PROPOSAL_QUEUED is completed
|
|
@@ -66,19 +69,49 @@ export declare class ProposalStageTracker {
|
|
|
66
69
|
static readCacheStatus(cachePath: string): Promise<{
|
|
67
70
|
watermarks: DiscoveryWatermarks;
|
|
68
71
|
checkpoints: Map<string, TrackingCheckpoint>;
|
|
72
|
+
elections: Map<number, TrackingCheckpoint>;
|
|
69
73
|
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Clear a specific cache entry. Used by --force to ensure fresh tracking.
|
|
76
|
+
*/
|
|
77
|
+
clearCacheEntry(key: string): Promise<void>;
|
|
70
78
|
/**
|
|
71
79
|
* Load discovery watermarks from cache.
|
|
72
80
|
* Watermarks are stored as a TrackingCheckpoint for unified cache format.
|
|
73
81
|
* Returns empty object if no watermarks are cached.
|
|
74
82
|
*/
|
|
75
|
-
loadWatermarks(): Promise<
|
|
83
|
+
loadWatermarks(): Promise<LoadedWatermarks>;
|
|
76
84
|
/**
|
|
77
85
|
* Save discovery watermarks to cache.
|
|
78
86
|
* Watermarks are stored as TrackingCheckpoint with proper metadata,
|
|
79
87
|
* following the same pattern as proposal/timelock checkpoints.
|
|
88
|
+
*
|
|
89
|
+
* @param watermarks - Block numbers per discovery key
|
|
90
|
+
* @param hashes - Block hashes per discovery key (for reorg detection)
|
|
80
91
|
*/
|
|
81
|
-
saveWatermarks(watermarks: DiscoveryWatermarks): Promise<void>;
|
|
92
|
+
saveWatermarks(watermarks: DiscoveryWatermarks, hashes?: WatermarkHashes): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Save an election checkpoint to cache.
|
|
95
|
+
* Elections are stored with key format: `election:{electionIndex}`
|
|
96
|
+
*
|
|
97
|
+
* For COMPLETED elections, automatically fetches and caches nominee/member
|
|
98
|
+
* election details to enable zero-RPC reads for historical elections.
|
|
99
|
+
*
|
|
100
|
+
* @param electionStatus - Election status from trackElectionProposal
|
|
101
|
+
* @param options.nomineeDetails - Pre-fetched nominee details (skips RPC fetch)
|
|
102
|
+
* @param options.memberDetails - Pre-fetched member details (skips RPC fetch)
|
|
103
|
+
*/
|
|
104
|
+
saveElectionCheckpoint(electionStatus: ElectionProposalStatus, options?: {
|
|
105
|
+
nomineeDetails?: SerializableNomineeDetails;
|
|
106
|
+
memberDetails?: SerializableMemberDetails;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Get an election checkpoint from cache.
|
|
110
|
+
*
|
|
111
|
+
* @param electionIndex - Election index
|
|
112
|
+
* @returns Election status or null if not cached
|
|
113
|
+
*/
|
|
114
|
+
getElectionCheckpoint(electionIndex: number): Promise<ElectionProposalStatus | null>;
|
|
82
115
|
/**
|
|
83
116
|
* Discover proposals from a governor in a block range.
|
|
84
117
|
*
|
|
@@ -101,9 +134,10 @@ export declare class ProposalStageTracker {
|
|
|
101
134
|
* Discover all proposals and timelock operations with auto-watermark management.
|
|
102
135
|
*
|
|
103
136
|
* This is the unified discovery API that handles everything internally:
|
|
137
|
+
* - Verifies watermark hashes to detect chain reorgs (rolls back if mismatch)
|
|
104
138
|
* - Loads watermarks from cache (or uses provided fromWatermarks)
|
|
105
139
|
* - Discovers from all enabled targets in parallel
|
|
106
|
-
* - Auto-saves updated watermarks to cache
|
|
140
|
+
* - Auto-saves updated watermarks and hashes to cache
|
|
107
141
|
*
|
|
108
142
|
* @param targets - Which governors/timelocks to scan
|
|
109
143
|
* @param toBlock - End block for discovery
|
|
@@ -244,6 +278,46 @@ export declare class ProposalStageTracker {
|
|
|
244
278
|
l2: ethers.providers.Provider;
|
|
245
279
|
nova?: ethers.providers.Provider;
|
|
246
280
|
};
|
|
281
|
+
/**
|
|
282
|
+
* Track election status for a given proposal ID.
|
|
283
|
+
*
|
|
284
|
+
* Searches through elections to find the one containing this proposal,
|
|
285
|
+
* then tracks the full election lifecycle.
|
|
286
|
+
*/
|
|
287
|
+
private trackElectionStatus;
|
|
288
|
+
/**
|
|
289
|
+
* Track an election by its index.
|
|
290
|
+
*
|
|
291
|
+
* This method provides direct election tracking when you have the election index.
|
|
292
|
+
* For tracking via tx hash, use trackByTxHash() which auto-detects elections.
|
|
293
|
+
*
|
|
294
|
+
* Caching behavior:
|
|
295
|
+
* - COMPLETED elections: Returns cached data immediately (0 RPC calls)
|
|
296
|
+
* - Incomplete elections: Makes fresh RPC calls and updates cache
|
|
297
|
+
* - No cache: Always makes fresh RPC calls
|
|
298
|
+
*
|
|
299
|
+
* @param electionIndex - Election index (0-based)
|
|
300
|
+
* @param options.force - Force fresh tracking even for completed elections
|
|
301
|
+
* @returns Election status
|
|
302
|
+
*/
|
|
303
|
+
trackElection(electionIndex: number, options?: {
|
|
304
|
+
force?: boolean;
|
|
305
|
+
}): Promise<ElectionProposalStatus>;
|
|
306
|
+
/**
|
|
307
|
+
* Track all elections with caching.
|
|
308
|
+
*
|
|
309
|
+
* Caching behavior:
|
|
310
|
+
* - COMPLETED elections: Returns cached data immediately (0 RPC calls)
|
|
311
|
+
* - Incomplete elections: Makes fresh RPC calls and updates cache
|
|
312
|
+
*
|
|
313
|
+
* @param options.includeNext - Include the "next" election slot (default: true)
|
|
314
|
+
* @param options.force - Force fresh tracking for all elections
|
|
315
|
+
* @returns Array of election statuses
|
|
316
|
+
*/
|
|
317
|
+
trackAllElections(options?: {
|
|
318
|
+
includeNext?: boolean;
|
|
319
|
+
force?: boolean;
|
|
320
|
+
}): Promise<ElectionProposalStatus[]>;
|
|
247
321
|
/**
|
|
248
322
|
* Check Security Council election status and prepare available actions
|
|
249
323
|
*
|
package/dist/tracker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../src/tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../src/tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,OAAO,EACL,cAAc,EACd,cAAc,EAId,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,cAAc,EAEd,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAcjB,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAwErF,OAAO,EAAkC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAgB,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAIL,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAU7B;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,GAAG,SAAS,CA0BpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,UAAU,CAAC,CAAqB;IACxC,8CAA8C;IAC9C,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,+CAA+C;IAC/C,OAAO,CAAC,KAAK,CAAC,CAAe;gBAEjB,OAAO,EAAE,cAAc;IAuBnC;;;;;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AC9B,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;KAClC;IAUD;;;;;OAKG;YACW,mBAAmB;IA+BjC;;;;;;;;;;;;;;OAcG;IACG,aAAa,CACjB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GAChC,OAAO,CAAC,sBAAsB,CAAC;IAmClC;;;;;;;;;;OAUG;IACG,iBAAiB,CACrB,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO,GACvD,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAiFpC;;;;;OAKG;IACG,aAAa,CACjB,OAAO,GAAE;QAAE,sBAAsB,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,mBAAmB,CAAC;CA8ChC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,oBAAoB,CAE3E"}
|
package/dist/tracker.js
CHANGED
|
@@ -19,12 +19,50 @@ exports.createTracker = createTracker;
|
|
|
19
19
|
const ethers_1 = require("ethers");
|
|
20
20
|
const logger_1 = require("./utils/logger");
|
|
21
21
|
const rpc_utils_1 = require("./utils/rpc-utils");
|
|
22
|
+
const timing_1 = require("./utils/timing");
|
|
23
|
+
const checkpoint_helpers_1 = require("./tracker/checkpoint-helpers");
|
|
22
24
|
const constants_1 = require("./constants");
|
|
23
25
|
const election_1 = require("./election");
|
|
24
26
|
const governor_discovery_1 = require("./discovery/governor-discovery");
|
|
25
27
|
const timelock_discovery_1 = require("./discovery/timelock-discovery");
|
|
26
28
|
const utils_1 = require("./stages/utils");
|
|
27
29
|
const { tracker: logTracker, discovery: logDiscovery } = logger_1.loggers;
|
|
30
|
+
/**
|
|
31
|
+
* Build a TrackingContext with current block numbers and timestamp.
|
|
32
|
+
* Called once at the start of a tracking session for consistent state.
|
|
33
|
+
*/
|
|
34
|
+
async function buildTrackingContext(options) {
|
|
35
|
+
const { l2Provider, l1Provider, novaProvider, chunkSize, skipCache } = options;
|
|
36
|
+
const l2BlockInfo = await (0, timing_1.getCurrentBlockInfo)(l2Provider);
|
|
37
|
+
const context = {
|
|
38
|
+
l2BlockNumber: l2BlockInfo.blockNumber,
|
|
39
|
+
timestamp: l2BlockInfo.timestamp,
|
|
40
|
+
chunkSize,
|
|
41
|
+
skipCache,
|
|
42
|
+
};
|
|
43
|
+
logTracker("buildTrackingContext: l2Block=%d timestamp=%d", context.l2BlockNumber, context.timestamp);
|
|
44
|
+
if (l1Provider) {
|
|
45
|
+
try {
|
|
46
|
+
const l1Block = await (0, timing_1.getL1BlockNumberFromL2)(l2Provider);
|
|
47
|
+
context.l1BlockNumber = l1Block.toNumber();
|
|
48
|
+
logTracker("buildTrackingContext: l1Block=%d", context.l1BlockNumber);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
logTracker("buildTrackingContext: failed to get L1 block: %s", err.message);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (novaProvider) {
|
|
55
|
+
try {
|
|
56
|
+
const novaBlockInfo = await (0, timing_1.getCurrentBlockInfo)(novaProvider);
|
|
57
|
+
context.novaBlockNumber = novaBlockInfo.blockNumber;
|
|
58
|
+
logTracker("buildTrackingContext: novaBlock=%d", context.novaBlockNumber);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
logTracker("buildTrackingContext: failed to get Nova block: %s", err.message);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return context;
|
|
65
|
+
}
|
|
28
66
|
// Import context and pipeline from tracker modules
|
|
29
67
|
const state_1 = require("./tracker/state");
|
|
30
68
|
const pipeline_1 = require("./tracker/pipeline");
|
|
@@ -118,6 +156,15 @@ class ProposalStageTracker {
|
|
|
118
156
|
static async readCacheStatus(cachePath) {
|
|
119
157
|
return (0, cache_1.readCacheStatus)(cachePath);
|
|
120
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Clear a specific cache entry. Used by --force to ensure fresh tracking.
|
|
161
|
+
*/
|
|
162
|
+
async clearCacheEntry(key) {
|
|
163
|
+
if (this.cache) {
|
|
164
|
+
await this.cache.delete(key);
|
|
165
|
+
logTracker("cleared cache entry: %s", key);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
121
168
|
// Watermark Management
|
|
122
169
|
/**
|
|
123
170
|
* Load discovery watermarks from cache.
|
|
@@ -131,9 +178,73 @@ class ProposalStageTracker {
|
|
|
131
178
|
* Save discovery watermarks to cache.
|
|
132
179
|
* Watermarks are stored as TrackingCheckpoint with proper metadata,
|
|
133
180
|
* following the same pattern as proposal/timelock checkpoints.
|
|
181
|
+
*
|
|
182
|
+
* @param watermarks - Block numbers per discovery key
|
|
183
|
+
* @param hashes - Block hashes per discovery key (for reorg detection)
|
|
134
184
|
*/
|
|
135
|
-
async saveWatermarks(watermarks) {
|
|
136
|
-
return (0, discovery_1.saveWatermarks)(watermarks, this.cache);
|
|
185
|
+
async saveWatermarks(watermarks, hashes = {}) {
|
|
186
|
+
return (0, discovery_1.saveWatermarks)(watermarks, hashes, this.cache);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Save an election checkpoint to cache.
|
|
190
|
+
* Elections are stored with key format: `election:{electionIndex}`
|
|
191
|
+
*
|
|
192
|
+
* For COMPLETED elections, automatically fetches and caches nominee/member
|
|
193
|
+
* election details to enable zero-RPC reads for historical elections.
|
|
194
|
+
*
|
|
195
|
+
* @param electionStatus - Election status from trackElectionProposal
|
|
196
|
+
* @param options.nomineeDetails - Pre-fetched nominee details (skips RPC fetch)
|
|
197
|
+
* @param options.memberDetails - Pre-fetched member details (skips RPC fetch)
|
|
198
|
+
*/
|
|
199
|
+
async saveElectionCheckpoint(electionStatus, options = {}) {
|
|
200
|
+
if (!this.cache)
|
|
201
|
+
return;
|
|
202
|
+
const key = `election:${electionStatus.electionIndex}`;
|
|
203
|
+
const now = Date.now();
|
|
204
|
+
let nomineeDetails = options.nomineeDetails;
|
|
205
|
+
let memberDetails = options.memberDetails;
|
|
206
|
+
// For COMPLETED elections, fetch details if not provided
|
|
207
|
+
if (electionStatus.phase === "COMPLETED" && !nomineeDetails && !memberDetails) {
|
|
208
|
+
try {
|
|
209
|
+
const [rawNomineeDetails, rawMemberDetails] = await Promise.all([
|
|
210
|
+
(0, election_1.getNomineeElectionDetails)(electionStatus.electionIndex, this.l2Provider),
|
|
211
|
+
(0, election_1.getMemberElectionDetails)(electionStatus.electionIndex, this.l2Provider),
|
|
212
|
+
]);
|
|
213
|
+
if (rawNomineeDetails) {
|
|
214
|
+
nomineeDetails = (0, election_1.serializeNomineeDetails)(rawNomineeDetails);
|
|
215
|
+
}
|
|
216
|
+
if (rawMemberDetails) {
|
|
217
|
+
memberDetails = (0, election_1.serializeMemberDetails)(rawMemberDetails);
|
|
218
|
+
}
|
|
219
|
+
logTracker("fetched election %d details: nominees=%d, members=%d", electionStatus.electionIndex, nomineeDetails?.nominees?.length ?? 0, memberDetails?.nominees?.length ?? 0);
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
logTracker("failed to fetch election %d details (non-fatal): %s", electionStatus.electionIndex, err.message);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
await this.cache.set(key, {
|
|
226
|
+
version: 1,
|
|
227
|
+
createdAt: now,
|
|
228
|
+
input: { type: "election", electionIndex: electionStatus.electionIndex },
|
|
229
|
+
lastProcessedStage: null,
|
|
230
|
+
lastProcessedBlock: { l1: 0, l2: 0 },
|
|
231
|
+
cachedData: { electionStatus, nomineeDetails, memberDetails },
|
|
232
|
+
metadata: { errorCount: 0, lastTrackedAt: now },
|
|
233
|
+
});
|
|
234
|
+
logTracker("saved election checkpoint: %s (phase: %s)", key, electionStatus.phase);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get an election checkpoint from cache.
|
|
238
|
+
*
|
|
239
|
+
* @param electionIndex - Election index
|
|
240
|
+
* @returns Election status or null if not cached
|
|
241
|
+
*/
|
|
242
|
+
async getElectionCheckpoint(electionIndex) {
|
|
243
|
+
if (!this.cache)
|
|
244
|
+
return null;
|
|
245
|
+
const key = `election:${electionIndex}`;
|
|
246
|
+
const checkpoint = await this.cache.get(key);
|
|
247
|
+
return checkpoint?.cachedData?.electionStatus ?? null;
|
|
137
248
|
}
|
|
138
249
|
// Discovery API
|
|
139
250
|
/**
|
|
@@ -162,9 +273,10 @@ class ProposalStageTracker {
|
|
|
162
273
|
* Discover all proposals and timelock operations with auto-watermark management.
|
|
163
274
|
*
|
|
164
275
|
* This is the unified discovery API that handles everything internally:
|
|
276
|
+
* - Verifies watermark hashes to detect chain reorgs (rolls back if mismatch)
|
|
165
277
|
* - Loads watermarks from cache (or uses provided fromWatermarks)
|
|
166
278
|
* - Discovers from all enabled targets in parallel
|
|
167
|
-
* - Auto-saves updated watermarks to cache
|
|
279
|
+
* - Auto-saves updated watermarks and hashes to cache
|
|
168
280
|
*
|
|
169
281
|
* @param targets - Which governors/timelocks to scan
|
|
170
282
|
* @param toBlock - End block for discovery
|
|
@@ -172,11 +284,13 @@ class ProposalStageTracker {
|
|
|
172
284
|
* @returns Discovered proposals, timelock ops, and updated watermarks
|
|
173
285
|
*/
|
|
174
286
|
async discoverAll(targets, toBlock, fromWatermarks) {
|
|
175
|
-
// Load watermarks from cache (or use provided override)
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
//
|
|
179
|
-
await
|
|
287
|
+
// Load watermarks and hashes from cache (or use provided override)
|
|
288
|
+
const loaded = await this.loadWatermarks();
|
|
289
|
+
const watermarks = fromWatermarks ?? loaded.watermarks;
|
|
290
|
+
const hashes = fromWatermarks ? {} : loaded.hashes; // Only use cached hashes if using cached watermarks
|
|
291
|
+
const result = await (0, discovery_2.discoverAll)(targets, toBlock, this.l2Provider, this.cache, watermarks, hashes, { chunkSize: this.chunkingConfig.l2ChunkSize });
|
|
292
|
+
// Auto-save updated watermarks and hashes
|
|
293
|
+
await this.saveWatermarks(result.watermarks, result.hashes);
|
|
180
294
|
return result;
|
|
181
295
|
}
|
|
182
296
|
// Checkpoint Query API
|
|
@@ -240,7 +354,7 @@ class ProposalStageTracker {
|
|
|
240
354
|
async trackByTxHash(txHash) {
|
|
241
355
|
logTracker("trackByTxHash %s", txHash);
|
|
242
356
|
// Cache key for this transaction
|
|
243
|
-
const cacheKey = (0,
|
|
357
|
+
const cacheKey = (0, checkpoint_helpers_1.txHashCacheKey)(txHash);
|
|
244
358
|
// Load checkpoint from cache for resume
|
|
245
359
|
let checkpoint;
|
|
246
360
|
if (this.cache) {
|
|
@@ -263,8 +377,8 @@ class ProposalStageTracker {
|
|
|
263
377
|
creationTxHash: txHash,
|
|
264
378
|
};
|
|
265
379
|
const prevErrorCount = checkpoint?.metadata?.errorCount ?? 0;
|
|
380
|
+
const newErrorCount = (0, checkpoint_helpers_1.incrementErrorCount)(prevErrorCount, error);
|
|
266
381
|
const isGasError = (0, rpc_utils_1.isGasEstimationError)(error);
|
|
267
|
-
const newErrorCount = isGasError ? prevErrorCount : prevErrorCount + 1;
|
|
268
382
|
const errorCheckpoint = checkpoint ?? {
|
|
269
383
|
version: 1,
|
|
270
384
|
createdAt: Date.now(),
|
|
@@ -273,7 +387,7 @@ class ProposalStageTracker {
|
|
|
273
387
|
lastProcessedBlock: { l1: 0, l2: 0 },
|
|
274
388
|
cachedData: {},
|
|
275
389
|
};
|
|
276
|
-
errorCheckpoint.metadata =
|
|
390
|
+
errorCheckpoint.metadata = (0, checkpoint_helpers_1.createCheckpointMetadata)(newErrorCount);
|
|
277
391
|
await this.cache.set(cacheKey, errorCheckpoint);
|
|
278
392
|
logTracker("saved checkpoint on error: %s (errorCount=%d%s)", cacheKey, newErrorCount, isGasError ? " - gas error, not incrementing" : "");
|
|
279
393
|
}
|
|
@@ -353,7 +467,23 @@ class ProposalStageTracker {
|
|
|
353
467
|
const finalState = await (0, pipeline_1.trackGovernorPipeline)(initialState);
|
|
354
468
|
// Build result from state
|
|
355
469
|
const result = this.buildResultFromState(finalState);
|
|
356
|
-
//
|
|
470
|
+
// Track election status if this is an election governor proposal
|
|
471
|
+
if (result.isElection) {
|
|
472
|
+
const electionStatus = await this.trackElectionStatus(proposalId);
|
|
473
|
+
if (electionStatus) {
|
|
474
|
+
result.electionStatus = electionStatus;
|
|
475
|
+
await this.saveElectionCheckpoint(electionStatus);
|
|
476
|
+
// Elections are fully tracked via election checkpoints, remove tx:* checkpoint
|
|
477
|
+
if (this.cache && cacheKey) {
|
|
478
|
+
await this.cache.delete(cacheKey);
|
|
479
|
+
logTracker("election tracked via election checkpoint, removed tx:* checkpoint: %s", cacheKey);
|
|
480
|
+
}
|
|
481
|
+
return result;
|
|
482
|
+
}
|
|
483
|
+
// If election tracking failed, fall through to save tx:* checkpoint for retry
|
|
484
|
+
logTracker("election tracking failed, saving tx:* checkpoint for retry");
|
|
485
|
+
}
|
|
486
|
+
// Save checkpoint to cache (non-elections and failed election tracking)
|
|
357
487
|
if (this.cache && cacheKey) {
|
|
358
488
|
result.checkpoint.metadata = { errorCount: 0, lastTrackedAt: Date.now() };
|
|
359
489
|
await this.cache.set(cacheKey, result.checkpoint);
|
|
@@ -517,6 +647,154 @@ class ProposalStageTracker {
|
|
|
517
647
|
nova: this.novaProvider,
|
|
518
648
|
};
|
|
519
649
|
}
|
|
650
|
+
// Election Tracking
|
|
651
|
+
/**
|
|
652
|
+
* Track election status for a given proposal ID.
|
|
653
|
+
*
|
|
654
|
+
* Searches through elections to find the one containing this proposal,
|
|
655
|
+
* then tracks the full election lifecycle.
|
|
656
|
+
*/
|
|
657
|
+
async trackElectionStatus(proposalId) {
|
|
658
|
+
logTracker("trackElectionStatus for proposal %s", proposalId);
|
|
659
|
+
try {
|
|
660
|
+
// Get current L2 block for block-scoped caching
|
|
661
|
+
const { blockNumber: l2BlockNumber } = await (0, timing_1.getCurrentBlockInfo)(this.l2Provider);
|
|
662
|
+
const electionIndex = await (0, election_1.getElectionIndexForProposalId)(proposalId, this.l2Provider, this.l1Provider, { novaProvider: this.novaProvider, blockNumber: l2BlockNumber });
|
|
663
|
+
if (electionIndex === null) {
|
|
664
|
+
logTracker("no election found for proposal %s", proposalId);
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
logTracker("found election index %d for proposal %s", electionIndex, proposalId);
|
|
668
|
+
return (0, election_1.trackElectionProposal)(electionIndex, this.l2Provider, this.l1Provider, {
|
|
669
|
+
novaProvider: this.novaProvider,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
// Election tracking is non-critical - log and return null
|
|
674
|
+
// The proposal stages are already tracked successfully
|
|
675
|
+
logTracker("election tracking failed for proposal %s: %O", proposalId, error);
|
|
676
|
+
return null;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Track an election by its index.
|
|
681
|
+
*
|
|
682
|
+
* This method provides direct election tracking when you have the election index.
|
|
683
|
+
* For tracking via tx hash, use trackByTxHash() which auto-detects elections.
|
|
684
|
+
*
|
|
685
|
+
* Caching behavior:
|
|
686
|
+
* - COMPLETED elections: Returns cached data immediately (0 RPC calls)
|
|
687
|
+
* - Incomplete elections: Makes fresh RPC calls and updates cache
|
|
688
|
+
* - No cache: Always makes fresh RPC calls
|
|
689
|
+
*
|
|
690
|
+
* @param electionIndex - Election index (0-based)
|
|
691
|
+
* @param options.force - Force fresh tracking even for completed elections
|
|
692
|
+
* @returns Election status
|
|
693
|
+
*/
|
|
694
|
+
async trackElection(electionIndex, options = {}) {
|
|
695
|
+
logTracker("trackElection for index %d (force=%s)", electionIndex, options.force ?? false);
|
|
696
|
+
// Check cache first for completed elections (skip RPC calls)
|
|
697
|
+
if (this.cache && !options.force) {
|
|
698
|
+
const cached = await this.getElectionCheckpoint(electionIndex);
|
|
699
|
+
if (cached && cached.phase === "COMPLETED") {
|
|
700
|
+
logTracker("returning cached COMPLETED election %d (0 RPC calls)", electionIndex);
|
|
701
|
+
return cached;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
// Build full tracking context for consistent state across all calls
|
|
705
|
+
const context = await buildTrackingContext({
|
|
706
|
+
l2Provider: this.l2Provider,
|
|
707
|
+
l1Provider: this.l1Provider,
|
|
708
|
+
novaProvider: this.novaProvider,
|
|
709
|
+
skipCache: options.force,
|
|
710
|
+
});
|
|
711
|
+
// Track fresh for incomplete elections or cache miss
|
|
712
|
+
const status = await (0, election_1.trackElectionProposal)(electionIndex, this.l2Provider, this.l1Provider, {
|
|
713
|
+
novaProvider: this.novaProvider,
|
|
714
|
+
l2BlockNumber: context.l2BlockNumber,
|
|
715
|
+
timestamp: context.timestamp,
|
|
716
|
+
skipCache: context.skipCache,
|
|
717
|
+
});
|
|
718
|
+
if (this.cache) {
|
|
719
|
+
await this.saveElectionCheckpoint(status);
|
|
720
|
+
}
|
|
721
|
+
return status;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Track all elections with caching.
|
|
725
|
+
*
|
|
726
|
+
* Caching behavior:
|
|
727
|
+
* - COMPLETED elections: Returns cached data immediately (0 RPC calls)
|
|
728
|
+
* - Incomplete elections: Makes fresh RPC calls and updates cache
|
|
729
|
+
*
|
|
730
|
+
* @param options.includeNext - Include the "next" election slot (default: true)
|
|
731
|
+
* @param options.force - Force fresh tracking for all elections
|
|
732
|
+
* @returns Array of election statuses
|
|
733
|
+
*/
|
|
734
|
+
async trackAllElections(options = {}) {
|
|
735
|
+
logTracker("trackAllElections (includeNext=%s, force=%s)", options.includeNext ?? true, options.force ?? false);
|
|
736
|
+
// Build context once at the start for consistent state across all elections
|
|
737
|
+
const context = await buildTrackingContext({
|
|
738
|
+
l2Provider: this.l2Provider,
|
|
739
|
+
l1Provider: this.l1Provider,
|
|
740
|
+
novaProvider: this.novaProvider,
|
|
741
|
+
skipCache: options.force,
|
|
742
|
+
});
|
|
743
|
+
const status = await (0, election_1.checkElectionStatus)(this.l2Provider, this.l1Provider);
|
|
744
|
+
const electionCount = status.electionCount;
|
|
745
|
+
const results = [];
|
|
746
|
+
// Track existing elections (indices 0 to electionCount-1)
|
|
747
|
+
for (let i = 0; i < electionCount; i++) {
|
|
748
|
+
try {
|
|
749
|
+
// Check cache first for completed elections (skip RPC calls)
|
|
750
|
+
if (this.cache && !options.force) {
|
|
751
|
+
const cached = await this.getElectionCheckpoint(i);
|
|
752
|
+
if (cached && cached.phase === "COMPLETED") {
|
|
753
|
+
logTracker("returning cached COMPLETED election %d (0 RPC calls)", i);
|
|
754
|
+
results.push(cached);
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
// Track with shared context
|
|
759
|
+
const electionStatus = await (0, election_1.trackElectionProposal)(i, this.l2Provider, this.l1Provider, {
|
|
760
|
+
novaProvider: this.novaProvider,
|
|
761
|
+
l2BlockNumber: context.l2BlockNumber,
|
|
762
|
+
timestamp: context.timestamp,
|
|
763
|
+
skipCache: context.skipCache,
|
|
764
|
+
});
|
|
765
|
+
results.push(electionStatus);
|
|
766
|
+
if (this.cache) {
|
|
767
|
+
await this.saveElectionCheckpoint(electionStatus);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
catch (err) {
|
|
771
|
+
logTracker("Failed to track election %d: %s", i, err);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
// Optionally track the next election (not yet created) for createElection preparation
|
|
775
|
+
if (options.includeNext ?? true) {
|
|
776
|
+
try {
|
|
777
|
+
// Next election always needs fresh RPC calls since it doesn't exist yet
|
|
778
|
+
const nextElectionStatus = await (0, election_1.trackElectionProposal)(electionCount, this.l2Provider, this.l1Provider, {
|
|
779
|
+
novaProvider: this.novaProvider,
|
|
780
|
+
l2BlockNumber: context.l2BlockNumber,
|
|
781
|
+
timestamp: context.timestamp,
|
|
782
|
+
});
|
|
783
|
+
results.push({
|
|
784
|
+
...nextElectionStatus,
|
|
785
|
+
canCreateElection: status.canCreateElection,
|
|
786
|
+
secondsUntilElection: status.secondsUntilElection,
|
|
787
|
+
timeUntilElection: status.timeUntilElection,
|
|
788
|
+
});
|
|
789
|
+
// Don't cache the "next" election since it doesn't exist yet
|
|
790
|
+
}
|
|
791
|
+
catch (err) {
|
|
792
|
+
logTracker("Failed to track next election %d: %s", electionCount, err);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
logTracker("Tracked %d elections", results.length);
|
|
796
|
+
return results;
|
|
797
|
+
}
|
|
520
798
|
// Election Support
|
|
521
799
|
/**
|
|
522
800
|
* Check Security Council election status and prepare available actions
|
|
@@ -532,6 +810,7 @@ class ProposalStageTracker {
|
|
|
532
810
|
status,
|
|
533
811
|
canCreate: status.canCreateElection,
|
|
534
812
|
canTriggerMember: false,
|
|
813
|
+
canExecuteMember: false,
|
|
535
814
|
prepared: {},
|
|
536
815
|
};
|
|
537
816
|
if (status.canCreateElection) {
|
|
@@ -540,15 +819,23 @@ class ProposalStageTracker {
|
|
|
540
819
|
}
|
|
541
820
|
if (status.electionCount > 0) {
|
|
542
821
|
const currentElectionIndex = status.electionCount - 1;
|
|
543
|
-
|
|
822
|
+
// Use cached tracking for the current election
|
|
823
|
+
const electionStatus = await this.trackElection(currentElectionIndex);
|
|
544
824
|
result.currentElection = electionStatus;
|
|
545
825
|
result.canTriggerMember = electionStatus.canProceedToMemberPhase;
|
|
826
|
+
result.canExecuteMember = electionStatus.canExecuteMember;
|
|
546
827
|
if (electionStatus.canProceedToMemberPhase) {
|
|
547
828
|
const memberTx = await (0, election_1.prepareMemberElectionTrigger)(electionStatus, this.l2Provider);
|
|
548
829
|
if (memberTx) {
|
|
549
830
|
result.prepared.triggerMember = memberTx;
|
|
550
831
|
}
|
|
551
832
|
}
|
|
833
|
+
if (electionStatus.canExecuteMember) {
|
|
834
|
+
const executeTx = await (0, election_1.prepareMemberElectionExecution)(electionStatus, this.l2Provider);
|
|
835
|
+
if (executeTx) {
|
|
836
|
+
result.prepared.executeMember = executeTx;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
552
839
|
}
|
|
553
840
|
return result;
|
|
554
841
|
}
|