diff --git a/.env-example b/.env-example index fd4e7b5e..a616c611 100644 --- a/.env-example +++ b/.env-example @@ -1,3 +1,18 @@ INCLUDE_CASES=00_00_01-sync.js,01_01_01-pre_orchid_2wp.js RUN_EACH_TEST_FILE_THESE_TIMES=1 RUN_ALL_TESTS_THESE_TIMES=1 + +# Amount of time in milliseconds for the `waitForBlock` utility function to wait. +# Configurable because depending on the resources of the machine the tests are running on, the wait time might change. +# In a machine with little resources (CPU, RAM, disk), a small wait time might not be enough because blocks can be mined slow and `waitForBlock` +# might fail with a message like `Block number 800 never reached, last seen was 600`, or `Blockchain not advancing after attempting to find a new block 80 times checking every 200 milliseconds. +# Couldn't reach block number 800. Last block number seen was: 600`. In a machine with enough resources having a high wait time might be a waste of time since the tests would run slower because if this wait time. +# In this case, it can be set to a small value. `200` recommended for most machines with enough resources. `500`, `600`, etc., or more for machine with limited resources. +# Adjust as needed, starting with low values so the tests run as fast as they can. +WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS= + +# Max attempts for the `waitForBlock` utility function to 'wait' for the given block, trying to find that block once every `WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS`. +# The same as the `WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS` variable, the value for this variable could be updated depending on the machine the tests are running on. +# `80` recommended for most machines with enough resources. `160`, `250` or more for machine with limited resources. +# Adjust as needed, starting with low values so the tests run as fast as they can. +WAIT_FOR_BLOCK_MAX_ATTEMPTS= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2a2edb74 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,127 @@ +name: RIT Action Continuous Integration Test + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + packages: write +env: + TEST_TAG: ${{ github.event.repository.name }}/rit:test + LATEST_TAG: ghcr.io/rsksmart/${{ github.event.repository.name }}/rit + +jobs: + build-push-rit-action-container-action: + name: Test RIT Action docker container-action + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.LATEST_TAG }} + ${{ env.TEST_TAG }} + + - name: Setup Docker BuildX + id: setup-buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + driver-opts: network=host + platforms: linux/amd64 + + - name: Build and export locally Docker + uses: docker/build-push-action@v6 + with: + context: container-action/ + load: true + tags: ${{ env.TEST_TAG }} + + - name: Test the RIT Container Action + id: test-container + env: + INPUT_RSKJ_BRANCH: master + INPUT_POWPEG_NODE_BRANCH: master + INPUT_RIT_BRANCH: main + INPUT_RIT_LOG_LEVEL: info + run: | + docker run \ + --env GITHUB_OUTPUT="/github-output" \ + --env INPUT_RSKJ_BRANCH="${{ env.INPUT_RSKJ_BRANCH }}" \ + --env INPUT_POWPEG_NODE_BRANCH="${{ env.INPUT_POWPEG_NODE_BRANCH }}" \ + --env INPUT_RIT_BRANCH="${{ env.INPUT_RIT_BRANCH }}" \ + --env INPUT_RIT_LOG_LEVEL="${{ env.INPUT_RIT_LOG_LEVEL }}" \ + -v "$GITHUB_OUTPUT:/github-output" \ + --rm ${{ env.TEST_TAG }} + + - name: GitHub container registry login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build the RIT Action Container Image + uses: docker/build-push-action@v6 + with: + context: container-action/ + tags: ${{ env.LATEST_TAG }} + labels: ${{ steps.meta.outputs.labels }} + load: true + push: true + + test-rit-action: + needs: build-push-rit-action-container-action + name: GitHub Actions Test + runs-on: ubuntu-latest + timeout-minutes: 60 + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Test RIT Action + id: test-rit-action + uses: ./container-action/ + with: + rskj-branch: master + powpeg-node-branch: master + + - name: Print RIT Status and Message + id: output + run: | + echo "RIT Status = ${{ steps.test-rit-action.outputs.status }}" + echo "RIT Message = ${{ steps.test-rit-action.outputs.message }}" + + publish-rit-action-tag: + needs: test-rit-action + name: Publish RIT Action tag + runs-on: ubuntu-latest + timeout-minutes: 60 + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout + id: checkout + uses: actions/checkout@v4 + + - name: Create GitHub Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: rootstock-integration-tests@v1 + release_name: Release rootstock-integration-tests@v1 + draft: false + prerelease: false diff --git a/.gitignore b/.gitignore index a33923ed..77cde6cd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ config/*.js logs .env .DS_Store +.idea/ diff --git a/container-action/Dockerfile b/container-action/Dockerfile new file mode 100644 index 00000000..862b0230 --- /dev/null +++ b/container-action/Dockerfile @@ -0,0 +1,60 @@ +FROM ubuntu:24.04 AS builder + +LABEL Description="Custom RSK node image to execute Rootstock Integration Tests" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates curl git gnupg2 mocha wget \ + && apt clean + +# -- nodeJs --------------------------------------------------------- +ENV NODE_VERSION v20.14.0 +RUN mkdir -p /usr/local/nvm +ENV NVM_DIR /usr/local/nvm + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ + && . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +ENV NODE_PATH $NVM_DIR/$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH + +# -- java --------------------------------------------------------- +ENV JAVA_VERSION 17 + +RUN apt-get -y install "openjdk-$JAVA_VERSION-jdk" + +ENV JAVA_HOME="/usr/lib/jvm/java-$JAVA_VERSION-openjdk-amd64" + +# -- bitcoind --------------------------------------------------------- +ENV BITCOIN_VERSION 0.18.1 + +RUN cd /tmp \ + && wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz \ + && tar -xzvf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz -C /opt \ + && mv /opt/bitcoin-${BITCOIN_VERSION} /opt/bitcoin \ + && rm -v /opt/bitcoin/bin/test_bitcoin /opt/bitcoin/bin/bitcoin-qt \ + && ln -sv /opt/bitcoin/bin/* /usr/local/bin + +# -- configure entrypoint to run RIT-------------------------------------------- + +RUN mkdir -p /usr/src/logbacks + +WORKDIR /usr/src + +COPY entrypoint.sh /usr/src/entrypoint.sh +COPY rit-local-configs/regtest-all-keys.js /usr/src/regtest.js +COPY rit-local-configs/logbacks/* /usr/src/logbacks/ +COPY scripts/* /usr/src/ + +RUN chmod +x /usr/src/entrypoint.sh \ + && chmod +x /usr/src/configure_gradle_powpeg.sh \ + && chmod +x /usr/src/configure_rit_locally.sh \ + && mkdir -p /usr/src/bitcoindata \ + && chmod -R 755 /usr/src/bitcoindata + +ENTRYPOINT ["/usr/src/entrypoint.sh"] + +EXPOSE 18332 diff --git a/container-action/README.md b/container-action/README.md new file mode 100644 index 00000000..f3ac048a --- /dev/null +++ b/container-action/README.md @@ -0,0 +1,60 @@ +# Rootstock Integration Tests Action + +This action provides a containerized environment for running integration tests on Rootstock. +It receives as inputs the branches of `powpeg`, `rskj` and `rootstock-integration-tests` repositories, +checkout at the branches passed as parameters, build the projects and run the integration tests. + +The rootstock-integration-tests it's a project that tests the integration between rskj and powpeg-node, +it validates that the peg-in and peg-out processes are working correctly. It's extremely important to both projects, +and should be executed before any release of both projects or any merge to the master/main branch. + +To achieve this and make this test more accessible, we created a container-action created to execute this test, +it offers the flexibility to run the tests with any specific tag or branch from *powpeg-node* or *rskj*. +That way, we will add steps on each repository to run the integration tests with the version that we want to test. +No matter if it's a tag, a branch or a specific commit. + +## Inputs +By default, all the inputs are pointed to the `master/main` branch of the repositories. But, ideally, the action step +should receive the branches, commit or tag that should be tested by the pipeline execution. If we want to test +a specific tag from `powpeg-node`, the input parameter `powpeg-node-branch` should be the tag number `6.4.0.0-rc` for example. + +### `rskj-branch` + +The rskj branch to checkout. If no branch or tag passed, it will be used the default `master`. + +### `powpeg-node-branch` + +The powpeg-node branch to checkout. If no branch or tag passed, it will be used the default `master`. + +### `rit-branch` + +**Optional** The rootstock-integration-tests branch to checkout. This one it's optional, if it's needed +to use a different branch for the rootstock-integration-test. It's offered the possibility +to use a different one, but the default and most frequently used, should be `main`. + +### `rit-log-level` + +**Optional** Log level for the rootstock-integration-tests. Default is `info`. + +## Outputs +The output of the action are basically two values, one is the status of the integration tests, and the other is the message. +I +### `status` + +The status of the integration tests. It would be `0` for success and `1` for failure. + +### `message` + +The output message of the integration tests. It will be: +- In case of success: `Rootstock Integration Tests Status: PASSED` +- In case of error: `Rootstock Integration Tests Status: FAILED` + +## Example usage + +```yaml +uses: rootstock-integration-tests@v1 +with: + rskj-branch: master + powpeg-node-branch: master + rit-branch: main +``` \ No newline at end of file diff --git a/container-action/action.yml b/container-action/action.yml new file mode 100644 index 00000000..657b65ea --- /dev/null +++ b/container-action/action.yml @@ -0,0 +1,36 @@ +name: 'Rootstock Integration Tests Action' +description: 'This action provides a containerized environment for running integration tests on Rootstock.' +author: 'Rootstock Labs' + +inputs: + rskj-branch: + description: 'The rskj branch to checkout' + required: true + default: 'master' + powpeg-node-branch: + description: 'The powpeg-node branch to checkout' + required: true + default: 'master' + rit-branch: + description: 'The rootstock-integration-tests branch to checkout' + required: false + default: 'main' + rit-log-level: + description: 'Log level for the rootstock-integration-tests' + required: false + default: 'info' + +outputs: + status: + description: 'The status of the integration tests' + message: + description: 'The output message of the integration tests' + +runs: + using: docker + image: Dockerfile + env: + INPUT_RSKJ_BRANCH: ${{ inputs.rskj-branch }} + INPUT_POWPEG_NODE_BRANCH: ${{ inputs.powpeg-node-branch }} + INPUT_RIT_BRANCH: ${{ inputs.rit-branch }} + INPUT_RIT_LOG_LEVEL: ${{ inputs.rit-log-level }} diff --git a/container-action/entrypoint.sh b/container-action/entrypoint.sh new file mode 100644 index 00000000..1003f44d --- /dev/null +++ b/container-action/entrypoint.sh @@ -0,0 +1,65 @@ +#!/bin/sh -l + +set -e +RSKJ_BRANCH="${INPUT_RSKJ_BRANCH}" +POWPEG_NODE_BRANCH="${INPUT_POWPEG_NODE_BRANCH}" +RIT_BRANCH="${INPUT_RIT_BRANCH}" +LOG_LEVEL="${INPUT_RIT_LOG_LEVEL}" + +echo -e "\n\n--------- Input parameters received ---------\n\n" +echo "RSKJ_BRANCH=$RSKJ_BRANCH" +echo "POWPEG_NODE_BRANCH=$POWPEG_NODE_BRANCH" +echo "RIT_BRANCH=$RIT_BRANCH" +echo "LOG_LEVEL=$LOG_LEVEL" + +echo -e "\n\n--------- Starting the configuration of rskj ---------\n\n" +cd /usr/src/ +git clone https://github.com/rsksmart/rskj.git rskj +cd rskj && git checkout "$RSKJ_BRANCH" +chmod +x ./configure.sh && chmod +x gradlew +./configure.sh + +echo -e "\n\n--------- Starting the configuration of powpeg ---------\n\n" +cd /usr/src/ +git clone https://github.com/rsksmart/powpeg-node.git powpeg +cp configure_gradle_powpeg.sh powpeg +cd powpeg && git checkout "$POWPEG_NODE_BRANCH" +chmod +x ./configure.sh && chmod +x gradlew +POWPEG_VERSION=$(bash configure_gradle_powpeg.sh) +echo "POWPEG_VERSION=$POWPEG_VERSION" +./configure.sh +./gradlew --info --no-daemon clean build -x test + +echo -e "\n\n--------- Starting the configuration of RIT ---------\n\n" +cd /usr/src/ +git clone https://github.com/rsksmart/rootstock-integration-tests.git rit +mv configure_rit_locally.sh rit +mv regtest.js rit/config/regtest.js +mv /usr/src/logbacks/* /usr/src/rit/logbacks/ +cd rit +git checkout "$RIT_BRANCH" +chmod +x ./configure.sh +./configure.sh +./configure_rit_locally.sh "${POWPEG_VERSION}" +export LOG_LEVEL="$LOG_LEVEL" + +echo -e "\n\n--------- Executing Rootstock Integration Tests ---------\n\n" +npm install -y +npm run test-fail-fast +STATUS=$? + +echo -e "\n\n--------- RIT Tests Result ---------\n\n" +if [ $STATUS -ne 0 ]; then + MESSAGE="Rootstock Integration Tests Status: FAILED" +else + MESSAGE="Rootstock Integration Tests Status: PASSED" +fi +echo -e "$MESSAGE" + +echo "status=${STATUS}" >> "${GITHUB_OUTPUT}" +echo "message=${MESSAGE}" >> "${GITHUB_OUTPUT}" + +if [ $STATUS -ne 0 ]; then + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/container-action/rit-local-configs/logbacks/logback-fed-1.xml b/container-action/rit-local-configs/logbacks/logback-fed-1.xml new file mode 100644 index 00000000..56c73786 --- /dev/null +++ b/container-action/rit-local-configs/logbacks/logback-fed-1.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + System.out + + %date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n + + + + + /usr/src/logs/rsk-fed-1.log + + + %date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n + + + + ./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz + 100MB + 7 + 1GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/container-action/rit-local-configs/logbacks/logback-fed-2.xml b/container-action/rit-local-configs/logbacks/logback-fed-2.xml new file mode 100644 index 00000000..0b925b2a --- /dev/null +++ b/container-action/rit-local-configs/logbacks/logback-fed-2.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + System.out + + %date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n + + + + + /usr/src/logs/rsk-fed-2.log + + + %date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n + + + + ./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz + 100MB + 7 + 1GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/container-action/rit-local-configs/logbacks/logback-fed-3.xml b/container-action/rit-local-configs/logbacks/logback-fed-3.xml new file mode 100644 index 00000000..5a79fec6 --- /dev/null +++ b/container-action/rit-local-configs/logbacks/logback-fed-3.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + System.out + + %date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n + + + + + /usr/src/logs/rsk-fed-3.log + + + %date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n + + + + ./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz + 100MB + 7 + 1GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/container-action/rit-local-configs/logbacks/logback-fed-4.xml b/container-action/rit-local-configs/logbacks/logback-fed-4.xml new file mode 100644 index 00000000..9b36ddf1 --- /dev/null +++ b/container-action/rit-local-configs/logbacks/logback-fed-4.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + System.out + + %date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n + + + + + /usr/src/logs/rsk-fed-4.log + + + %date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n + + + + ./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz + 100MB + 7 + 1GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/container-action/rit-local-configs/logbacks/logback-fed-5.xml b/container-action/rit-local-configs/logbacks/logback-fed-5.xml new file mode 100644 index 00000000..495ffc4c --- /dev/null +++ b/container-action/rit-local-configs/logbacks/logback-fed-5.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + System.out + + %date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n + + + + + /usr/src/logs/rsk-fed-5.log + + + %date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n + + + + ./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz + 100MB + 7 + 1GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ + + + + + + + + + + + + + diff --git a/container-action/rit-local-configs/regtest-all-keys.js b/container-action/rit-local-configs/regtest-all-keys.js new file mode 100644 index 00000000..20a62915 --- /dev/null +++ b/container-action/rit-local-configs/regtest-all-keys.js @@ -0,0 +1,116 @@ +const path = require('path'); +const nodesConfigPath = 'config/node-configs'; +const keysPathResolve = 'node-keys'; +const classpath = process.env.POWPEG_NODE_JAR_PATH; +const federatesLogbackPath = path.resolve(__dirname, 'logbacks'); + +module.exports = { + init: { + mineInitialBitcoin: true, + federatesLogbackFile: federatesLogbackPath + }, + btc: { + rpcUser: 'test', + rpcPassword: 'test', + dir: process.env.BITCOIN_DATA_DIR, + }, + federate: [ + { + logbackFile: `${federatesLogbackPath}/logback-fed-1.xml`, + classpath: classpath, + configFile: `${nodesConfigPath}/rsk-reg-1.conf`, + publicKeys: { + btc: '0362634ab57dae9cb373a5d536e66a8c4f67468bbcfb063809bab643072d78a124', + rsk: '0362634ab57dae9cb373a5d536e66a8c4f67468bbcfb063809bab643072d78a124', + mst: '0362634ab57dae9cb373a5d536e66a8c4f67468bbcfb063809bab643072d78a124', + }, + customConfig: { + 'federator.signers.BTC.type': 'keyFile', + 'federator.signers.BTC.path': path.resolve(__dirname, `${keysPathResolve}/reg1.key`), + 'federator.signers.RSK.type': 'keyFile', + 'federator.signers.RSK.path': path.resolve(__dirname, `${keysPathResolve}/reg1.key`), + 'federator.signers.MST.type': 'keyFile', + 'federator.signers.MST.path': path.resolve(__dirname, `${keysPathResolve}/reg1.key`) + }, + nodeId: '62634ab57dae9cb373a5d536e66a8c4f67468bbcfb063809bab643072d78a1243bd206c2c7a218d6ff4c9a185e71f066bd354e5267875b7683fbc70a1d455e87' + }, + { + logbackFile: `${federatesLogbackPath}/logback-fed-2.xml`, + classpath: classpath, + configFile: `${nodesConfigPath}/rsk-reg-2.conf`, + publicKeys: { + btc: '03c5946b3fbae03a654237da863c9ed534e0878657175b132b8ca630f245df04db', + rsk: '03c5946b3fbae03a654237da863c9ed534e0878657175b132b8ca630f245df04db', + mst: '03c5946b3fbae03a654237da863c9ed534e0878657175b132b8ca630f245df04db', + }, + customConfig: { + 'federator.signers.BTC.type': 'keyFile', + 'federator.signers.BTC.path': path.resolve(__dirname, `${keysPathResolve}/reg2.key`), + 'federator.signers.RSK.type': 'keyFile', + 'federator.signers.RSK.path': path.resolve(__dirname, `${keysPathResolve}/reg2.key`), + 'federator.signers.MST.type': 'keyFile', + 'federator.signers.MST.path': path.resolve(__dirname, `${keysPathResolve}/reg2.key`) + }, + nodeId: 'c5946b3fbae03a654237da863c9ed534e0878657175b132b8ca630f245df04dbb0bde4f3854613b16032fb214f9cc00f75363976ee078cc4409cdc543036ccfd' + }, + { + logbackFile: `${federatesLogbackPath}/logback-fed-3.xml`, + classpath: classpath, + configFile: `${nodesConfigPath}/rsk-reg-3.conf`, + publicKeys: { + btc: '02cd53fc53a07f211641a677d250f6de99caf620e8e77071e811a28b3bcddf0be1', + rsk: '02cd53fc53a07f211641a677d250f6de99caf620e8e77071e811a28b3bcddf0be1', + mst: '02cd53fc53a07f211641a677d250f6de99caf620e8e77071e811a28b3bcddf0be1', + }, + customConfig: { + 'federator.signers.BTC.type': 'keyFile', + 'federator.signers.BTC.path': path.resolve(__dirname, `${keysPathResolve}/reg3.key`), + 'federator.signers.RSK.type': 'keyFile', + 'federator.signers.RSK.path': path.resolve(__dirname, `${keysPathResolve}/reg3.key`), + 'federator.signers.MST.type': 'keyFile', + 'federator.signers.MST.path': path.resolve(__dirname, `${keysPathResolve}/reg3.key`) + }, + nodeId: 'cd53fc53a07f211641a677d250f6de99caf620e8e77071e811a28b3bcddf0be19e9da12b897b83765fbaebe717fab74fcb1b57c82f7978b8be3296239909e626' + } + ], + additionalFederateNodes: [ + { + logbackFile: `${federatesLogbackPath}/logback-fed-4.xml`, + classpath: classpath, + configFile: `${nodesConfigPath}/rsk-reg-4.conf`, + publicKeys: { + btc: '031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5', + rsk: '031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5', + mst: '031da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc5', + }, + customConfig: { + 'federator.signers.BTC.type': 'keyFile', + 'federator.signers.BTC.path': path.resolve(__dirname, `${keysPathResolve}/reg4.key`), + 'federator.signers.RSK.type': 'keyFile', + 'federator.signers.RSK.path': path.resolve(__dirname, `${keysPathResolve}/reg4.key`), + 'federator.signers.MST.type': 'keyFile', + 'federator.signers.MST.path': path.resolve(__dirname, `${keysPathResolve}/reg4.key`) + }, + nodeId: '1da807c71c2f303b7f409dd2605b297ac494a563be3b9ca5f52d95a43d183cc52191fc2bd3b06ece06b68390cbb3ba306284aed9ca7cb61dd6289e66e693126f' + }, + { + logbackFile: `${federatesLogbackPath}/logback-fed-5.xml`, + classpath: classpath, + configFile: `${nodesConfigPath}/rsk-reg-5.conf`, + publicKeys: { + btc: '036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a', + rsk: '036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a', + mst: '036bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a', + }, + customConfig: { + 'federator.signers.BTC.type': 'keyFile', + 'federator.signers.BTC.path': path.resolve(__dirname, `${keysPathResolve}/reg5.key`), + 'federator.signers.RSK.type': 'keyFile', + 'federator.signers.RSK.path': path.resolve(__dirname, `${keysPathResolve}/reg5.key`), + 'federator.signers.MST.type': 'keyFile', + 'federator.signers.MST.path': path.resolve(__dirname, `${keysPathResolve}/reg5.key`) + }, + nodeId: '6bb9eab797eadc8b697f0e82a01d01cabbfaaca37e5bafc06fdc6fdd38af894a9a8cbaf526d344b5df39b80433609e006586050fd2188d30ab000b0fb6a6baaf' + } + ] +} diff --git a/container-action/scripts/configure_gradle_powpeg.sh b/container-action/scripts/configure_gradle_powpeg.sh new file mode 100755 index 00000000..1baac99f --- /dev/null +++ b/container-action/scripts/configure_gradle_powpeg.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +read -r -d '' SETTINGS_GRADLE_CONTENT_LOCAL < + if (dependency.requested instanceof ModuleComponentSelector + && dependency.requested.group == 'co.rsk' + && dependency.requested.module == 'rskj-core' + && (dependency.requested.version.endsWith('SNAPSHOT') || dependency.requested.version.endsWith('RC'))) { + def targetProject = project(":\${dependency.requested.module}") + if (targetProject != null) { + println('---- USING LOCAL ' + dependency.requested.displayName + ' PROJECT ----') + dependency.useTarget targetProject + } + } + } + } +} +EOF + +# Read the version.properties from federator file +while IFS='=' read -r key value +do + # Remove all spaces + key=$(echo $key | tr -d ' ') + value=$(echo $value | tr -d ' ') + + # Check if key is 'modifier' or 'versionNumber' + if [[ "$key" == "modifier" ]]; then + modifier=${value//\"/} + elif [[ "$key" == "versionNumber" ]]; then + versionNumber=${value//\'/} + fi +done < "src/main/resources/version.properties" + +# Concatenate modifier and versionNumber +FED_VERSION="$modifier-$versionNumber" +echo "$FED_VERSION" +if [[ $FED_VERSION == SNAPSHOT* || $FED_VERSION == RC* ]]; then + echo -e "$SETTINGS_GRADLE_CONTENT_LOCAL" > DONT-COMMIT-settings.gradle +fi \ No newline at end of file diff --git a/container-action/scripts/configure_rit_locally.sh b/container-action/scripts/configure_rit_locally.sh new file mode 100755 index 00000000..2c0bc511 --- /dev/null +++ b/container-action/scripts/configure_rit_locally.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ $# -ne 1 ] || [ -z "${1:-}" ]; then + echo "Usage: ${0##*/} POWPEG_VERSION" >&2 + exit 1 +fi +POWPEG_VERSION=$1 +shift +echo "POWPEG_VERSION received as parameter: $POWPEG_VERSION" + +read -r -d '' SETTINGS_RIT < .env diff --git a/lib/rsk-utils-legacy.js b/lib/rsk-utils-legacy.js index 4639d610..e10c323d 100644 --- a/lib/rsk-utils-legacy.js +++ b/lib/rsk-utils-legacy.js @@ -2,8 +2,10 @@ const expect = require('chai').expect; const btcClientProvider = require('./btc-client-provider'); const { sequentialPromise, wait, interval } = require('./utils'); const { getBridgeAbi, getLatestActiveForkName } = require('./precompiled-abi-forks-util'); +const waitForBlockAttemptTimeMillis = process.env.WAIT_FOR_BLOCK_ATTEMPT_TIME_MILLIS || 200; +const waitForBlockMaxAttempts = process.env. WAIT_FOR_BLOCK_MAX_ATTEMPTS || 600; -var getMaxBlockNumber = (rskClients) => { +let getMaxBlockNumber = (rskClients) => { var maxBlockNumber; var result = Promise.resolve(0); rskClients.forEach(client => { @@ -16,7 +18,7 @@ var getMaxBlockNumber = (rskClients) => { return result; }; -var waitForSync = (rskClients) => { +let waitForSync = (rskClients) => { return getMaxBlockNumber(rskClients).then(bn => { var result = Promise.resolve(); rskClients.forEach(client => { @@ -26,7 +28,7 @@ var waitForSync = (rskClients) => { }); }; -var waitForBlock = (rskClient, blockNumber, waitTime = 200, maxAttempts = 600) => { +let waitForBlock = (rskClient, blockNumber, waitTime = waitForBlockAttemptTimeMillis, maxAttempts = waitForBlockMaxAttempts) => { return new Promise((resolve, reject) => { var clearPoll; var attempts = 0; @@ -51,7 +53,7 @@ var waitForBlock = (rskClient, blockNumber, waitTime = 200, maxAttempts = 600) = }); }; -var sendTxWithCheck = (rskClient) => (method, check, fromAddress) => () => { +let sendTxWithCheck = (rskClient) => (method, check, fromAddress) => () => { var txReceiptPromise = method.call({ from: fromAddress }) .then(check) .then(() => method.estimateGas({ from: fromAddress })) @@ -88,18 +90,18 @@ var sendTxWithCheck = (rskClient) => (method, check, fromAddress) => () => { }); }; -var triggerRelease = async(rskClients, btcClient, releaseCreatedCallback, releaseConfirmedCallback) => { +let triggerRelease = async(rskClients, btcClient, releaseCreatedCallback, releaseConfirmedCallback) => { const mineFunction = (amountOfBlocks) => btcClient.generate(amountOfBlocks); await triggerReleaseWithMineFunction(rskClients, mineFunction, releaseCreatedCallback, releaseConfirmedCallback); }; -var triggerRelease2 = async(rskClients, releaseCreatedCallback, releaseConfirmedCallback) => { +let triggerRelease2 = async(rskClients, releaseCreatedCallback, releaseConfirmedCallback) => { const btcClient = btcClientProvider.getBtcClient(); const mineFunction = (amountOfBlocks) => btcClient.nodeClient.mine(amountOfBlocks); await triggerReleaseWithMineFunction(rskClients, mineFunction, releaseCreatedCallback, releaseConfirmedCallback); }; -var triggerPegoutEvent = async(rskClients, releaseCreatedCallback, releaseConfirmedCallback) => { +let triggerPegoutEvent = async(rskClients, releaseCreatedCallback, releaseConfirmedCallback) => { const isHop400AlreadyActive = await Runners.common.forks.hop400.isAlreadyActive(); if (isHop400AlreadyActive) { await increaseBlockToNextPegoutHeight(rskClients[0]); @@ -107,7 +109,7 @@ var triggerPegoutEvent = async(rskClients, releaseCreatedCallback, releaseConfir await triggerRelease2(rskClients, releaseCreatedCallback, releaseConfirmedCallback); }; -var triggerReleaseWithMineFunction = async(rskClients, mineFunction, releaseCreatedCallback, releaseConfirmedCallback) => { +let triggerReleaseWithMineFunction = async(rskClients, mineFunction, releaseCreatedCallback, releaseConfirmedCallback) => { var rskClient = rskClients[0]; // Sync all nodes @@ -158,7 +160,7 @@ var triggerReleaseWithMineFunction = async(rskClients, mineFunction, releaseCrea await wait(2500); }; -var sendFromCow = (rskClient) => (toAddress, amount) => { +let sendFromCow = (rskClient) => (toAddress, amount) => { var initialAddressBalance; var cowAddress; amount = Number(amount); @@ -227,7 +229,7 @@ const getBridgeEventInBlockAndRunAssertions = async(block, eventName, eventAsser return false; } -var getBridgeEventAndRunAssertions = (eventName, eventAssertions, rsk, maxPastBlocksToCheck) => async (rskClient, blocksDepth) => { +let getBridgeEventAndRunAssertions = (eventName, eventAssertions, rsk, maxPastBlocksToCheck) => async (rskClient, blocksDepth) => { var block = await rskClient.eth.getBlock("latest"); if (!!blocksDepth) { block = await rskClient.eth.getBlock(block.number - blocksDepth); @@ -245,7 +247,7 @@ var getBridgeEventAndRunAssertions = (eventName, eventAssertions, rsk, maxPastBl } } -var getTransactionHashFromTxToBridge = async (functionName, rsk, rskClient) => { +let getTransactionHashFromTxToBridge = async (functionName, rsk, rskClient) => { var abi = getBridgeAbi(); var block = await rskClient.eth.getBlock("latest"); var txs = block.transactions;