Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Feat/observability#12

Open
lionakhnazarov wants to merge 407 commits intothreshold-network:mainfrom
tlabs-xyz:feat/observability
Open

Feat/observability#12
lionakhnazarov wants to merge 407 commits intothreshold-network:mainfrom
tlabs-xyz:feat/observability

Conversation

@lionakhnazarov
Copy link
Copy Markdown

refactor(logging): enhance logging with correlation IDs for better traceability

  • Introduced correlation IDs in logging across various services to improve traceability of deposit and redemption states.
  • Updated logger utility to support correlation context for deposits and redemptions, allowing for better monitoring and debugging.
  • Modified multiple services and utilities to utilize the new logging structure, ensuring consistent logging practices throughout the codebase.
  • Removed redundant logging statements and replaced them with the new correlation-based logging approach.

This change aims to facilitate easier tracking of operations and enhance observability in the system.

piotr-roslaniec and others added 30 commits June 4, 2025 13:14
Improves the detail and clarity of error logging for chain configuration failures in .

Key changes include:

- Updated  to better distinguish error types and capture input details more accurately, especially when input generation fails.

- Ensured raw error objects are stored for non-Zod errors.

- Modified logging to concatenate stringified JSON of errors and inputs directly into log messages for improved console output. This ensures flattened Zod errors and full details (including stack traces) for other errors are visible directly in the console.

- These changes also enhance the content of the  file.

Additionally, applied the Boy Scout Rule by:

- Removing unused commented-out code in  and .

- Removing unused  variables from  blocks in  and  as identified by the linter.
Applies Prettier formatting updates to  and

. These changes were likely introduced

by yarn run v1.22.22
$ bun run lint:fix && bun run format:fix

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/config/app.config.ts
  8:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/config/index.ts
   70:10  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   71:11  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   97:28  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  103:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  107:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  267:13  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/controllers/Endpoint.controller.ts
   91:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  139:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/controllers/Operations.controller.ts
   25:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   57:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   89:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  121:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/controllers/Utils.controller.ts
   81:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  128:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/handlers/BaseChainHandler.ts
  161:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  239:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  311:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  346:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/handlers/EVMChainHandler.ts
  116:27  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  229:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/handlers/L1RedemptionHandler.ts
  147:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/handlers/SolanaChainHandler.ts
   85:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  114:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  164:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  259:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/handlers/StarknetChainHandler.ts
   45:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  117:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  261:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  327:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  466:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  567:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  606:32  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  643:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/index.ts
  113:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/scripts/validate-config.ts
   92:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  269:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  321:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  341:51  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  343:32  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/services/Core.ts
  211:23  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/services/L2RedemptionService.ts
  194:23  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  254:23  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/services/WormholeVaaService.ts
   42:22  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  128:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  173:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  182:63  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  183:47  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  184:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  185:47  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  212:20  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/mocks/BlockchainMock.ts
    9:37  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   25:48  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   36:47  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   46:54  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   69:41  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   80:41  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   90:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   90:54  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   99:52  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  107:56  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  107:66  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  114:45  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  114:61  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  125:36  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  125:52  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  140:54  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  140:66  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/mocks/MockChainHandler.ts
   41:45  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   43:21  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  384:41  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  395:42  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  409:45  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/unit/handlers/StarknetChainHandler.test.ts
   83:57  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   94:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  106:51  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  123:71  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  129:34  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  137:54  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  162:80  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  236:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  237:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  238:30  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  239:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  241:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  243:33  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  244:17  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  247:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  253:24  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  260:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  261:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  376:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  540:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  628:14  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  637:14  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  667:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  699:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  718:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  745:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  765:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  844:43  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  851:35  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  881:74  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  886:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  903:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  912:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  913:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  927:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  956:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  968:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  974:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  983:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  986:40  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/unit/utils/AuditLog.test.ts
   64:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   65:25  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   77:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   85:22  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   95:48  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  102:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  109:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/unit/utils/Deposits.test.ts
  688:53  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  689:30  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  690:24  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/tests/unit/utils/starknetAddress.test.ts
   14:20  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  129:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  155:44  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/utils/RedemptionStore.ts
    6:59  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   30:46  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   31:18  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   56:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
   80:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  112:35  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  129:26  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  134:35  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any
  156:19  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/home/piotr/Documents/projects/tLabs/tbtc-crosschain-relayer/utils/prisma.ts
  6:89  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

✖ 136 problems (0 errors, 136 warnings)

