Skip to content

Rosetta API

Rosetta API #1311

Workflow file for this run

name: Rosetta API
on:
schedule:
- cron: "0 1 * * *" # Daily at 1:00 AM
push:
branches:
- 'main'
tags:
- 'v*'
defaults:
run:
shell: bash
working-directory: ./hedera-mirror-rosetta
permissions:
contents: read
env:
MODULE: hedera-mirror-rosetta
NETWORK: previewnet
jobs:
validate:
runs-on: [self-hosted, Linux, large, ephemeral]
timeout-minutes: 30
env:
ROSETTA_CLI_VERSION: v0.10.3
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Setup Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 21
- name: Set Importer StartDate
run: |
# Set start date to 60 seconds before the first block timestamp in the network
url="https://${NETWORK}.mirrornode.hedera.com/api/v1/blocks?limit=1&order=asc"
firstTimestamp=$(curl -s "${url}" | jq -r .blocks[0].timestamp.from)
if [[ -z "${firstTimestamp}" ]]; then
echo "Unable to get first block timestamp"
exit 1
fi
startSecs=$((${firstTimestamp%.*}-60))
startDate=$(date --date="@${startSecs}" -Iseconds -u | grep -o -e '^[0-9T:-]\+')
startDate="${startDate}Z"
echo "STARTDATE=${startDate}" >> $GITHUB_ENV
echo "Set importer startDate to ${startDate}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Build Image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
build-args: GIT_REF=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./hedera-mirror-rosetta/container
load: true
provenance: false
push: false
tags: "${{ env.MODULE }}:${{ github.sha }}"
- name: Importer Configuration
run: echo "${{ secrets.ROSETTA_IMPORTER_CONFIG }}" | base64 -d > /tmp/application_importer.yml
- name: Rosetta Configuration
run: echo "${{ secrets.ROSETTA_ROSETTA_CONFIG }}" | base64 -d > /tmp/application_rosetta.yml
- name: Run Mirror Node in Online Mode
run: |
ONLINE_CONTAINER_ID=$(docker run -d -e HEDERA_MIRROR_IMPORTER_STARTDATE=${STARTDATE} \
-e NETWORK=${NETWORK} \
-e HEDERA_MIRROR_ROSETTA_RESPONSE_MAXTRANSACTIONSINBLOCK=4 \
-v /tmp/application_importer.yml:/app/importer/application.yml \
-v /tmp/application_rosetta.yml:/app/rosetta/application.yml \
-p 5700:5700 "${MODULE}:${{ github.sha }}")
echo "ONLINE_CONTAINER_ID=$ONLINE_CONTAINER_ID" >> $GITHUB_ENV
- name: Wait for Mirror Node to Start Syncing
run: ./scripts/wait-for-mirror-node.sh
env:
MAX_WAIT_SECONDS: 900
- name: Rosetta CLI Configuration
working-directory: ./hedera-mirror-rosetta/scripts/validation/${{ env.NETWORK }}
run: |
# set start index to genesis index + 1
body='{"network_identifier": {"blockchain": "Hedera", "network": "'${NETWORK}'"}}'
startIndex=$(curl -sL -d "${body}" http://localhost:5700/network/status | jq '.genesis_block_identifier.index+1')
echo "Setting data start_index to $startIndex"
jq --argjson startIndex $startIndex '.data.start_index=$startIndex' validation.json > tmp.json && \
mv tmp.json validation.json
- name: Run Rosetta CLI Validation
working-directory: ./hedera-mirror-rosetta/scripts/validation
run: ./run-validation.sh ${NETWORK} data
- name: Run Rosetta Postman API Tests
working-directory: ./charts/hedera-mirror-rosetta
run: |
npm install -g newman
newman run postman.json
- name: Show Container Log
if: ${{ failure() }}
run: |
echo "Logs for online container ${ONLINE_CONTAINER_ID}"
[[ -n "${ONLINE_CONTAINER_ID}" ]] && docker logs ${ONLINE_CONTAINER_ID} || true