Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(*): switch to trunk based #31

Merged
merged 13 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 0 additions & 105 deletions .circleci/config.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci

on:
pull_request:
branches:
- '**'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.3.1
with:
go-version: '1.23'
go-lint-version: 'v1.60.2'
run-unit-tests: true
run-integration-tests: true
run-lint: true
install-dependencies-command: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev

docker_pipeline:
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.3.1
secrets: inherit
with:
publish: false
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: docker_publish

on:
push:
branches:
- 'main'
tags:
- '*'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.3.1
with:
go-version: '1.23'
go-lint-version: 'v1.60.2'
run-unit-tests: true
run-integration-tests: true
run-lint: true
install-dependencies-command: |
sudo apt-get update
sudo apt-get install -y libzmq3-dev


docker_pipeline:
needs: ["lint_test"]
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.3.1
secrets: inherit
with:
publish: true
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

Vigilante repository follows the same contributing rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/CONTRIBUTING.md)
repository.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Image for building
FROM golang:1.21-alpine AS build-env
FROM golang:1.23-alpine AS build-env


# TARGETPLATFORM should be one of linux/amd64 or linux/arm64.
Expand Down Expand Up @@ -46,7 +46,7 @@
RUN apk add bash curl jq

# Label should match your github repo
LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/vigilante:${VERSION}"

Check warning on line 49 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

COPY --from=build-env /go/src/github.com/babylonlabs-io/vigilante/build/vigilante /bin/vigilante

Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ MOCKGEN_CMD=go run ${MOCKGEN_REPO}@${MOCKGEN_VERSION}
BUILDDIR ?= $(CURDIR)/build
TOOLS_DIR := tools

BTCD_PKG := github.com/btcsuite/btcd
BTCDW_PKG := github.com/btcsuite/btcwallet
BABYLON_PKG := github.com/babylonlabs-io/babylon/cmd/babylond

GO_BIN := ${GOPATH}/bin
BTCD_BIN := $(GO_BIN)/btcd

ldflags := $(LDFLAGS)
build_tags := $(BUILD_TAGS)
Expand Down Expand Up @@ -52,7 +49,7 @@ test:
go test ./...

test-e2e:
cd $(TOOLS_DIR); go install -trimpath $(BTCD_PKG); go install -trimpath $(BTCDW_PKG); go install -trimpath $(BABYLON_PKG);
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG);
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e

build-docker:
Expand Down
113 changes: 41 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ There are four vigilante programs:

## Requirements