.github/dependabot.yml 26ms (unchanged)
.github/workflows/ci.yml 14ms (unchanged)
.github/workflows/docker.yml 3ms (unchanged)
.github/workflows/security.yml 7ms (unchanged)
.prettierrc.json 38ms (unchanged)
config/app.config.ts 63ms (unchanged)
config/chain/arbitrumMainnet.chain.ts 29ms (unchanged)
config/chain/base-sepolia-testnet.chain.ts 16ms (unchanged)
config/chain/baseMainnet.chain.ts 14ms (unchanged)
config/chain/common.chain.ts 25ms (unchanged)
config/chain/sepolia.chain.ts 13ms (unchanged)
config/chain/solana-common.ts 3ms (unchanged)
config/chain/solana.chain.ts 10ms (unchanged)
config/chain/solanaDevnetImported.chain.ts 13ms (unchanged)
config/chain/starknet-common.ts 6ms (unchanged)
config/chain/starknet.chain.ts 6ms (unchanged)
config/chain/sui-common.ts 8ms (unchanged)
config/chain/sui.chain.ts 8ms (unchanged)
config/index.ts 75ms (unchanged)
config/schemas/app.schema.ts 10ms (unchanged)
config/schemas/common.schema.ts 9ms (unchanged)
config/schemas/evm.chain.schema.ts 8ms (unchanged)
config/schemas/shared.ts 1ms (unchanged)
config/schemas/solana.chain.schema.ts 12ms (unchanged)
config/schemas/starknet.chain.schema.ts 9ms (unchanged)
config/schemas/sui.chain.schema.ts 6ms (unchanged)
controllers/Endpoint.controller.ts 27ms (unchanged)
controllers/Operations.controller.ts 17ms (unchanged)
controllers/Utils.controller.ts 18ms (unchanged)
docker-compose.ci.yml 6ms (unchanged)
docker-compose.yml 7ms (unchanged)
eslint.config.js 18ms (unchanged)
handlers/BaseChainHandler.ts 78ms (unchanged)
handlers/ChainHandlerFactory.ts 7ms (unchanged)
handlers/ChainHandlerRegistry.ts 9ms (unchanged)
handlers/ChainHandlerRegistryContext.ts 6ms (unchanged)
handlers/EVMChainHandler.ts 40ms (unchanged)
handlers/L1RedemptionHandler.ts 19ms (unchanged)
handlers/L1RedemptionHandlerRegistry.ts 10ms (unchanged)
handlers/SolanaChainHandler.ts 46ms (unchanged)
handlers/StarknetChainHandler.ts 100ms (unchanged)
handlers/SuiChainHandler.ts 13ms (unchanged)
helpers/CustomResponse.helper.ts 22ms (unchanged)
index.ts 42ms (unchanged)
interfaces/ChainHandler.interface.ts 6ms (unchanged)
interfaces/common.ts 9ms (unchanged)
interfaces/IStarkNetBitcoinDepositor.ts 160ms (unchanged)
interfaces/L1BitcoinDepositor.ts 37ms (unchanged)
interfaces/L1BitcoinRedeemer.ts 6ms (unchanged)
interfaces/L2BitcoinDepositor.ts 20ms (unchanged)
interfaces/L2BitcoinRedeemer.ts 4ms (unchanged)
interfaces/StarkNetBitcoinDepositor.ts 9ms (unchanged)
interfaces/TBTCVault.ts 70ms (unchanged)
jest.config.cjs 10ms (unchanged)
jest.global-setup.js 8ms (unchanged)
jest.global-teardown.js 6ms (unchanged)
package.json 7ms (unchanged)
routes/Routes.ts 18ms (unchanged)
scripts/migrate-auditlog-to-db.ts 21ms (unchanged)
scripts/validate-config.ts 53ms (unchanged)
services/CleanupDeposits.ts 12ms (unchanged)
services/Core.ts 37ms (unchanged)
services/L2RedemptionService.ts 32ms (unchanged)
services/WormholeVaaService.ts 30ms (unchanged)
target/idl/tbtc.json 13ms (unchanged)
target/idl/wormhole_gateway.json 15ms (unchanged)
tests/e2e/api.test.ts 18ms (unchanged)
tests/integration/controllers/Endpoint.controller.test.ts 14ms (unchanged)
tests/mocks/BlockchainMock.ts 15ms (unchanged)
tests/mocks/MockChainHandler.ts 32ms (unchanged)
tests/setup.ts 4ms (unchanged)
tests/unit/handlers/StarknetChainHandler.test.ts 67ms (unchanged)
tests/unit/utils/AuditLog.test.ts 10ms (unchanged)
tests/unit/utils/Deposits.test.ts 75ms (unchanged)
tests/unit/utils/starknetAddress.test.ts 15ms (unchanged)
tsconfig.json 6ms (unchanged)
types/Deposit.type.ts 5ms (unchanged)
types/DepositQueuedData.ts 1ms (unchanged)
types/DepositStatus.enum.ts 1ms (unchanged)
types/FundingTransaction.type.ts 2ms (unchanged)
types/Redemption.type.ts 4ms (unchanged)
types/ResponseJson.type.ts 2ms (unchanged)
types/Reveal.type.ts 1ms (unchanged)
utils/AuditLog.ts 14ms (unchanged)
utils/Constants.ts 2ms (unchanged)
utils/Deposits.ts 14ms (unchanged)
utils/DepositStore.ts 6ms (unchanged)
utils/Env.ts 6ms (unchanged)
utils/GetTransactionHash.ts 4ms (unchanged)
utils/Logger.ts 3ms (unchanged)
utils/Numbers.ts 1ms (unchanged)
utils/prisma.ts 1ms (unchanged)
utils/RedemptionStore.ts 10ms (unchanged)
utils/starknetAddress.ts 5ms (unchanged)
Done in 13.93s. or a pre-commit hook after the previous logical commit.
Adds the .do/ directory to .gitignore to exclude DigitalOcean

