shinjuku-shielded 0.3.63 → 0.3.65

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/manifest.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "schema": "carbon-shielded-wallet/bundle-manifest/v1",
3
3
  "file": "shinjuku-wallet.mjs",
4
- "sha256": "f3c652001435e22d3e54232fe742166dd8dd5ae183b92c1a24274c7a52ed137c",
5
- "bytes": 12174893,
6
- "sourceCommit": "46ac2745bf8ffeabba0e0cfaf8d052b20d6313e4",
4
+ "sha256": "f1563e53fc8d137fe44e6fb65d7247fa157b3066b7129b41ef9f99d2e3061ba7",
5
+ "bytes": 12180292,
6
+ "sourceCommit": "274f1d09a81983902118eeb923b5a4093acd757c",
7
7
  "sourceDirty": false,
8
8
  "installRecordMatchesLockfile": true,
9
9
  "releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
@@ -1282,5 +1282,5 @@
1282
1282
  "version": "1.8.0"
1283
1283
  }
1284
1284
  ],
1285
- "publishedAt": "2026-10-22T08:20:53.830Z"
1285
+ "publishedAt": "2026-10-22T10:20:32.328Z"
1286
1286
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "shinjuku-shielded",
3
- "version": "0.3.63",
3
+ "version": "0.3.65",
4
4
  "mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
5
5
  "description": "Shinjuku Shielded, the private x402 facilitator on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
6
- "shinjukuRelease": "f3c65200",
7
- "shinjukuSha256": "f3c652001435e22d3e54232fe742166dd8dd5ae183b92c1a24274c7a52ed137c",
6
+ "shinjukuRelease": "f1563e53",
7
+ "shinjukuSha256": "f1563e53fc8d137fe44e6fb65d7247fa157b3066b7129b41ef9f99d2e3061ba7",
8
8
  "license": "SEE LICENSE IN LICENSE.txt",
9
9
  "author": "Shinjuku Shielded",
10
10
  "homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
@@ -50664,11 +50664,12 @@ function poolLayoutForLength(length) {
50664
50664
  }
