Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zeta-chain/node into avo…
Browse files Browse the repository at this point in the history
…id-submitting-invalid-tracker-hash-evm
  • Loading branch information
ws4charlie committed Aug 7, 2024
2 parents 08107c9 + d8a23e3 commit 0ffaeec
Show file tree
Hide file tree
Showing 376 changed files with 16,338 additions and 15,005 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ concurrency:
cancel-in-progress: false

jobs:
check_branch:
check-branch:
if: ${{ (startsWith(github.ref, 'refs/heads/release/v') || startsWith(github.ref, 'refs/heads/hotfix/v')) }}
runs-on: ubuntu-22.04
steps:
- name: Branch
run: |
echo "${{ github.ref }}"
check-goreleaser:
needs:
- check-branch
runs-on: ubuntu-22.04
steps:
- name: Branch
run: |
make release-dry-run
check-changelog:
needs:
- check_branch
- check-branch
runs-on: ubuntu-22.04
steps:

Expand Down Expand Up @@ -75,7 +84,7 @@ jobs:
check-upgrade-handler-updated:
needs:
- check_branch
- check-branch
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
Expand Down Expand Up @@ -114,7 +123,7 @@ jobs:
needs:
- check-changelog
- check-upgrade-handler-updated
- check_branch
- check-branch
runs-on: ubuntu-22.04
timeout-minutes: 60
environment: release
Expand Down
7 changes: 3 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ env:
- CC_windows_amd64=x86_64-w64-mingw32-gcc
- CXX_windows_amd64=x86_64-w64-mingw32-g++
- VERSION={{ .Version }}
- COMMIT={{ .Commit }}
- BUILDTIME={{ .Date }}
# - CC_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES
# - CXX_windows_arm64= NOT_CREATING_WINDOWS_ARM64_BINARIES
Expand Down Expand Up @@ -54,10 +53,10 @@ builds:
- -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={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Env.COMMIT }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .FullCommit }}
- -X github.com/zeta-chain/zetacore/pkg/constant.Name=zetacored
- -X github.com/zeta-chain/zetacore/pkg/constant.Version={{ .Version }}
- -X github.com/zeta-chain/zetacore/pkg/constant.CommitHash={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/pkg/constant.CommitHash={{ .FullCommit }}
- -X github.com/zeta-chain/zetacore/pkg/constant.BuildTime={{ .Env.BUILDTIME }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

Expand Down Expand Up @@ -100,7 +99,7 @@ release:
# Available only for GitHub and Gitea.
draft: false

target_commitish: "{{ .Commit }}"
target_commitish: "{{ .FullCommit }}"

# If set, will create a release discussion in the category specified.
#
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax=ghcr.io/zeta-chain/docker-dockerfile:1.7-labs
# 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

ENV GOPATH /go
ENV GOPATH=/go
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV GOCACHE=/root/.cache/go-build
Expand Down Expand Up @@ -41,7 +42,7 @@ RUN mkdir -p /root/.zetacored/cosmovisor/genesis/bin && \
ln -s /usr/local/bin/zetaclientd /root/.zetaclientd/upgrades/genesis/zetacored && \
ln -s /root/.zetaclientd/upgrades/genesis /root/.zetaclientd/upgrades/current

ENV PATH /root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/current/:${PATH}
ENV PATH=/root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/current/:${PATH}

COPY contrib/localnet/scripts /root
COPY contrib/localnet/ssh_config /etc/ssh/ssh_config.d/localnet.conf
Expand All @@ -62,7 +63,7 @@ COPY --from=latest-build /go/bin/zetacored /go/bin/zetaclientd /go/bin/zetaclien

# Optional old version build (from source). This old build is used as the genesis version in the upgrade tests.
# Use --target latest-runtime to skip.
FROM base-build as old-build-source
FROM base-build AS old-build-source

ARG OLD_VERSION
RUN git clone https://github.com/zeta-chain/node.git
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ start-upgrade-import-mainnet-test: zetanode-upgrade
###############################################################################

PACKAGE_NAME := github.com/zeta-chain/node
GOLANG_CROSS_VERSION ?= v1.20.7
GOLANG_CROSS_VERSION ?= v1.22.4
GOPATH ?= '$(HOME)/go'
release-dry-run:
docker run \
Expand All @@ -334,7 +334,7 @@ release-dry-run:
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--clean --skip-validate --skip-publish --snapshot
--clean --skip=validate --skip=publish --snapshot

release:
@if [ ! -f ".release-env" ]; then \
Expand All @@ -350,7 +350,7 @@ release:
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --clean --skip-validate
release --clean --skip=validate

###############################################################################
### Local Mainnet Development ###
Expand Down Expand Up @@ -430,4 +430,4 @@ filter-missed-eth: install-zetatool
zetatool filterdeposit eth \
--config ./tool/filter_missed_deposits/zetatool_config.json \
--evm-max-range 1000 \
--evm-start-block 19464041
--evm-start-block 19464041
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
### Features

* [2578](https://github.com/zeta-chain/node/pull/2578) - Add Gateway address in protocol contract list
* [2634](https://github.com/zeta-chain/node/pull/2634) - add support for EIP-1559 gas fees
* [2597](https://github.com/zeta-chain/node/pull/2597) - Add generic rpc metrics to zetaclient
* [2538](https://github.com/zeta-chain/node/pull/2538) - add background worker routines to shutdown zetaclientd when needed for tss migration

### Refactor

* [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers

## v19.0.0

Expand Down
133 changes: 5 additions & 128 deletions cmd/zetaclientd-supervisor/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import (
"runtime"
"strings"
"sync"
"syscall"
"time"

"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/hashicorp/go-getter"
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

Expand Down Expand Up @@ -79,7 +78,7 @@ func newZetaclientdSupervisor(
logger = logger.With().Str("module", "zetaclientdSupervisor").Logger()
conn, err := grpc.Dial(
fmt.Sprintf("%s:9090", zetaCoreURL),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return nil, fmt.Errorf("grpc dial: %w", err)
Expand All @@ -99,9 +98,6 @@ func newZetaclientdSupervisor(
func (s *zetaclientdSupervisor) Start(ctx context.Context) {
go s.watchForVersionChanges(ctx)
go s.handleCoreUpgradePlan(ctx)
go s.handleNewKeygen(ctx)
go s.handleNewTSSKeyGeneration(ctx)
go s.handleTSSUpdate(ctx)
}

func (s *zetaclientdSupervisor) WaitForReloadSignal(ctx context.Context) {
Expand Down Expand Up @@ -177,125 +173,6 @@ func (s *zetaclientdSupervisor) watchForVersionChanges(ctx context.Context) {
}
}

func (s *zetaclientdSupervisor) handleTSSUpdate(ctx context.Context) {
maxRetries := 11
retryInterval := 5 * time.Second

// TODO : use retry library under pkg/retry
// https://github.com/zeta-chain/node/issues/2492
for i := 0; i < maxRetries; i++ {
client := observertypes.NewQueryClient(s.zetacoredConn)
tss, err := client.TSS(ctx, &observertypes.QueryGetTSSRequest{})
if err != nil {
s.logger.Warn().Err(err).Msg("unable to get original tss")
time.Sleep(retryInterval)
continue
}
i = 0
for {
select {
case <-time.After(time.Second):
case <-ctx.Done():
return
}
tssNew, err := client.TSS(ctx, &observertypes.QueryGetTSSRequest{})
if err != nil {
s.logger.Warn().Err(err).Msg("unable to get tss")
continue
}

if tssNew.TSS.TssPubkey == tss.TSS.TssPubkey {
continue
}

tss = tssNew
s.logger.Info().
Msgf("tss address is updated from %s to %s", tss.TSS.TssPubkey, tssNew.TSS.TssPubkey)
time.Sleep(6 * time.Second)
s.logger.Info().Msg("restarting zetaclientd to update tss address")
s.restartChan <- syscall.SIGHUP
}
}
s.logger.Warn().Msg("handleTSSUpdate exiting without success")
}

func (s *zetaclientdSupervisor) handleNewTSSKeyGeneration(ctx context.Context) {
maxRetries := 11
retryInterval := 5 * time.Second

// TODO : use retry library under pkg/retry
for i := 0; i < maxRetries; i++ {
client := observertypes.NewQueryClient(s.zetacoredConn)
alltss, err := client.TssHistory(ctx, &observertypes.QueryTssHistoryRequest{})
if err != nil {
s.logger.Warn().Err(err).Msg("unable to get tss original history")
time.Sleep(retryInterval)
continue
}
i = 0
tssLenCurrent := len(alltss.TssList)
for {
select {
case <-time.After(time.Second):
case <-ctx.Done():
return
}
tssListNew, err := client.TssHistory(ctx, &observertypes.QueryTssHistoryRequest{})
if err != nil {
s.logger.Warn().Err(err).Msg("unable to get tss new history")
continue
}
tssLenUpdated := len(tssListNew.TssList)

if tssLenUpdated == tssLenCurrent {
continue
}
if tssLenUpdated < tssLenCurrent {
tssLenCurrent = len(tssListNew.TssList)
continue
}

tssLenCurrent = tssLenUpdated
s.logger.Info().Msgf("tss list updated from %d to %d", tssLenCurrent, tssLenUpdated)
time.Sleep(5 * time.Second)
s.logger.Info().Msg("restarting zetaclientd to update tss list")
s.restartChan <- syscall.SIGHUP
}
}
s.logger.Warn().Msg("handleNewTSSKeyGeneration exiting without success")
}

func (s *zetaclientdSupervisor) handleNewKeygen(ctx context.Context) {
client := observertypes.NewQueryClient(s.zetacoredConn)
prevKeygenBlock := int64(0)
for {
select {
case <-time.After(time.Second):
case <-ctx.Done():
return
}
resp, err := client.Keygen(ctx, &observertypes.QueryGetKeygenRequest{})
if err != nil {
s.logger.Warn().Err(err).Msg("unable to get keygen")
continue
}
if resp.Keygen == nil {
s.logger.Warn().Err(err).Msg("keygen is nil")
continue
}

if resp.Keygen.Status != observertypes.KeygenStatus_PendingKeygen {
continue
}
keygenBlock := resp.Keygen.BlockNumber
if prevKeygenBlock == keygenBlock {
continue
}
prevKeygenBlock = keygenBlock
s.logger.Info().Msgf("got new keygen at block %d", keygenBlock)
s.restartChan <- syscall.SIGHUP
}
}
func (s *zetaclientdSupervisor) handleCoreUpgradePlan(ctx context.Context) {
client := upgradetypes.NewQueryClient(s.zetacoredConn)

Expand Down Expand Up @@ -345,16 +222,16 @@ func (s *zetaclientdSupervisor) downloadZetaclientd(ctx context.Context, plan *u
if plan.Info == "" {
return errors.New("upgrade info empty")
}
var config upgradeConfig
err := json.Unmarshal([]byte(plan.Info), &config)
var cfg upgradeConfig
err := json.Unmarshal([]byte(plan.Info), &cfg)
if err != nil {
return fmt.Errorf("unmarshal upgrade config: %w", err)
}

s.logger.Info().Msg("downloading zetaclientd")

binKey := fmt.Sprintf("%s-%s/%s", zetaclientdBinaryName, runtime.GOOS, runtime.GOARCH)
binURL, ok := config.Binaries[binKey]
binURL, ok := cfg.Binaries[binKey]
if !ok {
return fmt.Errorf("no binary found for: %s", binKey)
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/zetaclientd-supervisor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"
"time"

"cosmossdk.io/errors"
"golang.org/x/sync/errgroup"

"github.com/zeta-chain/zetacore/app"
Expand Down Expand Up @@ -69,10 +70,17 @@ func main() {
cmd.Stdin = &passwordInputBuffer

eg, ctx := errgroup.WithContext(ctx)
eg.Go(cmd.Run)
eg.Go(func() error {
defer cancel()
if err := cmd.Run(); err != nil {
return errors.Wrap(err, "zetaclient process failed")
}

logger.Info().Msg("zetaclient process exited")
return nil
})
eg.Go(func() error {
supervisor.WaitForReloadSignal(ctx)
cancel()
return nil
})
eg.Go(func() error {
Expand Down
Loading

0 comments on commit 0ffaeec

Please sign in to comment.