@xyo-network/chain-bridge 1.23.0 → 2.0.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/dist/node/BridgeActor.d.ts +1 -0
- package/dist/node/BridgeActor.d.ts.map +1 -1
- package/dist/node/index.mjs +2056 -1407
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/server/routes/bridge/routeDefinitions/getRouteDefinitions.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/pathParams/ChainIdPathParam.d.ts +2 -1
- package/dist/node/server/routes/bridge/routeDefinitions/pathParams/ChainIdPathParam.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts +0 -22
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteEstimate.d.ts +4 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteEstimate.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetry.d.ts +10 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetry.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetryFailed.d.ts +9 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetryFailed.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatus.d.ts +0 -81
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatus.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatusByTx.d.ts +28 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatusByTx.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts +0 -81
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts +0 -72
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts +0 -72
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetry.d.ts +10 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetry.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetryFailed.d.ts +9 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetryFailed.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts +0 -81
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts +6 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts.map +1 -1
- package/dist/node/server/server.d.ts +3 -1
- package/dist/node/server/server.d.ts.map +1 -1
- package/dist/node/services/BridgeFulfillmentState.d.ts +22 -13
- package/dist/node/services/BridgeFulfillmentState.d.ts.map +1 -1
- package/dist/node/services/IBridgeServiceCollection.d.ts +12 -1
- package/dist/node/services/IBridgeServiceCollection.d.ts.map +1 -1
- package/dist/node/services/evm/getFeeStructure.d.ts +1 -1
- package/dist/node/services/evm/getFeeStructure.d.ts.map +1 -1
- package/dist/node/services/evm/getRemoteConfirmationDepth.d.ts.map +1 -1
- package/dist/node/services/evm/index.d.ts +1 -0
- package/dist/node/services/evm/index.d.ts.map +1 -1
- package/dist/node/services/evm/resolveDeployBlock.d.ts +28 -0
- package/dist/node/services/evm/resolveDeployBlock.d.ts.map +1 -0
- package/dist/node/services/getServices.d.ts +3 -1
- package/dist/node/services/getServices.d.ts.map +1 -1
- package/dist/node/services/queue/flows/createEthToXl1BridgeJob/createEthToXl1BridgeJob.d.ts +1 -1
- package/dist/node/services/queue/flows/createEthToXl1BridgeJob/getJobIdForEthToXl1BridgeJob.d.ts +2 -13
- package/dist/node/services/queue/flows/createEthToXl1BridgeJob/getJobIdForEthToXl1BridgeJob.d.ts.map +1 -1
- package/dist/node/services/queue/index.d.ts +2 -0
- package/dist/node/services/queue/index.d.ts.map +1 -1
- package/dist/node/services/queue/retryFailedJobs.d.ts +39 -0
- package/dist/node/services/queue/retryFailedJobs.d.ts.map +1 -0
- package/dist/node/services/queue/retrySingleFailedJob.d.ts +29 -0
- package/dist/node/services/queue/retrySingleFailedJob.d.ts.map +1 -0
- package/dist/node/services/queue/scanner/EvmBridgeCursor.d.ts +1 -0
- package/dist/node/services/queue/scanner/EvmBridgeCursor.d.ts.map +1 -1
- package/dist/node/services/queue/scanner/EvmBridgeScanner.d.ts +1 -0
- package/dist/node/services/queue/scanner/EvmBridgeScanner.d.ts.map +1 -1
- package/dist/node/services/queue/scanner/EvmBridgeScannerRunner.d.ts +1 -2
- package/dist/node/services/queue/scanner/EvmBridgeScannerRunner.d.ts.map +1 -1
- package/dist/node/services/queue/scanner/buildEvmBridgeScannerRunner.d.ts +0 -3
- package/dist/node/services/queue/scanner/buildEvmBridgeScannerRunner.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthEventVerification.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthToXl1BridgeParent.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthTransactionPreparation.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthTransactionSubmission.d.ts.map +1 -1
- package/dist/node/services/queue/workers/EthTransactionSubmissionStorage.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1ReserveTxFulfillment.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -1
- package/dist/node/services/queue/workers/Xl1TransactionSubmissionStorage.d.ts.map +1 -1
- package/dist/node/services/queue/workers/util/buildAcceptedSnapshot.d.ts +47 -0
- package/dist/node/services/queue/workers/util/buildAcceptedSnapshot.d.ts.map +1 -0
- package/dist/node/services/queue/workers/util/buildEthToXl1ReserveTx.d.ts +22 -6
- package/dist/node/services/queue/workers/util/buildEthToXl1ReserveTx.d.ts.map +1 -1
- package/dist/node/services/queue/workers/util/index.d.ts +1 -0
- package/dist/node/services/queue/workers/util/index.d.ts.map +1 -1
- package/dist/node/services/queue/workers/util/resolveEvmBlockTagAtDepth.d.ts +22 -7
- package/dist/node/services/queue/workers/util/resolveEvmBlockTagAtDepth.d.ts.map +1 -1
- package/dist/node/services/queue/workers/util/verifyEthBridgeEvent.d.ts +7 -4
- package/dist/node/services/queue/workers/util/verifyEthBridgeEvent.d.ts.map +1 -1
- package/dist/node/services/util/generateBridgeEstimate.d.ts.map +1 -1
- package/dist/node/services/util/index.d.ts +0 -5
- package/dist/node/services/util/index.d.ts.map +1 -1
- package/dist/node/services/validation/index.d.ts +1 -0
- package/dist/node/services/validation/index.d.ts.map +1 -1
- package/dist/node/services/validation/validateAmountMeetsMinBridgeAmount.d.ts +20 -0
- package/dist/node/services/validation/validateAmountMeetsMinBridgeAmount.d.ts.map +1 -0
- package/dist/node/services/validation/validateBridgeEstimate.d.ts.map +1 -1
- package/dist/node/services/validation/validateSufficientXl1ReserveBalance.d.ts +15 -10
- package/dist/node/services/validation/validateSufficientXl1ReserveBalance.d.ts.map +1 -1
- package/dist/node/telemetry/bucketFailureReason.d.ts +17 -0
- package/dist/node/telemetry/bucketFailureReason.d.ts.map +1 -0
- package/dist/node/telemetry/createBalanceMonitor.d.ts +5 -0
- package/dist/node/telemetry/createBalanceMonitor.d.ts.map +1 -1
- package/dist/node/telemetry/createBridgeFlowMetrics.d.ts +76 -0
- package/dist/node/telemetry/createBridgeFlowMetrics.d.ts.map +1 -0
- package/dist/node/telemetry/createInFlightPoller.d.ts +29 -0
- package/dist/node/telemetry/createInFlightPoller.d.ts.map +1 -0
- package/dist/node/telemetry/createQueueMetrics.d.ts +4 -0
- package/dist/node/telemetry/createQueueMetrics.d.ts.map +1 -1
- package/dist/node/telemetry/index.d.ts +3 -0
- package/dist/node/telemetry/index.d.ts.map +1 -1
- package/package.json +98 -97
- package/dist/node/services/util/BridgeFees.d.ts +0 -13
- package/dist/node/services/util/BridgeFees.d.ts.map +0 -1
- package/dist/node/services/util/bridgeFeesAsBigInt.d.ts +0 -7
- package/dist/node/services/util/bridgeFeesAsBigInt.d.ts.map +0 -1
- package/dist/node/services/util/calculateBridgeFees.d.ts +0 -6
- package/dist/node/services/util/calculateBridgeFees.d.ts.map +0 -1
- package/dist/node/services/util/calculateMaxBridgeAmount.d.ts +0 -11
- package/dist/node/services/util/calculateMaxBridgeAmount.d.ts.map +0 -1
- package/dist/node/services/util/createBridgeTransfer.d.ts +0 -14
- package/dist/node/services/util/createBridgeTransfer.d.ts.map +0 -1
|
@@ -2,6 +2,8 @@ import type { Address, Hex } from '@xylabs/sdk-js';
|
|
|
2
2
|
import type { AccountInstance } from '@xyo-network/sdk-js';
|
|
3
3
|
import type { ChainId, SignedHydratedTransaction, XL1BlockNumber } from '@xyo-network/xl1-sdk';
|
|
4
4
|
export interface BuildEthToXl1ReserveTxOptions {
|
|
5
|
+
/** Gross deposit on the EVM side (from `bridgesToRemote[id].amount`). The user's destination
|
|
6
|
+
* credit is `amount - feesAmount`; the fees address receives `feesAmount`. */
|
|
5
7
|
amount: bigint;
|
|
6
8
|
bridgeAccount: AccountInstance;
|
|
7
9
|
/** Contract-assigned bridge id from `bridgesToRemote(bridgeId)` storage. */
|
|
@@ -14,23 +16,37 @@ export interface BuildEthToXl1ReserveTxOptions {
|
|
|
14
16
|
/** Tx hash of the EVM transaction that emitted BridgedToRemote(bridgeId). */
|
|
15
17
|
evmTxHash: Hex;
|
|
16
18
|
exp: XL1BlockNumber;
|
|
19
|
+
/** XL1 address that receives the bridge fee. Pass the same value as `destAddress` to
|
|
20
|
+
* collapse to a single-output Transfer (the user effectively pays themselves). */
|
|
21
|
+
feesAddress: Address;
|
|
22
|
+
/** Total fee, in atto, to be credited to `feesAddress`. Caller is responsible for ensuring
|
|
23
|
+
* `amount >= feesAmount` (typically by enforcing `amount >= minBridgeAmount` upstream).
|
|
24
|
+
* Computed as `hexToBigInt(feeFixed) + hexToBigInt(feeVariable)`. */
|
|
25
|
+
feesAmount: bigint;
|
|
17
26
|
nbf: XL1BlockNumber;
|
|
18
27
|
xl1ChainId: ChainId;
|
|
19
28
|
xl1TokenAddress: Hex;
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
|
-
* Builds a signed XL1 transaction that
|
|
23
|
-
* the
|
|
24
|
-
*
|
|
25
|
-
*
|
|
31
|
+
* Builds a signed XL1 transaction that settles an EVM→XL1 inbound bridge. The Transfer
|
|
32
|
+
* splits the gross `amount` between `destAddress` (net = amount - feesAmount) and
|
|
33
|
+
* `feesAddress`, mirroring the XL1→EVM outbound model where `createBridgeTransfer` splits
|
|
34
|
+
* the user's source amount between escrow and fees. `BridgeIntent` + `BridgeSourceObservation`
|
|
35
|
+
* attach the cross-chain provenance off-chain.
|
|
26
36
|
*
|
|
27
37
|
* The Transfer payload is what actually moves balance on XL1 (on-chain). The intent +
|
|
28
38
|
* source observation are off-chain provenance: they record what cross-chain operation this
|
|
29
39
|
* transfer represents and which EVM tx emitted the source-side `BridgedToRemote` event.
|
|
30
40
|
*
|
|
31
|
-
*
|
|
41
|
+
* Field semantics in the intent/observation: `srcAmount = amount` (gross EVM deposit) and
|
|
42
|
+
* `destAmount = amount - feesAmount` (net XL1 credit). This makes the fee directly derivable
|
|
43
|
+
* from the intent (`srcAmount - destAmount`) without consulting external config — the
|
|
44
|
+
* inbound mirror of how the outbound flow records what hits destAddress as `destAmount`.
|
|
45
|
+
*
|
|
46
|
+
* The BridgeIntent.nonce is the deterministic `evm-{chainId}-{contract}-{bridgeId}` form so
|
|
32
47
|
* it aligns with the BullMQ jobId and the status route's URL `:nonce` parameter — a single
|
|
33
|
-
* canonical id ties the same logical bridge across all surfaces.
|
|
48
|
+
* canonical id ties the same logical bridge across all surfaces. Dash delimiter is used
|
|
49
|
+
* because BullMQ rejects custom jobIds containing `:`.
|
|
34
50
|
*/
|
|
35
51
|
export declare function buildEthToXl1ReserveTx(options: BuildEthToXl1ReserveTxOptions): Promise<SignedHydratedTransaction>;
|
|
36
52
|
//# sourceMappingURL=buildEthToXl1ReserveTx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildEthToXl1ReserveTx.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/buildEthToXl1ReserveTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"buildEthToXl1ReserveTx.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/buildEthToXl1ReserveTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EACe,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAC5E,MAAM,sBAAsB,CAAA;AAG7B,MAAM,WAAW,6BAA6B;IAC5C;kFAC8E;IAC9E,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,GAAG,CAAA;IACf,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,GAAG,CAAA;IACpB,6EAA6E;IAC7E,SAAS,EAAE,GAAG,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB;sFACkF;IAClF,WAAW,EAAE,OAAO,CAAA;IACpB;;yEAEqE;IACrE,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,GAAG,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,yBAAyB,CAAC,CAgEpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA"}
|
|
@@ -3,14 +3,29 @@ import type { EvmConfirmationDepth } from '../../../evm/index.ts';
|
|
|
3
3
|
/**
|
|
4
4
|
* Resolves an EvmConfirmationDepth into the concrete block reference used by `eth_call`
|
|
5
5
|
* / `eth_getLogs` / `nextBridgeToId({ blockTag })` / `bridgesToRemote(id, { blockTag })` /
|
|
6
|
-
* `queryFilter(filter, fromBlock, toBlock)`. Return
|
|
7
|
-
*
|
|
6
|
+
* `queryFilter(filter, fromBlock, toBlock)`. Return type covers all three forms ethers
|
|
7
|
+
* accepts as BlockTag and that typechain's `queryFilter` overload tolerates (`string |
|
|
8
|
+
* number`).
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* Three branches, picked to avoid an unnecessary RPC round-trip *and* to avoid a class of
|
|
11
|
+
* pre-deploy-block bugs:
|
|
11
12
|
*
|
|
12
|
-
* 'finalized': forwarded as-is.
|
|
13
|
-
*
|
|
13
|
+
* - 'finalized': forwarded as-is. Resolved server-side, so no head fetch needed.
|
|
14
|
+
*
|
|
15
|
+
* - depth === 0: returns 'latest' rather than computing `head - 0`. Semantically
|
|
16
|
+
* identical ("trust head, no reorg buffer"), but materially safer. ethers v6 caches
|
|
17
|
+
* `getBlockNumber()` for up to `pollingInterval` ms (~1s WS, ~4s JSON-RPC), so a
|
|
18
|
+
* stale read can hand back a block number from BEFORE the contract was deployed —
|
|
19
|
+
* then `eth_call` at that historical block returns `0x` (no code at that address
|
|
20
|
+
* yet) and ethers throws BAD_DATA. Letting the server resolve 'latest' at call time
|
|
21
|
+
* sidesteps the race entirely. Also saves the head-fetch round-trip.
|
|
22
|
+
*
|
|
23
|
+
* - numeric depth > 0: subtract from the current head and clamp to >= `deployBlock`.
|
|
24
|
+
* The head fetch is unavoidable here — we need a specific past block, not the live
|
|
25
|
+
* head. The deploy-block floor guards against the early-life scenario where
|
|
26
|
+
* `head - depth < deployBlock` (e.g. the actor starts on a 32-confirmation depth a
|
|
27
|
+
* few blocks after deploy): a pre-deploy block would fail an `eth_call` with
|
|
28
|
+
* BAD_DATA, so we clamp upward to the deploy block instead.
|
|
14
29
|
*/
|
|
15
|
-
export declare function resolveEvmBlockTagAtDepth(provider: Provider, depth: EvmConfirmationDepth): Promise<number | 'finalized'>;
|
|
30
|
+
export declare function resolveEvmBlockTagAtDepth(provider: Provider, depth: EvmConfirmationDepth, deployBlock: number): Promise<number | 'latest' | 'finalized'>;
|
|
16
31
|
//# sourceMappingURL=resolveEvmBlockTagAtDepth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveEvmBlockTagAtDepth.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/resolveEvmBlockTagAtDepth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE
|
|
1
|
+
{"version":3,"file":"resolveEvmBlockTagAtDepth.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/resolveEvmBlockTagAtDepth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC,CAK1C"}
|
|
@@ -8,6 +8,10 @@ export interface EthBridgeEventData {
|
|
|
8
8
|
destToken: Address;
|
|
9
9
|
/** Tx hash of the EVM transaction that emitted BridgedToRemote(id). */
|
|
10
10
|
evmTxHash: Hex;
|
|
11
|
+
/** Wall-clock timestamp (epoch ms) the bridge actor observed the event at confirmation
|
|
12
|
+
* depth. Optional for back-compat with state-map entries written before this field
|
|
13
|
+
* existed; new writes always populate it. Powers the settle-latency histogram. */
|
|
14
|
+
observedAt?: number;
|
|
11
15
|
srcAddress: Address;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
@@ -23,9 +27,8 @@ export interface EthBridgeEventData {
|
|
|
23
27
|
* or never reached canonical state — the caller must treat this as terminal.
|
|
24
28
|
*
|
|
25
29
|
* The event-log lookup is what surfaces the EVM tx hash for `BridgeSourceObservation`'s
|
|
26
|
-
* `srcConfirmation`.
|
|
27
|
-
*
|
|
28
|
-
* contract's deploy block or accept a fromBlock hint).
|
|
30
|
+
* `srcConfirmation`. Floored at `deployBlock` (cached at actor startup) so the eth_getLogs
|
|
31
|
+
* range is the contract's lifetime, not genesis-to-now.
|
|
29
32
|
*/
|
|
30
|
-
export declare function verifyEthBridgeEvent(id: bigint, bridge: LiquidityPoolBridge, provider: Provider, confirmationDepth: EvmConfirmationDepth): Promise<EthBridgeEventData | null>;
|
|
33
|
+
export declare function verifyEthBridgeEvent(id: bigint, bridge: LiquidityPoolBridge, provider: Provider, confirmationDepth: EvmConfirmationDepth, deployBlock: number): Promise<EthBridgeEventData | null>;
|
|
31
34
|
//# sourceMappingURL=verifyEthBridgeEvent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEthBridgeEvent.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/verifyEthBridgeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGjE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,GAAG,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;CACpB;AAED
|
|
1
|
+
{"version":3,"file":"verifyEthBridgeEvent.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/verifyEthBridgeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGjE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,GAAG,CAAA;IACd;;sFAEkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,oBAAoB,EACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA4BpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/util/generateBridgeEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"generateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/util/generateBridgeEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIlE,eAAO,MAAM,sBAAsB,GACjC,YAAY,GAAG,EACf,WAAW,GAAG,EACd,aAAa,GAAG,EAChB,QAAQ,YAAY,EACpB,gBAAgB,MAAM,KACrB,OAAO,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAGlC,CAAA"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from './BridgeFees.ts';
|
|
2
|
-
export * from './bridgeFeesAsBigInt.ts';
|
|
3
|
-
export * from './calculateBridgeFees.ts';
|
|
4
|
-
export * from './calculateMaxBridgeAmount.ts';
|
|
5
|
-
export * from './createBridgeTransfer.ts';
|
|
6
1
|
export * from './generateBridgeEstimate.ts';
|
|
7
2
|
export * from './getConfigFromEnv.ts';
|
|
8
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iDAAiD,CAAA;AAC/D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,0CAA0C,CAAA;AACxD,cAAc,gDAAgD,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAA;AACvD,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iDAAiD,CAAA;AAC/D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,+CAA+C,CAAA;AAC7D,cAAc,0CAA0C,CAAA;AACxD,cAAc,gDAAgD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
2
|
+
export interface ValidateAmountMeetsMinBridgeAmountArgs {
|
|
3
|
+
/** Gross deposit amount in atto. For EVM→XL1 this is `bridgesToRemote[id].amount`. */
|
|
4
|
+
amount: bigint;
|
|
5
|
+
/** Configured floor (Hex-encoded atto), shared with the XL1→EVM outbound direction
|
|
6
|
+
* (BridgeConfig.minBridgeAmount). */
|
|
7
|
+
minBridgeAmount: Hex;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if `amount >= minBridgeAmount`. Used by Stage 2 of the EVM→XL1 inbound flow
|
|
11
|
+
* to short-circuit fulfillment for deposits below the bridge's configured floor.
|
|
12
|
+
*
|
|
13
|
+
* The contract (`LiquidityPoolBridge.bridgeToRemote`) does NOT enforce a minimum — it only
|
|
14
|
+
* rejects zero and over-max. So any inbound deposit smaller than what the bridge service
|
|
15
|
+
* considers economical (post-fee) reaches Stage 2 and must be filtered here. Failed
|
|
16
|
+
* inbound deposits sit in the EVM-side `liquiditySource` reserve and are operator-refundable
|
|
17
|
+
* out-of-band; this is documented behavior, not a protocol guarantee.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateAmountMeetsMinBridgeAmount({ amount, minBridgeAmount, }: ValidateAmountMeetsMinBridgeAmountArgs): boolean;
|
|
20
|
+
//# sourceMappingURL=validateAmountMeetsMinBridgeAmount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateAmountMeetsMinBridgeAmount.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateAmountMeetsMinBridgeAmount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAGzC,MAAM,WAAW,sCAAsC;IACrD,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAA;IACd;yCACqC;IACrC,eAAe,EAAE,GAAG,CAAA;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAAC,EACjD,MAAM,EACN,eAAe,GAChB,EAAE,sCAAsC,GAAG,OAAO,CAElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateBridgeEstimate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateBridgeEstimate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIlE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAuCjB,CAAA"}
|
|
@@ -8,21 +8,26 @@ export interface ValidateSufficientXl1ReserveBalanceArgs {
|
|
|
8
8
|
logger?: AsyncLogger;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* 1 XL1 of headroom above the requested amount. The actual XL1 transaction the bridge will
|
|
12
|
+
* submit pays a small network fee on top of the transfer; without a buffer, an exactly-equal
|
|
13
|
+
* balance check would pass here and the chain would then reject the tx for being a few atto
|
|
14
|
+
* short. One XL1 is far above any realistic per-tx fee and stays comfortably under the
|
|
15
|
+
* configured minBridgeAmount (1500 XL1 by default), so it doesn't materially affect the
|
|
16
|
+
* threshold at which legitimate bridges become serviceable.
|
|
17
|
+
*/
|
|
18
|
+
export declare const RESERVE_FEE_BUFFER: bigint;
|
|
19
|
+
/**
|
|
20
|
+
* Checks that the bridge's XL1 reserve account has at least `amount + RESERVE_FEE_BUFFER`
|
|
21
|
+
* of native balance available to cover an inbound (EVM → XL1) reserve transfer plus the
|
|
22
|
+
* network fee the actual submission will pay. Mirrors the XL1 → EVM direction's
|
|
23
|
+
* `validateSufficientXL1SourceAddressBalance` in spirit: a quick pre-flight gate to avoid
|
|
24
|
+
* building, signing, and dispatching a transaction the chain will then reject for
|
|
25
|
+
* insufficient funds.
|
|
16
26
|
*
|
|
17
27
|
* Race conditions: a concurrent submission could deplete the reserve between this check
|
|
18
28
|
* and the actual XL1 submission. That's acceptable — the worker chain will fail the
|
|
19
29
|
* submission, BullMQ will retry, and the next retry will re-validate. The check exists to
|
|
20
30
|
* filter the bulk of insufficient-balance cases cheaply, not to be perfectly atomic.
|
|
21
|
-
*
|
|
22
|
-
* Network fees are not included in the comparison (matching the XL1 → EVM validator's
|
|
23
|
-
* convention). Operators are expected to keep the reserve sufficiently above any single
|
|
24
|
-
* bridge amount; tiny network-fee deltas would only flip the outcome at the margin and
|
|
25
|
-
* BullMQ retry handles those.
|
|
26
31
|
*/
|
|
27
32
|
export declare function validateSufficientXl1ReserveBalance({ amount, bridgeAccount, gateway, logger, }: ValidateSufficientXl1ReserveBalanceArgs): Promise<boolean>;
|
|
28
33
|
//# sourceMappingURL=validateSufficientXl1ReserveBalance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateSufficientXl1ReserveBalance.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateSufficientXl1ReserveBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"validateSufficientXl1ReserveBalance.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateSufficientXl1ReserveBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,WAAW,uCAAuC;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAsC,CAAA;AAEvE;;;;;;;;;;;;GAYG;AACH,wBAAsB,mCAAmC,CAAC,EACxD,MAAM,EACN,aAAa,EACb,OAAO,EACP,MAAM,GACP,EAAE,uCAAuC,GAAG,OAAO,CAAC,OAAO,CAAC,CAS5D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed-enum failure-reason buckets for the bridge's terminal-failure counter. Free-form
|
|
3
|
+
* `failedReason` strings (from thrown Errors at BullMQ retry exhaustion) get collapsed to
|
|
4
|
+
* one of these values so the metric label stays low-cardinality and queryable.
|
|
5
|
+
*
|
|
6
|
+
* Adding a new bucket here means the `reason` label gets a new possible value — coordinate
|
|
7
|
+
* with the dashboard / alert rules before doing so.
|
|
8
|
+
*/
|
|
9
|
+
export type BridgeFailureReason = 'attempts_exhausted' | 'below_min_bridge_amount' | 'orphaned_at_depth' | 'other' | 'reserve_insufficient';
|
|
10
|
+
/**
|
|
11
|
+
* Map a free-form `failedReason` (BullMQ's `Job.failedReason` or `Error.message` at terminal
|
|
12
|
+
* failure) into a `BridgeFailureReason`. Order matters — more specific patterns come first
|
|
13
|
+
* so the well-known structured errors don't fall through to the generic 'attempts_exhausted'
|
|
14
|
+
* bucket.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bucketFailureReason(failedReason: string): BridgeFailureReason;
|
|
17
|
+
//# sourceMappingURL=bucketFailureReason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucketFailureReason.d.ts","sourceRoot":"","sources":["../../../src/telemetry/bucketFailureReason.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GACzB,oBAAoB,GACpB,yBAAyB,GACzB,mBAAmB,GACnB,OAAO,GACP,sBAAsB,CAAA;AAE5B;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAS7E"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
2
3
|
import type { AccountInstance } from '@xyo-network/sdk-js';
|
|
3
4
|
import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain';
|
|
4
5
|
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk';
|
|
@@ -11,6 +12,10 @@ export interface BalanceMonitorConfig {
|
|
|
11
12
|
intervalMs?: number;
|
|
12
13
|
meter: Meter;
|
|
13
14
|
provider: Provider;
|
|
15
|
+
/** Remote (EVM) chain id, attached as a low-cardinality `remoteChainId` label so a
|
|
16
|
+
* single bridge actor monitoring multiple destinations can be queried per-chain in
|
|
17
|
+
* Prometheus. */
|
|
18
|
+
remoteChainId: Hex;
|
|
14
19
|
wallet: Wallet;
|
|
15
20
|
}
|
|
16
21
|
export interface BalanceMonitorHandle {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBalanceMonitor.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBalanceMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAOD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,
|
|
1
|
+
{"version":3,"file":"createBalanceMonitor.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBalanceMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB;;qBAEiB;IACjB,aAAa,EAAE,GAAG,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAOD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAwFvF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
3
|
+
import type { BridgeFailureReason } from './bucketFailureReason.ts';
|
|
4
|
+
export type BridgeDirection = 'inbound' | 'outbound';
|
|
5
|
+
/**
|
|
6
|
+
* What user-facing action caused the retry. `api_singular` for the singular retry routes
|
|
7
|
+
* (one bridge id, one increment); `api_bulk` for the bulk retryFailed routes (one
|
|
8
|
+
* increment per actually-retried job). BullBoard's manual retry button has no operator-
|
|
9
|
+
* facing hook today, so it is deliberately not represented here.
|
|
10
|
+
*/
|
|
11
|
+
export type BridgeRetryTrigger = 'api_singular' | 'api_bulk';
|
|
12
|
+
export interface RecordBridgeRetryOptions {
|
|
13
|
+
/** Default 1. Bulk routes pass `result.counts.retried` so a single call records the
|
|
14
|
+
* whole batch atomically. */
|
|
15
|
+
count?: number;
|
|
16
|
+
direction: BridgeDirection;
|
|
17
|
+
trigger: BridgeRetryTrigger;
|
|
18
|
+
}
|
|
19
|
+
export interface RecordBridgeSuccessOptions {
|
|
20
|
+
direction: BridgeDirection;
|
|
21
|
+
/** Fee skim, in AttoXL1, attributable to this single bridge. Recorded as a counter
|
|
22
|
+
* increment on bridge_fee_revenue_total. */
|
|
23
|
+
feeAmount: bigint;
|
|
24
|
+
/** Wall-clock seconds from acceptance (canonical observed) to fulfillment (tx submitted /
|
|
25
|
+
* confirmed). Optional — outbound may pass `undefined` when a clean
|
|
26
|
+
* acceptance-to-fulfillment timestamp isn't available, in which case the histogram is
|
|
27
|
+
* not recorded for that flow. */
|
|
28
|
+
latencySeconds?: number;
|
|
29
|
+
/** Token contract / chain id the fee is denominated in. Bridge fees are XL1-denominated
|
|
30
|
+
* for both directions today; this label exists so future direction-specific fee streams
|
|
31
|
+
* can be distinguished without a metric rename. */
|
|
32
|
+
token: Hex;
|
|
33
|
+
}
|
|
34
|
+
export interface BridgeFlowMetricsConfig {
|
|
35
|
+
/** Optional — when absent (no OTel meter wired up), the returned handle records nothing
|
|
36
|
+
* (no-op). Keeps worker call sites unconditional. */
|
|
37
|
+
meter?: Meter;
|
|
38
|
+
/** Low-cardinality remote-chain label attached to every recording. */
|
|
39
|
+
remoteChainId: Hex;
|
|
40
|
+
}
|
|
41
|
+
export interface BridgeFlowMetricsHandle {
|
|
42
|
+
/** Increments bridge_attempt_expirations_total for a non-terminal per-attempt failure
|
|
43
|
+
* (inbound: Stage 2's exp-block elapsed; outbound: BullMQ retry with attempts remaining). */
|
|
44
|
+
recordAttemptExpiration(opts: {
|
|
45
|
+
direction: BridgeDirection;
|
|
46
|
+
}): void;
|
|
47
|
+
/** Increments bridge_retried_total. Fired from the retry routes when a job actually
|
|
48
|
+
* moves from `failed` to `waiting` (never on dry-run, never on filter-mismatch /
|
|
49
|
+
* not-in-failed-state skips). */
|
|
50
|
+
recordRetried(opts: RecordBridgeRetryOptions): void;
|
|
51
|
+
recordSuccess(opts: RecordBridgeSuccessOptions): void;
|
|
52
|
+
/** Increments bridge_terminal_failures_total. Fired from the leaf worker's .on('failed')
|
|
53
|
+
* when `job.attemptsMade >= job.opts.attempts` (or one-shot attempts=1). */
|
|
54
|
+
recordTerminalFailure(opts: {
|
|
55
|
+
direction: BridgeDirection;
|
|
56
|
+
reason: BridgeFailureReason;
|
|
57
|
+
}): void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Three metrics for successful bridge settlements, per direction (inbound = EVM→XL1,
|
|
61
|
+
* outbound = XL1→EVM):
|
|
62
|
+
*
|
|
63
|
+
* - `bridge_completed_total` — counter, labels (remoteChainId, direction).
|
|
64
|
+
* - `bridge_settle_latency_seconds` — histogram, same labels. Recorded only when the
|
|
65
|
+
* caller can supply a latency; the inbound path always can (canonical.observedAt and
|
|
66
|
+
* fulfilled.submittedAt are both wall-clock ms), the outbound path supplies what it
|
|
67
|
+
* can (currently EthTransactionMonitor's own wait time).
|
|
68
|
+
* - `bridge_fee_revenue_total` — counter, labels (remoteChainId, direction, token).
|
|
69
|
+
* `feeAmount` is in AttoXL1 (matching the protocol); operators converting to whole
|
|
70
|
+
* XL1 can divide by 10^18 in their PromQL.
|
|
71
|
+
*
|
|
72
|
+
* No-op when constructed without a meter: workers can call recordSuccess unconditionally
|
|
73
|
+
* even on actors that don't have OTel wired up.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createBridgeFlowMetrics(config: BridgeFlowMetricsConfig): BridgeFlowMetricsHandle;
|
|
76
|
+
//# sourceMappingURL=createBridgeFlowMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBridgeFlowMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBridgeFlowMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACU,KAAK,EAC1B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,UAAU,CAAA;AAE5D,MAAM,WAAW,wBAAwB;IACvC;iCAC6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,kBAAkB,CAAA;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,eAAe,CAAA;IAC1B;gDAC4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB;;;qCAGiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;uDAEmD;IACnD,KAAK,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,uBAAuB;IACtC;yDACqD;IACrD,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,sEAAsE;IACtE,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC;iGAC6F;IAC7F,uBAAuB,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,eAAe,CAAA;KAAE,GAAG,IAAI,CAAA;IACnE;;qCAEiC;IACjC,aAAa,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IACnD,aAAa,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI,CAAA;IACrD;gFAC4E;IAC5E,qBAAqB,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE,GAAG,IAAI,CAAA;CAC/F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,uBAAuB,CA0EhG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
3
|
+
import type { IterableMap } from '@xyo-network/xl1-sdk';
|
|
4
|
+
import type { BridgeFulfillmentState } from '../services/index.ts';
|
|
5
|
+
export interface InFlightPollerConfig {
|
|
6
|
+
bridgeFulfillmentMap: IterableMap<string, BridgeFulfillmentState>;
|
|
7
|
+
intervalMs?: number;
|
|
8
|
+
meter: Meter;
|
|
9
|
+
/** Same low-cardinality label used by the other bridge metrics so dashboards can join. */
|
|
10
|
+
remoteChainId: Hex;
|
|
11
|
+
}
|
|
12
|
+
export interface InFlightPollerHandle {
|
|
13
|
+
/** Run one poll and record the gauge. Exposed for tests and so callers can prime the
|
|
14
|
+
* gauge before the first interval tick. */
|
|
15
|
+
poll: () => Promise<void>;
|
|
16
|
+
start: () => void;
|
|
17
|
+
stop: () => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Periodically counts entries in `bridgeFulfillmentMap` that represent in-flight inbound
|
|
21
|
+
* (EVM→XL1) bridges — those where Stage 1 wrote `canonical` but Stage 2 has not yet
|
|
22
|
+
* transitioned to `fulfilled`. Records the count on
|
|
23
|
+
* `bridge_in_flight{remoteChainId, direction='inbound'}`.
|
|
24
|
+
*
|
|
25
|
+
* Outbound (XL1→EVM) has no equivalent durable state map today; the gauge stays inbound-only
|
|
26
|
+
* until a parallel store exists.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createInFlightPoller(config: InFlightPollerConfig): InFlightPollerHandle;
|
|
29
|
+
//# sourceMappingURL=createInFlightPoller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInFlightPoller.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createInFlightPoller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,WAAW,oBAAoB;IACnC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,0FAA0F;IAC1F,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC;+CAC2C;IAC3C,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAID;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAwCvF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meter } from '@opentelemetry/api';
|
|
2
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
2
3
|
import type { Queue } from 'bullmq';
|
|
3
4
|
export interface QueueMetricsConfig {
|
|
4
5
|
intervalMs?: number;
|
|
@@ -11,6 +12,9 @@ export interface QueueMetricsConfig {
|
|
|
11
12
|
* shared XL1 queues collide on identical key names so spread-merge dedupes naturally.
|
|
12
13
|
*/
|
|
13
14
|
queues: Record<string, Queue>;
|
|
15
|
+
/** Remote (EVM) chain id, attached as a low-cardinality `remoteChainId` label on every
|
|
16
|
+
* queue gauge so queries can scope to a single destination chain. */
|
|
17
|
+
remoteChainId: Hex;
|
|
14
18
|
}
|
|
15
19
|
export interface QueueMetricsHandle {
|
|
16
20
|
start: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQueueMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createQueueMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"createQueueMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createQueueMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC7B;yEACqE;IACrE,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CA+DjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA"}
|