specific files and configurations from version control.
Refactors chain configuration loading across multiple files to standardize

the use of environment variables and default values.

Key changes include:

- Consolidated environment variable access using  and

   utilities within individual chain input functions

  (e.g., ).

- Provided explicit default values for many configuration parameters

  directly within the  calls or base schema definitions.

- Adjusted Zod schemas (e.g., )

  to accurately reflect optionality and allow for empty strings as

  valid defaults where appropriate (e.g., ).

- This makes chain configurations more robust, clarifies how defaults

  are applied, and resolves previous validation issues related to

  empty string values for optional fields.
Introduces a new shell script Updating DigitalOcean App: a5c99193-7e58-43a5-a9d5-3f1d23a57648 with spec: prod_spec.yaml
Deployment command finished.

for automating deployments to DigitalOcean.
Updates  to use

(sourced from the validated application configuration) instead of

directly accessing .

 is updated to define

 as an optional string in ,

aligning with this change.

This ensures that the SUPPORTED_CHAINS string is processed via the

main application configuration schema before use.
Adjusts  in the

method to re-derive the Solana signer's keypair from the

configuration string and convert the secret key to base58 format.

This ensures the private key is provided in the expected base58 string

format when initializing the  via the

's

function.
…n config factories -- use keyof Partial<T> for required field validation, standardize error messages, remove non-null assertions, ensure type safety, clean up imports and comments
…config - Add required field validation and type safety to Sui config factory - Replace non-null assertions with explicit type casts after validation - Standardize error messages and improve maintainability - Add JSDoc and re-export CommonChainInput in common.chain.ts for clarity and consistency
- Set FEATURE_FLAGS.USE_ENDPOINT to true for testing purposes.
- Implemented initialization of chain handlers when USE_ENDPOINT is true in main application logic.
- Added support for L1 private key in endpoint mode for StarkNet and updated related schemas.
- Enhanced BaseChainHandler to conditionally set up L1 signer for non-EVM chains using endpoint mode.
- Changed database provider from PostgreSQL to SQLite for local development.
- Added a new SQLite database file for local development.
- Added support for destinationChainDepositOwner in EndpointController to handle deposits more flexibly.
- Updated StarknetChainHandler to estimate gas for deposit transactions, improving transaction efficiency.
- Enhanced AppConfigSchema to parse boolean environment variables correctly.
- Introduced wormholeInfo field in Deposit model for additional data storage.
- Updated .gitignore to exclude database files for cleaner project structure.
- Changed deposit ID retrieval to use the actual ID from the database instead of recalculating it.
- Removed the requirement for an L2 transaction hash before finalization, clarifying the StarkNet flow process.
evandrosaturnino and others added 30 commits October 13, 2025 11:54
build: single stage ts shims to address oom issue
…integration

Add HTTP API endpoint allowing backend to notify relayer when deposits are
initialized, enabling gasless deposit flow where backend initializes on L1
and relayer handles finalization.

