From b64a0c49465e01dd022db7b1eb6301d1273f0f0e Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Wed, 11 Feb 2026 16:21:10 +0200 Subject: [PATCH 01/13] debug signature --- src/components/core/compute/startCompute.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/core/compute/startCompute.ts b/src/components/core/compute/startCompute.ts index 48aa56f49..384a4f3bb 100644 --- a/src/components/core/compute/startCompute.ts +++ b/src/components/core/compute/startCompute.ts @@ -68,6 +68,20 @@ export class PaidComputeStartHandler extends CommandHandler { if (!task.queueMaxWaitTime) { task.queueMaxWaitTime = 0 } + // DEBUG: Log the message construction + const debugMessage = String( + task.consumerAddress + task.datasets[0]?.documentId + task.nonce + ) + CORE_LOGGER.logMessage( + `[DEBUG] Signature validation message:\n` + + ` datasets: ${JSON.stringify(task.datasets)}\n` + + ` datasets[0]?.documentId: ${task.datasets[0]?.documentId}\n` + + ` consumerAddress: ${task.consumerAddress}\n` + + ` nonce: ${task.nonce}\n` + + ` Message: "${debugMessage}"`, + true + ) + const authValidationResponse = await this.validateTokenOrSignature( task.authorization, task.consumerAddress, From ead4615241674fc78fdb18d716f0b607447fe57b Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Wed, 11 Feb 2026 16:35:14 +0200 Subject: [PATCH 02/13] add more debugging logs --- src/components/core/utils/nonceHandler.ts | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/components/core/utils/nonceHandler.ts b/src/components/core/utils/nonceHandler.ts index 9fdd86a98..aac85e7e6 100644 --- a/src/components/core/utils/nonceHandler.ts +++ b/src/components/core/utils/nonceHandler.ts @@ -201,19 +201,45 @@ async function validateNonceAndSignature( ) const messageHashBytes = ethers.toBeArray(consumerMessage) + // DEBUG: Log validation details + CORE_LOGGER.logMessage( + `[DEBUG] Signature validation:\n` + + ` nonce: ${nonce}\n` + + ` existingNonce: ${existingNonce}\n` + + ` consumer: ${consumer}\n` + + ` message: "${message}"\n` + + ` messageHash: ${consumerMessage}\n` + + ` signature: ${signature}`, + true + ) + // Try EOA signature validation try { const addressFromHashSignature = ethers.verifyMessage(consumerMessage, signature) const addressFromBytesSignature = ethers.verifyMessage(messageHashBytes, signature) + + CORE_LOGGER.logMessage( + `[DEBUG] Recovered addresses:\n` + + ` From hash: ${addressFromHashSignature}\n` + + ` From bytes: ${addressFromBytesSignature}\n` + + ` Expected: ${consumer}\n` + + ` Hash match: ${ethers.getAddress(addressFromHashSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase()}\n` + + ` Bytes match: ${ethers.getAddress(addressFromBytesSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase()}`, + true + ) + if ( ethers.getAddress(addressFromHashSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase() || ethers.getAddress(addressFromBytesSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase() ) { + CORE_LOGGER.logMessage('[DEBUG] ✅ EOA signature validation PASSED', true) return { valid: true } } + CORE_LOGGER.logMessage('[DEBUG] ❌ EOA signature validation FAILED', true) } catch (error) { + CORE_LOGGER.logMessage(`[DEBUG] EOA validation exception: ${error.message}`, true) // Continue to smart account check } From 99f5a1d7a7b6737e678973bd74aa89752e984c67 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Mon, 16 Feb 2026 12:37:13 +0200 Subject: [PATCH 03/13] debug payment --- CLAUDE.md | 163 ++++++++++++++++++++ src/components/core/compute/startCompute.ts | 13 -- src/components/core/utils/escrow.ts | 5 + src/components/core/utils/nonceHandler.ts | 22 --- 4 files changed, 168 insertions(+), 35 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 000000000..ee73770d1 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,163 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +Ocean Node is a unified Node.js service consolidating three core Ocean Protocol components: +- **Provider**: Data access control & payment verification +- **Aquarius**: Metadata/DDO indexing and caching +- **Subgraph**: Blockchain event tracking + +Nodes communicate via HTTP API and libp2p P2P network, supporting multi-chain operations (Ethereum, Optimism, Polygon, etc.) for data asset discovery, compute-to-data (C2D), and transaction validation. + +## Build & Development Commands + +```bash +# Install dependencies and build +npm install +npm run build + +# Run the node (requires PRIVATE_KEY in .env) +npm run start + +# Lint and format +npm run lint # ESLint + type-check +npm run lint:fix # Auto-fix lint issues +npm run format # Prettier formatting +npm run type-check # TypeScript type checking only + +# Testing +npm run test:unit # Unit tests only +npm run test:integration # Integration tests (requires Barge - see below) +npm run test:integration:light # Integration tests without C2D + +# Run specific test file +npm run build-tests && npm run mocha "./dist/test/unit/TESTFILE.test.js" + +# Performance tests (requires k6 installed) +npm run test:smoke +npm run test:load +npm run test:stress +``` + +**Integration test setup**: Start [Barge](https://github.com/oceanprotocol/barge) in a separate terminal: +```bash +git clone https://github.com/oceanprotocol/barge.git && cd barge +git checkout feature/nodes +./start_ocean.sh -with-c2d +``` + +## Architecture + +### Handler-Registry Command Pattern + +All P2P and HTTP requests follow a handler-based architecture: + +1. **Command arrives** (via P2P or HTTP) → validated → handler resolved from `CoreHandlersRegistry` +2. **Handler execution**: Extends `CommandHandler` (or `AdminCommandHandler`), implements `validate()` and `handle()` methods +3. **Response returned**: Streams `P2PCommandResponse` (JSON or binary) + +**Key files**: +- `src/components/core/handler/coreHandlersRegistry.ts` - Handler registry (40+ handlers) +- `src/components/core/handler/handler.ts` - Base handler classes +- `src/utils/constants.ts` - `PROTOCOL_COMMANDS` and `SUPPORTED_PROTOCOL_COMMANDS` + +### Adding a New Command Handler + +1. Define command type in `src/@types/commands.ts` +2. Create handler class in `src/components/core/handler/`: + ```typescript + export class MyHandler extends CommandHandler { + validate(command: MyCommand): ValidateParams { + return validateCommandParameters(command, ['required', 'fields']) + } + async handle(task: MyCommand): Promise { + // Implementation + } + } + ``` +3. Register in `CoreHandlersRegistry` constructor: `this.registerCoreHandler(PROTOCOL_COMMANDS.MY_COMMAND, new MyHandler(node))` +4. Add to `SUPPORTED_PROTOCOL_COMMANDS` in `src/utils/constants.ts` + +### OceanNode Singleton + +Central coordinator managing all components. Access via `OceanNode.getInstance()`. Provides access to: +- `getDatabase()` - Database connections +- `getP2PNode()` - libp2p networking +- `getIndexer()` - Blockchain event indexer +- `getProvider()` - Payment/access validation +- `getCoreHandlers()` - Handler registry +- `getC2DEngines()` - Compute-to-data engines + +### Database Layer + +Multiple backends via `DatabaseFactory`: +- **Elasticsearch/Typesense**: DDO metadata, indexer state, orders +- **SQLite**: Nonce tracking, config storage, C2D database + +Access via `Database` instance: `db.ddo`, `db.indexer`, `db.order`, `db.c2d`, `db.nonce` + +### Node Layers + +1. **Network Layer**: libp2p (P2P) & Express (HTTP API) +2. **Components Layer**: Indexer, Provider +3. **Modules Layer**: MPC, TEE, Database, C2D engines + +## Key Conventions + +### Logging + +Use module-specific loggers, never `console.log`: +```typescript +import { CORE_LOGGER, INDEXER_LOGGER, P2P_LOGGER, PROVIDER_LOGGER } from './utils/logging/common.js' +``` + +### Validation Pattern + +Commands validate parameters before execution using `validateCommandParameters()`: +```typescript +validateCommandParameters(command, ['required', 'fields']) // returns ValidateParams +``` + +### Response Format + +All handlers return `P2PCommandResponse`: `{ httpStatus, body?, stream?, error? }`. Stream responses use Node.js Readable for large data. + +### TypeScript/ESM Configuration + +- Target: ES2022, Module resolution: Node +- Run node with: `node --experimental-specifier-resolution=node dist/index.js` +- Node version: 22 (see `.nvmrc`) + +## Configuration + +Environment-driven via `.env` or `CONFIG_PATH=/path/to/config.json`: +- **PRIVATE_KEY** (required): Node identity for P2P + crypto operations (include `0x` prefix) +- **DB_URL**: Elasticsearch/Typesense connection +- **RPCS**: JSON mapping network IDs to RPC endpoints +- **OPERATOR_SERVICE_URL**: C2D cluster URLs + +See `docs/env.md` for all environment variables. + +## Key Files Reference + +| File | Purpose | +|------|---------| +| `src/index.ts` | Entry point; Express app setup, component initialization | +| `src/OceanNode.ts` | Singleton coordinator; escrow, auth, rate limiting | +| `src/components/core/handler/coreHandlersRegistry.ts` | Command handler registry | +| `src/components/database/` | Database abstraction & factory | +| `src/components/P2P/` | libp2p networking, P2P command routing | +| `src/components/Indexer/` | Blockchain event crawling, DDO indexing | +| `src/components/Provider/` | Payment validation, access control | +| `src/components/c2d/` | Compute-to-data engines (Docker, Kubernetes) | +| `src/utils/constants.ts` | Protocol commands, environment variable definitions | +| `src/@types/` | Command & data type definitions | + +## Testing Conventions + +- **Unit tests**: `src/test/unit/` - handler validation, command parsing (no DB required) +- **Integration tests**: `src/test/integration/` - full stack with Docker Compose services +- Use `setupEnvironment()` / `tearDownEnvironment()` in test hooks to preserve env between tests +- Avoid overriding `process.env` directly in tests diff --git a/src/components/core/compute/startCompute.ts b/src/components/core/compute/startCompute.ts index 384a4f3bb..99b2ed1b2 100644 --- a/src/components/core/compute/startCompute.ts +++ b/src/components/core/compute/startCompute.ts @@ -68,19 +68,6 @@ export class PaidComputeStartHandler extends CommandHandler { if (!task.queueMaxWaitTime) { task.queueMaxWaitTime = 0 } - // DEBUG: Log the message construction - const debugMessage = String( - task.consumerAddress + task.datasets[0]?.documentId + task.nonce - ) - CORE_LOGGER.logMessage( - `[DEBUG] Signature validation message:\n` + - ` datasets: ${JSON.stringify(task.datasets)}\n` + - ` datasets[0]?.documentId: ${task.datasets[0]?.documentId}\n` + - ` consumerAddress: ${task.consumerAddress}\n` + - ` nonce: ${task.nonce}\n` + - ` Message: "${debugMessage}"`, - true - ) const authValidationResponse = await this.validateTokenOrSignature( task.authorization, diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index e336f63e1..6052e40e1 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -157,6 +157,11 @@ export class Escrow { if (!contract) throw new Error(`Failed to initialize escrow contract`) const wei = await this.getPaymentAmountInWei(amount, chain, token) const userBalance = await this.getUserAvailableFunds(chain, payer, token) + + CORE_LOGGER.logMessage( + `User balance ${BigInt(userBalance.toString())} and payment amount in wei ${BigInt(wei)}` + ) + if (BigInt(userBalance.toString()) < BigInt(wei)) { // not enough funds throw new Error(`User ${payer} does not have enough funds`) diff --git a/src/components/core/utils/nonceHandler.ts b/src/components/core/utils/nonceHandler.ts index aac85e7e6..19016f98a 100644 --- a/src/components/core/utils/nonceHandler.ts +++ b/src/components/core/utils/nonceHandler.ts @@ -201,33 +201,11 @@ async function validateNonceAndSignature( ) const messageHashBytes = ethers.toBeArray(consumerMessage) - // DEBUG: Log validation details - CORE_LOGGER.logMessage( - `[DEBUG] Signature validation:\n` + - ` nonce: ${nonce}\n` + - ` existingNonce: ${existingNonce}\n` + - ` consumer: ${consumer}\n` + - ` message: "${message}"\n` + - ` messageHash: ${consumerMessage}\n` + - ` signature: ${signature}`, - true - ) - // Try EOA signature validation try { const addressFromHashSignature = ethers.verifyMessage(consumerMessage, signature) const addressFromBytesSignature = ethers.verifyMessage(messageHashBytes, signature) - CORE_LOGGER.logMessage( - `[DEBUG] Recovered addresses:\n` + - ` From hash: ${addressFromHashSignature}\n` + - ` From bytes: ${addressFromBytesSignature}\n` + - ` Expected: ${consumer}\n` + - ` Hash match: ${ethers.getAddress(addressFromHashSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase()}\n` + - ` Bytes match: ${ethers.getAddress(addressFromBytesSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase()}`, - true - ) - if ( ethers.getAddress(addressFromHashSignature)?.toLowerCase() === ethers.getAddress(consumer)?.toLowerCase() || From 0f48b134eb949cd6b7ae506f5bba7738cf5d4d03 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Mon, 16 Feb 2026 12:37:38 +0200 Subject: [PATCH 04/13] debug payment --- CLAUDE.md | 163 ------------------------------------------------------ 1 file changed, 163 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index ee73770d1..000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,163 +0,0 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Project Overview - -Ocean Node is a unified Node.js service consolidating three core Ocean Protocol components: -- **Provider**: Data access control & payment verification -- **Aquarius**: Metadata/DDO indexing and caching -- **Subgraph**: Blockchain event tracking - -Nodes communicate via HTTP API and libp2p P2P network, supporting multi-chain operations (Ethereum, Optimism, Polygon, etc.) for data asset discovery, compute-to-data (C2D), and transaction validation. - -## Build & Development Commands - -```bash -# Install dependencies and build -npm install -npm run build - -# Run the node (requires PRIVATE_KEY in .env) -npm run start - -# Lint and format -npm run lint # ESLint + type-check -npm run lint:fix # Auto-fix lint issues -npm run format # Prettier formatting -npm run type-check # TypeScript type checking only - -# Testing -npm run test:unit # Unit tests only -npm run test:integration # Integration tests (requires Barge - see below) -npm run test:integration:light # Integration tests without C2D - -# Run specific test file -npm run build-tests && npm run mocha "./dist/test/unit/TESTFILE.test.js" - -# Performance tests (requires k6 installed) -npm run test:smoke -npm run test:load -npm run test:stress -``` - -**Integration test setup**: Start [Barge](https://github.com/oceanprotocol/barge) in a separate terminal: -```bash -git clone https://github.com/oceanprotocol/barge.git && cd barge -git checkout feature/nodes -./start_ocean.sh -with-c2d -``` - -## Architecture - -### Handler-Registry Command Pattern - -All P2P and HTTP requests follow a handler-based architecture: - -1. **Command arrives** (via P2P or HTTP) → validated → handler resolved from `CoreHandlersRegistry` -2. **Handler execution**: Extends `CommandHandler` (or `AdminCommandHandler`), implements `validate()` and `handle()` methods -3. **Response returned**: Streams `P2PCommandResponse` (JSON or binary) - -**Key files**: -- `src/components/core/handler/coreHandlersRegistry.ts` - Handler registry (40+ handlers) -- `src/components/core/handler/handler.ts` - Base handler classes -- `src/utils/constants.ts` - `PROTOCOL_COMMANDS` and `SUPPORTED_PROTOCOL_COMMANDS` - -### Adding a New Command Handler - -1. Define command type in `src/@types/commands.ts` -2. Create handler class in `src/components/core/handler/`: - ```typescript - export class MyHandler extends CommandHandler { - validate(command: MyCommand): ValidateParams { - return validateCommandParameters(command, ['required', 'fields']) - } - async handle(task: MyCommand): Promise { - // Implementation - } - } - ``` -3. Register in `CoreHandlersRegistry` constructor: `this.registerCoreHandler(PROTOCOL_COMMANDS.MY_COMMAND, new MyHandler(node))` -4. Add to `SUPPORTED_PROTOCOL_COMMANDS` in `src/utils/constants.ts` - -### OceanNode Singleton - -Central coordinator managing all components. Access via `OceanNode.getInstance()`. Provides access to: -- `getDatabase()` - Database connections -- `getP2PNode()` - libp2p networking -- `getIndexer()` - Blockchain event indexer -- `getProvider()` - Payment/access validation -- `getCoreHandlers()` - Handler registry -- `getC2DEngines()` - Compute-to-data engines - -### Database Layer - -Multiple backends via `DatabaseFactory`: -- **Elasticsearch/Typesense**: DDO metadata, indexer state, orders -- **SQLite**: Nonce tracking, config storage, C2D database - -Access via `Database` instance: `db.ddo`, `db.indexer`, `db.order`, `db.c2d`, `db.nonce` - -### Node Layers - -1. **Network Layer**: libp2p (P2P) & Express (HTTP API) -2. **Components Layer**: Indexer, Provider -3. **Modules Layer**: MPC, TEE, Database, C2D engines - -## Key Conventions - -### Logging - -Use module-specific loggers, never `console.log`: -```typescript -import { CORE_LOGGER, INDEXER_LOGGER, P2P_LOGGER, PROVIDER_LOGGER } from './utils/logging/common.js' -``` - -### Validation Pattern - -Commands validate parameters before execution using `validateCommandParameters()`: -```typescript -validateCommandParameters(command, ['required', 'fields']) // returns ValidateParams -``` - -### Response Format - -All handlers return `P2PCommandResponse`: `{ httpStatus, body?, stream?, error? }`. Stream responses use Node.js Readable for large data. - -### TypeScript/ESM Configuration - -- Target: ES2022, Module resolution: Node -- Run node with: `node --experimental-specifier-resolution=node dist/index.js` -- Node version: 22 (see `.nvmrc`) - -## Configuration - -Environment-driven via `.env` or `CONFIG_PATH=/path/to/config.json`: -- **PRIVATE_KEY** (required): Node identity for P2P + crypto operations (include `0x` prefix) -- **DB_URL**: Elasticsearch/Typesense connection -- **RPCS**: JSON mapping network IDs to RPC endpoints -- **OPERATOR_SERVICE_URL**: C2D cluster URLs - -See `docs/env.md` for all environment variables. - -## Key Files Reference - -| File | Purpose | -|------|---------| -| `src/index.ts` | Entry point; Express app setup, component initialization | -| `src/OceanNode.ts` | Singleton coordinator; escrow, auth, rate limiting | -| `src/components/core/handler/coreHandlersRegistry.ts` | Command handler registry | -| `src/components/database/` | Database abstraction & factory | -| `src/components/P2P/` | libp2p networking, P2P command routing | -| `src/components/Indexer/` | Blockchain event crawling, DDO indexing | -| `src/components/Provider/` | Payment validation, access control | -| `src/components/c2d/` | Compute-to-data engines (Docker, Kubernetes) | -| `src/utils/constants.ts` | Protocol commands, environment variable definitions | -| `src/@types/` | Command & data type definitions | - -## Testing Conventions - -- **Unit tests**: `src/test/unit/` - handler validation, command parsing (no DB required) -- **Integration tests**: `src/test/integration/` - full stack with Docker Compose services -- Use `setupEnvironment()` / `tearDownEnvironment()` in test hooks to preserve env between tests -- Avoid overriding `process.env` directly in tests From 95d548a7ec622e199bb63e4f17d96ea8ab08dfd5 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Mon, 16 Feb 2026 13:14:50 +0200 Subject: [PATCH 05/13] improve logging --- src/components/c2d/compute_engine_base.ts | 2 ++ src/components/core/utils/escrow.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/components/c2d/compute_engine_base.ts b/src/components/c2d/compute_engine_base.ts index b6cb3e1e5..439f8cf0c 100644 --- a/src/components/c2d/compute_engine_base.ts +++ b/src/components/c2d/compute_engine_base.ts @@ -529,6 +529,8 @@ export abstract class C2DEngine { token: string, maxJobDuration: number ): number | null { + CORE_LOGGER.logMessage(`Env minJobDuration ${BigInt(env.minJobDuration.toString())}`) + if (maxJobDuration < env.minJobDuration) maxJobDuration = env.minJobDuration const prices = this.getEnvPricesForToken(env, chainId, token) if (!prices) return null diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index 6052e40e1..a3be07da8 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -155,6 +155,7 @@ export class Escrow { const signer = await blockchain.getSigner() const contract = this.getContract(chain, signer) if (!contract) throw new Error(`Failed to initialize escrow contract`) + CORE_LOGGER.logMessage(`Cost ${BigInt(amount.toString())}`) const wei = await this.getPaymentAmountInWei(amount, chain, token) const userBalance = await this.getUserAvailableFunds(chain, payer, token) From 4f52e5eda6b2b26ea53c3c1f5ab2f2f8544fe97f Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Mon, 16 Feb 2026 13:22:03 +0200 Subject: [PATCH 06/13] remove toString --- src/components/c2d/compute_engine_base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/c2d/compute_engine_base.ts b/src/components/c2d/compute_engine_base.ts index 439f8cf0c..5314583f5 100644 --- a/src/components/c2d/compute_engine_base.ts +++ b/src/components/c2d/compute_engine_base.ts @@ -529,7 +529,7 @@ export abstract class C2DEngine { token: string, maxJobDuration: number ): number | null { - CORE_LOGGER.logMessage(`Env minJobDuration ${BigInt(env.minJobDuration.toString())}`) + CORE_LOGGER.logMessage(`Env minJobDuration ${BigInt(env.minJobDuration)}`) if (maxJobDuration < env.minJobDuration) maxJobDuration = env.minJobDuration const prices = this.getEnvPricesForToken(env, chainId, token) From 3ef388c4357c3d36d8da5bfda4c376c93567ac8a Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Mon, 16 Feb 2026 13:30:28 +0200 Subject: [PATCH 07/13] log maxJobDuration --- src/components/c2d/compute_engine_base.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/c2d/compute_engine_base.ts b/src/components/c2d/compute_engine_base.ts index 5314583f5..3202c7fc5 100644 --- a/src/components/c2d/compute_engine_base.ts +++ b/src/components/c2d/compute_engine_base.ts @@ -529,9 +529,9 @@ export abstract class C2DEngine { token: string, maxJobDuration: number ): number | null { - CORE_LOGGER.logMessage(`Env minJobDuration ${BigInt(env.minJobDuration)}`) - if (maxJobDuration < env.minJobDuration) maxJobDuration = env.minJobDuration + CORE_LOGGER.logMessage(`Env maxJobDuration ${maxJobDuration}`) + const prices = this.getEnvPricesForToken(env, chainId, token) if (!prices) return null let cost: number = 0 From 410ec6f2cf6b66e5ca63474ba4dea2c293249242 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Tue, 17 Feb 2026 12:22:44 +0200 Subject: [PATCH 08/13] improve logging --- src/components/c2d/compute_engine_base.ts | 2 ++ src/components/core/compute/startCompute.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/src/components/c2d/compute_engine_base.ts b/src/components/c2d/compute_engine_base.ts index 3202c7fc5..4b528109d 100644 --- a/src/components/c2d/compute_engine_base.ts +++ b/src/components/c2d/compute_engine_base.ts @@ -529,6 +529,8 @@ export abstract class C2DEngine { token: string, maxJobDuration: number ): number | null { + CORE_LOGGER.logMessage(`minJobDuration ${env?.minJobDuration}`) + if (maxJobDuration < env.minJobDuration) maxJobDuration = env.minJobDuration CORE_LOGGER.logMessage(`Env maxJobDuration ${maxJobDuration}`) diff --git a/src/components/core/compute/startCompute.ts b/src/components/core/compute/startCompute.ts index 99b2ed1b2..13a5bf3fc 100644 --- a/src/components/core/compute/startCompute.ts +++ b/src/components/core/compute/startCompute.ts @@ -523,6 +523,7 @@ export class PaidComputeStartHandler extends CommandHandler { // job ID unicity const jobId = generateUniqueID(s) // let's calculate payment needed based on resources request and maxJobDuration + CORE_LOGGER.logMessage(`MaxJobDuration received ${task.maxJobDuration}`) const cost = engine.calculateResourcesCost( task.resources, env, From 74a04ad63bd26ad1197c83a19a0f2bab97f05410 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Tue, 17 Feb 2026 12:29:56 +0200 Subject: [PATCH 09/13] add more logs --- src/components/c2d/compute_engine_base.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/c2d/compute_engine_base.ts b/src/components/c2d/compute_engine_base.ts index 4b528109d..119c5848c 100644 --- a/src/components/c2d/compute_engine_base.ts +++ b/src/components/c2d/compute_engine_base.ts @@ -538,8 +538,14 @@ export abstract class C2DEngine { if (!prices) return null let cost: number = 0 for (const request of resourcesRequest) { + CORE_LOGGER.logMessage(`Resource ${request.id} with amount ${request.amount}`) + const resourcePrice = this.getResourcePrice(prices, request.id) - cost += resourcePrice * request.amount * Math.ceil(maxJobDuration / 60) + CORE_LOGGER.logMessage(`Resource price ${resourcePrice}`) + const resourceCost = resourcePrice * request.amount * Math.ceil(maxJobDuration / 60) + CORE_LOGGER.logMessage(`Resource cost ${resourceCost}`) + + cost += resourceCost } return cost } From 060e632fe393495d64011f8ae9dea6c7070deccb Mon Sep 17 00:00:00 2001 From: giurgiur99 Date: Tue, 17 Feb 2026 13:19:12 +0200 Subject: [PATCH 10/13] logs lock --- src/components/core/utils/escrow.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index a3be07da8..7cf836646 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -38,6 +38,9 @@ export class Escrow { } getMinLockTime(maxJobDuration: number) { + console.log( + `maxJobDuration ${maxJobDuration} and claimDurationTimeout ${this.claimDurationTimeout}` + ) return maxJobDuration + this.claimDurationTimeout } @@ -201,9 +204,12 @@ export class Escrow { ) { throw new Error(`No valid escrow auths found(will go over limit)`) } + console.log('--> Before maxLockSeconds check') + if (BigInt(auths[0].maxLockSeconds.toString()) < BigInt(expiry)) { throw new Error(`No valid escrow auths found(maxLockSeconds too low)`) } + console.log('--> After maxLockSeconds check') if ( BigInt(auths[0].currentLocks.toString()) + BigInt(1) > BigInt(auths[0].maxLockCounts.toString()) From ca3a06a94ecef1e5e8f5b1f052e03da4b48c0b7e Mon Sep 17 00:00:00 2001 From: giurgiur99 Date: Tue, 17 Feb 2026 13:27:04 +0200 Subject: [PATCH 11/13] more logs --- src/components/core/utils/escrow.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index 7cf836646..56f183e68 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -153,6 +153,7 @@ export class Escrow { amount: number, expiry: BigNumberish ): Promise { + console.log(`--> createLock expiry ${expiry}`) const jobId = create256Hash(job) const blockchain = this.getBlockchain(chain) const signer = await blockchain.getSigner() @@ -161,11 +162,13 @@ export class Escrow { CORE_LOGGER.logMessage(`Cost ${BigInt(amount.toString())}`) const wei = await this.getPaymentAmountInWei(amount, chain, token) const userBalance = await this.getUserAvailableFunds(chain, payer, token) - + console.log(`--> createLock userBalance ${userBalance}`) + console.log(`--> createLock userBalance ${BigInt(userBalance.toString())}`) CORE_LOGGER.logMessage( `User balance ${BigInt(userBalance.toString())} and payment amount in wei ${BigInt(wei)}` ) - + console.log(`--> createLock wei ${wei}`) + console.log(`--> createLock wei ${BigInt(wei)}`) if (BigInt(userBalance.toString()) < BigInt(wei)) { // not enough funds throw new Error(`User ${payer} does not have enough funds`) @@ -198,6 +201,14 @@ export class Escrow { } authorizations.` ) } + console.log( + `--> createLock auths[0].currentLockedAmount ${auths[0].currentLockedAmount}` + ) + console.log(`--> createLock auths[0].maxLockedAmount ${auths[0].maxLockedAmount}`) + + console.log( + `--> createLock BigInt(auths[0].currentLockedAmount.toString()) + BigInt(wei) ${BigInt(auths[0].currentLockedAmount.toString()) + BigInt(wei)}` + ) if ( BigInt(auths[0].currentLockedAmount.toString()) + BigInt(wei) > BigInt(auths[0].maxLockedAmount.toString()) From bf99b6c2136c165b22ca7d1db471f475c1cf8bf7 Mon Sep 17 00:00:00 2001 From: giurgiur99 Date: Tue, 17 Feb 2026 13:33:14 +0200 Subject: [PATCH 12/13] no bigint cost log --- src/components/core/utils/escrow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index 56f183e68..41a0524e9 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -159,7 +159,7 @@ export class Escrow { const signer = await blockchain.getSigner() const contract = this.getContract(chain, signer) if (!contract) throw new Error(`Failed to initialize escrow contract`) - CORE_LOGGER.logMessage(`Cost ${BigInt(amount.toString())}`) + CORE_LOGGER.logMessage(`Cost ${amount}`) const wei = await this.getPaymentAmountInWei(amount, chain, token) const userBalance = await this.getUserAvailableFunds(chain, payer, token) console.log(`--> createLock userBalance ${userBalance}`) From 22849be50816d59a06d13d4811a5d700ec3a9d60 Mon Sep 17 00:00:00 2001 From: denisiuriet Date: Tue, 17 Feb 2026 13:36:01 +0200 Subject: [PATCH 13/13] remove failing log --- src/components/core/utils/escrow.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/core/utils/escrow.ts b/src/components/core/utils/escrow.ts index 41a0524e9..88b5764bc 100644 --- a/src/components/core/utils/escrow.ts +++ b/src/components/core/utils/escrow.ts @@ -159,7 +159,6 @@ export class Escrow { const signer = await blockchain.getSigner() const contract = this.getContract(chain, signer) if (!contract) throw new Error(`Failed to initialize escrow contract`) - CORE_LOGGER.logMessage(`Cost ${amount}`) const wei = await this.getPaymentAmountInWei(amount, chain, token) const userBalance = await this.getUserAvailableFunds(chain, payer, token) console.log(`--> createLock userBalance ${userBalance}`)