Skip to content

Commit

Permalink
Merge branch 'develop' into jkan2/test-lstn
Browse files Browse the repository at this point in the history
  • Loading branch information
jkan2 authored Nov 7, 2024
2 parents c191fa5 + 38fea4a commit 94e1ab1
Show file tree
Hide file tree
Showing 236 changed files with 11,503 additions and 8,396 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
rpcimportable:
runs-on: ubuntu-20.04
timeout-minutes: 15
# do not run this on forks as they are not installable
# it will still be check in the merge queue in this case
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node'
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
runs-on: ${{ vars.RELEASE_RUNNER }}
steps:
- uses: actions/checkout@v4
- name: Release build dry-run
- name: Build release snapshot
run: |
make release-dry-run
make release-snapshot
check-changelog:
needs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Login to Docker Hub registry
uses: docker/login-action@v3
if: (github.event_name == 'push' && github.repository == 'zeta-chain/node') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'zeta-chain/node')
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node'
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_READ_ONLY }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
container:
image: ghcr.io/zeta-chain/semgrep-semgrep:1.90.0

if: (github.actor != 'dependabot[bot]')
if: |
github.actor != 'dependabot[bot]' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node')
steps:
- uses: actions/checkout@v4
- name: Checkout semgrep-utilities repo
Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/sim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: sim

on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, labeled]
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
make-targets:
description: 'Comma separated list of make targets to run (e.g., test-sim-nondeterminism, test-sim-fullappsimulation)'
required: true
default: 'test-sim-nondeterminism'

