From 4e949a57732ffc1d6cb0816bd34b3cd6d204db37 Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Tue, 16 Jul 2024 07:21:17 -0600 Subject: [PATCH 1/2] feat(ao): allow AO env variables to point process evaluation against specific AO infrastrucutre The defaults are reccomended, but this gives operators the ability to point the resolvers dryRuns to specific AO infrastructure. Useful for testing and if you are running any part of an AO stack yourself to avoid rate-limiting/network issues. --- package.json | 3 ++- src/config.ts | 7 +++++++ src/system.ts | 13 ++++++++++++- yarn.lock | 22 ++++++++++++++++++---- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e2c3bd9..278b929 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "url": "https://github.com/ar-io/arns-resolver" }, "dependencies": { - "@ar.io/sdk": "^2.0.0", + "@ar.io/sdk": "^2.0.2", + "@permaweb/aoconnect": "^0.0.56", "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^4.18.2", diff --git a/src/config.ts b/src/config.ts index ce6dce8..2457e9f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -43,3 +43,10 @@ export const ARNS_CACHE_PATH = env.varOrDefault( './data/arns', ); export const PORT = +env.varOrDefault('PORT', '6000'); + +// AO + +export const AO_MU_URL = env.varOrUndefined('AO_MU_URL'); +export const AO_CU_URL = env.varOrUndefined('AO_CU_URL'); +export const AO_GRAPHQL_URL = env.varOrUndefined('AO_GRAPHQL_URL'); +export const AO_GATEWAY_URL = env.varOrUndefined('AO_GATEWAY_URL'); diff --git a/src/system.ts b/src/system.ts index eac845d..bf7a0b9 100644 --- a/src/system.ts +++ b/src/system.ts @@ -18,12 +18,14 @@ import { ANT, ANTRecord, + AOProcess, AoIORead, IO, ProcessId, fetchAllArNSRecords, isLeasedArNSRecord, } from '@ar.io/sdk/node'; +import { connect } from '@permaweb/aoconnect'; import pLimit from 'p-limit'; import { LmdbKVStore } from './cache/lmdb-kv-store.js'; @@ -36,7 +38,16 @@ let evaluationInProgress = false; export const getLastEvaluatedTimestamp = () => lastEvaluationTimestamp; export const isEvaluationInProgress = () => evaluationInProgress; export const contract: AoIORead = IO.init({ - processId: config.IO_PROCESS_ID, + process: new AOProcess({ + processId: config.IO_PROCESS_ID, + ao: connect({ + // @permaweb/aoconnect defaults will be used if these are not provided + MU_URL: config.AO_CU_URL, + CU_URL: config.AO_CU_URL, + GRAPHQL_URL: config.AO_GATEWAY_URL, + GATEWAY_URL: config.AO_GATEWAY_URL, + }), + }), }); // TODO: this could be done using any KV store - or in memory. For now, we are using LMDB for persistence. diff --git a/yarn.lock b/yarn.lock index 822ec70..4282a2d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -33,10 +33,10 @@ call-me-maybe "^1.0.1" js-yaml "^4.1.0" -"@ar.io/sdk@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.0.tgz#8725d1ece71b19dd7bfe44e846190bd458164206" - integrity sha512-at40lht1K6BOegoHoTezgL3z8y+Wj3VTEHMjNcoAywAV4R5l69xOTkJqEDL1uyLahspmxYGgX7rf50XFaVxMOw== +"@ar.io/sdk@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-2.0.2.tgz#64aa7c4e6b30bbe36d7cc7d450f32d100ee731b3" + integrity sha512-DGSHo9Bf90Pe2m4lBEJPFuUageAaoO+nA42nhGJ2vCn6dKVM/y3aSqCJ+H5enHjidx0H1MmsgysiBQGEBElMHg== dependencies: "@permaweb/aoconnect" "^0.0.55" arbundles "0.11.0" @@ -1298,6 +1298,20 @@ warp-arbundles "^1.0.4" zod "^3.22.4" +"@permaweb/aoconnect@^0.0.56": + version "0.0.56" + resolved "https://registry.yarnpkg.com/@permaweb/aoconnect/-/aoconnect-0.0.56.tgz#28dcf1a094a2b1c1cbaa246d63eeb08a5a0c7269" + integrity sha512-Eu4AC1KeX2EOIS9ihWkwPJs7rK+/+XV43QwOJ9DCQAu6EhjanlT3UfV2wSpGiFK/dT/B1YsQyTcxNrmQaXn81g== + dependencies: + "@permaweb/ao-scheduler-utils" "~0.0.16" + buffer "^6.0.3" + debug "^4.3.4" + hyper-async "^1.1.2" + mnemonist "^0.39.8" + ramda "^0.29.1" + warp-arbundles "^1.0.4" + zod "^3.22.4" + "@randlabs/communication-bridge@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@randlabs/communication-bridge/-/communication-bridge-1.0.1.tgz#d1ecfc29157afcbb0ca2d73122d67905eecb5bf3" From 5c19db24d6b7891f39562707f2aab15614f4e164 Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Tue, 16 Jul 2024 07:26:01 -0600 Subject: [PATCH 2/2] chore(build): @permaweb/aoconnect reccomends using npm, but we use yarn Adding --ignore-engines to avoid failing builds --- .github/workflows/build.yml | 2 +- Dockerfile | 2 +- src/system.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3bd95d0..a1831cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: with: node-version-file: .nvmrc cache: 'yarn' - - run: yarn --immutable --immutable-cache + - run: yarn --immutable --immutable-cache --ignore-engines - run: yarn - run: yarn ${{ matrix.step }} diff --git a/Dockerfile b/Dockerfile index 3debc3c..471c2dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ FROM node:${NODE_VERSION}-bullseye-slim AS builder # Build WORKDIR /app COPY . . -RUN yarn && yarn build +RUN yarn --ignore-engines && yarn build RUN rm-rf node_modules & yarn install --force # Runtime diff --git a/src/system.ts b/src/system.ts index bf7a0b9..0070f3a 100644 --- a/src/system.ts +++ b/src/system.ts @@ -42,7 +42,7 @@ export const contract: AoIORead = IO.init({ processId: config.IO_PROCESS_ID, ao: connect({ // @permaweb/aoconnect defaults will be used if these are not provided - MU_URL: config.AO_CU_URL, + MU_URL: config.AO_MU_URL, CU_URL: config.AO_CU_URL, GRAPHQL_URL: config.AO_GATEWAY_URL, GATEWAY_URL: config.AO_GATEWAY_URL,