-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add teardown script * chore: set teardown script image * update: permissions * chore: update docker image * update docker image * fix script * set docker image * fix keyring filename * set docker image * fix address extraction * set docker image * fix: send tx error * update: docker image * fix script * set docker image * feat: update makefile * delete dry run * chore: update image * fix gas cost * set docker image * add back gas params * remove duplicate volume * print tx output * update docker images * chore: remove temp branch from docker ci * simplify commands * nit: cleanup script * publish new image
- Loading branch information
Showing
5 changed files
with
97 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
docker compose -f docker/docker-compose-babylon-integration.yml up -d teardown | ||
docker logs -f teardown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
set -uo pipefail | ||
|
||
source "./common.sh" | ||
|
||
# Get the consumer FP address | ||
KEYRING_DIR=/home/.babylond | ||
CONSUMER_FP_KEYRING_DIR=$KEYRING_DIR/$CONSUMER_FINALITY_PROVIDER_KEY | ||
CONSUMER_FP_ADDRESS=$(babylond keys show -a consumer-finality-provider \ | ||
--keyring-dir $CONSUMER_FP_KEYRING_DIR \ | ||
--keyring-backend test) | ||
echo "Consumer FP address: $CONSUMER_FP_ADDRESS" | ||
|
||
# Get the prefunded key address | ||
PREFUNDED_ADDRESS=$(babylond keys show -a "$BABYLON_PREFUNDED_KEY" \ | ||
--keyring-dir "$KEYRING_DIR" \ | ||
--keyring-backend test) | ||
echo "Prefunded address: $PREFUNDED_ADDRESS" | ||
|
||
# Check remaining balance | ||
CONSUMER_FP_BALANCE=$(babylond query bank balances "$CONSUMER_FP_ADDRESS" \ | ||
--node "$BABYLON_RPC_URL" \ | ||
-o json | jq -r '.balances[0].amount') | ||
echo "Consumer FP balance: $CONSUMER_FP_BALANCE" | ||
|
||
# If balance is less than gas transfer cost, don't send funds | ||
TRANSFER_GAS_COST=100000 | ||
if [ "$CONSUMER_FP_BALANCE" -lt "$TRANSFER_GAS_COST" ]; then | ||
echo "Consumer FP balance is less than gas transfer cost, skipping funds transfer" | ||
exit 0 | ||
fi | ||
|
||
# Otherwise, send out funds to prefunded key | ||
# Reserve 0.001 bbn = 1000 ubbn for gas | ||
|
||
AMOUNT_TO_SEND=$((CONSUMER_FP_BALANCE - TRANSFER_GAS_COST)) | ||
echo "Sending $AMOUNT_TO_SEND ubbn to prefunded key..." | ||
echo "Consumer FP keyring dir: $CONSUMER_FP_KEYRING_DIR" | ||
SEND_TX_OUTPUT=$(babylond tx bank send \ | ||
${CONSUMER_FINALITY_PROVIDER_KEY} \ | ||
${PREFUNDED_ADDRESS} \ | ||
"${AMOUNT_TO_SEND}ubbn" \ | ||
--keyring-dir $CONSUMER_FP_KEYRING_DIR \ | ||
--keyring-backend test \ | ||
--chain-id $BABYLON_CHAIN_ID \ | ||
--node $BABYLON_RPC_URL \ | ||
--gas auto \ | ||
--gas-adjustment 1.5 \ | ||
--gas-prices 0.2ubbn \ | ||
--output json -y) | ||
echo "$SEND_TX_OUTPUT" | ||
SEND_TX_HASH=$(echo "$SEND_TX_OUTPUT" | jq -r '.txhash') | ||
|
||
# Wait for transaction to complete | ||
if ! wait_for_tx "$SEND_TX_HASH" 10 3; then | ||
echo "Failed to send funds back to prefunded key" | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully sent $AMOUNT_TO_SEND ubbn back to prefunded key" | ||
echo "Transaction hash: $SEND_TX_HASH" | ||
echo | ||
|
||
# Verify final balance = initial balance - amount sent | ||
FINAL_BALANCE=$(babylond query bank balances "$CONSUMER_FP_ADDRESS" \ | ||
--node "$BABYLON_RPC_URL" \ | ||
-o json | jq -r '.balances[0].amount') | ||
echo "Initial consumer FP balance: $CONSUMER_FP_BALANCE" | ||
echo "Final consumer FP balance: $FINAL_BALANCE" |