50665
50665
  function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fetch2) => fetch2 } = {}) {
50666
50666
  const pooled = (input, init) => rpcFetch(input, rpcKeepAliveInit(input, init));
50667
- const fetch2 = wrapFetch(timeoutMs === void 0 ? pooled : async (input, init) => {
50667
+ const fetch2 = wrapFetch(timeoutMs === void 0 ? pooled : async (input, { onResponseHead, ...init } = {}) => {
50668
50668
  const circuit = torCircuit();
50669
50669
  const timeout = AbortSignal.timeout(timeoutMs);
50670
50670
  try {
50671
50671
  const response = await pooled(input, { ...init, signal: init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout });
50672
+ onResponseHead?.(response);
50672
50673
  const body = await response.text();
50673
50674
  const headers = new Headers(response.headers);
50674
50675
  headers.delete("content-encoding");
@@ -50682,13 +50683,24 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fe
50682
50683
  const connection = countRpcCalls(new import_web395.Connection(rpcUrl, { commitment, fetch: fetch2, disableRetryOnRateLimit: true }));
50683
50684
  let nextId = 0;
50684
50685
  Object.defineProperty(connection, "abortableRpcRequest", {
50685
- value: async (method, params, signal) => {
50686
+ value: async (method, params, signal, onResponse) => {
50687
+ let reported = false;
50688
+ const onResponseHead = (response2) => {
50689
+ if (reported) return;
50690
+ reported = true;
50691
+ try {
50692
+ onResponse?.({ status: response2.status, contentLength: Number(response2.headers.get("content-length")) });
50693
+ } catch {
50694
+ }
50695
+ };
50686
50696
  const response = await fetch2(rpcUrl, {
50687
50697
  method: "POST",
50688
50698
  signal,
50699
+ onResponseHead,
50689
50700
  headers: { "content-type": "application/json" },
50690
50701
  body: JSON.stringify({ jsonrpc: "2.0", id: `abortable-${nextId += 1}`, method, params })
50691
50702
  });
50703
+ onResponseHead(response);
50692
50704
  return response.json();
50693
50705
  },
50694
50706
  enumerable: false,
@@ -53948,6 +53960,24 @@ function parseE1TreeHeader(header) {
53948
53960
  bufferSize: u642(72)
53949
53961
  };
53950
53962
  }
53963
+ function programDataAddressOf(program) {
53964
+ const key = b58(program);
53965
+ let address5 = PROGRAMDATA_ADDRESSES.get(key);
53966
+ if (address5 === void 0) {
53967
+ address5 = import_web396.PublicKey.findProgramAddressSync([new import_web396.PublicKey(key).toBuffer()], BPF_LOADER_UPGRADEABLE_PROGRAM_ID)[0];
53968
+ PROGRAMDATA_ADDRESSES.set(key, address5);
53969
+ }
53970
+ return address5;
53971
+ }
53972
+ function reuseOptionRefused(connection) {
53973
+ const endpoint2 = connection.rpcEndpoint;
53974
+ return typeof endpoint2 === "string" ? REUSE_REFUSED_ENDPOINTS.has(endpoint2) : REUSE_REFUSED_CONNECTIONS.has(connection);
53975
+ }
53976
+ function rememberReuseOptionRefused(connection) {
53977
+ const endpoint2 = connection.rpcEndpoint;
53978
+ if (typeof endpoint2 === "string") REUSE_REFUSED_ENDPOINTS.add(endpoint2);
53979
+ else REUSE_REFUSED_CONNECTIONS.add(connection);
53980
+ }
53951
53981
  function slicesRefused(connection) {
53952
53982
  const endpoint2 = connection.rpcEndpoint;
53953
53983
  return typeof endpoint2 === "string" ? SLICES_REFUSED_ENDPOINTS.has(endpoint2) : SLICES_REFUSED_CONNECTIONS.has(connection);
@@ -53961,20 +53991,41 @@ function slicesMethodMissing(error) {
53961
53991
  const message = String(error?.message ?? "");
53962
53992
  return /^(404|405|501)\b/.test(message) || /-3260[12]\b/.test(message);
53963
53993
  }
53964
- function slicedAccountBytes(value, accountIndex) {
53994
+ function slicedAccountBytes(value, accountIndex, slices = POOL_SLICES) {
53965
53995
  if (value === null || typeof value !== "object" || typeof value.owner !== "string" || !Number.isSafeInteger(value.space) || value.space < 0 || !Array.isArray(value.data) || value.data.length !== 2 || value.data[1] !== "base64" || typeof value.data[0] !== "string") {
53966
53996
  return void 0;
53967
53997
  }
53968
53998
  const bytes2 = Buffer.from(value.data[0], "base64");
53969
53999
  if (bytes2.toString("base64") !== value.data[0]) return void 0;
53970
54000
  let expected = 0;
53971
- for (const [index, offset, length] of POOL_SLICES) {
54001
+ for (const [index, offset, length] of slices) {
53972
54002
  if (index === accountIndex) expected += Math.max(0, Math.min(offset + length, value.space) - offset);
53973
54003
  }
53974
54004
  return bytes2.length === expected ? bytes2 : void 0;
53975
54005
  }
53976
- function slicedSnapshot(result, program, pool2, tree) {
53977
- if (result === null || typeof result !== "object" || !Array.isArray(result.value) || result.value.length !== 2) return void 0;
54006
+ function slicedSnapshot(result, program, pool2, tree, programData) {
54007
+ if (result === null || typeof result !== "object" || !Array.isArray(result.value) || result.value.length !== (programData === void 0 ? 2 : 3)) return void 0;
54008
+ const snapshot = slicedPoolSnapshot(result, program, pool2, tree);
54009
+ if (snapshot === void 0 || programData === void 0) return snapshot;
54010
+ const value = result.value[2];
54011
+ const data = slicedAccountBytes(value, 2, POOL_SLICES_WITH_PROGRAMDATA);
54012
+ const newest = result.newestSignature;
54013
+ if (data === void 0 || typeof value.executable !== "boolean" || newest === null || typeof newest !== "object" || typeof newest.signature !== "string" || !Number.isSafeInteger(newest.slot)) {
54014
+ return snapshot;
54015
+ }
54016
+ return withPoolStateOf(snapshot, Object.freeze({
54017
+ ...snapshot,
54018
+ programDataReuse: Object.freeze({
54019
+ slot: snapshot.slot,
54020
+ address: programData.toBase58(),
54021
+ owner: value.owner,
54022
+ executable: value.executable,
54023
+ data,
54024
+ newestSignature: newest.signature
54025
+ })
54026
+ }));
54027
+ }
54028
+ function slicedPoolSnapshot(result, program, pool2, tree) {
53978
54029
  const [poolValue, treeValue] = result.value;
53979
54030
  const poolBytes2 = slicedAccountBytes(poolValue, 0);
53980
54031
  if (poolBytes2 === void 0 || poolValue.space > REFRESH_READ_BYTES) return void 0;
@@ -54003,22 +54054,37 @@ function slicedSnapshot(result, program, pool2, tree) {
54003
54054
  async function readFinalizedPoolSliced(connection, program, pool2) {
54004
54055
  if (typeof connection._rpcRequest !== "function" || slicesRefused(connection)) return void 0;
54005
54056
  const tree = new import_web396.PublicKey(e1TreeAddress2(b58(pool2), b58(program)));
54057
+ const programData = reuseOptionRefused(connection) ? void 0 : programDataAddressOf(program);
54058
+ const params = programData === void 0 ? [[b58(pool2), tree.toBase58()], { commitment: "finalized", slices: POOL_SLICES }] : [
54059
+ [b58(pool2), tree.toBase58(), programData.toBase58()],
54060
+ { commitment: "finalized", slices: POOL_SLICES_WITH_PROGRAMDATA, newestSignature: 2 }
54061
+ ];
54006
54062
  let response;
54007
54063
  try {
54008
- response = await connection._rpcRequest(P03_POOL_SLICES_METHOD, [[b58(pool2), tree.toBase58()], { commitment: "finalized", slices: POOL_SLICES }]);
54064
+ response = await connection._rpcRequest(P03_POOL_SLICES_METHOD, params);
54009
54065
  } catch (error) {
54066
+ if (programData !== void 0 && /-32602\b/.test(String(error?.message ?? ""))) {
54067
+ rememberReuseOptionRefused(connection);
54068
+ markPhase("pool-sliced-reuse-refused");
54069
+ return readFinalizedPoolSliced(connection, program, pool2);
54070
+ }
54010
54071
  if (slicesMethodMissing(error)) rememberSlicesRefused(connection);
54011
54072
  markPhase(`pool-sliced-fallback-${reuseRefusalCause(error)}`);
54012
54073
  return void 0;
54013
54074
  }
54014
54075
  if (response?.error !== void 0) {
54076
+ if (programData !== void 0 && response.error?.code === -32602) {
54077
+ rememberReuseOptionRefused(connection);
54078
+ markPhase("pool-sliced-reuse-refused");
54079
+ return readFinalizedPoolSliced(connection, program, pool2);
54080
+ }
54015
54081
  if (response.error?.code === -32601 || response.error?.code === -32602) rememberSlicesRefused(connection);
54016
54082
  markPhase("pool-sliced-fallback-refused");
54017
54083
  return void 0;
54018
54084
  }
54019
54085
  let snapshot;
54020
54086
  try {
54021
- snapshot = slicedSnapshot(response?.result, program, pool2, tree);
54087
+ snapshot = slicedSnapshot(response?.result, program, pool2, tree, programData);
54022
54088
  } catch {
54023
54089
  snapshot = void 0;
54024
54090
  }
@@ -54129,13 +54195,14 @@ async function readProgramDataHeader({ connection, address: address5, snapshotSl
54129
54195
  minContextSlot: snapshotSlot,
54130
54196
  dataSlice: { offset: 0, length: 45 }
54131
54197
  }));
54132
- const observedSlot = safeSlot(account2?.context?.slot, "programdata_snapshot_slot");
54133
- const value = account2?.value;
54198
+ assertProgramDataHeader(safeSlot(account2?.context?.slot, "programdata_snapshot_slot"), account2?.value, { snapshotSlot, deployedAtSlot });
54199
+ }
54200
+ function assertProgramDataHeader(observedSlot, value, { snapshotSlot, deployedAtSlot }) {
54134
54201
  if (observedSlot < snapshotSlot || !value || !canonicalKey(value.owner, "programdata_owner").equals(BPF_LOADER_UPGRADEABLE_PROGRAM_ID) || value.executable === true) {
54135
54202
  throw new Error("p03_history_programdata_account_invalid");
54136
54203
  }
54137
54204
  const data = Buffer.from(value.data);
54138
- if (data.length < 45 || data.readUInt32LE(0) !== 3 || data.readBigUInt64LE(4) !== deployedAtSlot) {
54205
+ if (data.length < PROGRAMDATA_HEADER_BYTES || data.readUInt32LE(0) !== 3 || data.readBigUInt64LE(4) !== deployedAtSlot) {
54139
54206
  throw new Error("p03_history_programdata_identity_invalid");
54140
54207
  }
54141
54208
  }
@@ -54204,7 +54271,11 @@ async function programDataCoverageFor({
54204
54271
  // so one RPC answers both, at or after snapshotSlot, with no history-source floor below it
54205
54272
  // (2026-10-16 c1s: the signature read on the proxy cost a -32016 retry, about 0.2 s).
54206
54273
  // The full attestation and its newest signature keep `connection`. Absent: `connection`.
54207
- reuseConnection = connection
54274
+ reuseConnection = connection,
54275
+ // The pool snapshot's `programDataReuse` (readFinalizedPoolSliced, 2026-10-22): the same two facts
54276
+ // from the same RPC as the pool account, at its slot. Used instead of the two reads only when it
54277
+ // is at `snapshotSlot` and names the cached attestation's address; checked exactly as they are.
54278
+ reuseAnswer
54208
54279
  }) {
54209
54280
  if (deploymentIdentity === void 0) return { coverage: void 0, attestation: void 0, reused: false };
54210
54281
  let priorRefused = false;
@@ -54212,27 +54283,43 @@ async function programDataCoverageFor({
54212
54283
  const key = coverageKey({ program, initialization, deploymentIdentity });
54213
54284
  if (key !== void 0 && prior?.key === key && typeof prior.newestSignature === "string" && prior.coverage?.throughFinalizedSlot <= BigInt(snapshotSlot)) {
54214
54285
  const address5 = new import_web396.PublicKey(prior.coverage.programDataAddress);
54215
- for (let attempt = 1; ; attempt += 1) {
54286
+ const deployedAtSlot = BigInt(prior.coverage.deployedAtSlot);
54287
+ const reuse = (signature2) => {
54288
+ const coverage2 = Object.freeze({ ...prior.coverage, throughFinalizedSlot: BigInt(snapshotSlot) });
54289
+ return { coverage: coverage2, attestation: { key, newestSignature: signature2, coverage: coverage2 }, reused: true };
54290
+ };
54291
+ const pooled = reuseAnswer !== void 0 && reuseAnswer.slot === snapshotSlot && reuseAnswer.address === address5.toBase58() ? reuseAnswer : void 0;
54292
+ if (pooled !== void 0) {
54216
54293
  try {
54217
- const [, newest2] = await Promise.all([
54218
- readProgramDataHeader({
54219
- connection: reuseConnection,
54220
- address: address5,
54221
- snapshotSlot,
54222
- deployedAtSlot: BigInt(prior.coverage.deployedAtSlot)
54223
- }),
54224
- newestSignature(reuseConnection, address5, snapshotSlot)
54225
- ]);
54226
- if (newest2.signature === prior.newestSignature) {
54227
- const coverage2 = Object.freeze({ ...prior.coverage, throughFinalizedSlot: BigInt(snapshotSlot) });
54228
- return { coverage: coverage2, attestation: { key, newestSignature: newest2.signature, coverage: coverage2 }, reused: true };
54294
+ assertProgramDataHeader(pooled.slot, pooled, { snapshotSlot, deployedAtSlot });
54295
+ if (pooled.newestSignature === prior.newestSignature) {
54296
+ markPhase("attest-reuse-in-pool-read");
54297
+ return reuse(pooled.newestSignature);
54229
54298
  }
54230
54299
  cause = "programdata_newest_signature_changed";
54231
- break;
54232
54300
  } catch (error) {
54233
54301
  cause = reuseRefusalCause(error);
54234
- if (attempt >= 2 || typeof onReuseRetry !== "function" || !isTransientRpcError(error)) break;
54235
- await onReuseRetry({ cause });
54302
+ }
54303
+ } else {
54304
+ for (let attempt = 1; ; attempt += 1) {
54305
+ try {
54306
+ const [, newest2] = await Promise.all([
54307
+ readProgramDataHeader({
54308
+ connection: reuseConnection,
54309
+ address: address5,
54310
+ snapshotSlot,
54311
+ deployedAtSlot
54312
+ }),
54313
+ newestSignature(reuseConnection, address5, snapshotSlot)
54314
+ ]);
54315
+ if (newest2.signature === prior.newestSignature) return reuse(newest2.signature);
54316
+ cause = "programdata_newest_signature_changed";
54317
+ break;
54318
+ } catch (error) {
54319
+ cause = reuseRefusalCause(error);
54320
+ if (attempt >= 2 || typeof onReuseRetry !== "function" || !isTransientRpcError(error)) break;
54321
+ await onReuseRetry({ cause });
54322
+ }
54236
54323
  }
54237
54324
  }
54238
54325
  priorRefused = true;
@@ -55680,7 +55767,7 @@ function base58Decode(value) {
55680
55767
  while (zeros < value.length && value[zeros] === "1") zeros += 1;
55681
55768
  return Uint8Array.from(Buffer.concat([Buffer.alloc(zeros), body]));
55682
55769
  }
55683
- var import_web396, b58Cache, b58, REPLAY_STORE_INDEXED, CLOSE_REPLAY_TREE_TAG, EXTEND_ANCHOR_RING_TAG, WIDEN_ANCHOR_RING_TAG, WIDE_ANCHOR_RING_POOL_BYTES, LINK_SUCCESSOR_TAG, IMPORT_REPLAY_LEAVES_TAG, SETTLE_MOVE_TAG, SWEEP_PREDECESSOR_VAULT_TAG, RELINK_SUCCESSOR_TAG, ROTATE_PAYMENT_SETTLER_TAG, IMPORT_A_LEAF_BYTES, IMPORT_MEMBERSHIP_BYTES, IMPORT_PRESENT_SHIFT, IMPORT_MAX_ENTRIES, MOVE_HEAD_BYTES, MOVE_INSERTED_VALUES, DEFAULT_KEY, FIELD_BYTES2, PRIMARY_PROOF_BYTES, SUBTREE_LEAVES, PAGE_SIZE, FIELD_MODULUS3, BPF_LOADER_UPGRADEABLE_PROGRAM_ID, SYSTEM_PROGRAM, TEST_EXECUTABLES, derivationMemo, memo, reviewedExecutables, isProgramDataIdentityError, ASSUMED_ORIGINAL_EXECUTABLE, AUTHENTICATED_HISTORY_REPORTS, HISTORY_ATTESTATIONS, SNAPSHOT_POOL_STATES, REPORT_POOL_STATES, hasExecutableEvidence, P03_FINALIZED_HISTORY_SOURCE_MODEL, P03_PROGRAMDATA_COVERAGE_SOURCE_MODEL, P03_RUN_RECOVER_UNAVAILABLE_FROM_CHAIN, PROFILES, P03_SETTLEMENT_TAGS, P03_INLINE_SETTLEMENT_TAGS, P03_PAYMENT_REPLAY_INDICES, NO_CONTEXTS, REFRESH_READ_BYTES, E1_TREE_HEADER_BYTES, E1_TREE_MAGIC, E1_CHANGELOG_BYTES, E1_CHANGELOGS_OFFSET, E1_RIGHTMOST_OFFSET, E1_LEAF_COUNT_OFFSET, E1_CANOPY_OFFSET, E1_CANOPY_NODES, P03_POOL_SLICES_METHOD, POOL_SLICES, SLICED_ROOTS_OFFSET, SLICED_LEAVES_OFFSET, SLICES_REFUSED_ENDPOINTS, SLICES_REFUSED_CONNECTIONS, HISTORY_FETCH_CONCURRENCY, HISTORY_BULK_TRANSACTIONS, HISTORY_BULK_ADDRESSES, TRANSIENT_RPC_ATTEMPTS, TRANSIENT_RPC_BASE_DELAY_MS, LAGGING_NODE_STEP_OF_BASE, LAGGING_NODE_MAX_RETRIES, LAGGING_NODE_FAST_RETRIES, LAGGING_NODE_SLOW_STEP_OF_BASE, LAGGING_NODE_RPC_CODES, lastVerifiedE1Tree, e1ReplayCounts, e1TreeCandidate;
55770
+ var import_web396, b58Cache, b58, REPLAY_STORE_INDEXED, CLOSE_REPLAY_TREE_TAG, EXTEND_ANCHOR_RING_TAG, WIDEN_ANCHOR_RING_TAG, WIDE_ANCHOR_RING_POOL_BYTES, LINK_SUCCESSOR_TAG, IMPORT_REPLAY_LEAVES_TAG, SETTLE_MOVE_TAG, SWEEP_PREDECESSOR_VAULT_TAG, RELINK_SUCCESSOR_TAG, ROTATE_PAYMENT_SETTLER_TAG, IMPORT_A_LEAF_BYTES, IMPORT_MEMBERSHIP_BYTES, IMPORT_PRESENT_SHIFT, IMPORT_MAX_ENTRIES, MOVE_HEAD_BYTES, MOVE_INSERTED_VALUES, DEFAULT_KEY, FIELD_BYTES2, PRIMARY_PROOF_BYTES, SUBTREE_LEAVES, PAGE_SIZE, FIELD_MODULUS3, BPF_LOADER_UPGRADEABLE_PROGRAM_ID, SYSTEM_PROGRAM, TEST_EXECUTABLES, derivationMemo, memo, reviewedExecutables, isProgramDataIdentityError, ASSUMED_ORIGINAL_EXECUTABLE, AUTHENTICATED_HISTORY_REPORTS, HISTORY_ATTESTATIONS, SNAPSHOT_POOL_STATES, REPORT_POOL_STATES, hasExecutableEvidence, P03_FINALIZED_HISTORY_SOURCE_MODEL, P03_PROGRAMDATA_COVERAGE_SOURCE_MODEL, P03_RUN_RECOVER_UNAVAILABLE_FROM_CHAIN, PROFILES, P03_SETTLEMENT_TAGS, P03_INLINE_SETTLEMENT_TAGS, P03_PAYMENT_REPLAY_INDICES, NO_CONTEXTS, REFRESH_READ_BYTES, E1_TREE_HEADER_BYTES, E1_TREE_MAGIC, E1_CHANGELOG_BYTES, E1_CHANGELOGS_OFFSET, E1_RIGHTMOST_OFFSET, E1_LEAF_COUNT_OFFSET, E1_CANOPY_OFFSET, E1_CANOPY_NODES, P03_POOL_SLICES_METHOD, POOL_SLICES, PROGRAMDATA_HEADER_BYTES, POOL_SLICES_WITH_PROGRAMDATA, SLICED_ROOTS_OFFSET, SLICED_LEAVES_OFFSET, SLICES_REFUSED_ENDPOINTS, SLICES_REFUSED_CONNECTIONS, REUSE_REFUSED_ENDPOINTS, REUSE_REFUSED_CONNECTIONS, PROGRAMDATA_ADDRESSES, HISTORY_FETCH_CONCURRENCY, HISTORY_BULK_TRANSACTIONS, HISTORY_BULK_ADDRESSES, TRANSIENT_RPC_ATTEMPTS, TRANSIENT_RPC_BASE_DELAY_MS, LAGGING_NODE_STEP_OF_BASE, LAGGING_NODE_MAX_RETRIES, LAGGING_NODE_FAST_RETRIES, LAGGING_NODE_SLOW_STEP_OF_BASE, LAGGING_NODE_RPC_CODES, lastVerifiedE1Tree, e1ReplayCounts, e1TreeCandidate;
55684
55771
  var init_walk = __esm({
55685
55772
  "wallet/src/history/walk.mjs"() {
55686
55773
  "use strict";
@@ -55955,10 +56042,15 @@ var init_walk = __esm({
55955
56042
  ...Array.from({ length: E1.bufferSize }, (_, index) => Object.freeze([1, E1_CHANGELOGS_OFFSET + E1_CHANGELOG_BYTES * index, 32])),
55956
56043
  Object.freeze([1, E1_LEAF_COUNT_OFFSET, 4])
55957
56044
  ]);
56045
+ PROGRAMDATA_HEADER_BYTES = 45;
56046
+ POOL_SLICES_WITH_PROGRAMDATA = Object.freeze([...POOL_SLICES, Object.freeze([2, 0, PROGRAMDATA_HEADER_BYTES])]);
55958
56047
  SLICED_ROOTS_OFFSET = E1_TREE_HEADER_BYTES;
55959
56048
  SLICED_LEAVES_OFFSET = SLICED_ROOTS_OFFSET + 32 * E1.bufferSize;
55960
56049
  SLICES_REFUSED_ENDPOINTS = /* @__PURE__ */ new Set();
55961
56050
  SLICES_REFUSED_CONNECTIONS = /* @__PURE__ */ new WeakSet();
56051
+ REUSE_REFUSED_ENDPOINTS = /* @__PURE__ */ new Set();
56052
+ REUSE_REFUSED_CONNECTIONS = /* @__PURE__ */ new WeakSet();
56053
+ PROGRAMDATA_ADDRESSES = /* @__PURE__ */ new Map();
55962
56054
  HISTORY_FETCH_CONCURRENCY = 4;
55963
56055
  HISTORY_BULK_TRANSACTIONS = 256;
55964
56056
  HISTORY_BULK_ADDRESSES = 256;
@@ -57839,6 +57931,8 @@ async function compactP03HistoryReportRun({
57839
57931
  getAccountInfoAndContext: (...args) => boundedOwnRead(() => own.getAccountInfoAndContext(...args)),
57840
57932
  getSignaturesForAddress: (...args) => boundedOwnRead(() => own.getSignaturesForAddress(...args))
57841
57933
  }))(connection.historyRpcOwnConnection) },
57934
+ // The same two facts from the pool account's own read, when it carried them (readFinalizedPoolSliced).
57935
+ ...snapshot2.programDataReuse === void 0 ? {} : { reuseAnswer: snapshot2.programDataReuse },
57842
57936
  program,
57843
57937
  initialization: initialization2,
57844
57938
  snapshotSlot: snapshot2.slot,
@@ -59082,13 +59176,23 @@ async function waitForCompactSource(source, pool2, slot3, budgetMs) {
59082
59176
  const until = Date.now() + budgetMs;
59083
59177
  for (; ; ) {
59084
59178
  const abort = new AbortController();
59179
+ let answerBytes;
59085
59180
  const params = [pool2, { commitment: "finalized", fromOrdinal: 0, toOrdinal: P03_COMPACT_PAGE, minContextSlot: slot3 }];
59086
- const read = (typeof source.abortableRpcRequest === "function" ? source.abortableRpcRequest("getP03Transitions", params, abort.signal) : source._rpcRequest("getP03Transitions", params)).catch(() => ({ failed: true }));
59181
+ const read = (typeof source.abortableRpcRequest === "function" ? source.abortableRpcRequest("getP03Transitions", params, abort.signal, ({ contentLength }) => {
59182
+ answerBytes = contentLength;
59183
+ }) : source._rpcRequest("getP03Transitions", params)).catch(() => ({ failed: true }));
59087
59184
  let timer;
59088
- const answer = await Promise.race([read, new Promise((resolve38) => {
59185
+ let answer = await Promise.race([read, new Promise((resolve38) => {
59089
59186
  timer = setTimeout(resolve38, Math.max(inTorRun() ? COMPACT_BEHIND_TOR_READ_MS : COMPACT_BEHIND_READ_MS, until - Date.now()));
59090
59187
  })]);
59091
59188
  clearTimeout(timer);
59189
+ if (answer === void 0 && answerBytes > COMPACT_BEHIND_REFUSAL_MAX_BYTES) {
59190
+ markPhase("compact-behind-page-coming");
59191
+ answer = await Promise.race([read, new Promise((resolve38) => {
59192
+ timer = setTimeout(resolve38, COMPACT_BEHIND_PAGE_BODY_MS);
59193
+ })]);
59194
+ clearTimeout(timer);
59195
+ }
59092
59196
  if (answer === void 0) abort.abort();
59093
59197
  if (answer?.result !== void 0) {
59094
59198
  markPhase("compact-behind-caught-up");
@@ -59149,7 +59253,7 @@ function reportHistoryRpc(split5, source, result, crossChecked) {
59149
59253
  writeStderr(`history: ${who} answered ${list(split5.history)}; your own RPC answered ${list(split5.own)} (the pool account the history must match, and the cross-check)${window2}${integrity}
59150
59254
  `);
59151
59255
  }
59152
- var prepareReport, strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, proofBuiltAt, historyCacheKey, latestPrewarm, HOME_MARKS_SETTLED_MS, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, isPrewarmedWalletHistory, REPORT_STARTED_AT, walkStartedAtOf, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
59256
+ var prepareReport, strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, proofBuiltAt, historyCacheKey, latestPrewarm, HOME_MARKS_SETTLED_MS, HISTORY_PREWARM_JOIN_MS, SHARED_WALK_WAIT_MS, PAGE0_PREREAD_AFTER_MS, SUBTREE_LEAVES4, prewarmedWalks, sharedWalks, PREWARMED_REPORTS, PAYMENT_TAKEN_REPORTS, isPrewarmedWalletHistory, REPORT_STARTED_AT, walkStartedAtOf, COMPACT_BEHIND_POLL_MS, COMPACT_BEHIND_READ_MS, COMPACT_BEHIND_TOR_READ_MS, COMPACT_BEHIND_REFUSAL_MAX_BYTES, COMPACT_BEHIND_PAGE_BODY_MS, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
59153
59257
  var init_walletHistory = __esm({
59154
59258
  "wallet/src/history/walletHistory.mjs"() {
59155
59259
  "use strict";
@@ -59192,6 +59296,8 @@ var init_walletHistory = __esm({
59192
59296
  COMPACT_BEHIND_POLL_MS = 150;
59193
59297
  COMPACT_BEHIND_READ_MS = 1e3;
59194
59298
  COMPACT_BEHIND_TOR_READ_MS = 5e3;
59299
+ COMPACT_BEHIND_REFUSAL_MAX_BYTES = 8192;
59300
+ COMPACT_BEHIND_PAGE_BODY_MS = HISTORY_RPC_REQUEST_TIMEOUT_MS;
59195
59301
  COMPACT_BEHIND_RETRY_MS = [500, 1e3, 2e3, 5e3];
59196
59302
  lastRunReports = /* @__PURE__ */ new Map();
59197
59303
  writeStderr = (text3) => {
@@ -97639,7 +97745,7 @@ async function payResourceOnce({
97639
97745
  mark("challenge");
97640
97746
  }
97641
97747
  const { requirement, recipient } = validateChallenge(record.paymentRequired, store, url, maximumAtomic, method);
97642
- const chainTime2 = await (chainTimeRead ?? startFinalizedChainTime(connection))();
97748
+ const chainTime2 = await withPhaseScope(mark, "quote", () => (chainTimeRead ?? startFinalizedChainTime(connection))());
97643
97749
  chainTimeRead = void 0;
97644
97750
  if (!requoted && Number.isSafeInteger(chainTime2) && Number(requirement.extra.validBefore) - chainTime2 < QUOTE_MARGIN_SECONDS && store.readWal(`resource-proof-${requestKey}`)?.proved === void 0) {
97645
97751
  requote();