@across-protocol/sdk 4.3.145-alpha.2 → 4.3.145-alpha.4

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.
Files changed (43) hide show
  1. package/dist/cjs/src/caching/Arweave/ArweaveClient.d.ts +2 -0
  2. package/dist/cjs/src/caching/Arweave/ArweaveClient.js +116 -40
  3. package/dist/cjs/src/caching/Arweave/ArweaveClient.js.map +1 -1
  4. package/dist/cjs/src/clients/BundleDataClient/BundleDataClient.d.ts +5 -2
  5. package/dist/cjs/src/clients/BundleDataClient/BundleDataClient.js +74 -10
  6. package/dist/cjs/src/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  7. package/dist/cjs/src/coingecko/Coingecko.js +2 -9
  8. package/dist/cjs/src/coingecko/Coingecko.js.map +1 -1
  9. package/dist/cjs/src/utils/CachingUtils.d.ts +1 -0
  10. package/dist/cjs/src/utils/CachingUtils.js +4 -0
  11. package/dist/cjs/src/utils/CachingUtils.js.map +1 -1
  12. package/dist/cjs/src/utils/common.d.ts +1 -24
  13. package/dist/cjs/src/utils/common.js +8 -33
  14. package/dist/cjs/src/utils/common.js.map +1 -1
  15. package/dist/esm/src/caching/Arweave/ArweaveClient.d.ts +2 -0
  16. package/dist/esm/src/caching/Arweave/ArweaveClient.js +117 -47
  17. package/dist/esm/src/caching/Arweave/ArweaveClient.js.map +1 -1
  18. package/dist/esm/src/clients/BundleDataClient/BundleDataClient.d.ts +5 -2
  19. package/dist/esm/src/clients/BundleDataClient/BundleDataClient.js +77 -13
  20. package/dist/esm/src/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  21. package/dist/esm/src/coingecko/Coingecko.js +2 -9
  22. package/dist/esm/src/coingecko/Coingecko.js.map +1 -1
  23. package/dist/esm/src/utils/CachingUtils.d.ts +1 -0
  24. package/dist/esm/src/utils/CachingUtils.js +3 -0
  25. package/dist/esm/src/utils/CachingUtils.js.map +1 -1
  26. package/dist/esm/src/utils/common.d.ts +6 -55
  27. package/dist/esm/src/utils/common.js +15 -32
  28. package/dist/esm/src/utils/common.js.map +1 -1
  29. package/dist/types/src/caching/Arweave/ArweaveClient.d.ts +2 -0
  30. package/dist/types/src/caching/Arweave/ArweaveClient.d.ts.map +1 -1
  31. package/dist/types/src/clients/BundleDataClient/BundleDataClient.d.ts +5 -2
  32. package/dist/types/src/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  33. package/dist/types/src/coingecko/Coingecko.d.ts.map +1 -1
  34. package/dist/types/src/utils/CachingUtils.d.ts +1 -0
  35. package/dist/types/src/utils/CachingUtils.d.ts.map +1 -1
  36. package/dist/types/src/utils/common.d.ts +6 -55
  37. package/dist/types/src/utils/common.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/caching/Arweave/ArweaveClient.ts +142 -54
  40. package/src/clients/BundleDataClient/BundleDataClient.ts +86 -17
  41. package/src/coingecko/Coingecko.ts +2 -9
  42. package/src/utils/CachingUtils.ts +4 -0
  43. package/src/utils/common.ts +14 -93