concurrency:
group: simulation-${{ github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
modified_files: ${{ steps.changes.outputs.modified_files }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get changed files in x directory
id: changes
run: |
echo "::set-output name=modified_files::$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^x/' | xargs)"
matrix-conditionals:
needs: changed-files
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
outputs:
SIM_TEST_NOND: ${{ steps.matrix-conditionals.outputs.SIM_TEST_NOND }}
SIM_TEST_FULL: ${{ steps.matrix-conditionals.outputs.SIM_TEST_FULL }}
SIM_TEST_IMPORT_EXPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT }}
SIM_TEST_AFTER_IMPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT }}
steps:
- id: matrix-conditionals
uses: actions/github-script@v7
with:
script: |
const makeTargetsInput = context.payload.inputs ? context.payload.inputs['make-targets'] : null;
const defaultTargets = ['test-sim-nondeterminism', 'test-sim-fullappsimulation', 'test-sim-import-export', 'test-sim-after-import'];
const makeTargets = makeTargetsInput ? makeTargetsInput.split(',') : defaultTargets;
core.setOutput('SIM_TEST_NOND', makeTargets.includes('test-sim-nondeterminism'));
core.setOutput('SIM_TEST_FULL', makeTargets.includes('test-sim-fullappsimulation'));
core.setOutput('SIM_TEST_IMPORT_EXPORT', makeTargets.includes('test-sim-import-export'));
core.setOutput('SIM_TEST_AFTER_IMPORT', makeTargets.includes('test-sim-after-import'));
simulation-tests:
needs:
- matrix-conditionals
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- make-target: "test-sim-nondeterminism"
condition: ${{ needs.matrix-conditionals.outputs.SIM_TEST_NOND == 'true' }}
- make-target: "test-sim-fullappsimulation"
condition: ${{ needs.matrix-conditionals.outputs.SIM_TEST_FULL == 'true' }}
- make-target: "test-sim-import-export"
condition: ${{ needs.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT == 'true' }}
- make-target: "test-sim-after-import"
condition: ${{ needs.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT == 'true' }}
name: ${{ matrix.make-target }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Install dependencies
run: make runsim

- name: Run ${{ matrix.make-target }}
if: ${{ matrix.condition }}
run: |
make ${{ matrix.make-target }}
sim-ok:
needs:
- simulation-tests
if: |
contains(github.event.pull_request.labels.*.name, 'SIM_TESTS') || needs.changed-files.outputs.modified_files
runs-on: ubuntu-22.04
steps:
- name: Aggregate Results
run: |
result="${{ needs.simulation-tests.result }}"
if [[ $result == "success" || $result == "skipped" ]]; then
exit 0
else
exit 1
fi
9 changes: 7 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .FullCommit }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb
- -X github.com/zeta-chain/node/pkg/constant.Name=zetacored
- -X github.com/zeta-chain/node/pkg/constant.Version={{ .Version }}
- -X github.com/zeta-chain/node/pkg/constant.CommitHash={{ .FullCommit }}
- -X github.com/zeta-chain/node/pkg/constant.BuildTime={{ .Env.BUILDTIME }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb
- -X github.com/zeta-chain/node/pkg/constant.BuildTime={{ .CommitDate }}
- -X main.version={{ .Version }}
- -X main.commit={{ .Commit }}
- -X main.date={{ .CommitDate }}
- -buildid=
- -s -w

- id: "zetaclientd"
main: ./cmd/zetaclientd
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=ghcr.io/zeta-chain/docker-dockerfile:1.9-labs
# check=error=true
FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS base-build
FROM ghcr.io/zeta-chain/golang:1.22.7-bookworm AS base-build

ENV GOPATH=/go
ENV GOOS=linux
Expand All @@ -27,10 +27,10 @@ RUN --mount=type=cache,target="/root/.cache/go-build" \
NODE_COMMIT=${NODE_COMMIT} \
make install install-zetae2e

FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS cosmovisor-build
FROM ghcr.io/zeta-chain/golang:1.22.7-bookworm AS cosmovisor-build
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS base-runtime
FROM ghcr.io/zeta-chain/golang:1.22.7-bookworm AS base-runtime

RUN apt update && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \
Expand Down
80 changes: 44 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,43 @@
PACKAGE_NAME := github.com/zeta-chain/node
NODE_VERSION := $(shell ./version.sh)
NODE_COMMIT := $(shell [ -z "${NODE_COMMIT}" ] && git log -1 --format='%H' || echo ${NODE_COMMIT} )
BUILDTIME := $(shell date -u +"%Y%m%d.%H%M%S" )
DOCKER ?= docker
# allow setting of NODE_COMPOSE_ARGS to pass additional args to docker compose
# useful for setting profiles and/ort optional overlays
# example: NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml"
DOCKER_COMPOSE ?= $(DOCKER) compose -f docker-compose.yml $(NODE_COMPOSE_ARGS)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
GOFLAGS := ""
GOLANG_CROSS_VERSION ?= v1.22.4
GOPATH ?= '$(HOME)/go'

# common goreaser command definition
GOLANG_CROSS_VERSION ?= v1.22.7@sha256:24b2d75007f0ec8e35d01f3a8efa40c197235b200a1a91422d78b851f67ecce4
GORELEASER := $(DOCKER) run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
-e "GITHUB_TOKEN=${GITHUB_TOKEN}" \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION}

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=zetacore \
-X github.com/cosmos/cosmos-sdk/version.ServerName=zetacored \
-X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(NODE_VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(NODE_COMMIT) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb \
-X github.com/zeta-chain/node/pkg/constant.Name=zetacored \
-X github.com/zeta-chain/node/pkg/constant.Version=$(NODE_VERSION) \
-X github.com/zeta-chain/node/pkg/constant.CommitHash=$(NODE_COMMIT) \
-X github.com/zeta-chain/node/pkg/constant.BuildTime=$(BUILDTIME) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb
-buildid= \
-s -w

BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger

TEST_DIR ?= "./..."
TEST_BUILD_FLAGS := -tags pebbledb,ledger
HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

export DOCKER_BUILDKIT := 1

Expand Down Expand Up @@ -62,9 +72,6 @@ test: clean-test-dir run-test
run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}

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

# Generate the test coverage
# "|| exit 1" is used to return a non-zero exit code if the tests fail
test-coverage:
Expand Down Expand Up @@ -301,7 +308,7 @@ ifdef UPGRADE_TEST_FROM_SOURCE
zetanode-upgrade: zetanode
@echo "Building zetanode-upgrade from source"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source \
--build-arg OLD_VERSION='release/v20' \
--build-arg OLD_VERSION='release/v21' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT)
.
Expand All @@ -310,7 +317,7 @@ else
zetanode-upgrade: zetanode
@echo "Building zetanode-upgrade from binaries"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime \
--build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v20.0.2' \
--build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v21.0.0' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT) \
.
Expand Down Expand Up @@ -360,7 +367,7 @@ start-upgrade-import-mainnet-test: zetanode-upgrade
###############################################################################