Changes:
- Add POST /api/:chainName/deposit/notify endpoint (always enabled)
- Add DepositNotificationSchema for request validation
- Add createDepositFromNotification() utility for INITIALIZED deposits
- Add handleDepositNotification() controller with security checks:
  - Schema validation
  - DepositKey verification (prevents spoofing)
  - Idempotency check (safe retries)
  - On-chain verification (prevents fake notifications)
- Add Ethereum L1 native deposit support:
  - ethereumMainnet chain configuration (NativeBTCDepositor)
  - ethereumSepolia chain configuration (testnet)
  - Register both chains in chainRegistry
- Update environment variables for Ethereum L1 chains

Security: Multi-layer verification ensures deposits are genuinely initialized
on-chain before relayer tracks them. DepositKey recalculation prevents
backend from providing mismatched or spoofed deposit data.

Implementation follows existing patterns for consistency with codebase
architecture and enables automatic finalization of gasless deposits.
…t both address and bytes32 formats

Accept both 20-byte address (0x + 40 hex) and 32-byte hex (0x + 64 hex) formats
to support mixed deployment of old contracts (Arbitrum, Base using address) and
new contracts (L1, Sui, StarkNet using bytes32).

This flexible validation ensures compatibility during contract migration period.
The backend sends depositKey as hex string (0x...) from
ethers.utils.solidityKeccak256(), but the relayer internally
uses decimal string format for deposit IDs throughout the
codebase (storage, lookups, finalization).

This mismatch caused all gasless deposit notifications to fail
with 400 error at the depositKey verification step, as hex
string never matched the calculated decimal string.

Changes:
- Add BigNumber import from ethers
- Normalize incoming depositKey from hex to decimal using
  BigNumber.from().toString()
- Rename variable to depositKeyRaw for clarity
- Add inline comments explaining the transformation

The decimal format is compatible with:
- EVM contract calls (ethers.js BigNumberish type)
- StarkNet handler (internal conversion to hex bytes32)
- Existing event-sourced deposits (already use decimal)
- All database operations (expect decimal string IDs)
…ticipant fields

Update deposit notification handler to use the actual backend wallet address
for deposit participant fields instead of incorrectly using the chain
identifier string.

Changes:
- Add backendAddress validation to DepositNotificationSchema
- Update createDepositFromNotification signature to accept backendAddress
- Replace chainId with backendAddress for receipt.depositor field
- Replace chainId with backendAddress for L1OutputEvent.l2Sender field
- Extract and pass backendAddress in Endpoint.controller

This fixes a bug where chain identifiers (e.g., "arbitrumSepolia") were
incorrectly stored as Ethereum addresses in deposit.receipt.depositor and
deposit.L1OutputEvent.l2Sender fields. These fields now correctly contain
the backend wallet address that called initializeDeposit on L1.
Fixed critical bug where controller used wrong hash function for depositKey
calculation, causing mismatches with on-chain contracts and backend.

Changes:
- controllers: Replace getFundingTxHash() with getTransactionHash() to use
  little-endian hash format (Bitcoin display format) which gets reversed to
  big-endian for keccak256 calculation
- utils: Throw error instead of logging on depositKey mismatch to prevent
  creating corrupted deposit records that would fail during finalization
- gitignore: Add package-lock.json and external/ directory

The controller was using getFundingTxHash() which returns big-endian format,
then passing it to getDepositId() which reverses it, resulting in
keccak256(little-endian, index). This didn't match the canonical implementation
which expects keccak256(big-endian, index).

Now correctly uses getTransactionHash() which returns little-endian format
(matching Bitcoin block explorers), gets reversed to big-endian, matching
the reference SDK implementation and on-chain contract behavior.
…support

feat(relayer): add gasless deposit notification endpoint for backend …
Disables automatic recovery mechanism in OptimisticMintingFinalized
event handler to prevent race conditions between chain handlers.

Root Cause:
- Multiple chain handlers (EthereumSepolia, ArbitrumSepolia, etc.) all
  listen to the same L1 TBTCVault events
- When an unknown deposit appears, ALL handlers attempt recovery
- Race condition: first handler to write wins
- Wrong handler creates deposit with incorrect chainId
- Example: ArbitrumSepolia handler creates deposit intended for
  EthereumSepolia with chainId="ArbitrumSepolia"

