Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
586 commits
Select commit Hold shift + click to select a range
3926a47
fix: ci
AdriGeorge Jun 2, 2025
dc402a8
fix: ci
AdriGeorge Jun 2, 2025
5656a4f
fix: tests
AdriGeorge Jun 2, 2025
a541140
fix: console
AdriGeorge Jun 2, 2025
8975648
fix: tests
AdriGeorge Jun 2, 2025
6a3c8f5
fix: tests
AdriGeorge Jun 2, 2025
2f98604
fix: ci cd
AdriGeorge Jun 3, 2025
bc21da1
fix: ci
AdriGeorge Jun 3, 2025
b7b8698
fix: ci
AdriGeorge Jun 3, 2025
b35071a
fix: tests
AdriGeorge Jun 3, 2025
6b32375
add log
AdriGeorge Jun 3, 2025
edcdedd
fix: logs
AdriGeorge Jun 3, 2025
696953e
fix: test and logs
AdriGeorge Jun 3, 2025
be9a5e9
fix: tests
AdriGeorge Jun 3, 2025
4cca11d
chore: return schema
AdriGeorge Jun 6, 2025
0839f35
fix: schema
AdriGeorge Jun 6, 2025
7814746
fix: typesense get schema
AdriGeorge Jun 6, 2025
cfbaf40
fix: typesense schema
AdriGeorge Jun 6, 2025
e34958e
fix: tests
AdriGeorge Jun 6, 2025
c58f5b2
Merge pull request #954 from oceanprotocol/feat/get-schema-name
AdriGeorge Jun 6, 2025
61b595d
fix: tests
AdriGeorge Jun 6, 2025
36bc330
Fix CI envs for system tests. (#955)
mariacarmina Jun 10, 2025
52283a1
fix: ddojs
AdriGeorge Jun 11, 2025
e8cc695
allow rawcode (#956)
giurgiur99 Jun 12, 2025
5fbd0fe
Auth token routes (#952)
giurgiur99 Jun 12, 2025
36dfdac
fix: console
AdriGeorge Jun 12, 2025
e8f6f2f
fix: update event
AdriGeorge Jun 12, 2025
88c7ed5
fix: update indexedMetadata event
AdriGeorge Jun 12, 2025
d6678dc
Merge pull request #960 from oceanprotocol/feat/update-event
AdriGeorge Jun 12, 2025
2c66a2c
optional rawcode (#962)
giurgiur99 Jun 12, 2025
0be52b1
fix: remove logs
AdriGeorge Jun 13, 2025
4544b33
Update publisherTrustedAlgorithmPublishers and publisherTrustedAlgori…
mariacarmina Jun 13, 2025
6784cb7
Merge pull request #43 from OceanProtocolEnterprise/feat/sync-nodes
AdriGeorge Jun 16, 2025
9ee90df
allow no dataset initialize (#966)
giurgiur99 Jun 17, 2025
ed12a92
fix: ddo chain id
AdriGeorge Jun 18, 2025
64fae5e
Merge branch 'main' into feature/credentials-check-for-compute
mariacarmina Jun 18, 2025
8cb5955
fix: chain
AdriGeorge Jun 19, 2025
0eb95bb
fix: metadata
AdriGeorge Jun 19, 2025
e2ffe7a
fix: merge
AdriGeorge Jun 19, 2025
9e0f995
fix: add logs
AdriGeorge Jun 19, 2025
f7466e1
fix: logs
AdriGeorge Jun 19, 2025
eb752d2
fix: logs
AdriGeorge Jun 19, 2025
2b79435
fix: logs
AdriGeorge Jun 19, 2025
78a5965
fix: logs
AdriGeorge Jun 19, 2025
2c92355
fix: logs
AdriGeorge Jun 19, 2025
484fa50
fix: logs
AdriGeorge Jun 19, 2025
8317f92
fix: test
AdriGeorge Jun 23, 2025
03e4294
fix: removed logs
AdriGeorge Jun 23, 2025
a919d84
Use signature or auth token for routes (#968)
giurgiur99 Jun 24, 2025
a2a9793
Fix commands usage for policy server.
mariacarmina Jun 24, 2025
65cb51a
fix: logs
AdriGeorge Jun 25, 2025
8c61711
fix: logs
AdriGeorge Jun 25, 2025
60258f5
Fix conflicts.
mariacarmina Jun 25, 2025
198f0e3
Fix arguments.
mariacarmina Jun 26, 2025
eb432d3
Add support for nvidia/amd gpus (#928)
alexcos20 Jun 30, 2025
9711be4
Refactor trusted algortihms and trusted publishers checks.
mariacarmina Jul 1, 2025
5df5bde
Use another branch from cli.
mariacarmina Jul 2, 2025
ecef864
chore: sync
AdriGeorge Jul 3, 2025
a164007
fix: ci
AdriGeorge Jul 3, 2025
0d37ead
chore: sync
AdriGeorge Jul 3, 2025
48c0316
fix: tests
AdriGeorge Jul 3, 2025
4a02b76
fix: remove logs
AdriGeorge Jul 3, 2025
3226891
fix: ci tests
AdriGeorge Jul 3, 2025
5456d3b
fix: ci tests
AdriGeorge Jul 3, 2025
eba1917
Metadata in compute jobs (#976)
giurgiur99 Jul 9, 2025
19afc71
Refactor trusted algortihms and trusted publishers checks. (#973)
mariacarmina Jul 9, 2025
ba189bb
Merge pull request #46 from OceanProtocolEnterprise/feature/refactor-…
AdriGeorge Jul 9, 2025
4f0d41f
resolve conflicts.
mariacarmina Jul 9, 2025
5ab79f9
Fix review.
mariacarmina Jul 9, 2025
1d14e9c
Use ddo.js for DDO fields manipulation.
mariacarmina Jul 10, 2025
b142f89
Update for free start compute.
mariacarmina Jul 10, 2025
ce88067
Update datasets samples.
mariacarmina Jul 10, 2025
dae8fa7
Update branch for cli.
mariacarmina Jul 10, 2025
a13bfb4
chore: stage
AdriGeorge Jul 10, 2025
37e6454
fix: lint
AdriGeorge Jul 10, 2025
d13b8ab
fix: log
AdriGeorge Jul 10, 2025
611c06c
fix: tests
AdriGeorge Jul 11, 2025
b2fca2d
fix: tests
AdriGeorge Jul 11, 2025
5c0f8ca
remove cli custom branch. (#977)
mariacarmina Jul 11, 2025
14e9ebd
Fix datasets samples.
mariacarmina Jul 11, 2025
e338882
Merge branch 'main' into feature/credentials-check-for-compute
mariacarmina Jul 11, 2025
12e1b73
fix: tests
AdriGeorge Jul 11, 2025
5477ba2
Fix samples and ci.
mariacarmina Jul 11, 2025
ccdc8d0
fix: tests
AdriGeorge Jul 11, 2025
e5a7d9f
fix: fix
AdriGeorge Jul 11, 2025
c9f6910
Update ddo.js.
mariacarmina Jul 11, 2025
faa9da0
Update lock.
mariacarmina Jul 11, 2025
7e7a3d9
Updated ddo schemas version.
mariacarmina Jul 13, 2025
5ea33f6
Fix samples.
mariacarmina Jul 13, 2025
e5f2068
Add engines for test.
mariacarmina Jul 13, 2025
219e97b
Bring all tests back.
mariacarmina Jul 13, 2025
4123778
Merge branch 'feature/credentials-check-for-compute' of https://githu…
AdriGeorge Jul 14, 2025
b706e0b
fix: tests
AdriGeorge Jul 14, 2025
bfbdfb1
fix: ci
AdriGeorge Jul 14, 2025
7819425
fix: fix
AdriGeorge Jul 15, 2025
268f9c0
fix: fix
AdriGeorge Jul 15, 2025
fcd6eda
fix: fix
AdriGeorge Jul 15, 2025
ae2e1c5
fix: fix
AdriGeorge Jul 15, 2025
be6dc31
fix: add logs
AdriGeorge Jul 17, 2025
c848cb9
fix: fix
AdriGeorge Jul 17, 2025
df1beb6
fix: fix
AdriGeorge Jul 17, 2025
f4eb27c
fix: fix
AdriGeorge Jul 18, 2025
fb37344
Merge pull request #47 from OceanProtocolEnterprise/feature/integrate…
AdriGeorge Jul 23, 2025
2c191b6
chore: sync nodes
AdriGeorge Jul 24, 2025
cd570cb
chore: sync nodes
AdriGeorge Jul 24, 2025
b8a0440
fix: lint
AdriGeorge Jul 24, 2025
741b52d
fix: fix
AdriGeorge Jul 25, 2025
71dc2e3
fix: tests
AdriGeorge Jul 25, 2025
9278d51
Merge pull request #48 from OceanProtocolEnterprise/feat/sync-nodes-july
AdriGeorge Jul 25, 2025
26d41c1
chore: sync initiate
AdriGeorge Jul 28, 2025
2b8c5ea
fix: fix
AdriGeorge Jul 29, 2025
325ffe1
Merge pull request #49 from OceanProtocolEnterprise/feat/syncInitiate
AdriGeorge Jul 29, 2025
172c305
chore: sync
AdriGeorge Jul 30, 2025
927317a
Merge pull request #50 from OceanProtocolEnterprise/feat/sync-node-30-07
AdriGeorge Jul 30, 2025
66dc099
chore: validate-algo-for-dataset-initialize
AdriGeorge Jul 31, 2025
13a37e5
fix: logs
AdriGeorge Jul 31, 2025
93dc15b
fix: logs
AdriGeorge Jul 31, 2025
4ca2533
Merge pull request #51 from OceanProtocolEnterprise/feature/validate-…
AdriGeorge Aug 4, 2025
eb8512c
chore: sync august
AdriGeorge Aug 29, 2025
7112765
fix: lint
AdriGeorge Aug 29, 2025
53775a8
fix: log
AdriGeorge Sep 1, 2025
3180c6e
fix: remove logs
AdriGeorge Sep 1, 2025
f1614ed
Merge pull request #53 from OceanProtocolEnterprise/feat/sync-august
AdriGeorge Sep 1, 2025
c0ca1c1
fix: logs
AdriGeorge Sep 19, 2025
79d3b7f
fix: add logs
AdriGeorge Sep 23, 2025
72cb15e
fix: remove logs
AdriGeorge Sep 23, 2025
7c3fcec
chore: algoCheck
AdriGeorge Sep 30, 2025
2776834
fix: logs
AdriGeorge Sep 30, 2025
8a4b589
fix: add logs
AdriGeorge Oct 1, 2025
8d86dca
fix: fix
AdriGeorge Oct 1, 2025
33965dc
fix: logs
AdriGeorge Oct 1, 2025
b9ec3ab
add configLog and check errors
alexcos20 Oct 1, 2025
17d361c
Merge pull request #57 from OceanProtocolEnterprise/bug/fix_c2d_provi…
AdriGeorge Oct 2, 2025
a706a49
fix: removed logs
AdriGeorge Oct 2, 2025
0f887d7
Merge pull request #56 from OceanProtocolEnterprise/feat/algoChecksum
AdriGeorge Oct 2, 2025
4151f73
chore: sync
AdriGeorge Oct 6, 2025
a9f5da5
fix: tests
AdriGeorge Oct 6, 2025
476071b
fix: tests
AdriGeorge Oct 6, 2025
369fad2
fix: tests
AdriGeorge Oct 6, 2025
2da15b4
Merge pull request #59 from OceanProtocolEnterprise/feta/sync-6-10
AdriGeorge Oct 7, 2025
68109b6
fix: add logs
AdriGeorge Oct 7, 2025
a085acc
fix: remove logs
AdriGeorge Oct 7, 2025
9441f09
fix: logs
AdriGeorge Oct 10, 2025
3276960
fix: logs
AdriGeorge Oct 10, 2025
20b8c77
fix: logs
AdriGeorge Oct 10, 2025
117fc35
fix: logs
AdriGeorge Oct 10, 2025
b80c21a
fix: logs
AdriGeorge Oct 10, 2025
ea01de0
fix: logs
AdriGeorge Oct 10, 2025
adb165c
fix: removed logs
AdriGeorge Oct 10, 2025
12cd997
fix: logs
AdriGeorge Oct 10, 2025
a050461
fix: logs
AdriGeorge Oct 27, 2025
619aee2
fix: logs
AdriGeorge Oct 27, 2025
2ae1e57
fix: logs
AdriGeorge Oct 27, 2025
6d5a403
fix: fix chain
AdriGeorge Oct 27, 2025
a66cb4e
chore: sync
AdriGeorge Oct 29, 2025
b288856
fix: fix time lock
AdriGeorge Oct 30, 2025
bea62c5
Merge pull request #62 from OceanProtocolEnterprise/feat/sync-29-10
AdriGeorge Oct 30, 2025
5238998
chore: sync 3 11
AdriGeorge Nov 3, 2025
6ee2513
Merge pull request #63 from OceanProtocolEnterprise/feat/sync-3-11
AdriGeorge Nov 3, 2025
4df9a1f
chore: fix validate algo
AdriGeorge Nov 4, 2025
8b48164
Merge pull request #64 from OceanProtocolEnterprise/feat/validate-alg…
AdriGeorge Nov 4, 2025
124d18f
fix: logs
AdriGeorge Nov 10, 2025
8d203b1
fix: logs
AdriGeorge Nov 10, 2025
12b7750
usr data in query
AdriGeorge Nov 10, 2025
92e0d75
fix: test
AdriGeorge Nov 10, 2025
f54647f
fix: fix
AdriGeorge Nov 10, 2025
908b2f6
fix: lint
AdriGeorge Nov 10, 2025
6591c59
Merge pull request #65 from OceanProtocolEnterprise/feat/userdata-dow…
AdriGeorge Nov 10, 2025
8baeefc
chore: user data on compute
AdriGeorge Nov 12, 2025
3b04f3a
fix: logs
AdriGeorge Nov 12, 2025
74dd212
fix: remove logs
AdriGeorge Nov 12, 2025
cf2358f
Merge pull request #66 from OceanProtocolEnterprise/feat/compute-user…
AdriGeorge Nov 12, 2025
a4fee4a
chore: sync 28-11-25
AdriGeorge Nov 28, 2025
19d9150
fix: logs
AdriGeorge Nov 28, 2025
7b664ab
fix: removed logs
AdriGeorge Nov 28, 2025
6193070
Merge pull request #67 from OceanProtocolEnterprise/feat/sync-28-11-25
AdriGeorge Nov 28, 2025
78f85ad
fix: escrow
AdriGeorge Dec 2, 2025
58c9546
fix: fix
AdriGeorge Dec 2, 2025
5a45a8b
fix: escrow
AdriGeorge Dec 2, 2025
81eb7ed
fix: add logs
AdriGeorge Dec 8, 2025
2e59698
fix: remove logs
AdriGeorge Dec 8, 2025
45c7c00
fix: fix
AdriGeorge Dec 8, 2025
d9f9c8e
chore: sync
AdriGeorge Dec 11, 2025
da43c53
fix: fix
AdriGeorge Dec 11, 2025
9e84141
fix: lint
AdriGeorge Dec 11, 2025
9818fb5
fix: revert test algo
AdriGeorge Dec 11, 2025
c5ff08c
fix: test
AdriGeorge Dec 11, 2025
494ae1e
fix: test
AdriGeorge Dec 11, 2025
cc8d878
fix: fix
AdriGeorge Dec 11, 2025
622f883
Merge pull request #68 from OceanProtocolEnterprise/feat/sync-dec
AdriGeorge Dec 11, 2025
6eb5ede
fix docker tests & build only x64
alexcos20 Dec 19, 2025
e85eeb6
fix: logs
AdriGeorge Jan 19, 2026
83c9f0f
fix: logs
AdriGeorge Jan 19, 2026
10f1f24
fix: logs
AdriGeorge Jan 19, 2026
9ee0e36
fix: removed logs
AdriGeorge Jan 19, 2026
c991758
fix: ci
AdriGeorge Jan 27, 2026
fb8f83d
fix: ci
AdriGeorge Jan 27, 2026
23d4dc4
Merge remote-tracking branch 'upstream/main' into feat/stage
AdriGeorge Jan 28, 2026
fe0cf8d
fix: fix
AdriGeorge Jan 28, 2026
035ecf7
fix: fix
AdriGeorge Jan 28, 2026
70ce3e6
fix: test
AdriGeorge Jan 28, 2026
52b7ce7
fix: ci
AdriGeorge Jan 28, 2026
0b54f30
fix: restore
AdriGeorge Jan 28, 2026
abbf86e
ci: update contracts container name
ndrpp Jan 29, 2026
fd3e111
fix: add unhandled rejection and exception logs
ndrpp Jan 29, 2026
256b7d0
fix: show node logs in integration tests fail, update check node curl
ndrpp Jan 29, 2026
92c4dbc
fix: log
AdriGeorge Jan 29, 2026
36362b1
fix: fix
AdriGeorge Jan 29, 2026
203576e
fix: display curl node output
ndrpp Jan 29, 2026
ab4b41f
fix: update start ocean node script
ndrpp Jan 29, 2026
d68d5d4
Revert "fix: restore"
ndrpp Jan 29, 2026
3a53dd7
fix: add db username & password
ndrpp Jan 29, 2026
3fce507
fix: comment rejection and exception logs
ndrpp Jan 29, 2026
6f75270
fix: update start ocean node to use main shell
ndrpp Jan 29, 2026
84d6ed5
fix: add logs to build & start
ndrpp Jan 29, 2026
fd6ca91
fix: print node version
ndrpp Jan 29, 2026
194908f
Merge branch 'feat/sync28-01' into fix/test-system
ndrpp Jan 29, 2026
47c8d97
fix: revert workflow and index logs
ndrpp Jan 29, 2026
9ab12d2
fix: add more logs in start paid compute
ndrpp Jan 30, 2026
5ddb871
fix: switch to log message instead of error
ndrpp Jan 30, 2026
594a626
fix: add log in validation for initialize compute
ndrpp Jan 30, 2026
7332908
fix: add more logs
ndrpp Jan 30, 2026
4b82d7e
fix: throw error if unable to add job to db
ndrpp Jan 30, 2026
0d77df9
ci: update test_sytem job to point to ocean cli branch with more logs
ndrpp Jan 30, 2026
d50f073
fix: switch node private key in ci tests
ndrpp Jan 30, 2026
95d7491
fix: update logs in escrow.ts
ndrpp Jan 30, 2026
28e339f
fix: revert to previous private key for node in system test
ndrpp Feb 2, 2026
76b6b7e
Revert "fix: show node logs in integration tests fail, update check n…
ndrpp Feb 2, 2026
66de20b
Revert "fix: add more logs in start paid compute"
ndrpp Feb 2, 2026
77c969c
chore: cleanup
ndrpp Feb 2, 2026
aca00b4
chore: cleanup leftovers
ndrpp Feb 2, 2026
745e961
chore: fix formatting
ndrpp Feb 2, 2026
62f197c
Merge pull request #74 from OceanProtocolEnterprise/fix/test-system
AdriGeorge Feb 2, 2026
3db55b0
Merge pull request #73 from OceanProtocolEnterprise/feat/sync28-01
AdriGeorge Feb 2, 2026
b04a3df
chore: sync 02-04
AdriGeorge Feb 4, 2026
b56ff5b
fix: fix
AdriGeorge Feb 4, 2026
ce5ad90
fix: add logs
AdriGeorge Feb 4, 2026
fa18a6f
fix: logs
AdriGeorge Feb 4, 2026
ed1a111
fix: logs
AdriGeorge Feb 4, 2026
4ce626c
chore: sync 05-02
AdriGeorge Feb 5, 2026
faf4376
fix: logs
AdriGeorge Feb 5, 2026
b36572d
fix: logs
AdriGeorge Feb 5, 2026
ed5bded
fix: remove logs
AdriGeorge Feb 5, 2026
684622f
fix: log
AdriGeorge Feb 5, 2026
7676825
fix: add logs
AdriGeorge Feb 5, 2026
1490f5c
fix: fix
AdriGeorge Feb 5, 2026
4b37b35
fix: add log
AdriGeorge Feb 6, 2026
0d2c39a
fix: fix
AdriGeorge Feb 6, 2026
f186562
fix: fix
AdriGeorge Feb 6, 2026
56691f2
Merge pull request #75 from OceanProtocolEnterprise/feat/sync-04-02
AdriGeorge Feb 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
/dist/*
!/dist/dashboard
/dist
logs
c2d_storage
.env.local
.env
19 changes: 16 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,25 @@ export FEE_AMOUNT=
export ADDRESS_FILE=
export NODE_ENV=
export AUTHORIZED_DECRYPTERS=
export AUTHORIZED_DECRYPTERS_LIST=
export OPERATOR_SERVICE_URL=
export POLICY_SERVER_URL
export INTERFACES=
export ALLOWED_VALIDATORS=
export ALLOWED_VALIDATORS_LIST=
export AUTHORIZED_PUBLISHERS=
export AUTHORIZED_PUBLISHERS_LIST=
export INDEXER_INTERVAL=
export ALLOWED_ADMINS=
export DASHBOARD=true
export ALLOWED_ADMINS_LIST=
export CONTROL_PANEL=true
export RATE_DENY_LIST=
export MAX_REQ_PER_SECOND=
export MAX_REQ_PER_MINUTE=
export MAX_CHECKSUM_LENGTH=
export LOG_LEVEL=
export HTTP_API_PORT=
export VALIDATE_UNSIGNED_DDO=
export JWT_SECRET=

## p2p

Expand All @@ -55,4 +63,9 @@ export P2P_ENABLE_AUTONAT=
export P2P_ENABLE_CIRCUIT_RELAY_SERVER=
export P2P_ENABLE_CIRCUIT_RELAY_CLIENT=
export P2P_BOOTSTRAP_NODES=
export P2P_FILTER_ANNOUNCED_ADDRESSES=
export P2P_FILTER_ANNOUNCED_ADDRESSES=

## compute
export DOCKER_COMPUTE_ENVIRONMENTS=


2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @alexcos20
- @alexcos20
288 changes: 288 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
# Ocean Node - AI Coding Agent Instructions

## Project Overview

**Ocean Node** is a unified Node.js service that consolidates 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, support multi-chain operations (Ethereum, Optimism, Polygon, etc.), and enable data asset discovery, compute-to-data (C2D), and transaction validation.

## Architecture Patterns

### Handler-Registry Command Pattern

All P2P and HTTP requests follow a handler-based architecture:

1. **Command arrives** (via P2P or HTTP) → request validated → handler resolved from `CoreHandlersRegistry`
2. **Handler execution**: Each extends `CommandHandler` or `AdminCommandHandler`, implements `validate()` and `handle()` methods
3. **Response returned**: Streams P2PCommandResponse (JSON or binary) to caller

**Key files**: [src/components/core/handler/coreHandlersRegistry.ts](src/components/core/handler/coreHandlersRegistry.ts), [src/components/core/handler/handler.ts](src/components/core/handler/handler.ts)

Example handler structure:

```typescript
export class FileInfoHandler extends CommandHandler {
validate(command: FileInfoCommand): ValidateParams {
return validateCommandParameters(command, ['fileIndex', 'documentId', 'serviceId'])
}
async handle(task: FileInfoCommand): Promise<P2PCommandResponse> {
// Implementation
}
}
```

**Protocol commands** defined in [src/utils/constants.ts](src/utils/constants.ts): `PROTOCOL_COMMANDS` object with 40+ commands (download, encrypt, compute operations, admin tasks, etc.)

### Database Abstraction Layer

Multiple database backends via `DatabaseFactory` pattern:

- **Elasticsearch**: DDO metadata, indexer state, orders (async)
- **Typesense**: Search-optimized metadata queries
- **SQLite**: Nonce tracking, config storage, c2d Database (local)

Access via singleton `Database` class: `db.ddo`, `db.indexer`, `db.order`, `db.c2d`, `db.nonce`, etc.

### OceanNode Singleton

Central coordinator managing all components. Initialize with configuration and optional database/P2P/Provider/Indexer instances. Accessed via `OceanNode.getInstance()`.

## Critical Workflows

### Adding a New Command Handler

1. Define command type in [src/@types/commands.ts](src/@types/commands.ts)
2. Create handler class extending `CommandHandler` in `src/components/core/handler/`
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](src/utils/constants.ts)
5. Handlers receive `OceanNode` in constructor for accessing escrow, config, database, P2P network

### Building & Testing

- **Build**: `npm run build` → compiles TypeScript to `./dist/`
- **Tests**: `npm run test` runs unit + integration (requires Docker Compose for Typesense)
- **Dev**: Use `npm run build:tsc` in watch mode, or Node's `--experimental-specifier-resolution=node` for ESM imports

### Configuration

Environment-driven via `.env` or `CONFIG_PATH=/path/to/config.json`:

- **PRIVATE_KEY** (required): Node identity for P2P + crypto operations
- **DB_URL**: Elasticsearch/Typesense connection
- **RPCS**: JSON mapping network IDs to RPC endpoints
- **OPERATOR_SERVICE_URL**: C2D cluster URLs (array of strings)
- See [docs/env.md](docs/env.md) for 40+ environment variables

## Project-Specific Patterns & Conventions

### Module-Specific Loggers

Use module-specific loggers instead of `console.log`. Import from [src/utils/logging/common.ts](src/utils/logging/common.ts):

```typescript
import {
CORE_LOGGER,
INDEXER_LOGGER,
P2P_LOGGER,
PROVIDER_LOGGER
} from './utils/logging/common.js'
```

Prevents log message mixing; enables module-level filtering/transport config.

### Validation Pattern

Commands validate parameters before execution. Use `validateCommandParameters()` in handlers:

```typescript
validateCommandParameters(command, ['required', 'fields']) // throws ValidateParams response
```

### Rate Limiting & Request Tracking

`BaseHandler.checkRequestData()` tracks per-IP/peer-ID requests within time windows. Respect `MAX_REQ_PER_MINUTE` config.

### DDO/Asset Schema Validation

DDOs validated against SHACL schemas in [schemas/](schemas/) (v1, v3, v5, v7). Indexer enforces validation; check `ValidateDDOHandler` for signature verification.

### Error Response Format

All handlers return `P2PCommandResponse`: `{ httpStatus, body?, stream?, error? }`. Stream responses use Node.js Readable for large data (downloads, logs).

### TypeScript ES Module Configuration

- Target: ES2022
- Module resolution: Node
- Config: [tsconfig.json](tsconfig.json) includes source maps for debugging
- Run node with: `node --experimental-specifier-resolution=node dist/index.js`

## Key Files Quick Reference

| File | Purpose |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [src/index.ts](src/index.ts) | Entry point; Express app setup, component initialization |
| [src/OceanNode.ts](src/OceanNode.ts) | Singleton coordinator; escrow, auth, rate limiting |
| [src/components/core/handler/coreHandlersRegistry.ts](src/components/core/handler/coreHandlersRegistry.ts) | Command handler registry (40+ handlers) |
| [src/components/database/](src/components/database/) | Database abstraction & factory |
| [src/components/P2P/](src/components/P2P/) | libp2p networking, P2P command routing |
| [src/components/Indexer/](src/components/Indexer/) | Blockchain event crawling, DDO indexing |
| [src/components/Provider/](src/components/Provider/) | Payment validation, access control |
| [src/utils/constants.ts](src/utils/constants.ts) | 40+ protocol commands, network IDs, environment variable definitions |
| [src/@types/](src/@types/) | Command & data type definitions |
| [docs/Arhitecture.md](docs/Arhitecture.md) | Detailed architecture (layers, components, modules) |

## Testing Approach

- **Unit tests**: [src/test/unit/](src/test/unit/) - handler validation, command parsing (no DB required)
- **Integration tests**: [src/test/integration/](src/test/integration/) - full stack with Docker Compose services
- **Performance tests**: [src/test/performance/](src/test/performance/) - k6 load/stress tests

Run specific suite: `npm run test:unit` | `npm run test:integration` | `npm run mocha "dist/test/unit/**/*.test.js"`

## P2P Communication (libp2p)

### Network Topology & Peer Discovery

- **Transport layers**: TCP, WebSockets, Circuit Relay (NAT traversal)
- **Peer discovery mechanisms**:
- mDNS (local network discovery)
- Kademlia DHT (global peer discovery)
- Bootstrap nodes (static list from config)
- **Core protocols**: Identify (peer metadata), Ping, AutoNAT (public address detection), UPnP (port forwarding)

### Command Flow

1. P2P request arrives on protocol stream
2. `handleProtocolCommands()` in [src/components/P2P/handleProtocolCommands.ts](src/components/P2P/handleProtocolCommands.ts) parses incoming JSON command
3. Rate limiting checks per peer ID and IP address
4. Handler resolved from `CoreHandlersRegistry.getHandler(command.command)`
5. Response streamed back (JSON metadata + optional binary payload for large data)
6. Stream automatically closed by libp2p after transmission

### Rate Limiting

P2P enforces two-tier rate limiting:

- **Per-peer limits**: `MAX_REQ_PER_MINUTE` (default 30) per peer ID
- **Global limits**: `MAX_CONNECTIONS_PER_MINUTE` (default 120) across all peers
- **Deny list**: `RATE_DENY_LIST` can block specific peer IDs or IP addresses

### Key Files

- [src/components/P2P/index.ts](src/components/P2P/index.ts) - libp2p initialization, topology
- [src/components/P2P/handleProtocolCommands.ts](src/components/P2P/handleProtocolCommands.ts) - command routing & rate limiting

## HTTP API

### Request Flow

1. Express route receives HTTP request (JSON or multipart)
2. Route handler maps to corresponding handler class
3. Handler executes same command logic as P2P
4. Response serialized as JSON or streamed binary data

### API Route Categories

- **Provider routes** (`/api/services/`): decrypt, encrypt, download, initialize, nonce - data access & payment
- **Aquarius routes** (`/api/aquarius/`): DDO retrieval, metadata querying, validation, state tracking
- **Compute routes** (`/api/services/compute`): start/stop jobs, get environments, fetch results/logs
- **P2P routes** (`/p2pRoutes`): get peer list, network stats
- **Admin routes** (`/admin/`): fetch/push config, reindex, stop node (requires ALLOWED_ADMINS)
- **Direct command route** (`/directCommand`): low-level handler invocation with raw command objects

### Key Pattern: Handler Reuse

HTTP routes instantiate handlers directly instead of going through P2P:

```typescript
const response = await new ComputeGetEnvironmentsHandler(req.oceanNode).handle(task)
```

This ensures **identical business logic** between P2P and HTTP endpoints.

### Streaming Large Data

Binary responses (encrypted files, logs) use Node.js Readable streams to avoid loading into memory:

```typescript
if (response.stream) {
res.setHeader('Content-Type', 'application/octet-stream')
response.stream.pipe(res)
}
```

### Key Files

- [src/components/httpRoutes/index.ts](src/components/httpRoutes/index.ts) - route aggregation
- [src/components/httpRoutes/commands.ts](src/components/httpRoutes/commands.ts) - `/directCommand` handler
- [src/components/httpRoutes/compute.ts](src/components/httpRoutes/compute.ts) - compute endpoints
- [src/components/httpRoutes/validateCommands.ts](src/components/httpRoutes/validateCommands.ts) - request validation

## Compute-to-Data (C2D)

### Architecture

C2D enables running algorithms on datasets without downloading them. The node coordinates with C2D clusters:

1. **Multiple C2D engines**: Support different deployment types (Docker-based, Kubernetes)
2. **Job tracking**: `C2DDatabase` stores job metadata, status, results
3. **Payment validation**: Escrow holds funds until job completes
4. **Result retrieval**: Users can fetch results/logs after completion

### C2D Engine Types

- **Docker**: Local or remote Docker daemon (light-weight, suitable for edge nodes)
- **Kubernetes**: Full Ocean C2D infrastructure (production scaling)

### Workflow Steps

1. **Initialize compute** (`COMPUTE_INITIALIZE`) - validates payment credentials, reserves escrow
2. **Start compute** (`COMPUTE_START` or `FREE_COMPUTE_START`) - submits job to C2D engine
3. **Get status** (`COMPUTE_GET_STATUS`) - polls job progress
4. **Fetch results** (`COMPUTE_GET_RESULT`) - retrieves algorithm output
5. **Stream logs** (`COMPUTE_GET_STREAMABLE_LOGS`) - live job log access
6. **Stop compute** (`COMPUTE_STOP`) - cancels running job, releases escrow (if applicable)

### Configuration

C2D clusters configured via `OPERATOR_SERVICE_URL`:

```json
{
"c2dClusters": [
{
"type": "docker",
"url": "http://localhost:8050",
"node": "local-docker-node"
}
]
}
```

### Key Files

- [src/components/c2d/compute_engines.ts](src/components/c2d/compute_engines.ts) - engine coordination
- [src/components/c2d/compute_engine_base.ts](src/components/c2d/compute_engine_base.ts) - base class interface
- [src/components/c2d/compute_engine_docker.ts](src/components/c2d/compute_engine_docker.ts) - Docker implementation
- [src/components/core/compute/](src/components/core/compute/) - compute handlers
- [src/components/database/C2DDatabase.ts](src/components/database/C2DDatabase.ts) - job persistence

## Common Tasks

| Task | Command |
| --------------------- | --------------------------------------------------------------- |
| Check code quality | `npm run lint` |
| Format code | `npm run format` |
| Type check only | `npm run type-check` |
| Start node locally | `npm run start` (requires `.env` setup) |
| Quick start in Docker | `npm run quickstart` or `bash scripts/ocean-node-quickstart.sh` |
| View logs | `./scripts/logs.sh` or `npm run logs` |

---

**When adding features or fixing bugs**: Verify the handler pattern/architecture applies, use module-specific loggers, follow rate-limit conventions, and ensure integration tests cover new command flows.
Loading
Loading