From 95ce0adc5bab6ec1ca168778102a1515bbff4881 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Wed, 25 Oct 2023 12:01:49 +0200 Subject: [PATCH 01/28] fix(aqua): Remove topology hack (#125) * Fix scripts * Remove hack --- gateway/aqua/rpc.aqua | 1 - gateway/package.json | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway/aqua/rpc.aqua b/gateway/aqua/rpc.aqua index 328f39b..aaf7561 100644 --- a/gateway/aqua/rpc.aqua +++ b/gateway/aqua/rpc.aqua @@ -42,7 +42,6 @@ func balancedEthCall{Logger, Balancer}(method: string, jsonArgs: []string) -> Js worker, provider <- Balancer.next() Logger.logWorker(worker) Logger.logCall(provider) - Op.noop() -- dirty hack for topology to converge rpc <- fromWorkerProvider(worker, provider) result <- rpcCall{rpc}(method, jsonArgs) <- result diff --git a/gateway/package.json b/gateway/package.json index 03a9a05..d38cf5a 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -5,9 +5,8 @@ "main": "src/index.js", "type": "module", "scripts": { - "run:example": "fluence aqua -i aqua/ -o aqua-compiled/ --js && node src/index.js \"config.json\"", - "run": "fluence aqua -i aqua/ -o aqua-compiled/ --js && node src/index.js", - "compile": "fluence aqua -i aqua/ -o aqua-compiled/ --js", + "run": "npm run compile && node src/index.js", + "compile": "fluence aqua -i aqua/ -o aqua-compiled/ --js --no-input", "req": "node web3run.js" }, "bin": { From 5269f453a2df6091622b8ef500978475af20d8a8 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Wed, 25 Oct 2023 18:22:55 +0200 Subject: [PATCH 02/28] feat(readme): Add `fluence deal logs` output example to README [DXJ-512] (#126) Add deal logs output to README --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/README.md b/README.md index cb8c594..e495d9f 100644 --- a/README.md +++ b/README.md @@ -507,6 +507,55 @@ Fluence CLI did a bunch of work for us behind the scenes and signing the transac Note that the deal's section in [fluence.yaml](./fluence.yaml) specifies the minimum and maximum workers that should be deployed under the *defaultWorker* namespace. Fluence CLI currently provides default values for min and max workers of one (1) and three (3), respectively. In the near future, you will be able to provide your spot price for service execution, hosting targets in the form of named capacity providers and more. +After successful deal deployment it is possible to retrieve logs for the deployed deal. + +**Command**: + +```bash +fluence deal logs +``` + +**Output**: + +```bash +Connecting to random stage relay: /dns4/0-stage.fluence.dev/tcp/9000/wss/p2p/12D3KooWDcpWuyrMTDinqNgmXAuRdfd2mTdY9VoXZSAet2pDzh6r +Connected +defaultWorker (host_id: 12D3KooWMMGdfVEJ1rWe1nH1nehYDzNEHhg5ogdfiGk88AupCMnf, worker_id: 12D3KooWGctQEUKcgWBetu9aiR3owMZcBGNcpDC5ZE3H6dL16uSP, spell_id: 679acf1c-57e2-4dd7-aa78-bb181df7a00a): + +2023-10-25 14:41:48 Installing worker for deal 0x02ab47b7b2737e16a516421c1b8ad36475e0f7ce +2023-10-25 14:41:48 parsed worker definition bafkreifp4gbp3emepswptldwlpbhpybt47uy2c3ksm3y7rut6cmcdnljwa { + "services": [ + { + "modules": [ + { + "config": "bafkreia2wftbxfd4blycnvlxw2yl7ibhan2g7vauexv7fspibodlu34que", + "wasm": "bafkreiarl3nin4jtauc52k76h4ze7yekvc5d2uno5fkgpotmcekwm7cnqa" + }, + { + "config": "bafkreiaclbxbmtydpwdcpoh2yggcd6uimicmbb6rxzab7bgp342w5vcz2m", + "wasm": "bafybeieeemeldllgokrkgybbrrjqeehyin3blv5cgehhdp3nlrfyj4eqoa" + } + ], + "name": "eth_rpc" + } + ], + "spells": [] +} +2023-10-25 14:41:50 Created service eth_rpc 2b5967ae-e5f9-4929-8668-d2039593af28 +2023-10-25 14:41:50 Installation finished +2023-10-25 14:41:50 Worker installation finished with status { + "message": "", + "state": "INSTALLATION_SUCCESSFUL", + "timestamp": 1698244910 +} + +defaultWorker (host_id: 12D3KooWJ4bTHirdTFNZpCS72TAzwtdmavTBkkEXtzo6wHL25CtE, worker_id: unknown, spell_id: unknown): Worker is not installed yet + +defaultWorker (host_id: 12D3KooWAKNos2KogexTXhrkMZzFYpLHuWJ4PgoAhurSAv7o5CWA, worker_id: unknown, spell_id: unknown): Worker is not installed yet +``` + +In the example output above, we see that the worker for the *defaultWorker* namespace was installed successfully. The worker is now ready to receive requests from the gateway. The other two workers are not installed yet. It should happen in a while and one can check the logs again to see the progress. + ### fRPC Aqua Code Now that we have our services deployed and ready for action, it's time to look at Aqua, which is utilized by the Gateway to bridge HTTP to/from libp2p. Let's have a look at the Aqua code and structure. From 0ce39ad21b58e17edca9d69a83b73d8ff679d2a7 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Fri, 27 Oct 2023 14:40:00 +0300 Subject: [PATCH 03/28] Setup fcli with action --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c664f34..05524b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,10 @@ jobs: repository: fluencelabs/frpc ref: ${{ inputs.ref }} - - name: Install fluence-cli@unstable - run: npm i -g @fluencelabs/cli@0.11.1 + - name: Setup fcli + uses: fluencelabs/setup-fluence@v1 + with: + version: stage - name: Check if main.aqua compiles run: fluence aqua --dry From b91be826de6f81bbfce71440042f4d5235a75ac3 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Fri, 27 Oct 2023 15:46:33 +0300 Subject: [PATCH 04/28] Use unstable --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 05524b7..f2d9a2a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: - name: Setup fcli uses: fluencelabs/setup-fluence@v1 with: - version: stage + version: unstable - name: Check if main.aqua compiles run: fluence aqua --dry From 8d8eeaa70f81afda515e33ab5aa7afc65cfae65a Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 30 Oct 2023 18:19:22 +0200 Subject: [PATCH 05/28] Test CI --- .github/workflows/tests.yml | 99 ++++++++++++++++++++++++++++++++++--- .gitignore | 4 +- fluence.yaml | 7 ++- 3 files changed, 99 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f2d9a2a..c22370d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,12 +7,35 @@ on: description: "git ref to checkout to" type: string default: "main" + nox-image: + description: "nox image tag" + type: string + default: "null" + fcli-version: + description: "fcli version to use" + type: string + default: "unstable" + js-client-version: + description: "@fluencelabs/js-client version" + type: string + default: "null" + fluence-env: + description: "env to run tests against" + type: string + default: "local" jobs: tests: - name: "build" + name: "Run tests" runs-on: ubuntu-latest + env: + FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" + + permissions: + contents: read + id-token: write + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -20,13 +43,77 @@ jobs: repository: fluencelabs/frpc ref: ${{ inputs.ref }} + - name: Import secrets + uses: hashicorp/vault-action@v2.5.0 + with: + url: https://vault.fluence.dev + path: jwt/github + role: ci + method: jwt + jwtGithubAudience: "https://github.com/fluencelabs" + jwtTtl: 300 + secrets: | + kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ; + kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ; + kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN; + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + registry: docker.fluence.dev + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + - name: Setup fcli uses: fluencelabs/setup-fluence@v1 with: - version: unstable + artifact: fcli + version: ${{ inputs.fcli-version }} + + - name: Init local env with fcli + run: fluence local init --no-input + + - name: Replace nox image in docker-compose + if: inputs.nox-image != 'null' + working-directory: .fluence + run: | + sed -i'' -e '/nox-/!b;n;s|image: fluencelabs/nox:.*$|image: ${{ inputs.nox-image }}|' docker-compose.yaml + + - name: Run local env + env: + FLUENCE_CHAIN_PRIVATE_KEY: ${{ secrets.FLUENCE_CHAIN_PRIVATE_KEY }} + RPC_PROVIDERS: ${{ secrets.RPC_PROVIDERS }} + run: fluence local up + + - name: Setup node with self-hosted registry + uses: actions/setup-node@v3 + with: + node-version: "18" + registry-url: "https://npm.fluence.dev" + cache: "npm" + + - name: Run npm i + run: npm i + + - name: Run npm i in gateway + working-directory: gateway + run: npm i + + - name: Set js-client version + if: inputs.js-client-version != 'null' + uses: fluencelabs/github-actions/npm-set-dependency@main + with: + package: "@fluencelabs/js-client" + version: "${{ inputs.js-client-version }}" + working-directory: gateway - - name: Check if main.aqua compiles - run: fluence aqua --dry + - name: Run tests + env: + FLUENCE_ENV: ${{ inputs.fluence-env }} + run: npm run test - - name: Check if services builds - run: fluence build + - name: Cleanup + if: always() + run: | + fluence local down + rm -rf tmp ${{ env.FLUENCE_USER_DIR }} diff --git a/.gitignore b/.gitignore index 2c76f1d..7529cc8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,9 +9,7 @@ src/js/src/aqua aqua-compiled # recommended by Fluence Labs: -/.fluence/project-secrets.yaml -/.fluence/schemas -/.fluence/tmp +.fluence/** # to avoid accidental publish of RPC URLs gateway/configs/quickstart_config.json diff --git a/fluence.yaml b/fluence.yaml index 724af0f..3b06853 100644 --- a/fluence.yaml +++ b/fluence.yaml @@ -4,16 +4,19 @@ # Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md -version: 2 +version: 4 + aquaInputPath: src/aqua/main.aqua + workers: defaultWorker: services: [ eth_rpc ] + deals: defaultWorker: minWorkers: 3 targetWorkers: 3 -relays: stage + services: eth_rpc: get: wasm-modules From cbf220f124bcb041101095d9059e34959706b7fa Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 30 Oct 2023 18:20:53 +0200 Subject: [PATCH 06/28] Fix --- fluence.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fluence.yaml b/fluence.yaml index 3b06853..17d08de 100644 --- a/fluence.yaml +++ b/fluence.yaml @@ -17,6 +17,8 @@ deals: minWorkers: 3 targetWorkers: 3 +relays: stage + services: eth_rpc: get: wasm-modules From b30b2e815dbd0191c638bcf4b8323c762685ed0d Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 30 Oct 2023 18:28:21 +0200 Subject: [PATCH 07/28] Fx --- .github/workflows/tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c22370d..5ee4d7b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -55,7 +55,9 @@ jobs: secrets: | kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ; kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD ; - kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN; + kv/npm-registry/basicauth/ci token | NODE_AUTH_TOKEN ; + kv/ci/frpc chain_urls | RPC_PROVIDERS ; + kv/ci/frpc private_key | FLUENCE_CHAIN_PRIVATE_KEY - name: Login to DockerHub uses: docker/login-action@v2 @@ -80,9 +82,6 @@ jobs: sed -i'' -e '/nox-/!b;n;s|image: fluencelabs/nox:.*$|image: ${{ inputs.nox-image }}|' docker-compose.yaml - name: Run local env - env: - FLUENCE_CHAIN_PRIVATE_KEY: ${{ secrets.FLUENCE_CHAIN_PRIVATE_KEY }} - RPC_PROVIDERS: ${{ secrets.RPC_PROVIDERS }} run: fluence local up - name: Setup node with self-hosted registry From 34be974c60a378195ad6d1cd85bfaf56626bfc4e Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Mon, 30 Oct 2023 18:52:58 +0200 Subject: [PATCH 08/28] Add colors --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5ee4d7b..d9458a3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,6 +31,8 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" + CI: true + FORCE_COLOR: true permissions: contents: read @@ -98,6 +100,9 @@ jobs: working-directory: gateway run: npm i + - name: Run npm run build + run: npm run build + - name: Set js-client version if: inputs.js-client-version != 'null' uses: fluencelabs/github-actions/npm-set-dependency@main From f1f360a8aa6dc625d576c6feb4255bde22290bc9 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:00:16 +0200 Subject: [PATCH 09/28] Fix --- .github/workflows/tests.yml | 3 ++- test/fRPC.integration-test.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d9458a3..98c5939 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,8 @@ on: fcli-version: description: "fcli version to use" type: string - default: "unstable" + # default: "unstable" + default: "main" js-client-version: description: "@fluencelabs/js-client version" type: string diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 8240cf6..505c234 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -143,7 +143,7 @@ describe("fRPC", () => { "provider", "add-peer", ...providerPeers.flatMap((id) => ["--peer-id", id]), - "--units", + "--compute-units", "1", ); From 44959e13519c9d5b6e25b22a85c5e44fa2b876f9 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:18:13 +0200 Subject: [PATCH 10/28] Dump logs --- .github/workflows/tests.yml | 4 ++++ provider.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 provider.yaml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 98c5939..00dc190 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -117,6 +117,10 @@ jobs: FLUENCE_ENV: ${{ inputs.fluence-env }} run: npm run test + - name: Dump container logs + if: always() + uses: jwalton/gh-docker-logs@v2 + - name: Cleanup if: always() run: | diff --git a/provider.yaml b/provider.yaml new file mode 100644 index 0000000..dc86daa --- /dev/null +++ b/provider.yaml @@ -0,0 +1,24 @@ +# yaml-language-server: $schema=.fluence/schemas/provider.json + +# Defines config used for provider set up + +# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/provider.md + +version: 0 + +computePeers: + nox-0: + computeUnits: 1 + nox-1: + computeUnits: 1 + nox-2: + computeUnits: 1 + +offers: + offer-0: + maxCollateralPerWorker: 1000000000000000000 + minPricePerWorkerEpoch: 83000000000000000 + computePeers: + - nox-0 + - nox-1 + - nox-2 From 55e662d68092274388b9495b24fe1992ea07376e Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:22:39 +0200 Subject: [PATCH 11/28] Bump js-client --- gateway/package-lock.json | 85 +++++++++++++++++++++++++++------------ gateway/package.json | 2 +- 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/gateway/package-lock.json b/gateway/package-lock.json index 65818ab..c37a87d 100644 --- a/gateway/package-lock.json +++ b/gateway/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.18", "license": "Apache-2.0", "dependencies": { - "@fluencelabs/js-client": "0.3.0", + "@fluencelabs/js-client": "0.4.2", "@fluencelabs/marine-worker": "0.3.3", "body-parser": "1.20.2", "express": "4.18.2", @@ -625,15 +625,17 @@ } }, "node_modules/@fluencelabs/js-client": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@fluencelabs/js-client/-/js-client-0.3.0.tgz", - "integrity": "sha512-mRlEeoDEAsHK4GK3vIlNBkXgfJ01maQ4WVefob4QNEqpshipf6XQpU6R8dpUsjyhx53nus3ui6BSUV6gi5jg8A==", + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@fluencelabs/js-client/-/js-client-0.4.2.tgz", + "integrity": "sha512-Sho12XpyGcWAxOK0jUeO2Mh0ur2xJWTL7rCVAIT+QR7KlghlrFP1jdw4OrDCRlEJR4bhdPtI1PPkDo3Gk+axGQ==", "dependencies": { "@chainsafe/libp2p-noise": "13.0.0", "@chainsafe/libp2p-yamux": "5.0.0", - "@fluencelabs/avm": "0.52.0", + "@fluencelabs/avm": "0.54.0", "@fluencelabs/interfaces": "0.8.2", - "@fluencelabs/marine-worker": "0.4.0", + "@fluencelabs/js-client-isomorphic": "0.2.1", + "@fluencelabs/marine-worker": "0.4.1", + "@fluencelabs/threads": "^2.0.0", "@libp2p/crypto": "2.0.3", "@libp2p/interface": "0.1.2", "@libp2p/peer-id": "3.0.2", @@ -652,7 +654,6 @@ "libp2p": "0.46.6", "multiformats": "11.0.1", "rxjs": "7.5.5", - "threads": "github:fluencelabs/threads.js#b00a5342380b0278d3ae56dcfb170effb3cad7cd", "ts-pattern": "3.3.3", "uint8arrays": "4.0.3", "uuid": "8.3.2", @@ -663,19 +664,45 @@ "pnpm": ">=8" } }, + "node_modules/@fluencelabs/js-client-isomorphic": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@fluencelabs/js-client-isomorphic/-/js-client-isomorphic-0.2.1.tgz", + "integrity": "sha512-o9uhjV2db7YvGHv38qXYecJmMlwnkiHqMX7dBAA8Z+89/J4lepvQydP9zU+qJHRGPcBjH4yPtnV4oEBXZbdhMg==", + "dependencies": { + "@fluencelabs/avm": "0.54.0", + "@fluencelabs/marine-js": "0.7.2", + "@fluencelabs/marine-worker": "0.4.1", + "@fluencelabs/threads": "^2.0.0" + } + }, + "node_modules/@fluencelabs/js-client-isomorphic/node_modules/@fluencelabs/avm": { + "version": "0.54.0", + "resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.54.0.tgz", + "integrity": "sha512-5GgROVly/vC7gasltr6/3TIY8vfV6b+SPfWUAGWnyXdbWt4jJANLO2YtXdaUsdNk9PiwOep7TMjLnypljdyMjQ==" + }, + "node_modules/@fluencelabs/js-client-isomorphic/node_modules/@fluencelabs/marine-worker": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@fluencelabs/marine-worker/-/marine-worker-0.4.1.tgz", + "integrity": "sha512-BnCOaAnzi3koFFHGy3955uYllI3TmQN++eI/0s5mou4pMZdF2H6qc40mXzgQb8dADpuE9cqRwQ2/0Ecwn5B3dg==", + "dependencies": { + "@fluencelabs/marine-js": "0.7.2", + "@fluencelabs/threads": "^2.0.0", + "observable-fns": "0.6.1" + } + }, "node_modules/@fluencelabs/js-client/node_modules/@fluencelabs/avm": { - "version": "0.52.0", - "resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.52.0.tgz", - "integrity": "sha512-T+/Hv/ZPfwWZAC4tH6wEDIRmtN6cTBebqbCaHfaq2PDLSMG0BgssdFF2BAaEXrvOvJbI5Bu/9bQhHv4ga7bYlA==" + "version": "0.54.0", + "resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.54.0.tgz", + "integrity": "sha512-5GgROVly/vC7gasltr6/3TIY8vfV6b+SPfWUAGWnyXdbWt4jJANLO2YtXdaUsdNk9PiwOep7TMjLnypljdyMjQ==" }, "node_modules/@fluencelabs/js-client/node_modules/@fluencelabs/marine-worker": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@fluencelabs/marine-worker/-/marine-worker-0.4.0.tgz", - "integrity": "sha512-nWri+j8Ey4UXoB32NPKsmVYzUKj6mwD7vh/5MjzCxrnVthnWnFdnkETF2BnZwjZWc701xeVhF3L5ZSjiQzKywQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@fluencelabs/marine-worker/-/marine-worker-0.4.1.tgz", + "integrity": "sha512-BnCOaAnzi3koFFHGy3955uYllI3TmQN++eI/0s5mou4pMZdF2H6qc40mXzgQb8dADpuE9cqRwQ2/0Ecwn5B3dg==", "dependencies": { "@fluencelabs/marine-js": "0.7.2", - "observable-fns": "0.6.1", - "threads": "github:fluencelabs/threads.js#b00a5342380b0278d3ae56dcfb170effb3cad7cd" + "@fluencelabs/threads": "^2.0.0", + "observable-fns": "0.6.1" } }, "node_modules/@fluencelabs/marine-js": { @@ -699,6 +726,23 @@ "threads": "1.7.0" } }, + "node_modules/@fluencelabs/threads": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@fluencelabs/threads/-/threads-2.0.0.tgz", + "integrity": "sha512-dgYpZg55OcEmop1U3G2bFKEJXg2avjXWYfWsdPlkSbHOHguaRifvr5bgwIYTg1wxoPGcn0jegcjKKwrY0qrV+g==", + "dependencies": { + "callsites": "^3.1.0", + "debug": "^4.2.0", + "is-observable": "^2.1.0", + "observable-fns": "^0.6.1" + }, + "funding": { + "url": "https://github.com/andywer/threads.js?sponsor=1" + }, + "optionalDependencies": { + "tiny-worker": ">= 2" + } + }, "node_modules/@libp2p/crypto": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@libp2p/crypto/-/crypto-2.0.3.tgz", @@ -2517,17 +2561,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", - "dependencies": { - "get-intrinsic": "^1.2.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/has-property-descriptors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", diff --git a/gateway/package.json b/gateway/package.json index d38cf5a..53b5d87 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -20,7 +20,7 @@ "author": "Fluence Labs", "license": "Apache-2.0", "dependencies": { - "@fluencelabs/js-client": "0.3.0", + "@fluencelabs/js-client": "0.4.2", "@fluencelabs/marine-worker": "0.3.3", "body-parser": "1.20.2", "express": "4.18.2", From 975d19ee1ac3d100dff1ca1dd3869f9330bf808c Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:30:29 +0200 Subject: [PATCH 12/28] More logs --- test/fRPC.integration-test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 505c234..85766bf 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -47,6 +47,7 @@ async function testGateway(mode?: string, times = 6) { id, }; const response = await gateway.request(request); + console.log(request); expect(response).toMatchObject({ jsonrpc: "2.0", id, From 2c182c10f7669c5f138f538f89c13763c418742f Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:35:34 +0200 Subject: [PATCH 13/28] Log stdout and stderr --- test/fRPC.integration-test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 85766bf..da874d0 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -48,6 +48,8 @@ async function testGateway(mode?: string, times = 6) { }; const response = await gateway.request(request); console.log(request); + console.log(gateway.stdout); + console.log(gateway.stderr); expect(response).toMatchObject({ jsonrpc: "2.0", id, From 074f717582b092613367f068172fde6888c50ec8 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:45:29 +0200 Subject: [PATCH 14/28] Capture stderr --- test/fRPC.integration-test.ts | 4 ++-- test/utils.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index da874d0..09c5446 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -48,8 +48,8 @@ async function testGateway(mode?: string, times = 6) { }; const response = await gateway.request(request); console.log(request); - console.log(gateway.stdout); - console.log(gateway.stderr); + console.log(gateway.getStdout); + console.log(gateway.getStderr); expect(response).toMatchObject({ jsonrpc: "2.0", id, diff --git a/test/utils.ts b/test/utils.ts index 59e0861..6c5ae19 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -16,7 +16,7 @@ import { relative } from "path"; import { promises as fs } from "fs"; -import { execFile, ChildProcess } from "child_process"; +import { ChildProcess, execFile } from "child_process"; import treeKill from "tree-kill"; @@ -76,6 +76,7 @@ export async function subnet(env: string): Promise { export class Gateway { private stdout: string = ""; + private stderr: string = ""; constructor( private readonly gateway: ChildProcess, @@ -84,6 +85,9 @@ export class Gateway { gateway.stdout?.on("data", (data: any) => { this.stdout += data; }); + gateway.stderr?.on("data", (data: any) => { + this.stderr += data; + }); } public async stop(): Promise { @@ -109,7 +113,7 @@ export class Gateway { } else { resolve(); } - }), + }) ); } return this.gateway.kill(); @@ -131,6 +135,9 @@ export class Gateway { public getStdout(): string { return this.stdout; } + public getStderr(): string { + return this.stderr; + } } export async function startGateway(mode?: string): Promise { From f06aee12217a0c4e57a87d2680f3e98723842367 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 14:49:33 +0200 Subject: [PATCH 15/28] F --- test/fRPC.integration-test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 09c5446..6868f59 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -48,8 +48,8 @@ async function testGateway(mode?: string, times = 6) { }; const response = await gateway.request(request); console.log(request); - console.log(gateway.getStdout); - console.log(gateway.getStderr); + console.log(gateway.getStdout()); + console.log(gateway.getStderr()); expect(response).toMatchObject({ jsonrpc: "2.0", id, From a3b7dfe3e2fb23859912c4a31c27fe17013948f3 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 15:53:11 +0200 Subject: [PATCH 16/28] F --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 00dc190..acc80c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -101,9 +101,6 @@ jobs: working-directory: gateway run: npm i - - name: Run npm run build - run: npm run build - - name: Set js-client version if: inputs.js-client-version != 'null' uses: fluencelabs/github-actions/npm-set-dependency@main @@ -112,6 +109,9 @@ jobs: version: "${{ inputs.js-client-version }}" working-directory: gateway + - name: Run npm run build + run: npm run build + - name: Run tests env: FLUENCE_ENV: ${{ inputs.fluence-env }} From 4f9fbdbab80d53aaa08ed055f6b0a1dcca70965c Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 16:20:12 +0200 Subject: [PATCH 17/28] F --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index acc80c5..61a33e5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -115,7 +115,7 @@ jobs: - name: Run tests env: FLUENCE_ENV: ${{ inputs.fluence-env }} - run: npm run test + run: npm run test -- -t deploy - name: Dump container logs if: always() From 41d6a0cc3052626058f42d27b9a5ee9ed7426321 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 16:32:38 +0200 Subject: [PATCH 18/28] > --- test/fRPC.integration-test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 6868f59..85fd649 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -47,9 +47,6 @@ async function testGateway(mode?: string, times = 6) { id, }; const response = await gateway.request(request); - console.log(request); - console.log(gateway.getStdout()); - console.log(gateway.getStderr()); expect(response).toMatchObject({ jsonrpc: "2.0", id, @@ -169,7 +166,7 @@ describe("fRPC", () => { const workersMatch = stderr.match(/(\d+)\s*workers/); const workers = - workersMatch?.[1] ?? throwError("Failed to parse workers"); + workersMatch?.[1] ?? throwError(`Failed to parse workers. stdout: ${stdout}, stderr: ${stderr}`); const workersNum = parseInt(workers); expect(workersNum).toBeGreaterThanOrEqual(3); From 192a117cf1568c29d4da43f22f618a9169777f7c Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 17:44:33 +0200 Subject: [PATCH 19/28] NO COLOR --- .github/workflows/tests.yml | 2 +- .gitignore | 6 +++++- test/fRPC.integration-test.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 61a33e5..5b9698d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" CI: true - FORCE_COLOR: true + # FORCE_COLOR: true permissions: contents: read diff --git a/.gitignore b/.gitignore index 7529cc8..bfb83a0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,11 @@ src/js/src/aqua aqua-compiled # recommended by Fluence Labs: -.fluence/** +.fluence/project-secrets.yaml +.fluence/docker-compose.yaml +.fluence/schemas +.fluence/secrets +.fluence/tmp # to avoid accidental publish of RPC URLs gateway/configs/quickstart_config.json diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index 85fd649..ff7c400 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -166,7 +166,7 @@ describe("fRPC", () => { const workersMatch = stderr.match(/(\d+)\s*workers/); const workers = - workersMatch?.[1] ?? throwError(`Failed to parse workers. stdout: ${stdout}, stderr: ${stderr}`); + workersMatch?.[1] ?? throwError(`Failed to parse workers.`); const workersNum = parseInt(workers); expect(workersNum).toBeGreaterThanOrEqual(3); From 9719b990f20759461d1b0c793d4344398187650b Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Tue, 31 Oct 2023 17:54:13 +0200 Subject: [PATCH 20/28] Setup tmate --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5b9698d..36937c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -112,6 +112,10 @@ jobs: - name: Run npm run build run: npm run build + - name: Setup tmate session + if: always() + uses: mxschmitt/action-tmate@v3 + - name: Run tests env: FLUENCE_ENV: ${{ inputs.fluence-env }} From 0911f271517a44b10f0f44c804a37316c637cdc6 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Tue, 31 Oct 2023 16:04:31 +0000 Subject: [PATCH 21/28] Add workers --- test/fRPC.integration-test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/fRPC.integration-test.ts b/test/fRPC.integration-test.ts index ff7c400..e8d9747 100644 --- a/test/fRPC.integration-test.ts +++ b/test/fRPC.integration-test.ts @@ -186,7 +186,10 @@ describe("fRPC", () => { } if (Date.now() > deadline) { throw new Error( - `Deployment timeout: ${workersNum} workers expected, ${deployed.length} deployed`, + `Deployment timeout: ${workersNum} workers expected, + ${deployed.length} deployed. + workers: ${JSON.stringify(workers)} + `, ); } } From 63b6f808a6d54682d6d0b3bfa28292deab7e9437 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 11:09:29 +0200 Subject: [PATCH 22/28] Run without CI true --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 36937c5..0624bef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" - CI: true + # CI: true # FORCE_COLOR: true permissions: From 305ab0d3971072f49bde8d5ae686f9c743e16262 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 13:38:34 +0200 Subject: [PATCH 23/28] Run on builder --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0624bef..4e3af58 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,12 +28,12 @@ on: jobs: tests: name: "Run tests" - runs-on: ubuntu-latest + runs-on: builder env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" - # CI: true - # FORCE_COLOR: true + CI: true + FORCE_COLOR: true permissions: contents: read @@ -112,9 +112,9 @@ jobs: - name: Run npm run build run: npm run build - - name: Setup tmate session - if: always() - uses: mxschmitt/action-tmate@v3 + # - name: Setup tmate session + # if: always() + # uses: mxschmitt/action-tmate@v3 - name: Run tests env: From a0ac37f06f3d8efb18992aca3e839f0a157fedba Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 13:47:55 +0200 Subject: [PATCH 24/28] Run tmata --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e3af58..d0a0a15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,8 +32,8 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" - CI: true - FORCE_COLOR: true + # CI: true + # FORCE_COLOR: true permissions: contents: read @@ -112,15 +112,15 @@ jobs: - name: Run npm run build run: npm run build - # - name: Setup tmate session - # if: always() - # uses: mxschmitt/action-tmate@v3 - - name: Run tests env: FLUENCE_ENV: ${{ inputs.fluence-env }} run: npm run test -- -t deploy + - name: Setup tmate session + if: failure() + uses: mxschmitt/action-tmate@v3 + - name: Dump container logs if: always() uses: jwalton/gh-docker-logs@v2 From 4003f4ae7840f88e52ef9ac6d9ab246455f0b016 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 14:17:43 +0200 Subject: [PATCH 25/28] Setup rust --- .github/workflows/tests.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0a0a15..95a9857 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,8 +32,8 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" - # CI: true - # FORCE_COLOR: true + CI: true + FORCE_COLOR: true permissions: contents: read @@ -69,6 +69,9 @@ jobs: username: ${{ env.DOCKER_USERNAME }} password: ${{ env.DOCKER_PASSWORD }} + - name: Setup Rust toolchain + uses: dsherret/rust-toolchain-file@v1 + - name: Setup fcli uses: fluencelabs/setup-fluence@v1 with: From b59d0ab558055a8fb37c16cf1341bf5509e3c08a Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 14:24:59 +0200 Subject: [PATCH 26/28] No colors --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95a9857..3a10fce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: env: FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence" CI: true - FORCE_COLOR: true + # FORCE_COLOR: true permissions: contents: read From 5068018246f86271af71a628d0a81f1153bc771c Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 14:33:27 +0200 Subject: [PATCH 27/28] Do not setup tmate --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3a10fce..44dfe04 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -120,10 +120,6 @@ jobs: FLUENCE_ENV: ${{ inputs.fluence-env }} run: npm run test -- -t deploy - - name: Setup tmate session - if: failure() - uses: mxschmitt/action-tmate@v3 - - name: Dump container logs if: always() uses: jwalton/gh-docker-logs@v2 From 556bc77f135c8d677a7bde6f68e746a15d3613c3 Mon Sep 17 00:00:00 2001 From: Anatoly Laskaris Date: Wed, 1 Nov 2023 14:34:27 +0200 Subject: [PATCH 28/28] Cleanup --- provider.yaml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 provider.yaml diff --git a/provider.yaml b/provider.yaml deleted file mode 100644 index dc86daa..0000000 --- a/provider.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# yaml-language-server: $schema=.fluence/schemas/provider.json - -# Defines config used for provider set up - -# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/provider.md - -version: 0 - -computePeers: - nox-0: - computeUnits: 1 - nox-1: - computeUnits: 1 - nox-2: - computeUnits: 1 - -offers: - offer-0: - maxCollateralPerWorker: 1000000000000000000 - minPricePerWorkerEpoch: 83000000000000000 - computePeers: - - nox-0 - - nox-1 - - nox-2