Skip to content

Commit

Permalink
fix: fg batch processing bug (#39)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
parketh authored Nov 7, 2024
1 parent 2364b7f commit cc1a401
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 <l2_rpc_url> -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
Expand Down Expand Up @@ -259,3 +270,31 @@ docker exec bitcoind /bin/sh -c "bitcoin-cli -signet -rpcuser=<BITCOIN_RPC_USER>
```
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 <hash>.address file
ls .consumer-finality-provider/keyring-test
# parse wallet address (first returned entry)
babylond keys parse <hash>
# check balance
babylond query bank balance <address> 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.
3 changes: 2 additions & 1 deletion configs/babylon-integration/opfgd.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ BBNRPCAddress = "${BABYLON_RPC_URL}"
GRPCListener = "0.0.0.0:50051"
HTTPListener = "0.0.0.0:8080"
PollInterval = "10s"
BatchSize = 10
BatchSize = 10
LogLevel = "info"
6 changes: 3 additions & 3 deletions docker/docker-compose-babylon-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/babylon-integration/utils/register-consumer-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit cc1a401

Please sign in to comment.