Skip to content

Commit

Permalink
Merge branch 'develop' into snapshots-command
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Dec 19, 2023
2 parents 3ce7f00 + ef8639d commit b978d7f
Show file tree
Hide file tree
Showing 429 changed files with 31,863 additions and 27,842 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
GOOS: linux
GOARCH: ${{ env.CPU_ARCH }}
run: |
make install-testnet
make install
cp "$HOME"/go/bin/* ./
chmod a+x ./zetacored
./zetacored version
Expand All @@ -79,7 +79,7 @@ jobs:

smoke-test:
runs-on: ["zeta-runners"] # 25 minutes
timeout-minutes: 30
timeout-minutes: 35
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine
FROM golang:1.20-alpine3.18

ENV GOPATH /go
ENV GOOS=linux
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-release
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine as builder
FROM golang:1.20-alpine3.18 as builder

ENV GOPATH /go
ENV GOOS=linux
Expand Down
72 changes: 72 additions & 0 deletions Dockerfile-versioned-source
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM golang:1.19-alpine

ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1

ARG old_version

RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux
RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""

WORKDIR /go/delivery/zeta-node

RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ENV NEW_VERSION=v42.0.0

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
COPY go.sum /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && go mod download
COPY . /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && make install
RUN cd /go/delivery/zeta-node/ && make install-smoketest
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/
RUN cp $GOPATH/bin/smoketest $GOPATH/bin/new/

# Checkout and build old binary
RUN git clone https://github.com/zeta-chain/node.git
RUN cd node && git fetch

RUN cd node && git checkout ${old_version}
RUN cd node && make install
RUN cd node && make install-smoketest
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/
RUN cp $GOPATH/bin/smoketest $GOPATH/bin/old/

RUN git clone https://github.com/zeta-chain/cosmos-sdk.git
RUN cd cosmos-sdk && git checkout zetavisor-v0.1.5
RUN cd cosmos-sdk/cosmovisor && make zetavisor
#
#FROM golang:1.19-alpine

#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys

RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
RUN cp /go/bin/smoketest /usr/local/bin
RUN cp /go/bin/zetavisor /usr/local/bin

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss

RUN chmod 755 /root/*.sh
RUN chmod 700 /root/.ssh
RUN chmod 600 /root/.ssh/*

WORKDIR /usr/local/bin
ENV SHELL /bin/sh
EXPOSE 22

ENTRYPOINT ["/usr/sbin/sshd", "-D"]
108 changes: 50 additions & 58 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=zetacore \
-X github.com/zeta-chain/zetacore/common.BuildTime=$(BUILDTIME) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

BUILD_FLAGS := -ldflags '$(ldflags)' -tags PRIVNET,pebbledb,ledger
TESTNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags TESTNET,pebbledb,ledger
MOCK_MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags MOCK_MAINNET,pebbledb,ledger
MAINNET_BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger
BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger

TEST_DIR?="./..."
TEST_BUILD_FLAGS := -tags TESTNET,pebbledb,ledger
PRIV_BUILD_FLAGS := -tags PRIVNET,pebbledb,ledger
HSM_BUILD_FLAGS := -tags TESTNET,pebbled,ledger,hsm_test
TEST_BUILD_FLAGS := -tags pebbledb,ledger
HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

clean: clean-binaries clean-dir clean-test-dir clean-coverage

Expand All @@ -40,6 +36,22 @@ clean-dir:

all: install

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

###############################################################################
### Test commands ###
###############################################################################

run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}

test :clean-test-dir run-test

test-hsm:
@go test ${HSM_BUILD_FLAGS} ${TEST_DIR}

test-coverage-exclude-core:
@go test ${TEST_BUILD_FLAGS} -v -coverprofile coverage.out $(go list ./... | grep -v /x/zetacore/)

Expand All @@ -58,24 +70,9 @@ clean-test-dir:
@rm -rf x/crosschain/client/querytests/.zetacored
@rm -rf x/observer/client/querytests/.zetacored

run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}

test :clean-test-dir run-test

test-priv:
@go test ${PRIV_BUILD_FLAGS} ${TEST_DIR}

test-hsm:
@go test ${HSM_BUILD_FLAGS} ${TEST_DIR}

gosec:
gosec -exclude-dir=localnet ./...

install-testnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetaclientd
###############################################################################
### Install commands ###
###############################################################################

build-testnet-ubuntu: go.sum
docker build -t zetacore-ubuntu --platform linux/amd64 -f ./Dockerfile-athens3-ubuntu .
Expand All @@ -89,44 +86,26 @@ install: go.sum
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-mainnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(MAINNET_BUILD_FLAGS) ./cmd/zetaclientd

install-mock-mainnet: go.sum
@echo "--> Installing zetacored & zetaclientd"
@go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetacored
@go install -mod=readonly $(MOCK_MAINNET_BUILD_FLAGS) ./cmd/zetaclientd


install-zetaclient: go.sum
@echo "--> Installing zetaclientd"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

# running with race detector on will be slow
install-zetaclient-race-test-only-build: go.sum
@echo "--> Installing zetaclientd"
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-zetacore: go.sum
@echo "--> Installing zetacored"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetacored

install-zetacore-testnet: go.sum
@echo "--> Installing zetacored"
@go install -mod=readonly $(TESTNET_BUILD_FLAGS) ./cmd/zetacored
# running with race detector on will be slow
install-zetaclient-race-test-only-build: go.sum
@echo "--> Installing zetaclientd"
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

install-smoketest: go.sum
@echo "--> Installing orchestrator"
@go install -mod=readonly $(BUILD_FLAGS) ./contrib/localnet/orchestrator/smoketest

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify
@go install -mod=readonly $(BUILD_FLAGS) ./contrib/localnet/orchestrator/smoketest/cmd/smoketest

test-cctx:
./standalone-network/cctx-creator.sh
###############################################################################
### Local network ###
###############################################################################

init:
./standalone-network/init.sh
Expand All @@ -140,12 +119,12 @@ chain-stop:
@killall zetacored
@killall tail

test-cctx:
./standalone-network/cctx-creator.sh

chain-init-testnet: clean install-zetacore-testnet init
chain-run-testnet: clean install-zetacore-testnet init run

chain-init-mock-mainnet: clean install-mock-mainnet init
chain-run-mock-mainnet: clean install-mock-mainnet init run
###############################################################################
### Linting ###
###############################################################################

lint-pre:
@test -z $(gofmt -l .)
Expand All @@ -157,6 +136,13 @@ lint: lint-pre
lint-cosmos-gosec:
@bash ./scripts/cosmos-gosec.sh

gosec:
gosec -exclude-dir=localnet ./...

###############################################################################
### Generation commands ###
###############################################################################

proto:
@echo "--> Removing old Go types "
@find . -name '*.pb.go' -type f -delete
Expand Down Expand Up @@ -197,7 +183,7 @@ generate: proto openapi specs typescript docs-zetacored
.PHONY: generate

###############################################################################
### Docker Images ###
### Smoke tests ###
###############################################################################

zetanode:
Expand Down Expand Up @@ -241,13 +227,19 @@ stateful-upgrade:
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d

stateful-upgrade-source:
@echo "--> Starting stateful smoketest"
$(DOCKER) build --build-arg old_version=v10.1.7 -t zetanode -f ./Dockerfile-versioned-source .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d

stop-stateful-upgrade:
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans


###############################################################################
### GoReleaser ###
###############################################################################

PACKAGE_NAME := github.com/zeta-chain/node
GOLANG_CROSS_VERSION ?= v1.20
GOPATH ?= '$(HOME)/go'
Expand Down
10 changes: 8 additions & 2 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"runtime/debug"

stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ethante "github.com/evmos/ethermint/app/ante"
cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types"

Expand Down Expand Up @@ -96,14 +97,19 @@ func NewAnteHandler(options ethante.HandlerOptions) (sdk.AnteHandler, error) {
found := false
for _, msg := range tx.GetMsgs() {
switch msg.(type) {
// treat these two msg types differently because they might call EVM which results in massive gas consumption
// treat these three msg types differently because they might call EVM which results in massive gas consumption
// For these two msg types, we don't check gas limit by using a different ante handler
case *cctxtypes.MsgGasPriceVoter, *cctxtypes.MsgVoteOnObservedInboundTx:
found = true
break
case *stakingtypes.MsgCreateValidator:
if ctx.BlockHeight() == 0 {
found = true
break
}
}
}
if found {
if len(tx.GetMsgs()) == 1 && found {
// this differs newCosmosAnteHandler only in that it doesn't check gas limit
// by using an Infinite Gas Meter.
anteHandler = newCosmosAnteHandlerNoGasLimit(options)
Expand Down
Loading

0 comments on commit b978d7f

Please sign in to comment.