diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts index 8da4c6bc46..03431fda5e 100644 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts +++ b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/generate-and-send-signed-transaction.test.ts @@ -8,9 +8,11 @@ // Constants ////////////////////////////////// +import { IROHA_TEST_LEDGER_DEFAULT_OPTIONS } from "@hyperledger/cactus-test-tooling"; + // Ledger settings const ledgerImageName = "ghcr.io/hyperledger/cactus-iroha-all-in-one"; -const ledgerImageVersion = "2021-08-16--1183"; +const ledgerImageVersion = IROHA_TEST_LEDGER_DEFAULT_OPTIONS.imageVersion; const postgresImageName = "postgres"; const postgresImageVersion = "9.5-alpine"; diff --git a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts index 682224e4ce..f66e781c21 100644 --- a/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts +++ b/packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts @@ -37,7 +37,7 @@ import { import cryptoHelper from "iroha-helpers/lib/cryptoHelper"; import { Constants } from "@hyperledger/cactus-core-api"; -const testCase = "runs tx on an Iroha v1.2.0 ledger"; +const testCase = "runs tx on an Iroha v1.4.0-patch-3 ledger"; const logLevel: LogLevelDesc = "INFO"; test.onFailure(async () => { @@ -87,7 +87,7 @@ test(testCase, async (t: Test) => { test.onFinish(async () => { await iroha.stop(); }); - await iroha.start(); + await iroha.start(false); const irohaPort = await iroha.getRpcToriiPort(); const rpcToriiPortHost = await iroha.getRpcToriiPortHost(); const rpcApiWsHost = await iroha.getRpcApiWsHost(); diff --git a/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts index 65a04a49e1..200c9de283 100644 --- a/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts +++ b/packages/cactus-test-tooling/src/main/typescript/iroha/iroha-test-ledger.ts @@ -32,13 +32,14 @@ export interface IIrohaTestLedgerOptions { readonly logLevel?: LogLevelDesc; readonly emitContainerLogs?: boolean; readonly rpcApiWsPort?: number; + readonly healthcheckPort?: number; } /* * Provides default options for Iroha container */ export const IROHA_TEST_LEDGER_DEFAULT_OPTIONS = Object.freeze({ - imageVersion: "2021-08-16--1183", + imageVersion: "2023-07-17-issue-2524", imageName: "ghcr.io/hyperledger/cactus-iroha-all-in-one", adminPriv: " ", adminPub: " ", @@ -46,11 +47,30 @@ export const IROHA_TEST_LEDGER_DEFAULT_OPTIONS = Object.freeze({ nodePub: " ", tlsCert: " ", tlsKey: " ", + healthcheckPort: 50508, rpcToriiPort: 50051, toriiTlsPort: 55552, envVars: [ + "IROHA_MST_EXPIRATION_TIME=1440", + "IROHA_MST_ENABLE=false", + "IROHA_HEALTHCHECK_PORT=50508", + "IROHA_PROPOSAL_CREATION_TIMEOUT=3000", + "IROHA_VOTE_DELAY=5000", + "IROHA_PROPOSAL_DELAY=5000", + "IROHA_MAX_PROPOSAL_SIZE=10", + "IROHA_DATABASE_TYPE=postgres", + "IROHA_INTER_PEER_TLS_KEY_PAIR_PATH=/opt/iroha_data/node0", + "IROHA_TORII_TLS_PARAMS_PORT=55552", + "IROHA_INTERNAL_PORT=10001", + "IROHA_BLOCK_STORE_PATH=/tmp/block_store/", + "IROHA_TORII_PORT=50051", + "IROHA_LOG_LEVEL=info", "IROHA_POSTGRES_USER=postgres", "IROHA_POSTGRES_PASSWORD=my-secret-password", + "IROHA_DATABASE_USER=postgres", + "IROHA_DATABASE_PASSWORD=my-secret-password", + "IROHA_DATABASE_WORKING DATABASE=iroha_default", + "IROHA_DATABASE_MAINTENANCE DATABASE=postgres", "KEY=node0", ], rpcApiWsPort: 50052, @@ -67,6 +87,9 @@ export const IROHA_TEST_LEDGER_OPTIONS_JOI_SCHEMA: Joi.Schema = Joi.object().key nodePub: Joi.string().min(1).max(64).required(), tlsCert: Joi.string().min(1).required(), tlsKey: Joi.string().min(1).required(), + healthcheckPort: Joi.number() + .port() + .default(IROHA_TEST_LEDGER_DEFAULT_OPTIONS.healthcheckPort), toriiTlsPort: Joi.number().port().required(), postgresPort: Joi.number().port().required(), postgresHost: Joi.string().hostname().required(), @@ -92,6 +115,7 @@ export class IrohaTestLedger implements ITestLedger { public readonly rpcApiWsPort: number; public readonly tlsCert?: string; public readonly tlsKey?: string; + public readonly healthcheckPort?: number; public readonly toriiTlsPort?: number; private readonly log: Logger; @@ -131,6 +155,12 @@ export class IrohaTestLedger implements ITestLedger { options.toriiTlsPort || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.toriiTlsPort; this.rpcApiWsPort = options.rpcApiWsPort || IROHA_TEST_LEDGER_DEFAULT_OPTIONS.rpcApiWsPort; + this.healthcheckPort = + options.healthcheckPort || + IROHA_TEST_LEDGER_DEFAULT_OPTIONS.healthcheckPort; + + this.envVars.push(`IROHA_DATABASE_HOST=${this.postgresHost}`); + this.envVars.push(`IROHA_DATABASE_PORT=${this.postgresPort}`); this.envVars.push(`IROHA_POSTGRES_HOST=${this.postgresHost}`); this.envVars.push(`IROHA_POSTGRES_PORT=${this.postgresPort}`); @@ -295,6 +325,7 @@ export class IrohaTestLedger implements ITestLedger { [`${this.rpcToriiPort}/tcp`]: {}, // Iroha RPC - Torii [`${this.toriiTlsPort}/tcp`]: {}, // Iroha TLS RPC [`${this.rpcApiWsPort}/tcp`]: {}, // Iroha RPC WS + [`${this.healthcheckPort}/tcp`]: {}, // Iroha Healthcheck Service }, Env: this.envVars, Healthcheck: { diff --git a/tools/docker/iroha-all-in-one/Dockerfile b/tools/docker/iroha-all-in-one/Dockerfile index e0df6d7c55..9c006b9ab6 100644 --- a/tools/docker/iroha-all-in-one/Dockerfile +++ b/tools/docker/iroha-all-in-one/Dockerfile @@ -1,40 +1,24 @@ -FROM ubuntu:20.04 as builder -ARG DEBIAN_FRONTEND=noninteractive +FROM hyperledger/iroha:1.4.0-patch-3 -RUN set -e && apt-get update && apt-get install -y --no-install-recommends \ - file build-essential ninja-build ca-certificates tar curl unzip cmake pkg-config zip software-properties-common - -RUN add-apt-repository ppa:git-core/ppa -RUN apt-get update -RUN apt-get install -y --no-install-recommends git - -RUN git clone https://github.com/hyperledger/iroha.git -b 1.4.0 -RUN iroha/vcpkg/build_iroha_deps.sh -RUN /vcpkg-build/vcpkg integrate install -WORKDIR /iroha/build/ - -RUN cmake -DCMAKE_TOOLCHAIN_FILE=/vcpkg-build/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TYPE=Release -DPACKAGE_DEB=ON -G "Ninja" .. -RUN cmake --build . --target package -- -j$(nproc) - -FROM ubuntu:20.04 ARG DEBIAN_FRONTEND=noninteractive RUN set -e && apt-get update && \ - apt-get install -y moreutils jq python3 python3-pip && \ + apt-get install -y moreutils jq wget python3 python3-pip && \ pip install iroha && \ apt-get purge -y `apt-get -s purge python3-pip | grep '^ ' | tr -d '*'` && \ apt-get -y clean && \ rm -rf /var/lib/apt/lists/* -# irohad is the core of Iroha ledger -COPY --from=builder /iroha/build/bin/irohad /usr/bin/irohad -# copying iroha-cli optional; only copied for debugging purpose -COPY --from=builder /iroha/build/bin/iroha-cli /usr/bin/iroha-cli -# files below are necessary -COPY --from=builder /iroha/example/ /opt/iroha_data/ -COPY --from=builder /iroha/docker/release/wait-for-it.sh / + COPY genesis.block /opt/iroha_data/genesis.block COPY entrypoint.sh healthcheck.py / -RUN chmod +x /entrypoint.sh /wait-for-it.sh +RUN chmod +x /entrypoint.sh WORKDIR /opt/iroha_data + +RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/admin%40test.pub --output-document=admin@test.pub +RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/admin%40test.priv --output-document=admin@test.priv +RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/node0.pub +RUN wget https://raw.githubusercontent.com/hyperledger/iroha/v1.4.0-patch-3/example/node0.priv + ENTRYPOINT ["/entrypoint.sh"] + CMD ["irohad"] \ No newline at end of file diff --git a/tools/docker/iroha-all-in-one/entrypoint.sh b/tools/docker/iroha-all-in-one/entrypoint.sh index a6b6885fde..6412d693ec 100644 --- a/tools/docker/iroha-all-in-one/entrypoint.sh +++ b/tools/docker/iroha-all-in-one/entrypoint.sh @@ -1,9 +1,6 @@ #!/usr/bin/env bash set -e -# sync the local config file with the environment variables for pg opts -export pg_opt_value="host=${IROHA_POSTGRES_HOST} port=${IROHA_POSTGRES_PORT} user=${IROHA_POSTGRES_USER} password=${IROHA_POSTGRES_PASSWORD}" - if [ ! $ADMIN_PRIV = *" "* ] && [ -n "$ADMIN_PRIV" ]; then sed -i "1s/.*/$ADMIN_PRIV/" admin@test.priv fi @@ -26,10 +23,6 @@ if [ ! $NODE_PUB = *" "* ] && [ -n "$NODE_PUB" ]; then genesis.block|sponge genesis.block fi -jq --arg pg_opt "${pg_opt_value}" \ - '.pg_opt = $pg_opt' \ - config.docker|sponge config.docker - # if first arg looks like a flag, assume we want to run irohad server if [ "${1:0:1}" = '-' ]; then set -- irohad "$@" @@ -46,7 +39,7 @@ if [ "$1" = 'irohad' ]; then echo "WARNING: IROHA_POSTGRES_HOST is not defined. Do not wait for Postgres to become ready. Iroha may fail to start up" fi - exec "$@" --genesis_block genesis.block --config config.docker --keypair_name $KEY + exec "$@" --genesis_block genesis.block --keypair_name $KEY --verbosity=${IROHA_LOG_LEVEL} fi exec "$@" \ No newline at end of file