Skip to content

Commit

Permalink
Release v0.6.0 (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitsalis authored May 10, 2023
2 parents c8315ce + a19d78a commit bae93e7
Show file tree
Hide file tree
Showing 370 changed files with 18,019 additions and 15,060 deletions.
122 changes: 96 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,128 @@
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
orbs:
aws-ecr: circleci/[email protected]
go: circleci/[email protected]


jobs:
build:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
build-test:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
resource_class: large
steps:
- go/install:
version: "1.20"
- checkout
- run:
name: Print Go environment
command: "go env"
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v6-{{ checksum "go.sum" }}
- go/load-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
- go/mod-download
- go/save-cache:
key: go-mod-v6-{{ checksum "go.sum" }}
path: "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Build babylond
command: make build
- save_cache:
key: go-mod-v6-{{ checksum "go.sum" }}
paths:
- "/home/circleci/.go_workspace/pkg/mod"
- run:
name: Lint
command: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.50.1
./bin/golangci-lint run
- run:
name: Run tests
command: |
make test
- run: # sudo is needed, so that integration test binary have proper access to nodes keyring
name: Run integration tests
command: |
make localnet-start-test
sudo -E env "PATH=$PATH" make test-babylon-integration
make localnet-stop
sudo -E env "PATH=$PATH" make localnet-test-integration
# TODO: If CI tests will take to long consider having only this e2e test
# instead of separate integration tests and e2e tests.
- run:
name: Run e2e tests
command: |
make test-e2e
make test-e2e
lint:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
steps:
- go/install:
version: "1.20"
- checkout
- run:
name: Lint proto files
command: make proto-lint
- run:
name: Lint
command: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.52.2
./bin/golangci-lint run
build_docker:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
steps:
- checkout
- aws-ecr/build-image:
push-image: false
dockerfile: Dockerfile
path: ./contrib/images/babylond/
build-path: ./
tag: "$CIRCLE_SHA1,$CIRCLE_TAG"
repo: "babylond"
- run:
name: Save Docker image to export it to workspace
command: |
docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}') > /tmp/babylond.tar
- persist_to_workspace:
root: /tmp
paths:
- babylond.tar

push_docker:
machine:
image: ubuntu-2204:2022.10.1
resource_class: large
steps:
- attach_workspace:
at: /tmp
- run:
name: Load Docker image from workspace
command: |
docker load -i /tmp/babylond.tar
- aws-ecr/ecr-login:
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
region: "$AWS_REGION"
- aws-ecr/push-image:
registry-id: AWS_ECR_REGISTRY_ID
region: "$AWS_REGION"
repo: "babylond"
tag: "$CIRCLE_SHA1,$CIRCLE_TAG"

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
build-lint-test:
version: 2
build-test:
jobs:
- build-test
lint:
jobs:
- lint
docker:
jobs:
- build
- build_docker:
filters:
tags:
only: /.*/
- push_docker:
requires:
- build_docker
filters:
tags:
only: /.*/
branches:
only:
- main
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# Build artifacts for wasm contracts used in tests
wasmbinding/testdata/target

# End of https://www.toptal.com/developers/gitignore/api/intellij,vscode,macos,windows
# The following content is adapted from https://github.com/osmosis-labs/osmosis/blob/main/.gitignore

Expand All @@ -211,4 +214,4 @@ docs/diagrams/plantuml.jar
.testnets/
.testnet/
mytestnet/
output/
output/
106 changes: 65 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
HTTPS_GIT := https://github.com/babylonchain/babylon.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
SIMAPP = ./simapp

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

CUR_DIR := $(shell pwd)

WASM_DIR := $(CUR_DIR)/wasmbinding/testdata

WASM_DIR_BASE_NAME := $(shell basename $(WASM_DIR))

# don't override user values
ifeq (,$(VERSION))
# Find a name that exactly describes the current commit (e.g. a version tag)
Expand Down Expand Up @@ -61,7 +66,7 @@ ifeq (secp,$(findstring secp,$(BABYLON_BUILD_OPTIONS)))
endif

whitespace :=
whitespace += $(whitespace)
whitespace := $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