- Go 1.21
- [Go 1.23](https://go.dev/dl/go1.23.0.src.tar.gz)
- [Bitcoind](https://bitcoincore.org/bin)
- Package [libzmq](https://github.com/zeromq/libzmq)
- [btcd](https://github.com/btcsuite/btcd/tree/master?tab=readme-ov-file#installation) binaries (only for testing)

## Building

Expand Down Expand Up @@ -66,100 +66,69 @@ This will be later used to retrieve the certificate required for RPC connections
mkdir $TESTNET_PATH/bitcoin
```

For a Docker deployment, we want the vigilante to be able to communicate with
the Babylon and Bitcoin instances running on the local network.
We can accomplish that through the `host.docker.internal` DNS name,
which the Docker network translates to the Docker machine.
To enable Bitcoin RPC requests, we need to add the `host.docker.internal`
DNS host to the `rpc.cert` file that was created by the previous command.
To do that we use the btcd `gencerts` utility,
```bash
# Download Bitcoin Core binary
wget https://bitcoincore.org/bin/bitcoin-core-27.0/bitcoin-27.0-x86_64-linux-gnu.tar.gz # or choose a version depending on your os

```shell
gencerts -d $TESTNET_PATH/bitcoin/ -H host.docker.internal
```

#### Running a Bitcoin simnet with an arbitrary mining address
# Extract the downloaded archive
tar -xvf bitcoin-27.0-x86_64-linux-gnu.tar.gz

Launch a simnet Bitcoin node
which listens for RPC connections at port `18556` and
stores the RPC certificate under the `$TESTNET_PATH/bitcoin` directory.
The mining address is arbitrary.

```shell
btcd --simnet --rpclisten 127.0.0.1:18556 --rpcuser rpcuser --rpcpass rpcpass \
--rpccert $TESTNET_PATH/bitcoin/rpc.cert --rpckey $TESTNET_PATH/bitcoin/rpc.key \
--miningaddr SQqHYFTSPh8WAyJvzbAC8hoLbF12UVsE5s
# Provide execution permissions to binaries
chmod +x bitcoin-27.0/bin/bitcoind
chmod +x bitcoin-27.0/bin/bitcoin-cli
```

#### Running a Bitcoin simnet with a wallet
#### Running a Bitcoin regtest with a wallet

Launch a simnet Bitcoin node
which listens for RPC connections at port `18556` and
stores the RPC certificate under the `$TESTNET_PATH/bitcoin` directory.
Launch a regtest Bitcoind node which listens for RPC connections at port `18443`.

```shell
btcd --simnet --rpclisten 127.0.0.1:18556 --rpcuser rpcuser --rpcpass rpcpass \
--rpccert $TESTNET_PATH/bitcoin/rpc.cert --rpckey $TESTNET_PATH/bitcoin/rpc.key
bitcoind -regtest \
-txindex \
-rpcuser=<rpc_user> \
-rpcpassword=<rpc_password> \
-rpcbind=0.0.0.0:18443 \
-zmqpubsequence=tcp://0.0.0.0:28333 \
-datadir=/data/.bitcoin \

```

Leave this process running.

Then, create a simnet Bitcoin wallet.
Then, create a regtest Bitcoin wallet.
If you want to use the default vigilante file, then give the password `walletpass`.
Otherwise, make sure to edit the `vigilante.yaml` to reflect the correct password.

```shell
btcwallet --simnet -u rpcuser -P rpcpass \
--rpccert $TESTNET_PATH/bitcoin/rpc-wallet.cert --rpckey $TESTNET_PATH/bitcoin/rpc-wallet.key \
--cafile $TESTNET_PATH/bitcoin/rpc.cert \
--create
bitcoin-cli -regtest \
-rpcuser=<rpc_user> \
-rpcpassword=<rpc_password> \
-named createwallet \
wallet_name="<wallet_name>" \
passphrase="<passphrase>" \
load_on_startup=true \
descriptors=true
```
You can generate a btc address through the `getnewaddress` command:

The above instruction is going to prompt you for a password and going to give you the seed.
Store those securely.

Afterwards, start the wallet service listening to port `18554`:

```shell
btcwallet --simnet -u rpcuser -P rpcpass --rpclisten=127.0.0.1:18554 \
--rpccert $TESTNET_PATH/bitcoin/rpc-wallet.cert --rpckey $TESTNET_PATH/bitcoin/rpc-wallet.key \
--cafile $TESTNET_PATH/bitcoin/rpc.cert
```bash
bitcoin-cli -regtest \
-rpcuser=<rpc_user> \
-rpcpassword=<rpc_password> \
getnewaddress
```

Leave this process running. If you get an error that a wallet already exists and you still want
to create one, delete the `wallet.db` file located in the path displayed by the error message.

Create an address that will be later used for mining. The output below is a sample one.

```shell
$ btcctl --simnet --wallet -u rpcuser -P rpcpass \
--rpccert $TESTNET_PATH/bitcoin/rpc-wallet.cert \
--rpcserver 127.0.0.1 getnewaddress

SQqHYFTSPh8WAyJvzbAC8hoLbF12UVsE5s
```

Finally, restart the btcd service with the new address.
First, kill the `btcd` process that you started in the first step, and then:

```shell
btcd --simnet --rpclisten 127.0.0.1:18556 --rpcuser rpcuser --rpcpass rpcpass \
--rpccert $TESTNET_PATH/bitcoin/rpc.cert --rpckey $TESTNET_PATH/bitcoin/rpc.key \
--miningaddr $MINING_ADDRESS
```

where `$MINING_ADDRESS` is the address that you got as an output in the previous command.

#### Generating BTC blocks

While running this setup, one might want to generate BTC blocks.
We accomplish that through the btcd `btcctl` utility and the use
We accomplish that through the `bitcoin-cli` utility and the use
of the parameters we defined above.

```shell
btcctl --simnet --wallet --rpcuser=rpcuser --rpcpass=rpcpass \
--rpccert=$TESTNET_PATH/bitcoin/rpc-wallet.cert \
generate $NUM_BLOCKS
bitcoin-cli -chain=regtest \
-rpcuser=<rpc_user> \
-rpcpassword=<rpc_password> \
-generate $NUM_BLOCKS
```

where `$NUM_BLOCKS` is the number of blocks you want to generate.
Expand Down Expand Up @@ -241,7 +210,7 @@ cp sample-vigilante-docker.yml $TESTNET_PATH/vigilante/vigilante.yml
make reporter-build
```

Afterwards, run the above image and attach the directories
Afterward, run the above image and attach the directories
that contain the configuration for Babylon, Bitcoin, and the vigilante.

```shell
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release Process

Vigilate repository follows the same release process rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/RELEASE_PROCESS.md)
repository.
Loading
Loading