Skip to content

Commit ea4a65f

Browse files
authored
chore: migrate cosmos bsn scripts and restructure files (#15)
* bump bbn to release/v3 branch * bump vigilante to latest main * bump btc-staker to latest main * bump fp to latest main * migrate cosmos-bsn-script * mv dir * mv dir * fix files * fix * rename and restruct * rm crypto tools from cosmos-bsn * fix artifcats contract * fix compose * fix make * fix * fix * fix * bump babylon submodule * fix ibcsim-bcd * fix make file
1 parent f683e9e commit ea4a65f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1711
-470
lines changed

Makefile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
start-deployment:
2-
@$(MAKE) -C $(CURDIR)/deployments/rollup-btc-staking-demo \
3-
start-deployment
1+
run-cosmos-bsn-demo:
2+
@$(MAKE) -C $(CURDIR)/deployments/cosmos-bsn-demo \
3+
run-demo
44

5-
run-demo:
6-
@$(MAKE) -C $(CURDIR)/deployments/rollup-btc-staking-demo \
5+
run-rollup-bsn-demo:
6+
@$(MAKE) -C $(CURDIR)/deployments/rollup-bsn-demo \
77
run-demo
88

9-
stop-deployment:
10-
@$(MAKE) -C $(CURDIR)/deployments/rollup-btc-staking-demo \
9+
stop-cosmos-bsn-demo:
10+
@$(MAKE) -C $(CURDIR)/deployments/cosmos-bsn-demo \
11+
stop-deployment
12+
13+
stop-rollup-bsn-demo:
14+
@$(MAKE) -C $(CURDIR)/deployments/rollup-bsn-demo \
1115
stop-deployment
16+
17+
stop-deployment: stop-cosmos-bsn-demo stop-rollup-bsn-demo

babylon

Submodule babylon updated 790 files

btc-staker

contrib/images/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ ibcsim-gaia:
1515
docker build --tag babylonlabs-io/ibcsim-gaia -f ibcsim-gaia/Dockerfile \
1616
$(shell git rev-parse --show-toplevel)/contrib/images/ibcsim-gaia
1717

18+
ibcsim-bcd:
19+
docker build --tag babylonlabs-io/ibcsim-bcd -f ibcsim-bcd/Dockerfile \
20+
$(shell git rev-parse --show-toplevel)/contrib/images/ibcsim-bcd
21+
1822
btcdsim-rmi:
1923
docker rmi babylonlabs-io/btcdsim 2>/dev/null; true
2024

@@ -24,8 +28,11 @@ bitcoindsim-rmi:
2428
ibcsim-gaia-rmi:
2529
docker rmi babylonlabs-io/ibcsim-gaia 2>/dev/null; true
2630

31+
ibcsim-bcd-rmi:
32+
docker rmi babylonlabs-io/ibcsim-bcd 2>/dev/null; true
33+
2734
tmkms:
2835
docker build --platform "linux/amd64" --tag babylonlabs-io/tmkms:latest -f tmkms/Dockerfile \
2936
$(shell git rev-parse --show-toplevel)/contrib/images/tmkms
3037

31-
.PHONY: all btcdsim btcdsim-rmi bitcoindsim bitcoindsim-rmi ibcsim-gaia ibcsim-gaia-rmi tmkms
38+
.PHONY: all btcdsim btcdsim-rmi bitcoindsim bitcoindsim-rmi ibcsim-gaia ibcsim-gaia-rmi ibcsim-bcd ibcsim-bcd-rmi tmkms
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
FROM debian:bullseye-slim AS build-env
2+
3+
RUN apt-get update && apt-get install -y git make gcc wget
4+
5+
WORKDIR /work
6+
7+
ARG TARGETARCH
8+
9+
# Download and install Go
10+
ENV GOLANG_VERSION 1.21.4
11+
RUN wget -q https://golang.org/dl/go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz && \
12+
tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz && \
13+
rm go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz
14+
# Set Go environment variables
15+
ENV PATH /usr/local/go/bin:$PATH
16+
ENV GOPATH /go
17+
ENV PATH $GOPATH/bin:$PATH
18+
19+
WORKDIR /work
20+
21+
ENV GO111MODULE on
22+
ENV RELAYER_TAG v2.5.2
23+
ENV BABYLON_SDK_TAG v0.9.0
24+
25+
# Install the relayer
26+
RUN git clone https://github.com/cosmos/relayer.git
27+
RUN cd relayer && git fetch origin && git checkout ${RELAYER_TAG} && make install && cd -
28+
29+
# Install bcd
30+
RUN git clone https://github.com/babylonlabs-io/babylon-sdk.git && \
31+
cd babylon-sdk && \
32+
git fetch origin && \
33+
git checkout ${BABYLON_SDK_TAG} && \
34+
make install && \
35+
cd -
36+
37+
FROM debian:bullseye-slim AS run
38+
39+
RUN apt-get update && apt-get install -y bash curl jq wget procps
40+
41+
# Install libraries
42+
# Cosmwasm - Download correct libwasmvm version
43+
COPY --from=build-env /work/babylon-sdk/demo/go.mod /tmp
44+
RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2) && \
45+
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.$(uname -m).so \
46+
-O /lib/libwasmvm.$(uname -m).so && \
47+
# verify checksum
48+
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
49+
sha256sum /lib/libwasmvm.$(uname -m).so | grep $(cat /tmp/checksums.txt | grep libwasmvm.$(uname -m) | cut -d ' ' -f 1)
50+
RUN rm -f /tmp/go.mod
51+
52+
# Install binaries
53+
COPY --from=build-env /go/bin/rly /usr/bin/rly
54+
COPY --from=build-env /go/bin/bcd /usr/bin/bcd
55+
56+
WORKDIR /ibcsim-bcd
57+
COPY wrapper.sh /ibcsim-bcd/wrapper.sh
58+
COPY setup-bcd.sh /ibcsim-bcd/setup-bcd.sh
59+
COPY --from=build-env /work/babylon-sdk/tests/testdata/babylon_contract.wasm /ibcsim-bcd/babylon_contract.wasm
60+
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_light_client.wasm /ibcsim-bcd/btc_light_client.wasm
61+
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_staking.wasm /ibcsim-bcd/btc_staking.wasm
62+
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_finality.wasm /ibcsim-bcd/btc_finality.wasm
63+
64+
ENV BABYLON_HOME=/data/node1/babylond
65+
ENV BABYLON_NODE_RPC="http://babylondnode1:26657"
66+
ENV UPDATE_CLIENTS_INTERVAL=20s
67+
68+
ENTRYPOINT ["/ibcsim-bcd/wrapper.sh"]
69+
CMD []
70+
STOPSIGNAL SIGTERM
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/bin/bash
2+
3+
display_usage() {
4+
echo "Missing parameters. Please check if all parameters were specified."
5+
echo "Usage: setup-bcd.sh [CHAIN_ID] [CHAIN_DIR] [RPC_PORT] [P2P_PORT] [PROFILING_PORT] [GRPC_PORT] [BABYLON_CONTRACT_CODE_FILE] [BTC_LC_CONTRACT_CODE_FILE] [BTCSTAKING_CONTRACT_CODE_FILE] [BTCFINALITY_CONTRACT_CODE_FILE]"
6+
echo "Example: setup-bcd.sh test-chain-id ./data 26657 26656 6060 9090 ./babylon_contract.wasm ./btc_light_client.wasm ./btc_staking.wasm ./btc_finality.wasm"
7+
exit 1
8+
}
9+
10+
BINARY=bcd
11+
DENOM=stake
12+
BASEDENOM=ustake
13+
KEYRING=--keyring-backend="test"
14+
SILENT=1
15+
16+
redirect() {
17+
if [ "$SILENT" -eq 1 ]; then
18+
"$@" >/dev/null 2>&1
19+
else
20+
"$@"
21+
fi
22+
}
23+
24+
if [ "$#" -lt "9" ]; then
25+
display_usage
26+
exit 1
27+
fi
28+
29+
CHAINID=$1
30+
CHAINDIR=$2
31+
RPCPORT=$3
32+
P2PPORT=$4
33+
PROFPORT=$5
34+
GRPCPORT=$6
35+
BABYLON_CONTRACT_CODE_FILE=$7
36+
BTC_LC_CONTRACT_CODE_FILE=$8
37+
BTCSTAKING_CONTRACT_CODE_FILE=$9
38+
BTCFINALITY_CONTRACT_CODE_FILE=${10}
39+
40+
# ensure the binary exists
41+
if ! command -v $BINARY &>/dev/null; then
42+
echo "$BINARY could not be found"
43+
exit
44+
fi
45+
46+
# Delete chain data from old runs
47+
echo "Deleting $CHAINDIR/$CHAINID folders..."
48+
rm -rf $CHAINDIR/$CHAINID &>/dev/null
49+
rm $CHAINDIR/$CHAINID.log &>/dev/null
50+
51+
echo "Creating $BINARY instance: home=$CHAINDIR | chain-id=$CHAINID | p2p=:$P2PPORT | rpc=:$RPCPORT | profiling=:$PROFPORT | grpc=:$GRPCPORT"
52+
53+
# Add dir for chain, exit if error
54+
if ! mkdir -p $CHAINDIR/$CHAINID 2>/dev/null; then
55+
echo "Failed to create chain folder. Aborting..."
56+
exit 1
57+
fi
58+
# Build genesis file incl account for passed address
59+
coins="100000000000$DENOM,100000000000$BASEDENOM"
60+
delegate="100000000000$DENOM"
61+
62+
redirect $BINARY --home $CHAINDIR/$CHAINID --chain-id $CHAINID init $CHAINID
63+
sleep 1
64+
$BINARY --home $CHAINDIR/$CHAINID keys add validator $KEYRING --output json >$CHAINDIR/$CHAINID/validator_seed.json 2>&1
65+
sleep 1
66+
$BINARY --home $CHAINDIR/$CHAINID keys add user $KEYRING --output json >$CHAINDIR/$CHAINID/key_seed.json 2>&1
67+
sleep 1
68+
redirect $BINARY --home $CHAINDIR/$CHAINID genesis add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show user -a) $coins
69+
sleep 1
70+
redirect $BINARY --home $CHAINDIR/$CHAINID genesis add-genesis-account $($BINARY --home $CHAINDIR/$CHAINID keys $KEYRING show validator -a) $coins
71+
sleep 1
72+
redirect $BINARY --home $CHAINDIR/$CHAINID genesis gentx validator $delegate $KEYRING --chain-id $CHAINID
73+
sleep 1
74+
redirect $BINARY --home $CHAINDIR/$CHAINID genesis collect-gentxs
75+
sleep 1
76+
77+
# Set proper defaults and change ports
78+
echo "Change settings in config.toml and genesis.json files..."
79+
sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:'"$RPCPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
80+
sed -i 's#"tcp://0.0.0.0:26656"#"tcp://0.0.0.0:'"$P2PPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
81+
sed -i 's#"localhost:6060"#"localhost:'"$PROFPORT"'"#g' $CHAINDIR/$CHAINID/config/config.toml
82+
sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
83+
sed -i 's/max_body_bytes = 1000000/max_body_bytes = 1000000000/g' $CHAINDIR/$CHAINID/config/config.toml
84+
sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.00001ustake"/g' $CHAINDIR/$CHAINID/config/app.toml
85+
sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' $CHAINDIR/$CHAINID/config/config.toml
86+
sed -i 's/index_all_keys = false/index_all_keys = true/g' $CHAINDIR/$CHAINID/config/config.toml
87+
sed -i 's#"tcp://0.0.0.0:1317"#"tcp://0.0.0.0:1318"#g' $CHAINDIR/$CHAINID/config/app.toml # ensure port is not conflicted with Babylon
88+
sed -i 's/"bond_denom": "stake"/"bond_denom": "'"$DENOM"'"/g' $CHAINDIR/$CHAINID/config/genesis.json
89+
# sed -i '' 's#index-events = \[\]#index-events = \["message.action","send_packet.packet_src_channel","send_packet.packet_sequence"\]#g' $CHAINDIR/$CHAINID/config/app.toml
90+
91+
# Start
92+
echo "Starting $BINARY..."
93+
$BINARY --home $CHAINDIR/$CHAINID start --pruning=nothing --grpc-web.enable=false --grpc.address="0.0.0.0:$GRPCPORT" --log_level trace --trace --log_format 'plain' --log_no_color 2>&1 | tee $CHAINDIR/$CHAINID.log &
94+
sleep 20
95+
96+
# upload contract code
97+
echo "Uploading babylon contract code $BABYLON_CONTRACT_CODE_FILE..."
98+
$BINARY --home $CHAINDIR/$CHAINID tx wasm store "$BABYLON_CONTRACT_CODE_FILE" $KEYRING --from user --chain-id $CHAINID --gas 200000000 --gas-prices 0.01ustake --node http://localhost:$RPCPORT -y
99+
sleep 5
100+
101+
# upload contract code
102+
echo "Uploading btc light client contract code $BTC_LC_CONTRACT_CODE_FILE..."
103+
$BINARY --home $CHAINDIR/$CHAINID tx wasm store "$BTC_LC_CONTRACT_CODE_FILE" $KEYRING --from user --chain-id $CHAINID --gas 200000000 --gas-prices 0.01ustake --node http://localhost:$RPCPORT -y
104+
sleep 5
105+
106+
# upload contract code
107+
echo "Uploading btcstaking contract code $BTCSTAKING_CONTRACT_CODE_FILE..."
108+
$BINARY --home $CHAINDIR/$CHAINID tx wasm store "$BTCSTAKING_CONTRACT_CODE_FILE" $KEYRING --from user --chain-id $CHAINID --gas 200000000 --gas-prices 0.01ustake --node http://localhost:$RPCPORT -y
109+
sleep 5
110+
111+
# upload contract code
112+
echo "Uploading btcfinality contract code $BTCFINALITY_CONTRACT_CODE_FILE..."
113+
$BINARY --home $CHAINDIR/$CHAINID tx wasm store "$BTCFINALITY_CONTRACT_CODE_FILE" $KEYRING --from user --chain-id $CHAINID --gas 200000000 --gas-prices 0.01ustake --node http://localhost:$RPCPORT -y
114+
sleep 5
115+
116+
# Echo the command with expanded variables
117+
echo "Instantiating contracts..."
118+
119+
ADMIN=$(bcd --home $CHAINDIR/$CHAINID keys show user --keyring-backend test -a)
120+
STAKING_MSG='{
121+
"admin": "'"$ADMIN"'"
122+
}'
123+
FINALITY_MSG='{
124+
"params": {
125+
"max_active_finality_providers": 100,
126+
"min_pub_rand": 1,
127+
"finality_inflation_rate": "0.035",
128+
"epoch_length": 10,
129+
"missed_blocks_window": 250,
130+
"jail_duration": 86400
131+
},
132+
"admin": "'"$ADMIN"'"
133+
}'
134+
135+
$BINARY --home $CHAINDIR/$CHAINID tx babylon instantiate-babylon-contracts \
136+
1 2 3 4 \
137+
"regtest" \
138+
"01020304" \
139+
1 2 false \
140+
"$STAKING_MSG" \
141+
"$FINALITY_MSG" \
142+
test-consumer \
143+
test-consumer-description \
144+
--admin=$ADMIN \
145+
--ibc-transfer-channel-id=channel-0 \
146+
$KEYRING \
147+
--from user \
148+
--chain-id $CHAINID \
149+
--gas 20000000000 \
150+
--gas-prices 0.001ustake \
151+
--node http://localhost:$RPCPORT \
152+
-y
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env sh
2+
# shellcheck disable=SC3037
3+
4+
# 0. Define configuration
5+
BABYLON_KEY="babylon-key"
6+
BABYLON_CHAIN_ID="chain-test"
7+
CONSUMER_KEY="bcd-key"
8+
CONSUMER_CHAIN_ID="bcd-test"
9+
RELAYER_CONF_DIR=/data/relayer
10+
CONSUMER_CONF=/data/bcd
11+
12+
# 1. Create a bcd testnet with Babylon contract
13+
./setup-bcd.sh $CONSUMER_CHAIN_ID $CONSUMER_CONF 26657 26656 6060 9090 ./babylon_contract.wasm ./btc_light_client.wasm ./btc_staking.wasm ./btc_finality.wasm
14+
15+
sleep 5
16+
17+
# 2. Set up the relayer
18+
mkdir -p $RELAYER_CONF_DIR
19+
rly --home $RELAYER_CONF_DIR config init
20+
RELAYER_CONF=$RELAYER_CONF_DIR/config/config.yaml
21+
22+
cat <<EOT >$RELAYER_CONF
23+
global:
24+
api-listen-addr: :5183
25+
max-retries: 20
26+
timeout: 20s
27+
memo: ""
28+
light-cache-size: 10
29+
chains:
30+
babylon:
31+
type: cosmos
32+
value:
33+
key: $BABYLON_KEY
34+
chain-id: $BABYLON_CHAIN_ID
35+
rpc-addr: $BABYLON_NODE_RPC
36+
account-prefix: bbn
37+
keyring-backend: test
38+
gas-adjustment: 1.5
39+
gas-prices: 0.002ubbn
40+
min-gas-amount: 1
41+
debug: true
42+
timeout: 10s
43+
output-format: json
44+
sign-mode: direct
45+
extra-codecs: []
46+
bcd:
47+
type: cosmos
48+
value:
49+
key: $CONSUMER_KEY
50+
chain-id: $CONSUMER_CHAIN_ID
51+
rpc-addr: http://localhost:26657
52+
account-prefix: bbnc
53+
keyring-backend: test
54+
gas-adjustment: 1.5
55+
gas-prices: 0.002ustake
56+
min-gas-amount: 1
57+
debug: true
58+
timeout: 10s
59+
output-format: json
60+
sign-mode: direct
61+
extra-codecs: []
62+
paths:
63+
bcd:
64+
src:
65+
chain-id: $BABYLON_CHAIN_ID
66+
dst:
67+
chain-id: $CONSUMER_CHAIN_ID
68+
EOT
69+
70+
echo "Inserting the consumer key"
71+
CONSUMER_MEMO=$(cat $CONSUMER_CONF/$CONSUMER_CHAIN_ID/key_seed.json | jq .mnemonic | tr -d '"')
72+
rly --home $RELAYER_CONF_DIR keys restore bcd $CONSUMER_KEY "$CONSUMER_MEMO"
73+
74+
echo "Inserting the babylond key"
75+
BABYLON_MEMO=$(cat $BABYLON_HOME/key_seed.json | jq .secret | tr -d '"')
76+
rly --home $RELAYER_CONF_DIR keys restore babylon $BABYLON_KEY "$BABYLON_MEMO"
77+
78+
# Keep script running silently
79+
while true; do
80+
sleep 10
81+
done

0 commit comments

Comments
 (0)