liqproof 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +536 -2
- package/bugs/README.md +144 -0
- package/bugs/coin-gecko-liquidity-report.md +283 -0
- package/bugs/collect-ds-aggregate.mjs +213 -0
- package/bugs/collect-evidence.mjs +458 -0
- package/bugs/collect-gt-aggregate.mjs +215 -0
- package/bugs/collect-raw-rpc.mjs +165 -0
- package/bugs/collect-sweep-context.mjs +162 -0
- package/bugs/dexscreener-fake-liquidity-report.md +310 -0
- package/bugs/evidence/aggregator-liquidity-claims.json +648 -0
- package/bugs/evidence/aggregator-liquidity-claims.md +103 -0
- package/bugs/evidence/bat-native-pool-drained.json +136 -0
- package/bugs/evidence/bat-native-pool-drained.md +51 -0
- package/bugs/evidence/chz-impersonator-pool-drained.json +136 -0
- package/bugs/evidence/chz-impersonator-pool-drained.md +51 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.json +141 -0
- package/bugs/evidence/gt-stale-reserve-after-drain.md +31 -0
- package/bugs/evidence/raw-rpc-transcript.json +683 -0
- package/bugs/evidence/raw-rpc-transcript.md +308 -0
- package/bugs/evidence/sweep-context.json +325 -0
- package/bugs/evidence/sweep-context.md +55 -0
- package/bugs/evidence/verified-aggregate.json +526 -0
- package/bugs/evidence/verified-aggregate.md +24 -0
- package/bugs/evidence/verified-ds-liquidity-usd.json +1197 -0
- package/bugs/evidence/verified-ds-liquidity-usd.md +250 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.json +1002 -0
- package/bugs/evidence/verified-gt-reserve-in-usd.md +218 -0
- package/bugs/fix-bundle-titles.mjs +72 -0
- package/bugs/geckoterminal-stale-reserve-after-drain.md +137 -0
- package/data/dataset-summary.md +103 -0
- package/data/impersonators.json +12888 -0
- package/data/verified-impersonators.json +725 -0
- package/data/wallets.json +23 -0
- package/dist/base58.js +70 -0
- package/dist/base58.js.map +1 -0
- package/dist/canonical.js +372 -0
- package/dist/canonical.js.map +1 -0
- package/dist/cli.js +830 -0
- package/dist/cli.js.map +1 -0
- package/dist/curve.js +255 -0
- package/dist/curve.js.map +1 -0
- package/dist/dashboard.js +485 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/keccak.js +197 -0
- package/dist/keccak.js.map +1 -0
- package/dist/mcp.js +604 -0
- package/dist/mcp.js.map +1 -0
- package/dist/operator.js +180 -0
- package/dist/operator.js.map +1 -0
- package/dist/pda.js +86 -0
- package/dist/pda.js.map +1 -0
- package/dist/receipt.js +897 -0
- package/dist/receipt.js.map +1 -0
- package/dist/render.js +335 -0
- package/dist/render.js.map +1 -0
- package/dist/rpc.js +377 -0
- package/dist/rpc.js.map +1 -0
- package/dist/sources.js +599 -0
- package/dist/sources.js.map +1 -0
- package/dist/store.js +330 -0
- package/dist/store.js.map +1 -0
- package/dist/tokenmeta.js +424 -0
- package/dist/tokenmeta.js.map +1 -0
- package/dist/util.js +273 -0
- package/dist/util.js.map +1 -0
- package/dist/vaults.js +510 -0
- package/dist/vaults.js.map +1 -0
- package/dist/wallet.js +404 -0
- package/dist/wallet.js.map +1 -0
- package/dist/warnings.js +41 -0
- package/dist/warnings.js.map +1 -0
- package/dist/worker.js +857 -0
- package/dist/worker.js.map +1 -0
- package/dist/x402.js +549 -0
- package/dist/x402.js.map +1 -0
- package/docs/HACKATHON-SUBMISSION.md +264 -0
- package/docs/liqproof-plan.md +221 -0
- package/docs/llms.txt +32 -0
- package/docs/mcp-registry.md +165 -0
- package/docs/screenshots/01-dashboard.png +0 -0
- package/docs/screenshots/02-receipt-drained.png +0 -0
- package/docs/screenshots/03-receipt-impersonator.png +0 -0
- package/docs/screenshots/04-receipt-canonical.png +0 -0
- package/docs/x402-pricing.md +171 -0
- package/docs/zero-xyz.md +250 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.json +1171 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.md +52 -0
- package/out/6eftxVbSAunVEoxUWdGhPdxg5UdsJ8Wkwy5w5YFuxouw.svg +25 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.json +3975 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.md +90 -0
- package/out/BTNiaZb6HaEFWeEtND4SXtZ7T6mgtDwSryHTAj6PuPyp.svg +25 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.json +1446 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.md +66 -0
- package/out/ENGkoidj2jNs73A7GZuseVmnkRg6EVF9tDtViwPz8o85.svg +25 -0
- package/out/dataset.csv +67 -0
- package/out/impersonation-table.md +156 -0
- package/out/index.html +1179 -0
- package/package.json +78 -4
- package/scripts/assert-no-canonical-accusations.mjs +193 -0
- package/scripts/backfill.mjs +1063 -0
- package/scripts/bundle-evidence.mjs +237 -0
- package/scripts/bundle-stale-claim.mjs +417 -0
- package/scripts/capture-bch-evidence.mjs +58 -0
- package/scripts/check-orientation-fix.mjs +40 -0
- package/scripts/check-wallet.mjs +54 -0
- package/scripts/daily-refresh.mjs +451 -0
- package/scripts/decode-clmm-vaults.mjs +180 -0
- package/scripts/falsifiability.mjs +263 -0
- package/scripts/impersonator-mining.mjs +156 -0
- package/scripts/inspect-matches.mjs +73 -0
- package/scripts/operator-sweep.mjs +252 -0
- package/scripts/publish-release.mjs +248 -0
- package/scripts/refresh-store.mjs +78 -0
- package/scripts/survival-miner.mjs +951 -0
- package/scripts/test-keccak.mjs +103 -0
- package/scripts/verify-bch-1p95b.mjs +124 -0
- package/scripts/verify-clmm-1p95b.mjs +127 -0
- package/scripts/verify-clmm-control.mjs +84 -0
- package/scripts/verify-impersonators.mjs +138 -0
- package/scripts/verify-raw.mjs +110 -0
- package/scripts/verify-raw2.mjs +99 -0
- package/server.json +34 -0
- package/src/base58.ts +68 -0
- package/src/canonical.ts +447 -0
- package/src/cli.ts +941 -0
- package/src/curve.ts +349 -0
- package/src/dashboard.ts +504 -0
- package/src/keccak.ts +228 -0
- package/src/mcp.ts +735 -0
- package/src/operator.ts +219 -0
- package/src/receipt.ts +1219 -0
- package/src/render.ts +396 -0
- package/src/rpc.ts +435 -0
- package/src/sources.ts +714 -0
- package/src/store.ts +428 -0
- package/src/tokenmeta.ts +460 -0
- package/src/util.ts +276 -0
- package/src/vaults.ts +574 -0
- package/src/wallet.ts +459 -0
- package/src/warnings.ts +40 -0
- package/src/worker.ts +1086 -0
- package/src/x402.ts +717 -0
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rpc.ts — rate-aware JSON-RPC client for free public Solana endpoints.
|
|
3
|
+
*
|
|
4
|
+
* MEASURED constraints (2026-12-04, not assumptions):
|
|
5
|
+
*
|
|
6
|
+
* api.mainnet-beta.solana.com (free tier, x-ratelimit-tier: free)
|
|
7
|
+
* getSlot 150 / 10s
|
|
8
|
+
* getAccountInfo 50 / 10s
|
|
9
|
+
* getTransaction 10 / 10s <-- hard bottleneck
|
|
10
|
+
* getSignaturesForAddress 10 / 10s
|
|
11
|
+
* getTokenAccountsByOwner 10 / 10s (indexed)
|
|
12
|
+
* endpoint limit unlimited
|
|
13
|
+
* rps limit 250
|
|
14
|
+
*
|
|
15
|
+
* solana-mainnet.gateway.tatum.io (anonymous)
|
|
16
|
+
* getTransaction works, ~5 req/min after burst
|
|
17
|
+
* getSignaturesForAddress PAID ONLY
|
|
18
|
+
* getTokenAccountsByOwner PAID ONLY
|
|
19
|
+
*
|
|
20
|
+
* Critical findings that shape this file:
|
|
21
|
+
* 1. A 429 can arrive INSIDE a JSON-RPC body (HTTP 200 + error.code 429).
|
|
22
|
+
* It must be treated as retryable, not as a terminal error.
|
|
23
|
+
* 2. The server's own `x-ratelimit-method-remaining` header is the
|
|
24
|
+
* authoritative budget. We read it and adapt, rather than guessing.
|
|
25
|
+
* 3. Batching reduces round-trips but each sub-call still consumes budget.
|
|
26
|
+
* 4. `commitment` must be omitted on several methods (HTTP 413).
|
|
27
|
+
* 5. `getProgramAccounts` is banned (375MB payload).
|
|
28
|
+
*
|
|
29
|
+
* Therefore the pool is built as a per-(endpoint, method) token bucket that
|
|
30
|
+
* self-corrects from response headers, with automatic rotation.
|
|
31
|
+
*/
|
|
32
|
+
import { HttpError } from './util.js';
|
|
33
|
+
export const DEFAULT_ENDPOINTS = [
|
|
34
|
+
'https://api.mainnet-beta.solana.com',
|
|
35
|
+
'https://solana-mainnet.gateway.tatum.io',
|
|
36
|
+
];
|
|
37
|
+
/** Fallback limits (calls per 10s window) used until the server tells us. */
|
|
38
|
+
const DEFAULT_METHOD_LIMITS = {
|
|
39
|
+
getSlot: 140,
|
|
40
|
+
getAccountInfo: 45,
|
|
41
|
+
getTransaction: 9,
|
|
42
|
+
getSignaturesForAddress: 9,
|
|
43
|
+
getTokenAccountsByOwner: 9,
|
|
44
|
+
getBlock: 9,
|
|
45
|
+
getBlockTime: 40,
|
|
46
|
+
getTokenSupply: 9,
|
|
47
|
+
getMultipleAccounts: 40,
|
|
48
|
+
getProgramAccounts: 0, // banned
|
|
49
|
+
};
|
|
50
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
51
|
+
export class RpcPool {
|
|
52
|
+
endpoints;
|
|
53
|
+
batchSize;
|
|
54
|
+
windowMs;
|
|
55
|
+
maxRetries;
|
|
56
|
+
timeoutMs;
|
|
57
|
+
verbose;
|
|
58
|
+
onEvent;
|
|
59
|
+
buckets = new Map();
|
|
60
|
+
endpointBlocked = new Map();
|
|
61
|
+
id = 1;
|
|
62
|
+
/** counters for the doctor command */
|
|
63
|
+
stats = { requests: 0, calls: 0, rpc429: 0, httpErrors: 0, retries: 0 };
|
|
64
|
+
constructor(opts = {}) {
|
|
65
|
+
this.endpoints = opts.endpoints?.length ? opts.endpoints : DEFAULT_ENDPOINTS;
|
|
66
|
+
this.batchSize = opts.batchSize ?? 20;
|
|
67
|
+
this.windowMs = opts.windowMs ?? 10_000;
|
|
68
|
+
this.maxRetries = opts.maxRetries ?? 5;
|
|
69
|
+
this.timeoutMs = opts.timeoutMs ?? 25_000;
|
|
70
|
+
this.verbose = opts.verbose ?? false;
|
|
71
|
+
this.onEvent = opts.onEvent;
|
|
72
|
+
}
|
|
73
|
+
// ── budget bookkeeping ────────────────────────────────────────────────────
|
|
74
|
+
bucket(endpoint, method) {
|
|
75
|
+
const key = `${endpoint}::${method}`;
|
|
76
|
+
let b = this.buckets.get(key);
|
|
77
|
+
if (!b) {
|
|
78
|
+
b = {
|
|
79
|
+
stamps: [],
|
|
80
|
+
limit: DEFAULT_METHOD_LIMITS[method] ?? 8,
|
|
81
|
+
blockedUntil: 0,
|
|
82
|
+
};
|
|
83
|
+
this.buckets.set(key, b);
|
|
84
|
+
}
|
|
85
|
+
return b;
|
|
86
|
+
}
|
|
87
|
+
learnLimits(endpoint, method, headers) {
|
|
88
|
+
const limit = Number(headers.get('x-ratelimit-method-limit'));
|
|
89
|
+
if (Number.isFinite(limit) && limit > 0) {
|
|
90
|
+
const b = this.bucket(endpoint, method);
|
|
91
|
+
// never trust the server upward past our own conservative ceiling
|
|
92
|
+
b.limit = Math.min(limit, DEFAULT_METHOD_LIMITS[method] ?? 8);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
prune(b) {
|
|
96
|
+
const now = Date.now();
|
|
97
|
+
while (b.stamps.length && now - b.stamps[0] >= this.windowMs)
|
|
98
|
+
b.stamps.shift();
|
|
99
|
+
}
|
|
100
|
+
/** Wait until `n` calls of `method` fit in the endpoint's budget. */
|
|
101
|
+
async acquire(endpoint, method, n) {
|
|
102
|
+
const b = this.bucket(endpoint, method);
|
|
103
|
+
for (;;) {
|
|
104
|
+
const now = Date.now();
|
|
105
|
+
const blocked = Math.max(b.blockedUntil, this.endpointBlocked.get(endpoint) ?? 0);
|
|
106
|
+
if (blocked > now) {
|
|
107
|
+
const waitMs = blocked - now + 25;
|
|
108
|
+
this.onEvent?.({ kind: 'throttle', method, endpoint, waitMs });
|
|
109
|
+
await sleep(waitMs);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
this.prune(b);
|
|
113
|
+
if (b.stamps.length + n <= b.limit) {
|
|
114
|
+
for (let i = 0; i < n; i++)
|
|
115
|
+
b.stamps.push(now);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const waitMs = this.windowMs - (now - b.stamps[0]) + 30;
|
|
119
|
+
this.onEvent?.({ kind: 'throttle', method, endpoint, waitMs });
|
|
120
|
+
await sleep(Math.max(40, waitMs));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
block(endpoint, method, ms) {
|
|
124
|
+
const b = this.bucket(endpoint, method);
|
|
125
|
+
b.blockedUntil = Math.max(b.blockedUntil, Date.now() + ms);
|
|
126
|
+
this.buckets.set(`${endpoint}::${method}`, b);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Pick the endpoint to use for a given method.
|
|
130
|
+
*
|
|
131
|
+
* Critical: this must be STABLE for the duration of one request. The
|
|
132
|
+
* budget for a call is reserved against a specific endpoint, so if the
|
|
133
|
+
* endpoint changed between reserving and sending, the accounting (and the
|
|
134
|
+
* rate limiting) would be wrong.
|
|
135
|
+
*
|
|
136
|
+
* We also remember which endpoints have REFUSED a method (e.g. Tatum
|
|
137
|
+
* requires a paid plan for getSignaturesForAddress) and skip them.
|
|
138
|
+
*/
|
|
139
|
+
pickEndpoint(method) {
|
|
140
|
+
const now = Date.now();
|
|
141
|
+
const candidates = this.endpoints.filter((ep) => {
|
|
142
|
+
if ((this.endpointBlocked.get(ep) ?? 0) > now)
|
|
143
|
+
return false;
|
|
144
|
+
const b = this.bucket(ep, method);
|
|
145
|
+
if (b.blockedUntil > now)
|
|
146
|
+
return false;
|
|
147
|
+
if (this.unsupported.get(`${ep}::${method}`))
|
|
148
|
+
return false;
|
|
149
|
+
return true;
|
|
150
|
+
});
|
|
151
|
+
if (candidates.length === 0) {
|
|
152
|
+
// Everything is blocked for this method. Fall back to an endpoint that
|
|
153
|
+
// at least supports it, even if it is currently cooling down.
|
|
154
|
+
const supporting = this.endpoints.filter((ep) => !this.unsupported.get(`${ep}::${method}`));
|
|
155
|
+
return supporting[0] ?? this.endpoints[0];
|
|
156
|
+
}
|
|
157
|
+
// Round-robin among the usable candidates so load is spread, but always
|
|
158
|
+
// return a deterministic answer for the duration of one call chain.
|
|
159
|
+
const idx = this.cursor % candidates.length;
|
|
160
|
+
this.cursor++;
|
|
161
|
+
return candidates[idx];
|
|
162
|
+
}
|
|
163
|
+
cursor = 0;
|
|
164
|
+
unsupported = new Map();
|
|
165
|
+
/** Remember that an endpoint refuses a method (paid plan, etc.). */
|
|
166
|
+
markUnsupported(endpoint, method) {
|
|
167
|
+
this.unsupported.set(`${endpoint}::${method}`, true);
|
|
168
|
+
}
|
|
169
|
+
// ── transport ─────────────────────────────────────────────────────────────
|
|
170
|
+
async post(endpoint, body) {
|
|
171
|
+
const res = await fetch(endpoint, {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
headers: {
|
|
174
|
+
'content-type': 'application/json',
|
|
175
|
+
accept: 'application/json',
|
|
176
|
+
'user-agent': 'liqproof/0.1 (+read-only on-chain receipts)',
|
|
177
|
+
},
|
|
178
|
+
body: JSON.stringify(body),
|
|
179
|
+
});
|
|
180
|
+
this.stats.requests++;
|
|
181
|
+
const text = await res.text();
|
|
182
|
+
if (!res.ok) {
|
|
183
|
+
this.stats.httpErrors++;
|
|
184
|
+
throw new HttpError(res.status, text.slice(0, 400), endpoint);
|
|
185
|
+
}
|
|
186
|
+
let parsed;
|
|
187
|
+
try {
|
|
188
|
+
parsed = JSON.parse(text);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw new Error(`invalid JSON from ${endpoint}: ${text.slice(0, 160)}`);
|
|
192
|
+
}
|
|
193
|
+
return { responses: Array.isArray(parsed) ? parsed : [parsed], headers: res.headers };
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Execute calls in order. Results are returned one-per-call, in input
|
|
197
|
+
* order. RPC-level 429s are retried after a cooldown; other RPC errors
|
|
198
|
+
* are returned as `{ error }` so a single bad tx never kills a backfill.
|
|
199
|
+
*/
|
|
200
|
+
async batch(calls) {
|
|
201
|
+
if (calls.length === 0)
|
|
202
|
+
return [];
|
|
203
|
+
const results = new Array(calls.length);
|
|
204
|
+
const chunks = [];
|
|
205
|
+
for (let i = 0; i < calls.length; i += this.batchSize) {
|
|
206
|
+
chunks.push(calls.slice(i, i + this.batchSize));
|
|
207
|
+
}
|
|
208
|
+
for (let ci = 0; ci < chunks.length; ci++) {
|
|
209
|
+
const chunk = chunks[ci];
|
|
210
|
+
const base = ci * this.batchSize;
|
|
211
|
+
// Group the chunk by method so we can reserve budget per method and
|
|
212
|
+
// report headers correctly. A chunk may contain mixed methods.
|
|
213
|
+
const byMethod = new Map();
|
|
214
|
+
chunk.forEach((c, i) => {
|
|
215
|
+
const arr = byMethod.get(c.method) ?? [];
|
|
216
|
+
arr.push(i);
|
|
217
|
+
byMethod.set(c.method, arr);
|
|
218
|
+
});
|
|
219
|
+
// ONE endpoint for the whole chunk: the budget must be reserved against
|
|
220
|
+
// the same endpoint the request is actually sent to.
|
|
221
|
+
const primaryMethod = chunk[0].method;
|
|
222
|
+
let endpoint = this.pickEndpoint(primaryMethod);
|
|
223
|
+
// Reserve budget for every call in the chunk before sending.
|
|
224
|
+
for (const [method, idxs] of byMethod) {
|
|
225
|
+
await this.acquire(endpoint, method, idxs.length);
|
|
226
|
+
}
|
|
227
|
+
const payload = chunk.map((call) => ({
|
|
228
|
+
jsonrpc: '2.0',
|
|
229
|
+
id: this.id++,
|
|
230
|
+
method: call.method,
|
|
231
|
+
params: call.params ?? [],
|
|
232
|
+
}));
|
|
233
|
+
let attempt = 0;
|
|
234
|
+
let settled = false;
|
|
235
|
+
while (!settled && attempt <= this.maxRetries) {
|
|
236
|
+
const started = Date.now();
|
|
237
|
+
try {
|
|
238
|
+
const { responses, headers } = await this.post(endpoint, payload);
|
|
239
|
+
this.stats.calls += chunk.length;
|
|
240
|
+
const primary = chunk[0].method;
|
|
241
|
+
this.learnLimits(endpoint, primary, headers);
|
|
242
|
+
const byId = new Map();
|
|
243
|
+
for (const r of responses)
|
|
244
|
+
byId.set(r?.id, r);
|
|
245
|
+
let sawRpc429 = false;
|
|
246
|
+
let sawUnsupported = false;
|
|
247
|
+
payload.forEach((p, i) => {
|
|
248
|
+
const r = byId.get(p.id);
|
|
249
|
+
const slot = base + i;
|
|
250
|
+
if (!r) {
|
|
251
|
+
results[slot] = { error: 'missing response', retriable: true };
|
|
252
|
+
}
|
|
253
|
+
else if (r.error) {
|
|
254
|
+
const code = Number(r.error.code);
|
|
255
|
+
const is429 = code === 429 || code === -32005;
|
|
256
|
+
// -16401 / -32601 = "method not available on this endpoint"
|
|
257
|
+
const isUnsupported = code === -16401 || code === -32601;
|
|
258
|
+
if (is429)
|
|
259
|
+
sawRpc429 = true;
|
|
260
|
+
if (isUnsupported)
|
|
261
|
+
sawUnsupported = true;
|
|
262
|
+
results[slot] = {
|
|
263
|
+
error: `${code}: ${r.error.message}`,
|
|
264
|
+
rpcCode: code,
|
|
265
|
+
retriable: is429,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
results[slot] = { value: r.result };
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (sawUnsupported) {
|
|
273
|
+
// This endpoint refuses one of these methods (paid plan). Mark it
|
|
274
|
+
// and retry the whole chunk elsewhere.
|
|
275
|
+
for (const [method] of byMethod)
|
|
276
|
+
this.markUnsupported(endpoint, method);
|
|
277
|
+
attempt++;
|
|
278
|
+
endpoint = this.pickEndpoint(primaryMethod);
|
|
279
|
+
for (const [method, idxs] of byMethod) {
|
|
280
|
+
await this.acquire(endpoint, method, idxs.length);
|
|
281
|
+
}
|
|
282
|
+
await sleep(200);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (sawRpc429) {
|
|
286
|
+
this.stats.rpc429++;
|
|
287
|
+
this.onEvent?.({ kind: 'rpc429', method: primary, endpoint });
|
|
288
|
+
// The server is stricter than our model: back off the whole method.
|
|
289
|
+
this.block(endpoint, primary, this.windowMs);
|
|
290
|
+
attempt++;
|
|
291
|
+
await sleep(300 * attempt);
|
|
292
|
+
// Re-reserve budget on the SAME endpoint (the previous reservation
|
|
293
|
+
// was consumed by the rejected attempt).
|
|
294
|
+
for (const [method, idxs] of byMethod) {
|
|
295
|
+
await this.acquire(endpoint, method, idxs.length);
|
|
296
|
+
}
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
this.onEvent?.({
|
|
300
|
+
kind: 'ok',
|
|
301
|
+
method: primary,
|
|
302
|
+
ms: Date.now() - started,
|
|
303
|
+
batch: chunk.length,
|
|
304
|
+
endpoint,
|
|
305
|
+
});
|
|
306
|
+
settled = true;
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
const isHttp = err instanceof HttpError;
|
|
310
|
+
const status = isHttp ? err.status : 0;
|
|
311
|
+
const retryable = status === 429 || status >= 500 || status === 0;
|
|
312
|
+
if (!retryable) {
|
|
313
|
+
const msg = err.message;
|
|
314
|
+
this.onEvent?.({ kind: 'error', method: primaryMethod, error: msg });
|
|
315
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
316
|
+
if (results[base + i] === undefined)
|
|
317
|
+
results[base + i] = { error: msg };
|
|
318
|
+
}
|
|
319
|
+
settled = true;
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
this.stats.retries++;
|
|
323
|
+
this.endpointBlocked.set(endpoint, Date.now() + 1500 * attempt);
|
|
324
|
+
this.onEvent?.({ kind: 'rotate', endpoint, reason: `HTTP ${status}` });
|
|
325
|
+
await sleep(400 * 2 ** attempt + Math.floor(Math.random() * 300));
|
|
326
|
+
attempt++;
|
|
327
|
+
endpoint = this.pickEndpoint(primaryMethod);
|
|
328
|
+
for (const [method, idxs] of byMethod) {
|
|
329
|
+
await this.acquire(endpoint, method, idxs.length);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
// If we exhausted retries without settling, fill every remaining slot so
|
|
335
|
+
// callers never see `undefined` holes.
|
|
336
|
+
if (!settled) {
|
|
337
|
+
const msg = `exhausted ${this.maxRetries} retries for ${chunk[0].method}`;
|
|
338
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
339
|
+
if (results[base + i] === undefined)
|
|
340
|
+
results[base + i] = { error: msg };
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return results;
|
|
345
|
+
}
|
|
346
|
+
/** Single call. Throws on RPC error. */
|
|
347
|
+
async call(method, params = []) {
|
|
348
|
+
const [res] = await this.batch([{ method, params }]);
|
|
349
|
+
if (!res)
|
|
350
|
+
throw new Error(`no response for ${method}`);
|
|
351
|
+
if (res.error)
|
|
352
|
+
throw new Error(`${method}: ${res.error}`);
|
|
353
|
+
return res.value;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Single call that returns null on error.
|
|
357
|
+
* NOTE: `null` means "the call failed", which is different from "the call
|
|
358
|
+
* succeeded and the answer was empty". Callers that need to distinguish
|
|
359
|
+
* must use `batch()` and inspect `error`.
|
|
360
|
+
*/
|
|
361
|
+
async tryCall(method, params = []) {
|
|
362
|
+
const [res] = await this.batch([{ method, params }]);
|
|
363
|
+
if (!res || res.error)
|
|
364
|
+
return null;
|
|
365
|
+
return res.value;
|
|
366
|
+
}
|
|
367
|
+
/** Single call with an explicit success flag — no ambiguity. */
|
|
368
|
+
async callDetailed(method, params = []) {
|
|
369
|
+
const [res] = await this.batch([{ method, params }]);
|
|
370
|
+
if (!res)
|
|
371
|
+
return { ok: false, value: null, error: 'no response' };
|
|
372
|
+
if (res.error)
|
|
373
|
+
return { ok: false, value: null, error: res.error };
|
|
374
|
+
return { ok: true, value: res.value };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
//# sourceMappingURL=rpc.js.map
|
package/dist/rpc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.js","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAa,SAAS,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,qCAAqC;IACrC,yCAAyC;CAC1C,CAAC;AAEF,6EAA6E;AAC7E,MAAM,qBAAqB,GAA2B;IACpD,OAAO,EAAE,GAAG;IACZ,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,CAAC;IACjB,uBAAuB,EAAE,CAAC;IAC1B,uBAAuB,EAAE,CAAC;IAC1B,QAAQ,EAAE,CAAC;IACX,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,CAAC;IACjB,mBAAmB,EAAE,EAAE;IACvB,kBAAkB,EAAE,CAAC,EAAE,SAAS;CACjC,CAAC;AAwBF,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAkB1E,MAAM,OAAO,OAAO;IACT,SAAS,CAAW;IACZ,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,OAAO,CAAU;IACjB,OAAO,CAA6B;IACpC,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpC,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrD,EAAE,GAAG,CAAC,CAAC;IAEf,sCAAsC;IAC7B,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,K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