From cc1a401de6d8200212feedfbe3693ff83754eaf3 Mon Sep 17 00:00:00 2001 From: parketh Date: Thu, 7 Nov 2024 12:05:34 +0000 Subject: [PATCH] fix: fg batch processing bug (#39) * feat: update default opfgd.toml * chore: update FG image * chore: update FG image * chore: update FG image * update finality explorer * fix: deploy script * debug: script * debug: script * remove debugging * docs: update readme for finalized block check * update FG image * docs: add 0 FP balance troubleshooting * chore: update FG --- README.md | 39 +++++++++++++++++++ configs/babylon-integration/opfgd.toml | 3 +- docker/docker-compose-babylon-integration.yml | 6 +-- .../utils/register-consumer-chain.sh | 4 +- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 89e17be..ce1fe8c 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ Besides these, you will need to set the following variables: ### 3. Set Babylon keys This step + - imports the pre-funded Babylon key, which will be used to deploy the finality contract, register your finality provider, create BTC delegation in later steps. - generates a new account for your OP-Stack chain's finality provider. - funds it with the pre-funded Babylon account, to pay for gas fees when submitting finality votes. @@ -206,6 +207,16 @@ make check-btc-delegation ### 11. Set `enabled` to `true` in finality contract +Before setting `IS_ENABLED=true`, first wait for your OP-Stack chain's finalized block to be above the BTC delegation activation height. You can check this by comparing the timestamp of the finalized block with the btc activation timestamp. + +```bash +# to find the latest finalized block +curl -sf -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized",false],"id":1}' + +# to find the btc activation timestamp +docker logs finality-gadget -f --tail 100 +``` + Once the BTC delegation is activated, set the `IS_ENABLED=true` in the `.env.babylon-integration` file and then run: ```bash @@ -259,3 +270,31 @@ docker exec bitcoind /bin/sh -c "bitcoin-cli -signet -rpcuser= ``` Now recheck the balance and unspent outputs. + +### 2. Consumer FP insufficient balance + +You need to maintain a sufficient balance on your consumer FP Babylon account. To check the balance: + +```bash +# find .address file +ls .consumer-finality-provider/keyring-test + +# parse wallet address (first returned entry) +babylond keys parse + +# check balance +babylond query bank balance
ubbn --chain-id euphrates-0.5.0 --node https://rpc-euphrates.devnet.babylonlabs.io:443 +``` + +If your consumer FP has insufficient balance to submit finality votes / commit pub rands, the FG may become stuck. To fix this: + +1. Funding the consumer FP +2. Restart it by running `make restart-consumer-finality-provider` + +At this point, FG may no longer be advancing because FP skips submitting the finality votes that it missed. If so, you need to reset the FG as follows: + +1. Toggle the CW contract off. You can do so by setting `IS_ENABLED=false` in `.env.babylon-integration` and running `make toggle-cw-killswitch`. +2. Wait for the finalized block to advance pass the last height with skipped finality votes. You can check this by running `docker logs consumer-finality-provider | grep "Successfully submitted finality votes"`. +3. Restart the FG from scratch by running `make stop-finality-gadget && make start-finality-gadget` +4. Toggle the CW contract back on. Set `IS_ENABLED=true` in `.env.babylon-integration` and running `make toggle-cw-killswitch`. +5. Wait for consumer FP and FG to catch up. diff --git a/configs/babylon-integration/opfgd.toml b/configs/babylon-integration/opfgd.toml index c9b7804..8de9d03 100644 --- a/configs/babylon-integration/opfgd.toml +++ b/configs/babylon-integration/opfgd.toml @@ -10,4 +10,5 @@ BBNRPCAddress = "${BABYLON_RPC_URL}" GRPCListener = "0.0.0.0:50051" HTTPListener = "0.0.0.0:8080" PollInterval = "10s" -BatchSize = 10 \ No newline at end of file +BatchSize = 10 +LogLevel = "info" \ No newline at end of file diff --git a/docker/docker-compose-babylon-integration.yml b/docker/docker-compose-babylon-integration.yml index 92265a7..4edefa8 100644 --- a/docker/docker-compose-babylon-integration.yml +++ b/docker/docker-compose-babylon-integration.yml @@ -98,8 +98,8 @@ services: finality-gadget: container_name: finality-gadget - # https://github.com/babylonlabs-io/finality-gadget/commit/9f7ee4c7c9ba7b07645a9aa3f79dc88987b0815a - image: babylonlabs/finality-gadget:9f7ee4c7c9ba7b07645a9aa3f79dc88987b0815a + # https://github.com/babylonlabs-io/finality-gadget/commit/8bdd24c7d32e7ffb8fe06cebcb571cb2ce52db12 + image: babylonlabs/finality-gadget:8bdd24c7d32e7ffb8fe06cebcb571cb2ce52db12 command: > opfgd start --cfg /home/finality-gadget/opfgd.toml ports: @@ -113,7 +113,7 @@ services: finality-explorer: container_name: finality-explorer - image: snapchain/finality-explorer:sha-3d96ccc + image: snapchain/finality-explorer:sha-3ea3cc3 ports: - "13000:3000" env_file: diff --git a/scripts/babylon-integration/utils/register-consumer-chain.sh b/scripts/babylon-integration/utils/register-consumer-chain.sh index 31a581f..b71a7e3 100755 --- a/scripts/babylon-integration/utils/register-consumer-chain.sh +++ b/scripts/babylon-integration/utils/register-consumer-chain.sh @@ -20,8 +20,8 @@ fi # register the consumer chain echo "Registering consumer chain $CONSUMER_ID..." CONSUMER_REGISTRATION_TX_HASH=$(babylond tx btcstkconsumer register-consumer \ - $CONSUMER_ID \ - $CONSUMER_CHAIN_NAME \ + "$CONSUMER_ID" \ + "$CONSUMER_CHAIN_NAME" \ --chain-id $BABYLON_CHAIN_ID \ --node $BABYLON_RPC_URL \ --from $BABYLON_PREFUNDED_KEY \