The Babylon Finality Gadget is a program that can be run by users of OP stack L2s to track consecutive L2 block quorum and query the BTC-finalised status of blocks.
See our proposal on Optimism for more details.
cmd
: entry point foropfgd
finality gadget daemonfinalitygadget
: top-level umbrella module that exposes query methods and coordinates calls to other clientsclient
: grpc client to query the finality gadgetserver
: grpc server for the finality gadgetproto
: protobuf definitions for the grpc serverconfig
: configs for the finality gadgetbtcclient
: wrapper around Bitcoin RPC clientbbnclient
: wrapper around Babylon RPC clientethl2client
: wrapper around OP stack L2 ETH RPC clientcwclient
: client to query CosmWasm smart contract deployed on BabylonChaindb
: handler for local database to store finalized block statetypes
: common typeslog
: custom loggertestutil
: test utilities and helpers
To get started, clone the repository.
git clone https://github.com/babylonlabs-io/finality-gadget.git
Copy the config.toml.example
file to config.toml
:
cp config.toml.example config.toml
Configure the config.toml
file with the following parameters:
L2RPCHost = # RPC URL of OP stack L2 chain
BitcoinRPCHost = # Bitcoin RPC URL
DBFilePath = # Path to local bbolt DB file
FGContractAddress = # Babylon finality gadget contract address
BBNChainID = # Babylon chain id
BBNRPCAddress = # Babylon RPC host URL
GRPCListener = # Host:port to listen for gRPC connections
PollInterval = # Interval to poll for new L2 blocks
At the top-level directory of the project
make install
The above command will build and install the opfgd
binary to
$GOPATH/bin
.
If your shell cannot find the installed binaries, make sure $GOPATH/bin
is in
the $PATH
of your shell. Usually these commands will do the job
export PATH=$HOME/go/bin:$PATH
echo 'export PATH=$HOME/go/bin:$PATH' >> ~/.profile
To start the daemon, run:
opfgd start --cfg config.toml
To run tests:
make test
-
Docker Desktop: Install from Docker's official website.
-
Make: Required for building service binaries. Installation guide available here.
-
GitHub SSH Key:
- Create a non-passphrase-protected SSH key.
- Add it to GitHub (instructions).
- Export the key path:
export BBN_PRIV_DEPLOY_KEY=FULL_PATH_TO_PRIVATE_KEY/.ssh/id_ed25519
-
Repository Setup:
git clone https://github.com/babylonlabs-io/finality-gadget.git
To build the docker image:
make build-docker