Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate nilDB <> nilComm to support writes / executes from chain #133

Merged
merged 16 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
APP_DB_NAME_DATA=datablocks_data
APP_DB_NAME_PRIMARY=datablocks
APP_DB_URI=mongodb://localhost:27017
APP_ENV=testnet
APP_ENABLED_FEATURES=openapi-docs,prometheus-metrics,migrations
APP_LOG_LEVEL=debug
APP_NILCOMM_PUBLIC_KEY=037a87f9b010687e23eccb2fc70a474cbb612418cb513a62289eaed6cf1f11ac6b
APP_METRICS_PORT=9091
APP_MQ_URI=amqp://guest:guest@localhost:5672
# Required iff running nilcomm integration
#APP_NILCOMM_PUBLIC_KEY=037a87f9b010687e23eccb2fc70a474cbb612418cb513a62289eaed6cf1f11ac6b
APP_NODE_SECRET_KEY=d5cf0b58964c516465d228be9330a047cb09bcdc7aaabea6485e1152182967fa
APP_NODE_PUBLIC_ENDPOINT=http://localhost:8080
APP_PORT=8080
5 changes: 4 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
APP_DB_NAME_DATA=test_datablocks_data
APP_DB_NAME_PRIMARY=test_datablocks
APP_DB_URI=mongodb://localhost:27017
APP_ENV=testnet
# If nilcomm is required in a test it should be enabled as a test fixture parameter, enabling here causes all tests to spin up conflicting consumers and producers
APP_ENABLED_FEATURES=migrations
APP_LOG_LEVEL=debug
APP_NILCOMM_PUBLIC_KEY=037a87f9b010687e23eccb2fc70a474cbb612418cb513a62289eaed6cf1f11ac6b
APP_METRICS_PORT=9091
APP_MQ_URI=amqp://guest:guest@localhost:5672
APP_NODE_SECRET_KEY=ac8d429739597744f5c638a069aa641d66dce6478580aa6369dab47ea47abbeb
APP_NODE_PUBLIC_ENDPOINT=http://localhost:8081
APP_PORT=8081
24 changes: 21 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,33 @@ jobs:
test:
needs: check
runs-on: ubuntu-latest

services:
rabbitmq:
image: rabbitmq:4
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:8.0
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "23"
- uses: pnpm/action-setup@v4
- uses: supercharge/[email protected]
with:
mongodb-version: "8.0"
- run: pnpm install
- run: pnpm vitest --coverage
- uses: davelosert/vitest-coverage-report-action@v2
Expand Down
9 changes: 1 addition & 8 deletions bin/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { PRIVATE_KEY_LENGTH, PUBLIC_KEY_LENGTH } from "#/env";
const Args = z.object({
secretKey: z.string().length(PRIVATE_KEY_LENGTH).optional(),
nodePublicKey: z.string().length(PUBLIC_KEY_LENGTH).optional(),
mainnet: z.boolean(),
});
type Args = z.infer<typeof Args>;

Expand Down Expand Up @@ -34,16 +33,10 @@ async function main(): Promise<void> {
"-n, --node-public-key <key>",
"The node's hex-encoded public key. Required for JWT generation.",
)
.option(
"-m --mainnet",
"Generate mainnet DIDs (defaults to testnet if not specified)",
false,
)
.version("0.0.1");

program.parse(process.argv);
const options = Args.parse(program.opts<Args>());
process.env.APP_ENV = options.mainnet ? "mainnet" : "testnet";

const result: Partial<Output> = {};

Expand All @@ -58,7 +51,7 @@ async function main(): Promise<void> {

if (options.nodePublicKey) {
const nodePk = options.nodePublicKey;
const nodeDid = Identity.didFromPk(nodePk);
const nodeDid = Identity.didFromPkHex(nodePk);
const jwt = await identity.createJwt({ aud: nodeDid });

result.client.jwt = jwt;
Expand Down
3 changes: 0 additions & 3 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
- APP_DB_NAME_DATA=datablocks_data
- APP_DB_NAME_PRIMARY=datablocks
- APP_DB_URI=mongodb://node-ucct-db:27017
- APP_ENV=testnet
- APP_LOG_LEVEL=debug
- APP_METRICS_PORT=9091
- APP_NODE_SECRET_KEY=6cab2d10ac21886404eca7cbd40f1777071a243177eae464042885b391412b4e
Expand All @@ -31,7 +30,6 @@ services:
- APP_DB_NAME_DATA=datablocks_data
- APP_DB_NAME_PRIMARY=datablocks
- APP_DB_URI=mongodb://node-cr35-db:27017
- APP_ENV=testnet
- APP_LOG_LEVEL=debug
- APP_METRICS_PORT=9091
- APP_NODE_SECRET_KEY=05cee0065bdd080a26310bd201e90075b7739aa97253cb35c351e1df1e3ebeec
Expand All @@ -53,7 +51,6 @@ services:
- APP_DB_NAME_DATA=datablocks_data
- APP_DB_NAME_PRIMARY=datablocks
- APP_DB_URI=mongodb://node-dglk-db:27017
- APP_ENV=testnet
- APP_LOG_LEVEL=debug
- APP_METRICS_PORT=9091
- APP_NODE_SECRET_KEY=1fa6a7620d08b5249f59f13219bd045b2440f512fb80c306d81d78a106a2eb8d
Expand Down
1 change: 0 additions & 1 deletion docs/admin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ services:
- APP_DB_NAME_DATA=datablocks_data
- APP_DB_NAME_PRIMARY=datablocks
- APP_DB_URI=mongodb://node-xxxx-db:27017
- APP_ENV=testnet
- APP_LOG_LEVEL=debug
- APP_METRICS_PORT=9091
- APP_NODE_SECRET_KEY=6cab2d10ac21886404eca7cbd40f1777071a243177eae464042885b391412b4e
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"@noble/secp256k1": "^2.2.3",
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"amqplib": "^0.10.5",
"bech32": "^2.0.0",
"commander": "^13.1.0",
"compression": "^1.7.5",
"cors": "^2.8.5",
"did-jwt": "^8.0.8",
"did-resolver": "^4.1.0",
"dotenv": "^16.4.7",
"eciesjs": "^0.4.14",
"effect": "^3.12.9",
"hono": "^4.6.20",
"http-status-codes": "^2.3.0",
Expand All @@ -40,7 +42,6 @@
"mongodb": "^6.13.0",
"pino": "^9.6.0",
"pino-http": "^10.4.0",
"pino-pretty": "^13.0.0",
"prom-client": "^15.1.3",
"swagger-ui-express": "^5.0.1",
"temporal-polyfill": "^0.2.5",
Expand All @@ -54,6 +55,7 @@
"@commitlint/types": "^19.5.0",
"@faker-js/faker": "^9.4.0",
"@stoplight/spectral-cli": "^6.14.2",
"@types/amqplib": "^0.10.6",
"@types/elliptic": "^6.4.18",
"@types/js-yaml": "^4.0.9",
"@types/jsonwebtoken": "^9.0.8",
Expand Down
Loading