Expand Down Expand Up @@ -93,6 +98,10 @@ ifeq (boltdb,$(findstring boltdb,$(BABYLON_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=boltdb
endif

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif

ifeq (,$(findstring nostrip,$(BABYLON_BUILD_OPTIONS)))
ldflags += -w -s
endif
Expand Down Expand Up @@ -219,10 +228,13 @@ endif

.PHONY: run-tests test test-all $(TEST_TARGETS)

test-babylon-integration:
test-integration:
@echo "Running babylon integration test"
@go test github.com/babylonchain/babylon/test -v -count=1 --tags=integration -p 1

test-e2e:
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e

test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
Expand Down Expand Up @@ -351,70 +363,82 @@ devdoc-update:
### Protobuf ###
###############################################################################

containerProtoVer=v0.7
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=babylon-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
containerProtoFmt=babylon-sdk-proto-fmt-$(containerProtoVer)
protoVer=0.12.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-all: proto-gen proto-swagger-gen

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./proto/scripts/protocgen.sh; fi
@$(protoImage) sh ./proto/scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./proto/scripts/protoc-swagger-gen.sh; fi
@$(protoImage) sh ./proto/scripts/protoc-swagger-gen.sh

proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(protoImage) buf lint --error-format=json

.PHONY: proto-gen proto-swagger-gen
.PHONY: proto-gen proto-swagger-gen proto-format prot-lint

###############################################################################
### Localnet ###
### Docker ###
###############################################################################

localnet-build-env:
$(MAKE) -C contrib/images babylond-env
build-docker:
$(MAKE) -C contrib/images babylond

localnet-build-dlv:
$(MAKE) -C contrib/images babylond-dlv
.PHONY: build-docker

localnet-build-nodes-test:
$(DOCKER) run --rm -v $(CURDIR)/.testnets:/data babylonchain/babylond \
testnet init-files --v 4 -o /data \
###############################################################################
### Localnet ###
###############################################################################

# init-testnet-dirs will create a ./.testnets directory containing configuration for 4 Babylon nodes
init-testnet-dirs:
# need to create the dir before hand so that the docker container has write access to the `.testnets` dir
# regardless of the user it uses
mkdir -p $(CURDIR)/.testnets && chmod o+w $(CURDIR)/.testnets
$(DOCKER) run --rm -v $(CURDIR)/.testnets:/home/babylon/.testnets:Z babylonchain/babylond \
babylond testnet init-files --v 4 -o /home/babylon/.testnets \
--starting-ip-address 192.168.10.2 --keyring-backend=test \
--chain-id chain-test --btc-confirmation-depth 2 --additional-sender-account true \
--epoch-interval 5
docker-compose up -d

localnet-build-nodes:
$(DOCKER) run --rm -v $(CURDIR)/.testnets:/data babylonchain/babylond \
testnet init-files --v 4 -o /data \
--starting-ip-address 192.168.10.2 --keyring-backend=test \
--chain-id chain-test
# localnet-start-nodes will boot the nodes described in the docker-compose.yml file
localnet-start-nodes: init-testnet-dirs
docker-compose up -d

# localnet-start will run a with 4 nodes with 4 nodes, a bitcoin instance, and a vigilante instance
localnet-start: localnet-stop localnet-build-env localnet-build-nodes

# localnet-start-test will start with 4 nodes with test confiuration and low
# epoch interval
localnet-start-test: localnet-stop localnet-build-env localnet-build-nodes-test

# localnet-debug will run a 4-node testnet locally in debug mode
# you can read more about the debug mode here: ./contrib/images/babylond-dlv/README.md
localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes

test-e2e:
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
localnet-start: localnet-stop build-docker localnet-start-nodes

# localnet-stop will stop all localnets running
localnet-stop:
docker-compose down

.PHONY: localnet-start localnet-stop localnet-debug localnet-build-env \
localnet-build-dlv localnet-build-nodes
# localnet-test-integration will spin up a localnet and run integration tests on it
localnet-test-integration: localnet-start test-integration localnet-stop

build-test-wasm:
docker run --rm -v "$(WASM_DIR)":/code \
--mount type=volume,source="$(WASM_DIR_BASE_NAME)_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer-arm64:0.12.13
docker run --rm -v "$(WASM_DIR)":/code \
--mount type=volume,source="$(WASM_DIR_BASE_NAME)_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.13

.PHONY: \
init-testnet-dirs \
localnet-start-nodes \
localnet-start \
localnet-test-integration \
localnet-stop

.PHONY: diagrams
diagrams:
Expand Down
14 changes: 10 additions & 4 deletions app/ante_btc_validation_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ package app

import (
bbn "github.com/babylonchain/babylon/types"
btccheckpointkeeper "github.com/babylonchain/babylon/x/btccheckpoint/keeper"
btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types"
btclightclient "github.com/babylonchain/babylon/x/btclightclient/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

type BtcValidationDecorator struct {
BtcCfg bbn.BtcConfig
BtcCfg bbn.BtcConfig
btccheckpointKeeper *btccheckpointkeeper.Keeper
}

func NewBtcValidationDecorator(cfg bbn.BtcConfig) BtcValidationDecorator {
func NewBtcValidationDecorator(
cfg bbn.BtcConfig,
k *btccheckpointkeeper.Keeper,
) BtcValidationDecorator {
return BtcValidationDecorator{
BtcCfg: cfg,
BtcCfg: cfg,
btccheckpointKeeper: k,
}
}

Expand All @@ -26,7 +32,7 @@ func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
switch msg := m.(type) {
case *btccheckpointtypes.MsgInsertBTCSpvProof:
powLimit := bvd.BtcCfg.PowLimit()
_, err := btccheckpointtypes.ParseSubmission(msg, &powLimit, bvd.BtcCfg.CheckpointTag())
_, err := btccheckpointtypes.ParseSubmission(msg, &powLimit, bvd.btccheckpointKeeper.GetExpectedTag(ctx))

if err != nil {
return ctx, btccheckpointtypes.ErrInvalidCheckpointProof.Wrap(err.Error())
Expand Down
Loading

0 comments on commit bae93e7

Please sign in to comment.