Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.

Commit 53b6644

Browse files
CAGS295friedger
andauthored
sbtc automatically deploy contracts (#294)
* don't build in `up.sh` * fund deployer * deploy contracts --------- Co-authored-by: Friedger <[email protected]>
1 parent ba870ab commit 53b6644

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
target
33
Cargo.lock
44
devenv/*
5+
!devenv/sbtc/docker/entrypoint
56
coverage
67
romeo/testing/
78
romeo/asset-contract/.test
89
romeo/asset-contract/.coverage
9-

devenv/sbtc/docker/Dockerfile

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
FROM rust:alpine as build
1+
FROM rust:bookworm as clarinet
22

3-
WORKDIR /romeo
3+
RUN apt update && apt install -y pkg-config libssl-dev clang && \
4+
rm -rf /var/lib/apt/lists/*
45

5-
RUN apk add --no-cache g++ musl-dev git openssl-dev clang-dev libsecp256k1-dev
6+
RUN cargo install clarinet-cli --bin clarinet --branch develop --locked --git https://github.com/hirosystems/clarinet.git
67

7-
RUN cargo install --version 0.36.13 cargo-make
8+
FROM rust:bookworm as romeo
89

9-
RUN rustup component add rustfmt
10-
11-
COPY . .
10+
RUN apt update && apt install -y g++ libssl-dev clang libsecp256k1-dev && \
11+
rm -rf /var/lib/apt/lists/*
1212

13-
RUN RUSTFLAGS="-C target-feature=-crt-static" cargo install --path sbtc-cli
13+
RUN cargo install --locked cargo-make
1414

15-
RUN RUSTFLAGS="-C target-feature=-crt-static" cargo install --path romeo
16-
17-
FROM alpine:latest
15+
RUN rustup component add rustfmt
1816

19-
RUN apk add --no-cache openssl libsecp256k1 g++
17+
COPY . .
18+
ENV RUSTFLAGS "-C target-feature=-crt-static"
19+
RUN cargo install --locked --path sbtc-cli
20+
RUN cargo install --locked --path romeo
2021

21-
COPY --from=build /usr/local/cargo/bin/sbtc /usr/local/bin
22-
COPY --from=build /usr/local/cargo/bin/romeo /usr/local/bin
22+
FROM rust:slim-bookworm
2323

24-
ENTRYPOINT ["romeo"]
25-
CMD ["-c", "/romeo/config.json"]
24+
RUN apt update && apt install -y openssl libsecp256k1-dev curl jq && \
25+
rm -rf /var/lib/apt/lists/*
2626

27+
COPY --from=clarinet /usr/local/cargo/bin/clarinet /usr/local/bin
28+
COPY --from=romeo /usr/local/cargo/bin/sbtc /usr/local/bin
29+
COPY --from=romeo /usr/local/cargo/bin/romeo /usr/local/bin
30+
ADD devenv/sbtc/docker/entrypoint /usr/local/bin
31+
RUN chmod a+x /usr/local/bin/entrypoint
32+
ADD romeo/asset-contract /asset-contract
2733

34+
ENTRYPOINT ["entrypoint"]

devenv/sbtc/docker/entrypoint

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo >/dev/null
4+
5+
API_URL=http://stacks:20443/v2/info
6+
7+
echo "Waiting on Stacks API $API_URL"
8+
while ! curl -s $API_URL >/dev/null; do
9+
sleep 1
10+
done
11+
12+
# stacks ready to take contracts
13+
STACKS_HEIGHT=1
14+
echo "Waiting on Stacks height $STACKS_HEIGHT"
15+
while [ "$(curl -s $API_URL | jq '.stacks_tip_height')" -lt $STACKS_HEIGHT ]; do
16+
sleep 2
17+
done
18+
19+
# deploy the contracts
20+
cd asset-contract
21+
sed -i "s/localhost:20443/stacks:20443/" deployments/default.devnet-plan.yaml
22+
sed -i "s/localhost:18443/bitcoin:18443/" deployments/default.devnet-plan.yaml
23+
clarinet deployments apply --no-dashboard -d -p deployments/default.devnet-plan.yaml
24+
cd -
25+
26+
#launch romeo
27+
romeo -c /romeo/config.json

devenv/up.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/usr/bin/env bash
22

3-
./build.sh
43
if [ $? -eq 0 ]
54
then
6-
docker compose up -d
5+
docker compose up -d
76
else
8-
echo "Build failed, not starting devenv"
7+
echo "Build failed, not starting devenv"
98
fi

devenv/utils/mine_btc.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ if [[ -z "$num_blocks" ]]; then
1010
exit 1
1111
fi
1212

13+
btc_address=$(source $dir/get_credentials.sh | jq -r '.credentials["0"].bitcoin.p2wpkh.address')
14+
$dir/../bitcoin/bin/bitcoin-cli generatetoaddress 1 $btc_address
15+
echo "Mined 1 BTC to $btc_address"
1316
btc_address=$(source $dir/get_credentials.sh | jq -r '.credentials["1"].bitcoin.p2wpkh.address')
14-
1517
$dir/../bitcoin/bin/bitcoin-cli generatetoaddress $num_blocks $btc_address
1618
echo "Mined $num_blocks BTC to $btc_address"

0 commit comments

Comments
 (0)