Impact Before Fix:
- Deposits created with wrong chainId
- Backend notifications find wrong records, return "already registered"
- Correct chain never processes deposit
- User never receives tBTC
- Deposits marked FINALIZED but never actually finalized

Fix:
- Remove automatic recovery from event handler
- Log warning when unknown deposit detected
- Rely on proper deposit creation paths:
  1. L2 event listeners (normal flow)
  2. Backend notify endpoint (gasless flow)

Testing:
- Verified code changes via git diff
- No syntax errors introduced
- Clear logging added for monitoring

Related Issues:
- Bug #1: Chain misidentification in recovery
- Bug #2: Incorrect status logic (deposits marked FINALIZED prematurely)
…ndition

fix: disable automatic L1 recovery to prevent race conditions
…aceability

- Introduced correlation IDs in logging across various services to improve traceability of deposit and redemption states.
- Updated logger utility to support correlation context for deposits and redemptions, allowing for better monitoring and debugging.
- Modified multiple services and utilities to utilize the new logging structure, ensuring consistent logging practices throughout the codebase.
- Removed redundant logging statements and replaced them with the new correlation-based logging approach.

This change aims to facilitate easier tracking of operations and enhance observability in the system.
Previously only SIGTERM was handled, which could leave OTel SDK in
inconsistent state when process is interrupted (e.g., Ctrl+C during dev).

Refactored shutdown logic into reusable gracefulOTelShutdown function
and registered it for both SIGTERM and SIGINT signals.
Enhanced header parsing to handle edge cases:
- Filters malformed headers without '=' separator
- Splits only on first '=' to preserve '=' in header values
- Trims whitespace from keys and values
- Filters out empty keys and values

Prevents runtime errors from malformed OTEL_EXPORTER_OTLP_HEADERS env var.
Removed premature error log at line 500 that was logging ALL errors including
'Deposit already revealed' (which is handled and not a real error).

Restored proper error logging after early-return check:
- Only logs actual errors that need investigation
- Already includes correlation IDs (depositId, chainName, fundingTxHash)
- Avoids duplicate logging for handled cases

Flow:
1. Catch error and extract reason
2. If 'Deposit already revealed' → handle and return (no error log)
3. If actual error → log with correlation IDs + continue error handling
fix: Address review findings from PR #47 deep review
…eful shutdown

- Updated environment variable documentation for OpenTelemetry to clarify usage for tracing and log export.
- Introduced a graceful shutdown mechanism in the main application to ensure proper cleanup of resources, including the HTTP server, Prisma connections, and OpenTelemetry SDK.
- Improved logging capabilities by refining the integration with SigNoz for better traceability of logs and traces.

These changes aim to enhance the observability and reliability of the application during shutdown processes.
Updated CI and security workflows to force the use of HTTPS for git protocol, ensuring compatibility with GitHub's requirements. This change prevents failures when dependencies are referenced via  or  URLs, which are not supported in the CI environment.
… dependencies

- Added instrumentation.ts to the Dockerfile to ensure it is included in the build.
- Updated package.json to include new dependencies with specific GitHub references for @thesis/solidity-contracts, @umpirsky/country-list, bip39, bls12377js, scrypt-shim, and websocket.
- Updated yarn.lock to reflect the changes in package versions and sources, ensuring consistency across installations.
…g Docker services

- Added a step to copy the example environment file to .env before bringing down Docker Compose services, ensuring the environment is set up correctly for subsequent tasks.
…stent dependency versioning

- Introduced a new script for depcheck to identify unused dependencies, ignoring specific packages.
- Ensured the depcheck dependency is listed in the package.json to maintain version consistency.
- Modified deposit state change log messages to provide clearer context by indicating the transition between statuses.
- Adjusted assertions to ensure the correct number of calls to dateNowSpy and removed unnecessary loggerInfoSpy checks for already finalized states.
- Enhanced test clarity by commenting on the expected behavior when statuses are unchanged.
- Activated OpenTelemetry environment variables for tracing and log export in both env.example and env.test.base files.
- Updated the OTLP endpoint to point to the correct SigNoz instance.
- Set the service name for better identification in logs.
…OpenTelemetry dependencies

- Removed the graceful shutdown function for the OpenTelemetry SDK from instrumentation.ts to streamline the shutdown process.
- Updated the OpenTelemetry dependencies in package.json to the latest versions for improved functionality and performance.
- Cleaned up yarn.lock to reflect the removal of unused dependencies and ensure consistency across installations.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants