Skip to content

Commit 877d68a

Browse files
committed
chore - address PR comments
updating docs where stx-rosetta is used add some docs around `SEED_CHAINSTATE` add -W to pg_ctl and removing sleep
1 parent 7d36694 commit 877d68a

File tree

4 files changed

+69
-32
lines changed

4 files changed

+69
-32
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ jobs:
955955
context: .
956956
build-args: |
957957
STACKS_API_VERSION=${{ github.head_ref || github.ref_name }}
958-
file: docker/stx-rosetta.Dockerfile
958+
file: docker/rosetta.Dockerfile
959959
tags: ${{ steps.meta_standalone.outputs.tags }}
960960
labels: ${{ steps.meta_standalone.outputs.labels }}
961961
# Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks)

README-rosetta.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Testing the Rosetta APIs
22

3-
Build and run the `stx-rosetta.Dockerfile` image:
3+
Build and run the `rosetta.Dockerfile` image:
44

5-
docker build -t stx-rosetta:stable -f stx-rosetta.Dockerfile .
5+
docker build -t rosetta:stable -f rosetta.Dockerfile .
66
docker run -d -p 3999:3999 --mount source=rosetta-data,target=/data \
7-
--name stx-rosetta stx-rosetta:stable
7+
--name rosetta rosetta:stable
88

99
By default, this will connect to the testnet. To run a local node, run
1010

1111