BINDIR ?= $(GOPATH)/bin
SIMAPP = ./tests/simulation
SIMAPP = ./simulation


# Run sim is a cosmos tool which helps us to run multiple simulations in parallel.
Expand All @@ -381,16 +388,22 @@ $(BINDIR)/runsim:
# Period: Invariant check period
# Timeout: Timeout for the simulation test
define run-sim-test
@echo "Running $(1)..."
@echo "Running $(1)"
@go test -mod=readonly $(SIMAPP) -run $(2) -Enabled=true \
-NumBlocks=$(3) -BlockSize=$(4) -Commit=true -Period=0 -v -timeout $(5)
endef

test-sim-nondeterminism:
$(call run-sim-test,"non-determinism test",TestAppStateDeterminism,100,200,2h)
$(call run-sim-test,"non-determinism test",TestAppStateDeterminism,100,200,30m)

test-sim-fullappsimulation:
$(call run-sim-test,"TestFullAppSimulation",TestFullAppSimulation,100,200,2h)
$(call run-sim-test,"TestFullAppSimulation",TestFullAppSimulation,100,200,30m)

test-sim-import-export:
$(call run-sim-test,"test-import-export",TestAppImportExport,100,200,30m)

test-sim-after-import:
$(call run-sim-test,"test-sim-after-import",TestAppSimulationAfterImport,100,200,30m)

test-sim-multi-seed-long: runsim
@echo "Running long multi-seed application simulation."
Expand All @@ -400,46 +413,41 @@ test-sim-multi-seed-short: runsim
@echo "Running short multi-seed application simulation."
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation

test-sim-import-export-long: runsim
@echo "Running application import/export simulation. This may take several minutes"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestAppImportExport

test-sim-after-import-long: runsim
@echo "Running application simulation-after-import. This may take several minute"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestAppSimulationAfterImport

.PHONY: \
test-sim-nondeterminism \
test-sim-fullappsimulation \
test-sim-multi-seed-long \
test-sim-multi-seed-short
test-sim-multi-seed-short \
test-sim-import-export \
test-sim-after-import \
test-sim-import-export-long \
test-sim-after-import-long


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

release-dry-run:
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip=validate --skip=publish --snapshot
release-snapshot:
$(GORELEASER) --clean --skip=validate --skip=publish --snapshot

release-build-only:
$(GORELEASER) --clean --skip=validate --skip=publish

release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
exit 1;\
fi
docker run \
--rm \
--privileged \
-e CGO_ENABLED=1 \
-e "GITHUB_TOKEN=${GITHUB_TOKEN}" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip=validate
$(GORELEASER) --clean --skip=validate

###############################################################################
### Local Mainnet Development ###
Expand Down
2 changes: 1 addition & 1 deletion app/ante/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type EVMKeeper interface {
statedb.Keeper
DynamicFeeEVMKeeper

NewEVM(ctx sdk.Context, msg core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) *vm.EVM
NewEVM(ctx sdk.Context, msg *core.Message, cfg *statedb.EVMConfig, tracer vm.EVMLogger, stateDB vm.StateDB) *vm.EVM
DeductTxCostsFromUserBalance(ctx sdk.Context, fees sdk.Coins, from common.Address) error
GetBalance(ctx sdk.Context, addr common.Address) *big.Int
ResetTransientGasUsed(ctx sdk.Context)
Expand Down
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ func New(
authAddr,
)

logger.Info("bank keeper blocklist addresses", "addresses", app.BlockedAddrs())

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
Expand Down Expand Up @@ -1060,6 +1058,10 @@ func (app *App) BasicManager() module.BasicManager {
return app.mb
}

func (app *App) ModuleManager() *module.Manager {
return app.mm
}

func (app *App) BlockedAddrs() map[string]bool {
blockList := make(map[string]bool)

Expand Down
Loading

0 comments on commit 94e1ab1

Please sign in to comment.