@@ -26,6 +26,8 @@ export declare class ArweaveClient {
26
26
  */
27
27
  private _failoverGateways;
28
28
  private _retryRequest;
29
+ private _isNotFoundError;
30
+ private _wrapWriteError;
29
31
  /**
30
32
  * Stores an arbitrary record in the Arweave network. The record is stored as a JSON string and uses
31
33
  * JSON.stringify to convert the record to a string. The record has all of its big numbers converted
@@ -1 +1 @@
1
- {"version":3,"file":"ArweaveClient.d.ts","sourceRoot":"","sources":["../../../../../src/caching/Arweave/ArweaveClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAU,MAAM,aAAa,CAAC;AAC7C,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAwE,MAAM,aAAa,CAAC;AAE9G,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;I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AC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAoB5E;;;;;;;;;;;OAWG;IACG,UAAU,CAAC,CAAC,EAChB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,EACpB,kBAAkB,SAAkC,GACnD,OAAO,CAAC;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAyEvC;;;;OAIG;IACG,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAoBhF;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;CAkBvC"}
@@ -1,4 +1,4 @@
1
- import { SpokePoolClientsByChain, LoadDataReturnValue, Clients, FillWithBlock, DepositWithBlock } from "../../interfaces";
1
+ import { SpokePoolClientsByChain, LoadDataReturnValue, Clients, FillWithBlock, DepositWithBlock, CachingMechanismInterface } from "../../interfaces";
2
2
  import { SpokePoolClient } from "..";
3
3
  import winston from "winston";
4
4
  import { SpokePoolManager } from "../SpokePoolClient/SpokePoolClientManager";
@@ -9,6 +9,7 @@ export declare class BundleDataClient {
9
9
  readonly blockRangeEndBlockBuffer: {
10
10
  [chainId: number]: number;
11
11
  };
12
+ readonly arweaveTopicCache?: CachingMechanismInterface | undefined;
12
13
  private loadDataCache;
13
14
  private arweaveDataCache;
14
15
  private bundleTimestampCache;
@@ -17,7 +18,7 @@ export declare class BundleDataClient {
17
18
  [chainId: number]: SpokePoolClient;
18
19
  }, chainIdListForBundleEvaluationBlockNumbers: number[], blockRangeEndBlockBuffer?: {
19
20
  [chainId: number]: number;
20
- });
21
+ }, arweaveTopicCache?: CachingMechanismInterface | undefined);
21
22
  clearCache(): void;
22
23
  private loadDataFromCache;
23
24
  getBundleTimestampsFromCache(key: string): undefined | {
@@ -28,6 +29,8 @@ export declare class BundleDataClient {
28
29
  }): void;
29
30
  static getArweaveClientKey(blockRangesForChains: number[][]): string;
30
31
  private getArweaveBundleDataClientKey;
32
+ private getPersistedArweaveTopicFromCache;
33
+ private backfillPersistedArweaveTopicCache;
31
34
  private loadPersistedDataFromArweave;
32
35
  private loadArweaveData;
33
36
  loadData(blockRangesForChains: number[][], spokePoolClients: SpokePoolClientsByChain, attemptArweaveLoad?: boolean): Promise<LoadDataReturnValue>;
@@ -1 +1 @@
1
- {"version":3,"file":"BundleDataClient.d.ts","sourceRoot":"","sources":["../../../../../src/clients/BundleDataClient/BundleDataClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,uBAAuB,EAGvB,mBAAmB,EAOnB,OAAO,EACP,aAAa,EAEb,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AA0BrC,OAAO,OAAO,MAAM,SAAS,CAAC;AAY9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAgG7E,qBAAa,gBAAgB;IASzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO;IAEzB,QAAQ,CAAC,0CAA0C,EAAE,MAAM,EAAE;IAC7D,QAAQ,CAAC,wBAAwB,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAZlE,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,gBAAgB,CAAgE;IAExF,OAAO,CAAC,oBAAoB,CAAuD;IACnF,QAAQ,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;gBAIvC,MAAM,EAAE,OAAO,CAAC,MAAM,EACtB,OAAO,EAAE,OAAO,EACzB,gBAAgB,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,EAC/C,0CAA0C,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,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,SAAS;IAU7G,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAwBhH,SAAS,CAAC,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;YAuB5E,UAAU;YAOV,QAAQ;CAIvB"}
@@ -15,4 +15,5 @@ export declare function setDepositInCache(deposit: Deposit, currentChainTime: nu
15
15
  * @returns The key for caching the event.
16
16
  */
17
17
  export declare function getDepositKey(bridgeEvent: Deposit | Fill | SlowFillRequest): string;
18
+ export declare function getArweaveTopicCacheKey(tag: string): string;
18
19
  //# sourceMappingURL=CachingUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CachingUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/CachingUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO1F,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAItG;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAGnH;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,yBAAyB,EAChC,aAAa,SAAsB,EACnC,WAAW,SAA2B,GACrC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,eAAe,GAAG,MAAM,CAGnF"}
1
+ {"version":3,"file":"CachingUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/CachingUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAO1F,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAItG;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAGnH;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,yBAAyB,EAChC,aAAa,SAAsB,EACnC,WAAW,SAA2B,GACrC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,eAAe,GAAG,MAAM,CAGnF;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3D"}
@@ -1,7 +1,6 @@
1
1
  import Decimal from "decimal.js";
2
2
  import bs58 from "bs58";
3
3
  import { ethers } from "ethers";
4
- import { Struct } from "superstruct";
5
4
  import { BigNumber, BigNumberish, BN } from "./BigNumberUtils";
6
5
  export type Decimalish = string | number | Decimal;
7
6
  export declare const AddressZero = "0x0000000000000000000000000000000000000000";
@@ -121,61 +120,13 @@ export declare const getSamplesBetween: (min: number, max: number, size: number)
121
120
  */
122
121
  export declare function delay(seconds: number): Promise<unknown>;
123
122
  /**
124
- * Discriminated union for operations that can fail. Callers narrow on `.ok`: success
125
- * carries `value`, failure carries the original `error` for inspection. Avoids the
126
- * control-flow cost of try/catch at call sites that want to handle failure as data.
123
+ * Attempt to retry a function call a number of times with a delay between each attempt
124
+ * @param call The function to call
125
+ * @param times The number of times to retry
126
+ * @param delayS The number of seconds to delay between each attempt
127
+ * @returns The result of the function call.
127
128
  */
128
- export type Result<T, E = Error> = {
129
- ok: true;
130
- value: T;
131
- } | {
132
- ok: false;
133
- error: E;
134
- };
135
- /**
136
- * Configures a single {@link attempt}. `schema`, when supplied, runs the successful value
137
- * through `create(value, schema)` before wrapping — validation failures surface as a
138
- * `{ ok: false }` Result like any other throw.
139
- */
140
- export type AttemptOptions<T = unknown> = {
141
- schema?: Struct<T>;
142
- };
143
- /**
144
- * Configures the outer loop of {@link retry}. Backoff is always exponential
145
- * (`delaySeconds * 2 ** attempt + random()` seconds) to play nicely with upstream
146
- * rate-limits; callers that want tighter spacing should lower {@link delaySeconds}.
147
- */
148
- export type RetryOptions = {
149
- /** Maximum number of retry attempts after the initial call (total attempts = retries + 1). Defaults to 2 (3 total tries). */
150
- retries?: number;
151
- /** Base delay in seconds for the exponential backoff. Defaults to 1. */
152
- delaySeconds?: number;
153
- /** Predicate evaluated against the thrown error to decide whether to retry. Defaults to retrying every error. */
154
- isRetryable?: (err: unknown) => boolean;
155
- };
156
- /**
157
- * Run a failable operation once, catching throws and returning a {@link Result}. When
158
- * `schema` is supplied, the successful value is validated via `create(value, schema)`
159
- * before being wrapped; a failed validation lands in `{ ok: false, error }` with the
160
- * superstruct error preserved.
161
- */
162
- export declare function attempt<T>(call: () => Promise<unknown>, options: AttemptOptions<T> & {
163
- schema: Struct<T>;
164
- }): Promise<Result<T>>;
165
- export declare function attempt<T>(call: () => Promise<T>, options?: AttemptOptions): Promise<Result<T>>;
166
- /**
167
- * Loop {@link attempt} with exponential backoff until success or a terminal failure —
168
- * exhausted retry budget or a failure rejected by `isRetryable`. The inner attempt's
169
- * validation (via `schema`) participates in the retry budget; a malformed response is
170
- * retried unless `isRetryable` opts out.
171
- * @param call The function to call on each attempt.
172
- * @param options Retry + attempt configuration (see {@link RetryOptions}, {@link AttemptOptions}).
173
- * @returns A `Result<T>` wrapping the terminal outcome.
174
- */
175
- export declare function retry<T>(call: () => Promise<unknown>, options: RetryOptions & AttemptOptions<T> & {
176
- schema: Struct<T>;
177
- }): Promise<Result<T>>;
178
- export declare function retry<T>(call: () => Promise<T>, options?: RetryOptions): Promise<Result<T>>;
129
+ export declare function retry<T>(call: () => Promise<T>, times: number, delayS: number): Promise<T>;
179
130
  export type TransactionCostEstimate = {
180
131
  nativeGasCost: BigNumber;
181
132
  tokenGasCost: BigNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAiC,MAAM,kBAAkB,CAAC;AAG9F,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AACnD,eAAO,MAAM,WAAW,+CAA+B,CAAC;AACxD,eAAO,MAAM,WAAW,kBAAqD,CAAC;AAE9E,eAAO,MAAQ,SAAS,+BAAiB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,CAAC;AAEhB;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,YAAY,EAAE,WAAW,MAAM,KAAG,EAU9D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,YAAY,EAAE,WAAW,MAAM,KAAG,MAA+C,CAAC;AAE/G;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,EAAE,CAIxD;AACD;;;;;;GA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AAC,OAAO,EAAE,MAAM,oBAEpC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ1F;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,SAAS,CAAC;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,SAAS,CAAC;CAC9B,CAAC;AAEF,wBAAgB,aAAa,WAE5B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@across-protocol/sdk",
3
3
  "author": "UMA Team",
4
- "version": "4.3.145-alpha.2",
4
+ "version": "4.3.145-alpha.4",
5
5
  "license": "AGPL-3.0",
6
6
  "homepage": "https://docs.across.to/reference/sdk",
7
7
  "repository": {
@@ -1,10 +1,20 @@
1
1
  import Arweave from "arweave";
2
+ import Transaction from "arweave/node/lib/transaction";
2
3
  import { JWKInterface } from "arweave/node/lib/wallet";
3
4
 
4
5
  import { Struct, create } from "superstruct";
5
6
  import winston from "winston";
6
7
  import { ARWEAVE_TAG_APP_NAME, ARWEAVE_TAG_APP_VERSION, DEFAULT_ARWEAVE_STORAGE_ADDRESS } from "../../constants";
7
- import { BigNumber, delay, fetchWithTimeout, isDefined, jsonReplacerWithBigNumbers, toBN } from "../../utils";
8
+ import {
9
+ BigNumber,
10
+ delay,
11
+ fetchWithTimeout,
12
+ isDefined,
13
+ isHttpError,
14
+ jsonReplacerWithBigNumbers,
15
+ postWithTimeout,
16
+ toBN,
17
+ } from "../../utils";
8
18
 
9
19
  export interface ArweaveGatewayConfig {
10
20
  host: string;
@@ -19,6 +29,28 @@ interface Gateway {
19
29
  url: string;
20
30
  }
21
31
 
32
+ interface GraphQLTransactionsResponse {
33
+ data?: {
34
+ transactions?: {
35
+ edges?: { node: { id: string } }[];
36
+ };
37
+ };
38
+ }
39
+
40
+ type WritePhase = "createTransaction" | "sign" | "post";
41
+
42
+ class ArweaveWriteError extends Error {
43
+ constructor(
44
+ message: string,
45
+ readonly phase: WritePhase,
46
+ readonly gateway: string,
47
+ readonly status?: number
48
+ ) {
49
+ super(message);
50
+ this.name = "ArweaveWriteError";
51
+ }
52
+ }
53
+
22
54
  export class ArweaveClient {
23
55
  private gateways: Gateway[];
24
56
 
@@ -69,16 +101,20 @@ export class ArweaveClient {
69
101
  * Tries gateways sequentially, returning the first successful response.
70
102
  * Used for write operations where we want exactly one successful submission.
71
103
  */
72
- private async _failoverGateways<T>(label: string, fn: (gw: Gateway) => Promise<T>): Promise<T> {
104
+ private async _failoverGateways<T>(label: string, fn: (gw: Gateway, attempt: number) => Promise<T>): Promise<T> {
73
105
  const errors: Error[] = [];
74
- for (const gw of this.gateways) {
106
+ for (const [index, gw] of this.gateways.entries()) {
75
107
  try {
76
- return await this._retryRequest(() => fn(gw), 0);
108
+ return await this._retryRequest(() => fn(gw, index + 1), 0);
77
109
  } catch (e) {
78
- errors.push(e as Error);
110
+ const error = e instanceof Error ? e : new Error(String(e));
111
+ errors.push(error);
79
112
  this.logger.debug({
80
113
  at: "ArweaveClient:failoverGateways",
81
- message: `Gateway ${gw.url} failed for ${label}, trying next: ${e}`,
114
+ message: `Gateway ${gw.url} failed for ${label}, trying next gateway`,
115
+ gateway: gw.url,
116
+ attempt: index + 1,
117
+ error: String(error),
82
118
  });
83
119
  }
84
120
  }
@@ -107,6 +143,25 @@ export class ArweaveClient {
107
143
  }
108
144
  }
109
145
 
146
+ private _isNotFoundError(error: unknown): boolean {
147
+ if (isHttpError(error)) {
148
+ return error.status === 404;
149
+ }
150
+ const message = error instanceof Error ? error.message : String(error);
151
+ return /404/i.test(message);
152
+ }
153
+
154
+ private _wrapWriteError(error: unknown, phase: WritePhase, gateway: string): ArweaveWriteError {
155
+ if (error instanceof ArweaveWriteError) {
156
+ return error;
157
+ }
158
+ if (isHttpError(error)) {
159
+ return new ArweaveWriteError(error.message, phase, gateway, error.status);
160
+ }
161
+ const message = error instanceof Error ? error.message : String(error);
162
+ return new ArweaveWriteError(message, phase, gateway);
163
+ }
164
+
110
165
  /**
111
166
  * Stores an arbitrary record in the Arweave network. The record is stored as a JSON string and uses
112
167
  * JSON.stringify to convert the record to a string. The record has all of its big numbers converted
@@ -116,49 +171,66 @@ export class ArweaveClient {
116
171
  * @returns The transaction ID of the stored value
117
172
  */
118
173
  async set(value: Record<string, unknown>, topicTag?: string | undefined): Promise<string | undefined> {
119
- // Get a template client to use for creating a transaction. Since clients are equal up to the gateway URL,
120
- // it does not matter which gateway is used, so we just choose the first one.
121
- const templateClient = this.gateways[0].client;
122
- const transaction = await templateClient.createTransaction(
123
- { data: JSON.stringify(value, jsonReplacerWithBigNumbers) },
124
- this.arweaveJWT
125
- );
174
+ const payload = JSON.stringify(value, jsonReplacerWithBigNumbers);
175
+ let signedTransaction: Transaction | undefined;
126
176
 
127
- // Add tags to the transaction
128
- transaction.addTag("Content-Type", "application/json");
129
- transaction.addTag("App-Name", ARWEAVE_TAG_APP_NAME);
130
- transaction.addTag("App-Version", ARWEAVE_TAG_APP_VERSION.toString());
131
- if (isDefined(topicTag)) {
132
- transaction.addTag("Topic", topicTag);
133
- }
177
+ try {
178
+ return await this._failoverGateways("set", async ({ client, url }, attempt) => {
179
+ if (!signedTransaction) {
180
+ let createdTransaction: Transaction;
181
+ try {
182
+ createdTransaction = await client.createTransaction({ data: payload }, this.arweaveJWT);
183
+ } catch (error) {
184
+ throw this._wrapWriteError(error, "createTransaction", url);
185
+ }
186
+
187
+ createdTransaction.addTag("Content-Type", "application/json");
188
+ createdTransaction.addTag("App-Name", ARWEAVE_TAG_APP_NAME);
189
+ createdTransaction.addTag("App-Version", ARWEAVE_TAG_APP_VERSION.toString());
190
+ if (isDefined(topicTag)) {
191
+ createdTransaction.addTag("Topic", topicTag);
192
+ }
193
+
194
+ try {
195
+ await client.transactions.sign(createdTransaction, this.arweaveJWT);
196
+ } catch (error) {
197
+ throw this._wrapWriteError(error, "sign", url);
198
+ }
199
+
200
+ signedTransaction = createdTransaction;
201
+ }
134
202
 
135
- // Sign the transaction
136
- await templateClient.transactions.sign(transaction, this.arweaveJWT);
137
- // Send the transaction
203
+ let result: Awaited<ReturnType<Arweave["transactions"]["post"]>>;
204
+ try {
205
+ result = await client.transactions.post(signedTransaction);
206
+ } catch (error) {
207
+ throw this._wrapWriteError(error, "post", url);
208
+ }
138
209
 
139
- return await this._failoverGateways("set", async ({ client }) => {
140
- const result = await client.transactions.post(transaction);
210
+ if (result.status !== 200) {
211
+ const message = result?.data?.error?.msg ?? result.statusText ?? `HTTP ${result.status}`;
212
+ throw new ArweaveWriteError(message, "post", url, result.status);
213
+ }
141
214
 
142
- // Ensure that the result is successful
143
- if (result.status !== 200) {
144
- const message = result?.data?.error?.msg ?? "Unknown error";
145
- this.logger.error({
215
+ this.logger.debug({
146
216
  at: "ArweaveClient:set",
147
- message,
148
- result,
149
- txn: transaction.id,
150
- address: await this.getAddress(),
151
- balance: (await this.getBalance()).toString(),
217
+ message: `Arweave transaction posted with ${signedTransaction.id}`,
218
+ gateway: url,
219
+ attempt,
220
+ phase: "post",
221
+ txn: signedTransaction.id,
152
222
  });
153
- throw new Error(message);
154
- }
155
-
156
- this.logger.debug({
223
+ return signedTransaction.id;
224
+ });
225
+ } catch (error) {
226
+ this.logger.error({
157
227
  at: "ArweaveClient:set",
158
- message: `Arweave transaction posted with ${transaction.id}`,
228
+ message: "Failed to persist data to Arweave after exhausting all gateways",
229
+ topicTag,
230
+ error: String(error),
159
231
  });
160
- return transaction.id;
161
- });
232
+ throw error;
233
+ }
162
234
  }
163
235
 
164
236
  /**
@@ -218,17 +290,11 @@ export class ArweaveClient {
218
290
  ) { edges { node { id } } }
219
291
  }`;
220
292
 
221
- const response = await this._raceGateways("getByTopic", async ({ client }) => {
222
- const response = await client.api.post<{
223
- data: { transactions: { edges: { node: { id: string } }[] } };
224
- }>("/graphql", { query });
225
- if (!response.ok) {
226
- throw new Error(`Arweave GraphQL request failed with status ${response.status}`);
227
- }
228
- return response;
293
+ const response = await this._raceGateways("getByTopic", async ({ url }) => {
294
+ return await postWithTimeout<GraphQLTransactionsResponse>(`${url}/graphql`, { query }, {}, {}, 20_000);
229
295
  });
230
296
 
231
- const entries = response?.data?.data?.transactions?.edges ?? [];
297
+ const entries = response?.data?.transactions?.edges ?? [];
232
298
  this.logger.debug({
233
299
  at: "ArweaveClient:getByTopic",
234
300
  message: `Retrieved ${entries.length} matching transactions from Arweave`,
@@ -239,6 +305,7 @@ export class ArweaveClient {
239
305
  appVersion: ARWEAVE_TAG_APP_VERSION,
240
306
  },
241
307
  });
308
+ const failures: { hash: string; error: unknown }[] = [];
242
309
  const results = await Promise.all(
243
310
  entries.map(async (edge) => {
244
311
  try {
@@ -250,14 +317,35 @@ export class ArweaveClient {
250
317
  }
251
318
  : null;
252
319
  } catch (e) {
253
- this.logger.warn({
254
- at: "ArweaveClient:getByTopic",
255
- message: `Bad request for Arweave topic ${edge.node.id}: ${e}`,
256
- });
320
+ failures.push({ hash: edge.node.id, error: e });
257
321
  return null;
258
322
  }
259
323
  })
260
324
  );
325
+ const notFoundFailures = failures.filter(({ error }) => this._isNotFoundError(error));
326
+ const unexpectedFailures = failures.filter(({ error }) => !this._isNotFoundError(error));
327
+
328
+ if (notFoundFailures.length > 0) {
329
+ this.logger.debug({
330
+ at: "ArweaveClient:getByTopic",
331
+ message: `Skipped ${notFoundFailures.length} Arweave topic entries that were not yet available`,
332
+ tag,
333
+ transactions: notFoundFailures.map(({ hash }) => hash),
334
+ });
335
+ }
336
+
337
+ if (unexpectedFailures.length > 0) {
338
+ this.logger.warn({
339
+ at: "ArweaveClient:getByTopic",
340
+ message: `Failed to fetch ${unexpectedFailures.length} Arweave topic entries`,
341
+ tag,
342
+ failures: unexpectedFailures.map(({ hash, error }) => ({
343
+ hash,
344
+ error: String(error),
345
+ })),
346
+ });
347
+ }
348
+
261
349
  return results.filter(isDefined);
262
350
  }
263
351
 
@@ -1,5 +1,6 @@
1
1
  import assert from "assert";
2
2
  import _ from "lodash";
3
+ import { create } from "superstruct";
3
4
  import {
4
5
  SlowFillRequestWithBlock,
5
6
  SpokePoolClientsByChain,
@@ -16,6 +17,7 @@ import {
16
17
  FillWithBlock,
17
18
  Deposit,
18
19
  DepositWithBlock,
20
+ CachingMechanismInterface,
19
21
  } from "../../interfaces";
20
22
  import { SpokePoolClient } from "..";
21
23
  import { findFillEvent as findEvmFillEvent } from "../../arch/evm";
@@ -42,10 +44,13 @@ import {
42
44
  convertRelayDataParamsToBytes32,
43
45
  convertFillParamsToBytes32,
44
46
  chainIsTvm,
47
+ getArweaveTopicCacheKey,
48
+ jsonReplacerWithBigNumbers,
45
49
  } from "../../utils";
46
50
  import winston from "winston";
47
51
  import {
48
52
  BundleDataSS,
53
+ BundleData as PersistedArweaveBundleData,
49
54
  getRefundInformationFromFill,
50
55
  isChainDisabledAtBlock,
51
56
  isChainPaused,
@@ -56,7 +61,7 @@ import {
56
61
  } from "./utils";
57
62
  import { isEVMSpokePoolClient, isSVMSpokePoolClient } from "../SpokePoolClient";
58
63
  import { SpokePoolManager } from "../SpokePoolClient/SpokePoolClientManager";
59
-
64
+ import { DEFAULT_CACHING_TTL } from "../../constants";
60
65
  type DataCache = Record<string, Promise<LoadDataReturnValue>>;
61
66
 
62
67
  // V3 dictionary helper functions
@@ -164,7 +169,8 @@ export class BundleDataClient {
164
169
  readonly clients: Clients,
165
170
  spokePoolClients: { [chainId: number]: SpokePoolClient },
166
171
  readonly chainIdListForBundleEvaluationBlockNumbers: number[],
167
- readonly blockRangeEndBlockBuffer: { [chainId: number]: number } = {}
172
+ readonly blockRangeEndBlockBuffer: { [chainId: number]: number } = {},
173
+ readonly arweaveTopicCache?: CachingMechanismInterface
168
174
  ) {
169
175
  this.spokePoolClientManager = new SpokePoolManager(logger, spokePoolClients);
170
176
  }
@@ -204,6 +210,50 @@ export class BundleDataClient {
204
210
  return `bundles-${BundleDataClient.getArweaveClientKey(blockRangesForChains)}`;
205
211
  }
206
212
 
213
+ private async getPersistedArweaveTopicFromCache(tag: string): Promise<PersistedArweaveBundleData | undefined> {
214
+ if (!isDefined(this.arweaveTopicCache)) {
215
+ return undefined;
216
+ }
217
+
218
+ try {
219
+ const cachedPayload = await this.arweaveTopicCache.get<string>(getArweaveTopicCacheKey(tag));
220
+ if (!isDefined(cachedPayload)) {
221
+ return undefined;
222
+ }
223
+
224
+ return create(JSON.parse(cachedPayload), BundleDataSS);
225
+ } catch (error) {
226
+ this.logger.debug({
227
+ at: "BundleDataClient#getPersistedArweaveTopicFromCache",
228
+ message: "Failed to restore persisted bundle data from topic cache, falling back to Arweave",
229
+ tag,
230
+ error: String(error),
231
+ });
232
+ return undefined;
233
+ }
234
+ }
235
+
236
+ private async backfillPersistedArweaveTopicCache(tag: string, data: PersistedArweaveBundleData): Promise<void> {
237
+ if (!isDefined(this.arweaveTopicCache)) {
238
+ return;
239
+ }
240
+
241
+ try {
242
+ await this.arweaveTopicCache.set(
243
+ getArweaveTopicCacheKey(tag),
244
+ JSON.stringify(data, jsonReplacerWithBigNumbers),
245
+ DEFAULT_CACHING_TTL
246
+ );
247
+ } catch (error) {
248
+ this.logger.debug({
249
+ at: "BundleDataClient#backfillPersistedArweaveTopicCache",
250
+ message: "Failed to backfill persisted bundle data into topic cache",
251
+ tag,
252
+ error: String(error),
253
+ });
254
+ }
255
+ }
256
+
207
257
  private async loadPersistedDataFromArweave(
208
258
  blockRangesForChains: number[][]
209
259
  ): Promise<LoadDataReturnValue | undefined> {
@@ -211,14 +261,25 @@ export class BundleDataClient {
211
261
  return undefined;
212
262
  }
213
263
  const start = performance.now();
214
- const persistedData = await this.clients.arweaveClient.getByTopic(
215
- this.getArweaveBundleDataClientKey(blockRangesForChains),
216
- BundleDataSS
217
- );
218
- // If there is no data or the data is empty, return undefined because we couldn't
219
- // pull info from the Arweave persistence layer.
220
- if (!isDefined(persistedData) || persistedData.length < 1) {
221
- return undefined;
264
+ const tag = this.getArweaveBundleDataClientKey(blockRangesForChains);
265
+ let data = await this.getPersistedArweaveTopicFromCache(tag);
266
+
267
+ if (!isDefined(data)) {
268
+ const persistedData = await this.clients.arweaveClient.getByTopic(tag, BundleDataSS);
269
+ // If there is no data or the data is empty, return undefined because we couldn't
270
+ // pull info from the Arweave persistence layer.
271
+ if (!isDefined(persistedData) || persistedData.length < 1) {
272
+ return undefined;
273
+ }
274
+ data = persistedData[0].data;
275
+ await this.backfillPersistedArweaveTopicCache(tag, data);
276
+ } else {
277
+ this.logger.debug({
278
+ at: "BundleDataClient#loadPersistedDataFromArweave",
279
+ message: "Loaded persisted bundle data from topic cache",
280
+ blockRanges: JSON.stringify(blockRangesForChains),
281
+ tag,
282
+ });
222
283
  }
223
284
 
224
285
  // A converter function to account for the fact that our SuperStruct schema does not support numeric
@@ -302,8 +363,6 @@ export class BundleDataClient {
302
363
  );
303
364
  };
304
365
 
305
- const data = persistedData[0].data;
306
-
307
366
  // This section processes and transforms bundle data loaded from Arweave storage into the correct format:
308
367
  // 1. Each field (bundleFillsV3, expiredDepositsToRefundV3, etc.) contains nested records keyed by chainId and token
309
368
  // 2. The chainId keys are converted from strings to numbers using convertTypedStringRecordIntoNumericRecord
@@ -365,7 +424,10 @@ export class BundleDataClient {
365
424
  const arweaveKey = this.getArweaveBundleDataClientKey(blockRangesForChains);
366
425
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
367
426
  if (!this.arweaveDataCache[arweaveKey]) {
368
- this.arweaveDataCache[arweaveKey] = this.loadPersistedDataFromArweave(blockRangesForChains);
427
+ this.arweaveDataCache[arweaveKey] = this.loadPersistedDataFromArweave(blockRangesForChains).catch((error) => {
428
+ delete this.arweaveDataCache[arweaveKey];
429
+ throw error;
430
+ });
369
431
  }
370
432
  const arweaveData = _.cloneDeep(await this.arweaveDataCache[arweaveKey]);
371
433
  return arweaveData!;
@@ -382,11 +444,18 @@ export class BundleDataClient {
382
444
  const key = JSON.stringify(blockRangesForChains);
383
445
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
384
446
  if (!this.loadDataCache[key]) {
385
- let arweaveData;
447
+ let arweaveData: LoadDataReturnValue | undefined;
386
448
  if (attemptArweaveLoad) {
387
- arweaveData = await this.loadArweaveData(blockRangesForChains);
388
- } else {
389
- arweaveData = undefined;
449
+ try {
450
+ arweaveData = await this.loadArweaveData(blockRangesForChains);
451
+ } catch (error) {
452
+ this.logger.warn({
453
+ at: "BundleDataClient#loadData",
454
+ message: "Failed to load bundle data from Arweave, falling back to on-chain reconstruction",
455
+ blockRanges: JSON.stringify(blockRangesForChains),
456
+ error: String(error),
457
+ });
458
+ }
390
459
  }
391
460
  const data = isDefined(arweaveData)
392
461
  ? // We can return the data to a Promise to keep the return type consistent.