1212
docker run -d -p 3999:3999 --mount source=rosetta-data,target=/data \
13-
--name stx-rosetta -e STACKS_NETWORK=mocknet stx-rosetta:stable
13+
--name rosetta -e STACKS_NETWORK=mocknet rosetta:stable
14+
15+
Optionally, you can seed the chainstate for testnet/mainnet using [Hiro archive data](https://docs.hiro.so/references/hiro-archive#what-is-the-hiro-archive):
16+
17+
18+
docker run -d -p 3999:3999 --mount source=rosetta-data,target=/data \
19+
--name rosetta -e SEED_CHAINSTATE=true rosetta:stable
1420

1521
Use a recent version of [rosetta-cli](https://github.com/coinbase/rosetta-cli) to test the endpoints:
1622

content/feature-guides/rosetta-support.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,51 @@ The Stacks Blockchain API supports [v1.4.6 of the Rosetta specification](https:/
88

99
# Testing the Rosetta APIs
1010

11-
To build and run the `stx-rosetta.Dockerfile` image, run the following command:
12-
13-
```docker build -t stx-rosetta:stable -f stx-rosetta.Dockerfile .
14-
docker run -d -p 3999:3999 --mount source=rosetta-data,target=/data \
15-
--name stx-rosetta stx-rosetta:stable```
16-
By default, this will connect to the testnet. To run a local node, run the following command:
17-
```docker run -d -p 3999:3999 --mount source=rosetta-data,target=/data \
18-
--name stx-rosetta -e STACKS_NETWORK=mocknet stx-rosetta:stable```
11+
To build and run the `rosetta.Dockerfile` image, run the following command:
12+
13+
```
14+
docker build -t rosetta:stable -f rosetta.Dockerfile .
15+
docker run -d \
16+
-p 3999:3999 \
17+
--mount source=rosetta-data,target=/data \
18+
--name rosetta \
19+
rosetta:stable
20+
```
21+
22+
To build and run the `rosetta.Dockerfile` image using an [archived chainstate](https://docs.hiro.so/references/hiro-archive#what-is-the-hiro-archive), run the following command:
23+
24+
```
25+
docker build -t rosetta:stable -f rosetta.Dockerfile .
26+
docker run -d \
27+
-p 3999:3999 \
28+
-e SEED_CHAINSTATE=true \
29+
--mount source=rosetta-data,target=/data \
30+
--name rosetta \
31+
rosetta:stable
32+
```
33+
34+
35+
By default, this will connect to the mainnet. To run a local node, run the following command:
36+
37+
```
38+
docker run -d \
39+
-p 3999:3999 \
40+
-e STACKS_NETWORK=mocknet \
41+
--mount source=rosetta-data,target=/data \
42+
--name rosetta \
43+
rosetta:stable
44+
```
45+
1946
To use a recent version of [rosetta-cli](https://github.com/coinbase/rosetta-cli) to test the endpoints, use the following command:
20-
```rosetta-cli --configuration-file rosetta-cli-config/rosetta-config.json \
21-
view:block 1
22-
rosetta-cli --configuration-file rosetta-cli-config/rosetta-config.json \
23-
check:data```
47+
```
48+
rosetta-cli \
49+
--configuration-file rosetta-cli-config/rosetta-config.json \
50+
view:block 1
51+
rosetta-cli \
52+
--configuration-file rosetta-cli-config/rosetta-config.json \
53+
check:data
54+
```
55+
2456
`rosetta-cli` will then sync with the blockchain until it reaches the tip, and then exit, displaying the test results.
2557
Currently, account reconciliation is disabled; proper testing of that feature requires token transfer transactions while `rosetta-cli` is running.
2658
Documentation for the Rosetta APIs can be found [here](https://hirosystems.github.io/stacks-blockchain-api/)

docker/rosetta.Dockerfile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ARG PG_PORT=5432
88
ARG PG_USER=postgres
99
ARG PG_PASSWORD=postgres
1010
ARG SEED_CHAINSTATE=false
11+
ARG ARCHIVE_VERSION=latest
1112

1213
#######################################################################
1314
## Build the stacks-blockchain-api
@@ -51,15 +52,15 @@ RUN apt-get update -y \
5152
## Build the final image with all components from build stages
5253
FROM debian:buster
5354
ARG STACKS_NETWORK
54-
ARG PG_VERSION
55-
ARG PG_VERSION
5655
ARG PG_HOST
5756
ARG PG_PORT
5857
ARG PG_USER
5958
ARG PG_PASSWORD
59+
ARG PG_VERSION
6060
ARG SEED_CHAINSTATE
6161
ARG STACKS_API_VERSION
6262
ARG STACKS_BLOCKCHAIN_VERSION
63+
ARG ARCHIVE_VERSION
6364
ENV SEED_CHAINSTATE=${SEED_CHAINSTATE}
6465
ENV STACKS_API_VERSION=${STACKS_API_VERSION}
6566
ENV STACKS_BLOCKCHAIN_VERSION=${STACKS_BLOCKCHAIN_VERSION}
@@ -82,6 +83,7 @@ ENV STACKS_BLOCKCHAIN_API_HOST=0.0.0.0
8283
ENV STACKS_CORE_RPC_HOST=127.0.0.1
8384
ENV STACKS_CORE_RPC_PORT=20443
8485
ENV STACKS_CORE_P2P_PORT=20444
86+
ENV ARCHIVE_VERSION=${ARCHIVE_VERSION}
8587
ENV LANG en_US.UTF-8
8688
ENV LANGUAGE en_US:en
8789
ENV LC_ALL en_US.UTF-8
@@ -130,10 +132,8 @@ mkdir -p "${PGDATA}" || exit 1
130132
chown -R postgres:postgres "${PGDATA}" || exit 1
131133
gosu postgres /usr/lib/postgresql/${PG_VERSION}/bin/initdb -D "${PGDATA}" --wal-segsize=512 || exit 1
132134
echo "host all all all trust" >> "$PGDATA/pg_hba.conf" || exit 1
133-
gosu postgres /usr/lib/postgresql/${PG_VERSION}/bin/pg_ctl start -W -D ${PGDATA} -o "-c listen_addresses='*'"
134-
# give postgres 10s to startup
135-
echo "waiting 10s for postgres to start"
136-
sleep 10
135+
gosu postgres /usr/lib/postgresql/${PG_VERSION}/bin/pg_ctl start -w -D ${PGDATA} -o "-c listen_addresses='*'" || exit 1
136+
137137
# download archive files if flag is true
138138
if [ "${SEED_CHAINSTATE}" = "true" ]; then
139139
/scripts/seed-chainstate.sh || exit 1
@@ -146,7 +146,6 @@ fi
146146
case "${STACKS_NETWORK}" in
147147
testnet)
148148
export STACKS_CHAIN_ID=0x80000000
149-
export V2_POX_MIN_AMOUNT_USTX=90000000260
150149
;;
151150
*)
152151
export STACKS_CHAIN_ID=0x00000001
@@ -208,16 +207,16 @@ echo "Seeding chainstate from https://archive.hiro.so"
208207
LOCAL_STACKS_API_VERSION=$(echo "${STACKS_API_VERSION:1}")
209208

210209
# define URL's to download
211-
PGDUMP_URL="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain-api-pg/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-latest.dump"
212-
PGDUMP_URL_SHA256="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain-api-pg/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-latest.sha256"
213-
CHAINDATA_URL="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-latest.tar.gz"
214-
CHAINDATA_URL_SHA256="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-latest.sha256"
210+
PGDUMP_URL="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain-api-pg/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-${ARCHIVE_VERSION}.dump"
211+
PGDUMP_URL_SHA256="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain-api-pg/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-${ARCHIVE_VERSION}.sha256"
212+
CHAINDATA_URL="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-${ARCHIVE_VERSION}.tar.gz"
213+
CHAINDATA_URL_SHA256="https://archive.hiro.so/${STACKS_NETWORK}/stacks-blockchain/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-${ARCHIVE_VERSION}.sha256"
215214

216215
# define local storage locations
217-
PGDUMP_DEST="/tmp/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-latest.dump"
218-
PGDUMP_DEST_SHA256="/tmp/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-latest.sha256"
219-
CHAINDATA_DEST="/tmp/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-latest.tar.gz"
220-
CHAINDATA_DEST_SHA256="/tmp/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-latest.sha256"
216+
PGDUMP_DEST="/tmp/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-${ARCHIVE_VERSION}.dump"
217+
PGDUMP_DEST_SHA256="/tmp/stacks-blockchain-api-pg-${PG_VERSION}-${LOCAL_STACKS_API_VERSION}-${ARCHIVE_VERSION}.sha256"
218+
CHAINDATA_DEST="/tmp/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-${ARCHIVE_VERSION}.tar.gz"
219+
CHAINDATA_DEST_SHA256="/tmp/${STACKS_NETWORK}-stacks-blockchain-${STACKS_BLOCKCHAIN_VERSION}-${ARCHIVE_VERSION}.sha256"
221220

222221
exit_error() {
223222
echo "${1}"

0 commit comments

Comments
 (0)