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: Rebase base onto dev #501

Draft
wants to merge 71 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
a26483d
Consumer chain finality provider (#276)
maurolacy Mar 25, 2024
4e20c08
Consumer FP registration test (#278)
maurolacy Mar 26, 2024
bc083e0
fix flaky e2e test
SebastianElvis May 14, 2024
b1d549b
cd: Allows base/consumer-chain-support branch to run push_docker job …
gusin13 May 22, 2024
41d4e9e
feat: support op-stack based L2 consumer chain (#348)
bap2pecs May 23, 2024
afe82dd
refactor: `QueryLatestFinalizedBlocks(count uint64)` -> `QueryLatestF…
bap2pecs May 23, 2024
08ce871
fix: fix lint/e2e error (#365)
gusin13 Jun 6, 2024
ce78cda
e2e: wasmd setup (#364)
gusin13 Jun 6, 2024
dfb4e4b
feat: wasmd clients (#368)
gusin13 Jun 11, 2024
66eb775
refactor: remove unused config in wasmd client (#376)
bap2pecs Jun 17, 2024
ef7c092
refactor: update `TxResponse` with generic `Events` (#377)
lesterli Jun 17, 2024
6725cc0
tests: submit finality sig to contract using admin (#374)
gusin13 Jun 17, 2024
cc74957
feat: OPStack L2 consumer controller (#379)
lesterli Jun 19, 2024
2bc851d
fix: typo in OPStack clientcontroller (#384)
gusin13 Jun 19, 2024
5e62766
feat: the queries for OPStack L2 consumer (#383)
lesterli Jun 19, 2024
18ca8c5
feat: query activated height (#387)
lesterli Jun 20, 2024
23385db
feat: queries for OPStack L2 (#392)
lesterli Jun 20, 2024
95887fb
feat: cosmwasm consumer queries (#381)
gusin13 Jun 20, 2024
819d760
chore: bump babylon and fix pub rand consumer query (#382)
gusin13 Jun 20, 2024
a9d894c
chore: fix nil pointer (#394)
SebastianElvis Jun 21, 2024
ccd1af1
chore: remove duplicate codes (#396)
lesterli Jun 22, 2024
a8df680
test: add e2e tests for opL2Stack consumer controller (#398)
bap2pecs Jun 22, 2024
6307cb8
test: add e2e tests for opL2Stack consumer controller - 2/x (#400)
bap2pecs Jun 22, 2024
79959ce
fix: fast sync for consumer (#401)
lesterli Jun 22, 2024
c8e9d46
fix: revert the pr #401 commit (#402)
lesterli Jun 22, 2024
df821f0
fix: init pubrand empty issue (#404)
bap2pecs Jun 22, 2024
fffdb6f
chore: add `clean-e2e` command to kill dangling babylond or wasmd pro…
bap2pecs Jun 22, 2024
7e3023f
refactor: expose a few private names from e2e test (#406)
bap2pecs Jun 22, 2024
4af4849
fix: parse cw data with null (#408)
lesterli Jun 23, 2024
1c9b2ee
chore: fix typo and duplicated codes (#409)
lesterli Jun 23, 2024
d43e0ae
refactor: expose a few private names from e2e test - 2/x (#410)
bap2pecs Jun 23, 2024
8fc6b23
refactor: move some e2e methods (#412)
bap2pecs Jun 23, 2024
9e9d358
chore: add .golangci.yml (#413)
bap2pecs Jun 23, 2024
7242de2
docs: fix incorrectly placed comments (#416)
bap2pecs Jun 23, 2024
4c3a8f7
test: start FP in op e2e (#418)
bap2pecs Jun 23, 2024
2bc6b84
test: opl2 consumer e2e (#411)
lesterli Jun 23, 2024
dc9194f
test: opl2 consumer e2e test -2/x (#419)
lesterli Jun 23, 2024
fc56fd6
test: submit batch signs (#421)
lesterli Jun 24, 2024
9f083c8
feat: bcd setup and e2e with fp daemon (#399)
gusin13 Jun 24, 2024
bda1e19
test: refactor the e2e test for opstack l2 (#422)
lesterli Jun 24, 2024
605ce5e
chore: refactor test directories (#423)
gusin13 Jun 25, 2024
fa3b2bb
fix: op e2e test (#426)
lesterli Jun 25, 2024
44e8e28
fix: remove unused Babylon FP in e2e test (#428)
bap2pecs Jun 25, 2024
7d3f99a
test: handle multiple providers in `InsertCovenantSigForDelegation` (…
bap2pecs Jun 25, 2024
994f641
refactor: move `WaitForFpPubRandCommitted` to utils to dedup (#430)
bap2pecs Jun 25, 2024
1d2bc68
refactor: create BaseTestManager (#433)
bap2pecs Jun 26, 2024
08c107e
test: add e2e test for SDK (#434)
bap2pecs Jun 26, 2024
d585d87
refactor: clean up interface `QueryLastCommittedPublicRand()` (#436)
bap2pecs Jun 27, 2024
6223d02
fix: add PubRandCommit.Validate() in few places (#440)
bap2pecs Jun 27, 2024
319a308
Update op e2e tests (#442)
lesterli Jun 28, 2024
e7a2633
test: add test case for op stack e2e test (#443)
lesterli Jun 28, 2024
e0378b1
fix: add missing Config.Validate() (#452)
bap2pecs Jul 1, 2024
fbd2fc0
fix: non-op logger in itests (#451)
bap2pecs Jul 1, 2024
4be27f3
chore: split CI tests (#458)
bap2pecs Jul 2, 2024
863c7c1
fix: start height of initial public randomness commit (#454)
bap2pecs Jul 2, 2024
3dc05be
test: set up OP devnet system in e2e tests (#447)
bap2pecs Jul 2, 2024
a5d9d8f
test: op e2e test with the L2 block (#459)
lesterli Jul 3, 2024
b8b72bd
chore: op query pub rand with `PubRandCommit` (#466)
lesterli Jul 3, 2024
649a458
fix: refactor op test manager (#467)
lesterli Jul 4, 2024
72050d9
feat: add json util (#469)
bap2pecs Jul 4, 2024
b9ee4c0
refactor: extract common logic for CW contract operations (#470)
bap2pecs Jul 4, 2024
29b9fe6
chore: add debug logs for op consumer controller (#472)
lesterli Jul 5, 2024
f9832ce
test: refactor op e2e tests to use `BTCClient` (#471)
parketh Jul 5, 2024
e6a5998
Fix/base64 encoding (#462)
maurolacy Jul 5, 2024
97d5209
tests: tallying and block finalization (#446)
gusin13 Jul 5, 2024
ffa95b7
chore: bump finality gadget / OP dependencies (#488)
SebastianElvis Jul 8, 2024
f307522
cosmwasm: fix check of activated height in CosmWasm controller (#489)
SebastianElvis Jul 8, 2024
6423646
chore: 1) fix null JSON resp handling; 2) op e2e test clean-up (#483)
lesterli Jul 8, 2024
0f35ec4
test: fix and re-enable fast sync (#484)
lesterli Jul 8, 2024
0cc725c
test: add test util to prefix t.Logf with date string (#485)
bap2pecs Jul 8, 2024
a06eeb1
fix: data race using `AccAddressFromBech32()` (#482)
bap2pecs Jul 9, 2024
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
102 changes: 101 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
command: "go env"
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- add_ssh_keys
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
Expand All @@ -59,24 +60,118 @@ jobs:
name: Run tests
command: |
make test

test_e2e_babylon:
machine:
image: ubuntu-2204:2024.01.1
resource_class: large
steps:
- go/install:
version: "1.21.4"
- checkout
- run:
name: Print Go environment
command: "go env"
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- add_ssh_keys
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
path: "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Run integration tests
command: |
make test-e2e-babylon

test_e2e_bcd:
machine:
image: ubuntu-2204:2024.01.1
resource_class: large
steps:
- go/install:
version: "1.21.4"
- checkout
- run:
name: Print Go environment
command: "go env"
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- add_ssh_keys
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
path: "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Run integration tests
command: |
make test-e2e-bcd

test_e2e_wasmd:
machine:
image: ubuntu-2204:2024.01.1
resource_class: large
steps:
- go/install:
version: "1.21.4"
- checkout
- run:
name: Print Go environment
command: "go env"
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- add_ssh_keys
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
path: "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Run integration tests
command: |
make test-e2e-wasmd

test_e2e_op:
machine:
image: ubuntu-2204:2024.01.1
resource_class: large
steps:
- go/install:
version: "1.21.4"
- checkout
- run:
name: Print Go environment
command: "go env"
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- add_ssh_keys
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
path: "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Download OP e2e devnet test data
command: |
make op-e2e-devnet
- run:
name: Run integration tests
command: |
make test-e2e
make test-e2e-op

build_docker:
machine:
image: ubuntu-2204:2024.01.1
resource_class: large
steps:
- checkout
- add_ssh_keys
- aws-ecr/build-image:
push-image: false
dockerfile: Dockerfile
path: ./
build-path: ./
tag: "$CIRCLE_SHA1,$CIRCLE_TAG"
repo: "$CIRCLE_PROJECT_REPONAME"
extra-build-args: "--secret id=sshKey,src=/home/circleci/.ssh/$DEPLOY_KEY_NAME"
- run:
name: Save Docker image to export it to workspace
command: |
Expand Down Expand Up @@ -112,6 +207,10 @@ workflows:
jobs:
- check-mock-gen
- build_lint_test
- test_e2e_babylon
- test_e2e_bcd
- test_e2e_wasmd
- test_e2e_op
- build_docker:
filters:
tags:
Expand All @@ -126,3 +225,4 @@ workflows:
only:
- main
- dev
- base/consumer-chain-support
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# Test binary, built with `go test -c`
*.test

# E2E test data
devnet-data/

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

Expand Down
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
run:
build-tags:
- e2e_op
- e2e_babylon
- e2e_bcd
- e2e_wasmd
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ RUN apk add --no-cache --update openssh git make build-base linux-headers libc-d
libzmq-static libsodium-static gcc


RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts
RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
ENV GOPRIVATE=github.com/babylonchain/*

# Build
WORKDIR /go/src/github.com/babylonchain/finality-provider
# Cache dependencies
COPY go.mod go.sum /go/src/github.com/babylonchain/finality-provider/
RUN go mod download
RUN --mount=type=secret,id=sshKey,target=/root/.ssh/id_rsa go mod download
# Copy the rest of the files
COPY ./ /go/src/github.com/babylonchain/finality-provider/

Expand Down
67 changes: 62 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ BUILDDIR ?= $(CURDIR)/build
TOOLS_DIR := tools

BABYLON_PKG := github.com/babylonchain/babylon/cmd/babylond
WASMD_PKG := github.com/CosmWasm/wasmd/cmd/wasmd
BCD_PKG := github.com/babylonchain/babylon-sdk/demo/cmd/bcd

GO_BIN := ${GOPATH}/bin
BTCD_BIN := $(GO_BIN)/btcd
Expand All @@ -18,6 +20,11 @@ build_tags := $(BUILD_TAGS)
build_args := $(BUILD_ARGS)

PACKAGES_E2E=$(shell go list ./... | grep '/itest')
# need to specify the full path to fix issue where logs won't stream to stdout
# due to multiple packages found
# context: https://github.com/golang/go/issues/24929
PACKAGES_E2E_OP=$(shell go list -tags=e2e_op ./... | grep '/itest/opstackl2')
PACKAGES_E2E_BCD=$(shell go list -tags=e2e_bcd ./... | grep '/itest/cosmwasm/bcd')

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" -v
Expand Down Expand Up @@ -49,18 +56,68 @@ $(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

build-docker:
$(DOCKER) build --tag babylonchain/finality-provider -f Dockerfile \
$(DOCKER) build --secret id=sshKey,src=${BBN_PRIV_DEPLOY_KEY} --tag babylonchain/finality-provider -f Dockerfile \
$(shell git rev-parse --show-toplevel)

.PHONY: build build-docker

.PHONY: lint
lint:
golangci-lint run

.PHONY: test
test:
go test ./...

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

install-wasmd:
cd $(TOOLS_DIR); \
go install -trimpath $(WASMD_PKG)

install-bcd:
cd $(TOOLS_DIR); \
go install -trimpath $(BCD_PKG)

.PHONY: clean-e2e test-e2e test-e2e-babylon test-e2e-wasmd test-e2e-bcd test-e2e-op

# Clean up environments by stopping processes and removing data directories
clean-e2e:
@pids=$$(ps aux | grep -E 'babylond start|wasmd start|bcd start' | grep -v grep | awk '{print $$2}' | tr '\n' ' '); \
if [ -n "$$pids" ]; then \
echo $$pids | xargs kill; \
echo "Killed processes $$pids"; \
else \
echo "No processes to kill"; \
fi
rm -rf ~/.babylond ~/.wasmd ~/.bcd

# Main test target that runs all e2e tests
test-e2e: test-e2e-babylon test-e2e-wasmd test-e2e-bcd test-e2e-op

test-e2e-babylon: clean-e2e install-babylond
@go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e_babylon

test-e2e-bcd: clean-e2e install-babylond install-bcd
@go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E_BCD) -count=1 --tags=e2e_bcd

test-e2e-wasmd: clean-e2e install-babylond install-wasmd
@go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e_wasmd

test-e2e-op: clean-e2e install-babylond
@go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E_OP) -count=1 --tags=e2e_op

DEVNET_REPO_URL := https://github.com/babylonchain/op-e2e-devnet
TARGET_DIR := ./itest/opstackl2/devnet-data

.PHONY: op-e2e-devnet
op-e2e-devnet:
@rm -rf $(TARGET_DIR)
@mkdir -p $(TARGET_DIR)
@git clone $(DEVNET_REPO_URL) $(TARGET_DIR)
@echo "Devnet data downloaded to $(TARGET_DIR)"

###############################################################################
### Protobuf ###
Expand All @@ -76,7 +133,7 @@ proto-gen:

mock-gen:
mkdir -p $(MOCKS_DIR)
$(MOCKGEN_CMD) -source=clientcontroller/interface.go -package mocks -destination $(MOCKS_DIR)/babylon.go
$(MOCKGEN_CMD) -source=clientcontroller/api/interface.go -package mocks -destination $(MOCKS_DIR)/clientcontroller.go

.PHONY: mock-gen

Expand Down
63 changes: 24 additions & 39 deletions clientcontroller/interface.go → clientcontroller/api/interface.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
package clientcontroller
package api

import (
"fmt"

"cosmossdk.io/math"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/chaincfg"
"go.uber.org/zap"

finalitytypes "github.com/babylonchain/babylon/x/finality/types"
fpcfg "github.com/babylonchain/finality-provider/finality-provider/config"
"github.com/babylonchain/finality-provider/types"
)

const (
babylonConsumerChainName = "babylon"
)

type ClientController interface {
// RegisterFinalityProvider registers a finality provider to the consumer chain
// it returns tx hash and error. The address of the finality provider will be
// the signer of the msg.
RegisterFinalityProvider(
chainID string,
chainPk []byte,
fpPk *btcec.PublicKey,
pop []byte,
commission *math.LegacyDec,
description []byte,
) (*types.TxResponse, error)

// Note: the following queries are only for PoC

// QueryFinalityProviderSlashed queries if the finality provider is slashed
// Note: if the FP wants to get the information from the consumer chain directly, they should add this interface
// function in ConsumerController. (https://github.com/babylonchain/finality-provider/pull/335#discussion_r1606175344)
QueryFinalityProviderSlashed(fpPk *btcec.PublicKey) (bool, error)

Close() error
}

type ConsumerController interface {
// CommitPubRandList commits a list of EOTS public randomness the consumer chain
// it returns tx hash and error
CommitPubRandList(fpPk *btcec.PublicKey, startHeight uint64, numPubRand uint64, commitment []byte, sig *schnorr.Signature) (*types.TxResponse, error)
Expand All @@ -44,46 +47,28 @@ type ClientController interface {
// QueryFinalityProviderVotingPower queries the voting power of the finality provider at a given height
QueryFinalityProviderVotingPower(fpPk *btcec.PublicKey, blockHeight uint64) (uint64, error)

// QueryFinalityProviderSlashed queries if the finality provider is slashed
QueryFinalityProviderSlashed(fpPk *btcec.PublicKey) (bool, error)

// QueryLatestFinalizedBlocks returns the latest finalized blocks
QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error)
// QueryLatestFinalizedBlock returns the latest finalized block
// Note: nil will be returned if the finalized block does not exist
QueryLatestFinalizedBlock() (*types.BlockInfo, error)

// QueryLastCommittedPublicRand returns the last committed public randomness
QueryLastCommittedPublicRand(fpPk *btcec.PublicKey, count uint64) (map[uint64]*finalitytypes.PubRandCommitResponse, error)
// QueryLastPublicRandCommit returns the last committed public randomness
QueryLastPublicRandCommit(fpPk *btcec.PublicKey) (*types.PubRandCommit, error)

// QueryBlock queries the block at the given height
QueryBlock(height uint64) (*types.BlockInfo, error)

// QueryIsBlockFinalized queries if the block at the given height is finalized
QueryIsBlockFinalized(height uint64) (bool, error)

// QueryBlocks returns a list of blocks from startHeight to endHeight
QueryBlocks(startHeight, endHeight, limit uint64) ([]*types.BlockInfo, error)

// QueryBestBlock queries the tip block of the consumer chain
QueryBestBlock() (*types.BlockInfo, error)
// QueryLatestBlockHeight queries the tip block height of the consumer chain
QueryLatestBlockHeight() (uint64, error)

// QueryActivatedHeight returns the activated height of the consumer chain
// error will be returned if the consumer chain has not been activated
QueryActivatedHeight() (uint64, error)

Close() error
}

func NewClientController(chainName string, bbnConfig *fpcfg.BBNConfig, netParams *chaincfg.Params, logger *zap.Logger) (ClientController, error) {
var (
cc ClientController
err error
)

switch chainName {
case babylonConsumerChainName:
cc, err = NewBabylonController(bbnConfig, netParams, logger)
if err != nil {
return nil, fmt.Errorf("failed to create Babylon rpc client: %w", err)
}
default:
return nil, fmt.Errorf("unsupported consumer chain")
}

return cc, err
}
Loading