From 24feb3ce73a7ce48668def7fab39dbfa0733ad49 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:11:51 +0500 Subject: [PATCH 01/23] initial commit --- packages/indexer/Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/indexer/Dockerfile b/packages/indexer/Dockerfile index f6a4d3d77..f6cecef87 100644 --- a/packages/indexer/Dockerfile +++ b/packages/indexer/Dockerfile @@ -1,7 +1,5 @@ -FROM rust:1.76-bookworm - -RUN apt-get update && apt-get install -y cmake clang - +FROM rust:1.80-alpine3.19 as build +RUN apk add --no-cache git cmake clang libressl-dev WORKDIR / RUN git clone --depth 1 --branch v1.0.0-beta.4 https://github.com/dashevo/platform @@ -10,6 +8,9 @@ COPY Cargo.lock /app COPY Cargo.toml /app COPY migrations /app/migrations COPY src /app/src - RUN cargo build -RUN cargo install refinery_cli + +FROM alpine:3.19 as indexer +WORKDIR /app +COPY --from=build /app/target/debug /app +COPY --from=build /app/migrations /app \ No newline at end of file From cb0ca3d47741e7068b4abf06ba5796a0aaf9098e Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:33:43 +0500 Subject: [PATCH 02/23] docker file fix --- .github/workflows/build.yml | 5 +++-- packages/indexer/Dockerfile | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12c701eb8..e577760ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -179,13 +179,14 @@ jobs: key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} script: | + docker pull owl352/refinery_cli_docker docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer docker stop $(docker ps -f name=platform-explorer-api -q) docker stop $(docker ps -f name=platform-explorer-indexer -q) docker rm platform-explorer-api platform-explorer-indexer docker run --rm --env-file api.env ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api npm run db:drop - docker run --rm --env-file api.env ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer refinery migrate -e DATABASE_URL -p /app/migrations + docker run --rm --env-file api.env -v `pwd`/packages/indexer/migrations:/migrations owl352/refinery_cli_docker refinery migrate -e DATABASE_URL -p /app/migrations docker run -d -p 3005:3005 --restart always --env-file api.env --name platform-explorer-api ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api sleep 3 - docker run -d --env-file api.env --restart always --name platform-explorer-indexer ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer cargo run + docker run -d --env-file api.env --restart always --name platform-explorer-indexer ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer ./indexer \ No newline at end of file diff --git a/packages/indexer/Dockerfile b/packages/indexer/Dockerfile index f6cecef87..dac06d9aa 100644 --- a/packages/indexer/Dockerfile +++ b/packages/indexer/Dockerfile @@ -12,5 +12,4 @@ RUN cargo build FROM alpine:3.19 as indexer WORKDIR /app -COPY --from=build /app/target/debug /app -COPY --from=build /app/migrations /app \ No newline at end of file +COPY --from=build /app/target/debug /app \ No newline at end of file From 3715b6dbd45897ef658ac15b0227d06425ed4789 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:34:29 +0500 Subject: [PATCH 03/23] new line fix --- packages/indexer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indexer/Dockerfile b/packages/indexer/Dockerfile index dac06d9aa..7be39f129 100644 --- a/packages/indexer/Dockerfile +++ b/packages/indexer/Dockerfile @@ -12,4 +12,4 @@ RUN cargo build FROM alpine:3.19 as indexer WORKDIR /app -COPY --from=build /app/target/debug /app \ No newline at end of file +COPY --from=build /app/target/debug /app From f6122cb56e99f426afecb53b85a56ac272d18ee8 Mon Sep 17 00:00:00 2001 From: owl352 Date: Thu, 1 Aug 2024 23:58:22 +0500 Subject: [PATCH 04/23] validators error fix --- .../api/src/controllers/ValidatorsController.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index 4e6ddf955..c1ea96a92 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -5,7 +5,7 @@ const DashCoreRPC = require('../dashcoreRpc') const ProTxInfo = require('../models/ProTxInfo') class ValidatorsController { - constructor (knex) { + constructor(knex) { this.validatorsDAO = new ValidatorsDAO(knex) } @@ -47,16 +47,22 @@ class ValidatorsController { ) const validatorsWithInfo = await Promise.all( - validators.resultSet.map(async (validator) => ({ ...validator, proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) }))) + validators.resultSet.map(async (validator) => { + try { + return { ...validator, proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) } + } catch (error) { + return {...validator, proTxInfo: null} + } + })) return response.send({ ...validators, resultSet: validatorsWithInfo.map(validator => new Validator(validator.proTxHash, activeValidators.some(activeValidator => activeValidator.pro_tx_hash === validator.proTxHash), - validator.proposedBlocksAmount, - validator.lastProposedBlockHeader, - ProTxInfo.fromObject(validator.proTxInfo) + validator.proposedBlocksAmount, + validator.lastProposedBlockHeader, + validator.proTxInfo ? ProTxInfo.fromObject(validator.proTxInfo) : null ) ) }) From d3007924d401dc56d62380850cada5531463f4a6 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 01:02:41 +0500 Subject: [PATCH 05/23] dashcore getRawTransaction implementation --- .../api/src/controllers/ValidatorsController.js | 12 ++++++++++-- packages/api/src/dashcoreRpc.js | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index c1ea96a92..6c6649a55 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -48,10 +48,18 @@ class ValidatorsController { const validatorsWithInfo = await Promise.all( validators.resultSet.map(async (validator) => { + // const validatorTx = try { - return { ...validator, proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) } + return { + ...validator, + proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) + } } catch (error) { - return {...validator, proTxInfo: null} + const txn = await DashCoreRPC.getRawTransaction(validator.proTxHash) + return { + ...validator, + proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash, txn.blockhash) + } } })) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 9c3f90ed5..3f00bffc2 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -12,9 +12,19 @@ const config = { const rpc = new RpcClient(config) class DashCoreRPC { - static async getProTxInfo (proTxHash) { + static async getProTxInfo(proTxHash,blockHash) { try { - const { result } = await rpc.protx('info', proTxHash) + const { result } = await rpc.protx('info', proTxHash, blockHash) + return result + } catch (e) { + console.error(e) + throw new ServiceNotAvailableError() + } + } + + static async getRawTransaction(proTxHash) { + try { + const { result } = await rpc.getRawTransaction(proTxHash, 1) return result } catch (e) { console.error(e) From 31f5c7f9aa6c033eb31b1e1a7f4c9838e13f0479 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 01:09:44 +0500 Subject: [PATCH 06/23] getValidatorByProTxHash update & lint --- .../src/controllers/ValidatorsController.js | 18 ++++++++++-------- packages/api/src/dashcoreRpc.js | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index 6c6649a55..bbb712e14 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -5,7 +5,7 @@ const DashCoreRPC = require('../dashcoreRpc') const ProTxInfo = require('../models/ProTxInfo') class ValidatorsController { - constructor(knex) { + constructor (knex) { this.validatorsDAO = new ValidatorsDAO(knex) } @@ -20,7 +20,9 @@ class ValidatorsController { const validators = await TenderdashRPC.getValidators() - const proTxInfo = await DashCoreRPC.getProTxInfo(validator.proTxHash) + const transaction = await DashCoreRPC.getRawTransaction(validator.proTxHash) + + const proTxInfo = await DashCoreRPC.getProTxInfo(validator.proTxHash, transaction.blockhash) const isActive = validators.some(validator => validator.pro_tx_hash === hash) @@ -48,17 +50,17 @@ class ValidatorsController { const validatorsWithInfo = await Promise.all( validators.resultSet.map(async (validator) => { - // const validatorTx = + // const validatorTx = try { return { ...validator, proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) } } catch (error) { - const txn = await DashCoreRPC.getRawTransaction(validator.proTxHash) + const transaction = await DashCoreRPC.getRawTransaction(validator.proTxHash) return { ...validator, - proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash, txn.blockhash) + proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash, transaction.blockhash) } } })) @@ -68,9 +70,9 @@ class ValidatorsController { resultSet: validatorsWithInfo.map(validator => new Validator(validator.proTxHash, activeValidators.some(activeValidator => activeValidator.pro_tx_hash === validator.proTxHash), - validator.proposedBlocksAmount, - validator.lastProposedBlockHeader, - validator.proTxInfo ? ProTxInfo.fromObject(validator.proTxInfo) : null + validator.proposedBlocksAmount, + validator.lastProposedBlockHeader, + validator.proTxInfo ? ProTxInfo.fromObject(validator.proTxInfo) : null ) ) }) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 3f00bffc2..84454c745 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -12,7 +12,7 @@ const config = { const rpc = new RpcClient(config) class DashCoreRPC { - static async getProTxInfo(proTxHash,blockHash) { + static async getProTxInfo (proTxHash, blockHash) { try { const { result } = await rpc.protx('info', proTxHash, blockHash) return result @@ -22,7 +22,7 @@ class DashCoreRPC { } } - static async getRawTransaction(proTxHash) { + static async getRawTransaction (proTxHash) { try { const { result } = await rpc.getRawTransaction(proTxHash, 1) return result From e118ad28708c2bd9815cf8ea1a78b3674fcb8daf Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 14:28:16 +0500 Subject: [PATCH 07/23] code optimization --- .../src/controllers/ValidatorsController.js | 31 ++++++------------- packages/api/src/dashcoreRpc.js | 15 ++++++--- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index bbb712e14..92708cb4a 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -5,7 +5,7 @@ const DashCoreRPC = require('../dashcoreRpc') const ProTxInfo = require('../models/ProTxInfo') class ValidatorsController { - constructor (knex) { + constructor(knex) { this.validatorsDAO = new ValidatorsDAO(knex) } @@ -20,9 +20,7 @@ class ValidatorsController { const validators = await TenderdashRPC.getValidators() - const transaction = await DashCoreRPC.getRawTransaction(validator.proTxHash) - - const proTxInfo = await DashCoreRPC.getProTxInfo(validator.proTxHash, transaction.blockhash) + const proTxInfo = await DashCoreRPC.getProTxInfo(validator.proTxHash) const isActive = validators.some(validator => validator.pro_tx_hash === hash) @@ -49,30 +47,19 @@ class ValidatorsController { ) const validatorsWithInfo = await Promise.all( - validators.resultSet.map(async (validator) => { - // const validatorTx = - try { - return { - ...validator, - proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) - } - } catch (error) { - const transaction = await DashCoreRPC.getRawTransaction(validator.proTxHash) - return { - ...validator, - proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash, transaction.blockhash) - } - } - })) + validators.resultSet.map(async (validator) => ({ + ...validator, + proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) + }))) return response.send({ ...validators, resultSet: validatorsWithInfo.map(validator => new Validator(validator.proTxHash, activeValidators.some(activeValidator => activeValidator.pro_tx_hash === validator.proTxHash), - validator.proposedBlocksAmount, - validator.lastProposedBlockHeader, - validator.proTxInfo ? ProTxInfo.fromObject(validator.proTxInfo) : null + validator.proposedBlocksAmount, + validator.lastProposedBlockHeader, + ProTxInfo.fromObject(validator.proTxInfo) ) ) }) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 84454c745..e0f8a7647 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -12,9 +12,9 @@ const config = { const rpc = new RpcClient(config) class DashCoreRPC { - static async getProTxInfo (proTxHash, blockHash) { + static async getRawTransaction(proTxHash) { try { - const { result } = await rpc.protx('info', proTxHash, blockHash) + const { result } = await rpc.getRawTransaction(proTxHash, 1) return result } catch (e) { console.error(e) @@ -22,11 +22,18 @@ class DashCoreRPC { } } - static async getRawTransaction (proTxHash) { + static async getProTxInfo(proTxHash, blockHash) { try { - const { result } = await rpc.getRawTransaction(proTxHash, 1) + const args = ['info', proTxHash, ] + if(blockHash) args.push(blockHash) + const { result } = await rpc.protx(...args) return result } catch (e) { + if (e.code == -8) { + const { blockhash } = await this.getRawTransaction(proTxHash) + const result = await this.getProTxInfo(proTxHash, blockhash) + return result + } console.error(e) throw new ServiceNotAvailableError() } From d99490baff69ccb58318fb4141f6b434056bffe9 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 14:30:13 +0500 Subject: [PATCH 08/23] lint --- packages/api/src/controllers/ValidatorsController.js | 8 ++++---- packages/api/src/dashcoreRpc.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index 92708cb4a..fe19b9054 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -5,7 +5,7 @@ const DashCoreRPC = require('../dashcoreRpc') const ProTxInfo = require('../models/ProTxInfo') class ValidatorsController { - constructor(knex) { + constructor (knex) { this.validatorsDAO = new ValidatorsDAO(knex) } @@ -57,9 +57,9 @@ class ValidatorsController { resultSet: validatorsWithInfo.map(validator => new Validator(validator.proTxHash, activeValidators.some(activeValidator => activeValidator.pro_tx_hash === validator.proTxHash), - validator.proposedBlocksAmount, - validator.lastProposedBlockHeader, - ProTxInfo.fromObject(validator.proTxInfo) + validator.proposedBlocksAmount, + validator.lastProposedBlockHeader, + ProTxInfo.fromObject(validator.proTxInfo) ) ) }) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index e0f8a7647..84ca543b7 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -12,7 +12,7 @@ const config = { const rpc = new RpcClient(config) class DashCoreRPC { - static async getRawTransaction(proTxHash) { + static async getRawTransaction (proTxHash) { try { const { result } = await rpc.getRawTransaction(proTxHash, 1) return result @@ -22,14 +22,14 @@ class DashCoreRPC { } } - static async getProTxInfo(proTxHash, blockHash) { + static async getProTxInfo (proTxHash, blockHash) { try { - const args = ['info', proTxHash, ] - if(blockHash) args.push(blockHash) + const args = ['info', proTxHash] + if (blockHash) args.push(blockHash) const { result } = await rpc.protx(...args) return result } catch (e) { - if (e.code == -8) { + if (e.code === -8) { const { blockhash } = await this.getRawTransaction(proTxHash) const result = await this.getProTxInfo(proTxHash, blockhash) return result From 9b4bd5ae9a16785837a6840b78104a4e0d3c3b2c Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 22:04:55 +0500 Subject: [PATCH 09/23] code optimization --- packages/api/src/dashcoreRpc.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 84ca543b7..5b786b858 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -15,6 +15,7 @@ class DashCoreRPC { static async getRawTransaction (proTxHash) { try { const { result } = await rpc.getRawTransaction(proTxHash, 1) + return result } catch (e) { console.error(e) @@ -22,18 +23,19 @@ class DashCoreRPC { } } - static async getProTxInfo (proTxHash, blockHash) { + static async getProTxInfo (proTxHash, blockHash = NaN) { try { - const args = ['info', proTxHash] - if (blockHash) args.push(blockHash) - const { result } = await rpc.protx(...args) + const { result } = await rpc.protx('info', proTxHash, blockHash) + return result } catch (e) { if (e.code === -8) { const { blockhash } = await this.getRawTransaction(proTxHash) const result = await this.getProTxInfo(proTxHash, blockhash) + return result } + console.error(e) throw new ServiceNotAvailableError() } From 928db521b73f1d05408155dc014b0722fdafda6e Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 22:16:54 +0500 Subject: [PATCH 10/23] code optimiation --- packages/api/src/dashcoreRpc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 5b786b858..c8d229fab 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -25,7 +25,10 @@ class DashCoreRPC { static async getProTxInfo (proTxHash, blockHash = NaN) { try { - const { result } = await rpc.protx('info', proTxHash, blockHash) + const args = ['info', proTxHash] + if (blockHash) args.push(blockHash) + + const { result } = await rpc.protx(...args) return result } catch (e) { From a2adb7ca5c5954fc4fbaf17da76b8df3632ff7d0 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 22:17:35 +0500 Subject: [PATCH 11/23] default value fix --- packages/api/src/dashcoreRpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index c8d229fab..89ee4a701 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -23,7 +23,7 @@ class DashCoreRPC { } } - static async getProTxInfo (proTxHash, blockHash = NaN) { + static async getProTxInfo (proTxHash, blockHash = undefined) { try { const args = ['info', proTxHash] if (blockHash) args.push(blockHash) From 84fdec447bf65eca3bd9f2b1ebc96508c692723c Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 16:01:20 +0500 Subject: [PATCH 12/23] initial commit --- packages/indexer/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indexer/Cargo.lock b/packages/indexer/Cargo.lock index 6ed2a4c11..85dae227f 100644 --- a/packages/indexer/Cargo.lock +++ b/packages/indexer/Cargo.lock @@ -3130,4 +3130,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", -] +] \ No newline at end of file From dfbd0575890bc10d66a78b884d2c8ec1e9c8a858 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 16:06:02 +0500 Subject: [PATCH 13/23] fix --- packages/indexer/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indexer/Cargo.lock b/packages/indexer/Cargo.lock index 85dae227f..6ed2a4c11 100644 --- a/packages/indexer/Cargo.lock +++ b/packages/indexer/Cargo.lock @@ -3130,4 +3130,4 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", -] \ No newline at end of file +] From 55c9f02327886d894e48f51326323cf26f9689a8 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 23:16:04 +0500 Subject: [PATCH 14/23] added dockerfile to migrations update build.yml, dockerfile optimization --- .github/workflows/build.yml | 35 ++++++++++++++++- packages/indexer/Cargo.lock | 52 +++++++------------------- packages/indexer/migrations/Dockerfile | 3 ++ 3 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 packages/indexer/migrations/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e577760ad..e5c341381 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,6 +137,37 @@ jobs: file: ./packages/api/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api + build_refinery_cli: + runs-on: ubuntu-latest + needs: test_api + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push API package Docker image + uses: docker/build-push-action@v4 + with: + context: ./ + file: ./packages/indexer/migrations/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:migrations build_indexer: runs-on: ubuntu-latest permissions: @@ -168,7 +199,7 @@ jobs: tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer deploy: runs-on: ubuntu-latest - needs: [build_api, build_indexer, test_frontend, test_data_contract] + needs: [build_api, build_indexer, build_refinery_cli, test_frontend, test_data_contract] if: github.event_name != 'pull_request' || github.event.pull_request.merged == true steps: - name: Deploy to the server @@ -189,4 +220,4 @@ jobs: docker run --rm --env-file api.env -v `pwd`/packages/indexer/migrations:/migrations owl352/refinery_cli_docker refinery migrate -e DATABASE_URL -p /app/migrations docker run -d -p 3005:3005 --restart always --env-file api.env --name platform-explorer-api ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api sleep 3 - docker run -d --env-file api.env --restart always --name platform-explorer-indexer ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer ./indexer \ No newline at end of file + docker run -d --env-file api.env --restart always --name platform-explorer-indexer ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer ./indexer diff --git a/packages/indexer/Cargo.lock b/packages/indexer/Cargo.lock index 6ed2a4c11..fe8f11967 100644 --- a/packages/indexer/Cargo.lock +++ b/packages/indexer/Cargo.lock @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "dashpay-contract" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "platform-value", "platform-version", @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "data-contracts" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "dashpay-contract", "dpns-contract", @@ -592,7 +592,7 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dpns-contract" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "platform-value", "platform-version", @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "dpp" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "anyhow", "async-trait", @@ -624,7 +624,6 @@ dependencies = [ "log", "nohash-hasher", "num_enum", - "once_cell", "platform-serialization", "platform-serialization-derive", "platform-value", @@ -713,7 +712,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "feature-flags-contract" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "platform-value", "platform-version", @@ -887,16 +886,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "grovedb-version" -version = "1.0.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7d7fcdd5b7873364d38ef0e9144871c11a2124f0192fc6afd6254a93f90273" -dependencies = [ - "thiserror", - "versioned-feature-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "h2" version = "0.3.26" @@ -1208,7 +1197,7 @@ dependencies = [ [[package]] name = "json-schema-compatibility-validator" -version = "1.0.0-beta.4" +version = "0.25.16-rc.4" dependencies = [ "json-patch", "once_cell", @@ -1279,7 +1268,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "masternode-reward-shares-contract" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "platform-value", "platform-version", @@ -1547,7 +1536,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platform-serialization" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "bincode", "platform-version", @@ -1555,7 +1544,7 @@ dependencies = [ [[package]] name = "platform-serialization-derive" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "proc-macro2", "quote", @@ -1565,7 +1554,7 @@ dependencies = [ [[package]] name = "platform-value" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "base64 0.22.1", "bincode", @@ -1584,18 +1573,14 @@ dependencies = [ [[package]] name = "platform-version" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ - "bincode", - "grovedb-version", - "once_cell", "thiserror", - "versioned-feature-core 1.0.0 (git+https://github.com/dashpay/versioned-feature-core)", ] [[package]] name = "platform-versioning" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "proc-macro2", "quote", @@ -2750,17 +2735,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "versioned-feature-core" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898c0ad500fdb1914df465a2c729fce33646ef65dfbbbd16a6d8050e0d2404df" - -[[package]] -name = "versioned-feature-core" -version = "1.0.0" -source = "git+https://github.com/dashpay/versioned-feature-core#560157096c8405a46ce0f21a2e7e1bd11d6625b4" - [[package]] name = "virtue" version = "0.0.13" @@ -3112,7 +3086,7 @@ dependencies = [ [[package]] name = "withdrawals-contract" -version = "1.0.0-beta.4" +version = "1.0.0-dev.12" dependencies = [ "num_enum", "platform-value", diff --git a/packages/indexer/migrations/Dockerfile b/packages/indexer/migrations/Dockerfile new file mode 100644 index 000000000..0a4be7e2a --- /dev/null +++ b/packages/indexer/migrations/Dockerfile @@ -0,0 +1,3 @@ +FROM rust:1.80-alpine3.19 +RUN apk add --no-cache cmake clang libressl-dev +RUN cargo install refinery_cli \ No newline at end of file From 855d916afa84874c60ed593c38261f85946da7c4 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 23:33:31 +0500 Subject: [PATCH 15/23] build.yml needs fix --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e5c341381..34a289e8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,7 +139,6 @@ jobs: tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api build_refinery_cli: runs-on: ubuntu-latest - needs: test_api permissions: contents: read packages: write From e17851ed2505feec317a672efcc7a8b17a12b1d8 Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 23:34:43 +0500 Subject: [PATCH 16/23] `Carglo.lock` fix --- packages/indexer/Cargo.lock | 52 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/packages/indexer/Cargo.lock b/packages/indexer/Cargo.lock index fe8f11967..6ed2a4c11 100644 --- a/packages/indexer/Cargo.lock +++ b/packages/indexer/Cargo.lock @@ -493,7 +493,7 @@ dependencies = [ [[package]] name = "dashpay-contract" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "platform-value", "platform-version", @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "data-contracts" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "dashpay-contract", "dpns-contract", @@ -592,7 +592,7 @@ checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dpns-contract" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "platform-value", "platform-version", @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "dpp" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "anyhow", "async-trait", @@ -624,6 +624,7 @@ dependencies = [ "log", "nohash-hasher", "num_enum", + "once_cell", "platform-serialization", "platform-serialization-derive", "platform-value", @@ -712,7 +713,7 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "feature-flags-contract" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "platform-value", "platform-version", @@ -886,6 +887,16 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "grovedb-version" +version = "1.0.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c7d7fcdd5b7873364d38ef0e9144871c11a2124f0192fc6afd6254a93f90273" +dependencies = [ + "thiserror", + "versioned-feature-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "h2" version = "0.3.26" @@ -1197,7 +1208,7 @@ dependencies = [ [[package]] name = "json-schema-compatibility-validator" -version = "0.25.16-rc.4" +version = "1.0.0-beta.4" dependencies = [ "json-patch", "once_cell", @@ -1268,7 +1279,7 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "masternode-reward-shares-contract" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "platform-value", "platform-version", @@ -1536,7 +1547,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platform-serialization" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "bincode", "platform-version", @@ -1544,7 +1555,7 @@ dependencies = [ [[package]] name = "platform-serialization-derive" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "proc-macro2", "quote", @@ -1554,7 +1565,7 @@ dependencies = [ [[package]] name = "platform-value" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "base64 0.22.1", "bincode", @@ -1573,14 +1584,18 @@ dependencies = [ [[package]] name = "platform-version" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ + "bincode", + "grovedb-version", + "once_cell", "thiserror", + "versioned-feature-core 1.0.0 (git+https://github.com/dashpay/versioned-feature-core)", ] [[package]] name = "platform-versioning" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "proc-macro2", "quote", @@ -2735,6 +2750,17 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "versioned-feature-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898c0ad500fdb1914df465a2c729fce33646ef65dfbbbd16a6d8050e0d2404df" + +[[package]] +name = "versioned-feature-core" +version = "1.0.0" +source = "git+https://github.com/dashpay/versioned-feature-core#560157096c8405a46ce0f21a2e7e1bd11d6625b4" + [[package]] name = "virtue" version = "0.0.13" @@ -3086,7 +3112,7 @@ dependencies = [ [[package]] name = "withdrawals-contract" -version = "1.0.0-dev.12" +version = "1.0.0-beta.4" dependencies = [ "num_enum", "platform-value", From e8ecf02cd7d2c6a7807c62cc08cb41294abd6b3e Mon Sep 17 00:00:00 2001 From: owl352 Date: Mon, 29 Jul 2024 23:53:43 +0500 Subject: [PATCH 17/23] build.yml fix --- .github/workflows/build.yml | 2 +- packages/indexer/migrations/Dockerfile | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 packages/indexer/migrations/Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34a289e8b..a958581be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -164,7 +164,7 @@ jobs: uses: docker/build-push-action@v4 with: context: ./ - file: ./packages/indexer/migrations/Dockerfile + file: github.com/owl352/refinery_cli_docker push: ${{ github.event_name != 'pull_request' }} tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:migrations build_indexer: diff --git a/packages/indexer/migrations/Dockerfile b/packages/indexer/migrations/Dockerfile deleted file mode 100644 index 0a4be7e2a..000000000 --- a/packages/indexer/migrations/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM rust:1.80-alpine3.19 -RUN apk add --no-cache cmake clang libressl-dev -RUN cargo install refinery_cli \ No newline at end of file From 72107290f62abc72ad97a5fc8b14b32b45e4035d Mon Sep 17 00:00:00 2001 From: owl352 Date: Tue, 30 Jul 2024 01:33:01 +0500 Subject: [PATCH 18/23] using owl352 migrations image --- .github/workflows/build.yml | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a958581be..45c055d9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,36 +137,6 @@ jobs: file: ./packages/api/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:api - build_refinery_cli: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push API package Docker image - uses: docker/build-push-action@v4 - with: - context: ./ - file: github.com/owl352/refinery_cli_docker - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:migrations build_indexer: runs-on: ubuntu-latest permissions: @@ -198,7 +168,7 @@ jobs: tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:indexer deploy: runs-on: ubuntu-latest - needs: [build_api, build_indexer, build_refinery_cli, test_frontend, test_data_contract] + needs: [build_api, build_indexer, test_frontend, test_data_contract] if: github.event_name != 'pull_request' || github.event.pull_request.merged == true steps: - name: Deploy to the server From 3c6ae68ca572641f5fc070b75e92268e1dde504a Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:42:47 +0500 Subject: [PATCH 19/23] changes fix --- packages/api/src/controllers/ValidatorsController.js | 2 +- packages/api/src/dashcoreRpc.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index fe19b9054..7c30321fb 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -82,4 +82,4 @@ class ValidatorsController { } } -module.exports = ValidatorsController +module.exports = ValidatorsController \ No newline at end of file diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 89ee4a701..9c267da2e 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -45,4 +45,4 @@ class DashCoreRPC { } } -module.exports = DashCoreRPC +module.exports = DashCoreRPC \ No newline at end of file From 834cdad39c5ce8f4d79f7f43579ad4b49d5370d9 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:44:42 +0500 Subject: [PATCH 20/23] controller changes fix --- packages/api/src/controllers/ValidatorsController.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/api/src/controllers/ValidatorsController.js b/packages/api/src/controllers/ValidatorsController.js index 7c30321fb..4e6ddf955 100644 --- a/packages/api/src/controllers/ValidatorsController.js +++ b/packages/api/src/controllers/ValidatorsController.js @@ -47,10 +47,7 @@ class ValidatorsController { ) const validatorsWithInfo = await Promise.all( - validators.resultSet.map(async (validator) => ({ - ...validator, - proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) - }))) + validators.resultSet.map(async (validator) => ({ ...validator, proTxInfo: await DashCoreRPC.getProTxInfo(validator.proTxHash) }))) return response.send({ ...validators, @@ -82,4 +79,4 @@ class ValidatorsController { } } -module.exports = ValidatorsController \ No newline at end of file +module.exports = ValidatorsController From 6afb2907dd77119581f8742be5af8fd498d827d2 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:46:55 +0500 Subject: [PATCH 21/23] rpc changes fix --- packages/api/src/dashcoreRpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/dashcoreRpc.js b/packages/api/src/dashcoreRpc.js index 9c267da2e..89ee4a701 100644 --- a/packages/api/src/dashcoreRpc.js +++ b/packages/api/src/dashcoreRpc.js @@ -45,4 +45,4 @@ class DashCoreRPC { } } -module.exports = DashCoreRPC \ No newline at end of file +module.exports = DashCoreRPC From fc56f192772375cda529596ea2bba0e5054d38f0 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:47:14 +0500 Subject: [PATCH 22/23] docker file changes fix --- packages/indexer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indexer/Dockerfile b/packages/indexer/Dockerfile index faa05f6b4..e6aff74c6 100644 --- a/packages/indexer/Dockerfile +++ b/packages/indexer/Dockerfile @@ -11,4 +11,4 @@ RUN cargo build FROM alpine:3.19 as indexer WORKDIR /app -COPY --from=build /app/target/debug /app +COPY --from=build /app/target/debug /app \ No newline at end of file From 77357ad7922769d82ceedff6a2a129df78565192 Mon Sep 17 00:00:00 2001 From: owl352 Date: Fri, 2 Aug 2024 23:47:51 +0500 Subject: [PATCH 23/23] docker file changes fix --- packages/indexer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/indexer/Dockerfile b/packages/indexer/Dockerfile index e6aff74c6..4c79ab160 100644 --- a/packages/indexer/Dockerfile +++ b/packages/indexer/Dockerfile @@ -11,4 +11,4 @@ RUN cargo build FROM alpine:3.19 as indexer WORKDIR /app -COPY --from=build /app/target/debug /app \ No newline at end of file +COPY --from=build /app/target/debug /app \ No newline at end of file