-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: add readme * feat: scaffold initial services * docs: update readme * chore: remove old comments * feat: add mutex for db write operations * feat: convert db write to tx with rollback * chore: rename main -> demo * fix: update verifier for sdk configs * feat: run server inside verifier * fix: remove hardcode sql script * fix: sql to handle query non locally stored blocks * Revert "fix: sql to handle query non locally stored blocks" This reverts commit 033ba5a. * fix: remove incorrect error check * debug: add test messages * fix: handle latest finalised block 0 exception * fix: log errors in demo process * fix: move server port and pg conn into configs * feat: add `processNBlocks` for testing, improve block handling on restart * fix: handle non-existent local block * chore: remove debugging logs * chore: fix lint errors * feat: refactor to bbolt db * fix: throw if block height is 0 * docs: update verifier readme * fix: gitignore .db * feat: create cli daemon and config file * feat: improve logging * chore: consolidate verifier code * fix: lint errors * fix: handle server error * fix: gracefully handle server shutdown * fix: gracefully shutdown verifier * fix: remove ProcessNBlocks * fix: handle stop error * fix: handle non-existent latest consecutively finalized block * chore: rm deprecated pg handler * chore: fix formatting * fix: remove .db * chore: use relative path for db * docs: update readme * chore: fix formatting * chore: clean unused deps * feat: remove duplicate tracker for consecutively finalized block * chore: restructure verifier as part of sdk * fix: remove isFinalized bool from db type * feat: refactor http -> grpc and rename verifier -> server * feat: refactor http -> grpc and rename verifier -> server * fix: deps * fix: remove grpc server ping to fix name conflict * debug: add logging * debug: add more logging and bug fixes * debug: add err logging for rpc client * debug: use fmt for logging * Revert "debug: use fmt for logging" This reverts commit fc7ba0f. * Revert "debug: add err logging for rpc client" This reverts commit 910f07b. * Revert "debug: add more logging and bug fixes" This reverts commit faab534. * Revert "debug: add logging" This reverts commit 370fce1. * feat: add method to delete local DB * fix: delete db path * feat: allow cancel ProcessBlocks with ctx * chore: remove print * update package name (#11) * fix: update package name * fix: block status queries * feat: rename daemon and add build instructions * fix: always persist DB state * chore: rename finality gadget * feat: normalise block hash for querying * test: add db unit tests * feat: refactor repo and merge finalitygadget <> sdk * test: regenerate mocks * chore: cleanup code and standardise client format * test: regenerate mocks * feat: use zap logger * docs: update readme * feat: add getBlockByHash route to db * feat: add get block routes to finalitygadget * chore: consolidate errors * test: add fg unit tests * feat: add logger * fix: lint errors * docs: add logger to readme * restore expected_clients * remove unused quit chan * feat: simplify grpc insertBlock response * chore: config.toml.example * chore: rename fns for consistency * nit: fix comment * remove DeleteDB api * chore: rename fns for consistency * remove InsertBlock from grpc * nit: fix comments * chore: rename fns for consistency --------- Co-authored-by: lesterli <[email protected]>
- Loading branch information
Showing
46 changed files
with
3,613 additions
and
1,044 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
**/target/ | ||
.DS_Store | ||
.DS_Store | ||
**/.env | ||
**/*.db | ||
*.db | ||
config.toml |
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 |
---|---|---|
@@ -1,19 +1,86 @@ | ||
# Babylon Finality Gadget | ||
|
||
We proposed a [Babylon finality gadget](https://github.com/ethereum-optimism/specs/discussions/218) for OP-stack chains. The finality gadget depends on the EOTS data in a CosmWasm contract deployed on the Babylon chain. | ||
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. | ||
|
||
We have modified the OP-stack codebase to use the SDK in this codebase for additional finalty checks. | ||
See our [proposal](https://github.com/ethereum-optimism/specs/discussions/218) on Optimism for more details. | ||
|
||
In the future, we will also move the CosmWasm contract code here. | ||
## Modules | ||
|
||
## Dependencies | ||
- `cmd` : entry point for `opfgd` finality gadget daemon | ||
- `finalitygadget` : top-level umbrella module that exposes query methods and coordinates calls to other clients | ||
- `client` : grpc client to query the finality gadget | ||
- `server` : grpc server for the finality gadget | ||
- `proto` : protobuf definitions for the grpc server | ||
- `config` : configs for the finality gadget | ||
- `btcclient` : wrapper around Bitcoin RPC client | ||
- `bbnclient` : wrapper around Babylon RPC client | ||
- `ethl2client` : wrapper around OP stack L2 ETH RPC client | ||
- `cwclient` : client to query CosmWasm smart contract deployed on BabylonChain | ||
- `db` : handler for local database to store finalized block state | ||
- `types` : common types | ||
- `log` : custom logger | ||
- `testutil` : test utilities and helpers | ||
|
||
The SDK requires a BTC RPC client defined in https://github.com/btcsuite/btcd/tree/master/rpcclient. We wrap it in our own BTC Client to make it easier to use. | ||
## Instructions | ||
|
||
## Usages | ||
### Download and configuration | ||
|
||
To run tests | ||
To get started, clone the repository. | ||
|
||
```bash | ||
git clone https://github.com/babylonlabs-io/finality-gadget.git | ||
``` | ||
|
||
Copy the `config.toml.example` file to `config.toml`: | ||
|
||
```bash | ||
cp config.toml.example config.toml | ||
``` | ||
|
||
Configure the `config.toml` file with the following parameters: | ||
|
||
```toml | ||
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 | ||
GRPCServerPort = # Port to run the gRPC server on | ||
PollInterval = # Interval to poll for new L2 blocks | ||
``` | ||
|
||
### Building and installing the binary | ||
|
||
At the top-level directory of the project | ||
|
||
```bash | ||
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 | ||
|
||
```bash | ||
export PATH=$HOME/go/bin:$PATH | ||
echo 'export PATH=$HOME/go/bin:$PATH' >> ~/.profile | ||
``` | ||
|
||
### Running the daemon | ||
|
||
To start the daemon, run: | ||
|
||
```bash | ||
opfgd start --cfg config.toml | ||
``` | ||
|
||
### Running tests | ||
|
||
To run tests: | ||
|
||
```bash | ||
make test | ||
``` |
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
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
Oops, something went wrong.