Skip to content

Commit

Permalink
Merge branch 'zeta-chain:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
royki authored Jul 13, 2024
2 parents 334443c + a076710 commit 7c37f77
Show file tree
Hide file tree
Showing 153 changed files with 4,863 additions and 3,062 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:
- uses: actions/setup-go@v5
if: ${{ inputs.skip_go == 'false' }}
with:
go-version: '1.20'
go-version: '1.22'
cache: false

- uses: actions/setup-python@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.22'

- name: Run Gosec Security Scanner
if: ${{ github.event.inputs.skip_checks != 'true' }}
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.22'

- name: Run Cosmos Gosec Security Scanner
if: ${{ github.event.inputs.skip_checks != 'true' }}
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.22'

- name: Run golangci-lint
if: ${{ github.event.inputs.skip_checks != 'true' }}
Expand Down
29 changes: 3 additions & 26 deletions .github/workflows/sast-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Run Gosec Security Scanner
uses: securego/[email protected]
with:
args: ./...

gosec-cosmos:
runs-on: ubuntu-22.04
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v4
uses: zeta-chain/[email protected]
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- name: Run Cosmos Gosec Security Scanner
run: make lint-cosmos-gosec
args: -exclude-generated -exclude-dir testutil ./...

lint:
runs-on: ubuntu-22.04
Expand All @@ -67,7 +44,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.22'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.7-labs
FROM golang:1.20.14-bookworm AS base-build
FROM golang:1.22.5-bookworm AS base-build

ENV GOPATH /go
ENV GOOS=linux
Expand All @@ -22,10 +22,10 @@ COPY --exclude=*.sh --exclude=*.md --exclude=*.yml . .
RUN --mount=type=cache,target="/root/.cache/go-build" make install
RUN --mount=type=cache,target="/root/.cache/go-build" make install-zetae2e

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

FROM golang:1.20.14-bookworm AS base-runtime
FROM golang:1.22.5-bookworm AS base-runtime

RUN apt update && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ lint-pre:
lint: lint-pre
@golangci-lint run

lint-cosmos-gosec:
@bash ./scripts/cosmos-gosec.sh
lint-gosec:
@bash ./scripts/gosec.sh

gosec:
gosec -exclude-dir=localnet ./...
Expand Down Expand Up @@ -271,6 +271,7 @@ zetanode-upgrade: zetanode
.PHONY: zetanode-upgrade
endif


start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
Expand All @@ -283,6 +284,14 @@ start-upgrade-test-light: zetanode-upgrade
export UPGRADE_HEIGHT=90 && \
cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d


start-upgrade-test-admin: zetanode-upgrade
@echo "--> Starting admin upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-import-mainnet-test: zetanode-upgrade
@echo "--> Starting import-data upgrade test"
export LOCALNET_MODE=upgrade && \
Expand Down
7 changes: 5 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Breaking Changes

* [List of the breaking changes can be found in this document](docs/releases/v17_breaking_changes.md)
* [2460](https://github.com/zeta-chain/node/pull/2460) - Upgrade to go 1.22. This required us to temporarily remove the QUIC backend from [go-libp2p](https://github.com/libp2p/go-libp2p). If you are a zetaclient operator and have configured quic peers, you need to switch to tcp peers.

### Features

Expand Down Expand Up @@ -58,6 +58,7 @@
* [2375](https://github.com/zeta-chain/node/pull/2375) - improve & speedup code formatting
* [2380](https://github.com/zeta-chain/node/pull/2380) - use `ChainInfo` in `authority` to allow dynamically support new chains
* [2395](https://github.com/zeta-chain/node/pull/2395) - converge AppContext with ZetaCoreContext in zetaclient
* [2428](https://github.com/zeta-chain/node/pull/2428) - propagate context across codebase & refactor zetacore client

### Tests

Expand All @@ -76,7 +77,8 @@
* [2349](https://github.com/zeta-chain/node/pull/2349) - add TestBitcoinDepositRefund and WithdrawBitcoinMultipleTimes E2E tests
* [2368](https://github.com/zeta-chain/node/pull/2368) - eliminate panic usage across testing suite
* [2369](https://github.com/zeta-chain/node/pull/2369) - fix random cross-chain swap failure caused by using tiny UTXO

* [2549](https://github.com/zeta-chain/node/pull/2459) - add separate accounts for each policy in e2e tests
* [2415](https://github.com/zeta-chain/node/pull/2415) - add e2e test for upgrade and test admin functionalities

### Fixes

Expand All @@ -89,6 +91,7 @@
* [2327](https://github.com/zeta-chain/node/pull/2327) - partially cherry picked the fix to Bitcoin outbound dust amount
* [2362](https://github.com/zeta-chain/node/pull/2362) - set 1000 satoshis as minimum BTC amount that can be withdrawn from zEVM
* [2382](https://github.com/zeta-chain/node/pull/2382) - add tx input and gas in rpc methods for synthetic eth txs
* [2396](https://github.com/zeta-chain/node/issues/2386) - special handle bitcoin testnet gas price estimator
* [2434](https://github.com/zeta-chain/node/pull/2434) - the default database when running `zetacored init` is now pebbledb

### CI
Expand Down
22 changes: 12 additions & 10 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
btcobserver "github.com/zeta-chain/zetacore/zetaclient/chains/bitcoin/observer"
evmobserver "github.com/zeta-chain/zetacore/zetaclient/chains/evm/observer"
"github.com/zeta-chain/zetacore/zetaclient/config"
clientcontext "github.com/zeta-chain/zetacore/zetaclient/context"
zctx "github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/keys"
"github.com/zeta-chain/zetacore/zetaclient/zetacore"
)
Expand Down Expand Up @@ -57,7 +57,8 @@ func debugCmd(_ *cobra.Command, args []string) error {
return err
}

appContext := clientcontext.New(cfg, zerolog.Nop())
appContext := zctx.New(cfg, zerolog.Nop())
ctx := zctx.WithAppContext(context.Background(), appContext)

chainID, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
Expand All @@ -74,15 +75,16 @@ func debugCmd(_ *cobra.Command, args []string) error {
"",
debugArgs.zetaChainID,
false,
nil)
zerolog.Nop(),
)
if err != nil {
return err
}
chainParams, err := client.GetChainParams()
chainParams, err := client.GetChainParams(ctx)
if err != nil {
return err
}
tssEthAddress, err := client.GetEthTssAddress()
tssEthAddress, err := client.GetEVMTSSAddress(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -148,19 +150,19 @@ func debugCmd(_ *cobra.Command, args []string) error {

switch coinType {
case coin.CoinType_Zeta:
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenZeta(tx, receipt, false)
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenZeta(ctx, tx, receipt, false)
if err != nil {
return err
}

case coin.CoinType_ERC20:
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenERC20(tx, receipt, false)
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenERC20(ctx, tx, receipt, false)
if err != nil {
return err
}

case coin.CoinType_Gas:
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenGas(tx, receipt, false)
ballotIdentifier, err = evmObserver.CheckAndVoteInboundTokenGas(ctx, tx, receipt, false)
if err != nil {
return err
}
Expand All @@ -186,15 +188,15 @@ func debugCmd(_ *cobra.Command, args []string) error {
return err
}
btcObserver.WithBtcClient(btcClient)
ballotIdentifier, err = btcObserver.CheckReceiptForBtcTxHash(inboundHash, false)
ballotIdentifier, err = btcObserver.CheckReceiptForBtcTxHash(ctx, inboundHash, false)
if err != nil {
return err
}
}
fmt.Println("BallotIdentifier : ", ballotIdentifier)

// query ballot
ballot, err := client.GetBallot(ballotIdentifier)
ballot, err := client.GetBallot(ctx, ballotIdentifier)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Initialize(_ *cobra.Command, _ []string) error {
}

//Create new config struct
configData := config.New()
configData := config.New(true)

//Validate Peer eg. /ip4/172.0.2.1/tcp/6668/p2p/16Uiu2HAmACG5DtqmQsHtXg4G2sLS65ttv84e7MrL4kapkjfmhxAp
if len(initArgs.peer) != 0 {
Expand Down
45 changes: 32 additions & 13 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"encoding/hex"
"encoding/json"
"errors"
Expand All @@ -16,35 +17,42 @@ import (

"github.com/zeta-chain/zetacore/pkg/chains"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/context"
zctx "github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
mc "github.com/zeta-chain/zetacore/zetaclient/tss"
"github.com/zeta-chain/zetacore/zetaclient/zetacore"
)

func GenerateTss(
appContext *context.AppContext,
ctx context.Context,
logger zerolog.Logger,
client *zetacore.Client,
peers p2p.AddrList,
priKey secp256k1.PrivKey,
ts *metrics.TelemetryServer,
tssHistoricalList []observertypes.TSS,
tssPassword string,
hotkeyPassword string) (*mc.TSS, error) {
hotkeyPassword string,
) (*mc.TSS, error) {
app, err := zctx.FromContext(ctx)
if err != nil {
return nil, err
}

keygenLogger := logger.With().Str("module", "keygen").Logger()

// Bitcoin chain ID is currently used for using the correct signature format
// TODO: remove this once we have a better way to determine the signature format
// https://github.com/zeta-chain/node/issues/1397
bitcoinChainID := chains.BitcoinRegtest.ChainId
btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig()
btcChain, _, btcEnabled := app.GetBTCChainAndConfig()
if btcEnabled {
bitcoinChainID = btcChain.ChainId
}

tss, err := mc.NewTSS(
appContext,
ctx,
app,
peers,
priKey,
preParams,
Expand Down Expand Up @@ -74,7 +82,7 @@ func GenerateTss(
// This loop will try keygen at the keygen block and then wait for keygen to be successfully reported by all nodes before breaking out of the loop.
// If keygen is unsuccessful, it will reset the triedKeygenAtBlock flag and try again at a new keygen block.

keyGen := appContext.GetKeygen()
keyGen := app.GetKeygen()
if keyGen.Status == observertypes.KeygenStatus_KeyGenSuccess {
return tss, nil
}
Expand All @@ -86,7 +94,7 @@ func GenerateTss(
// Try generating TSS at keygen block , only when status is pending keygen and generation has not been tried at the block
if keyGen.Status == observertypes.KeygenStatus_PendingKeygen {
// Return error if RPC is not working
currentBlock, err := client.GetBlockHeight()
currentBlock, err := client.GetBlockHeight(ctx)
if err != nil {
keygenLogger.Error().Err(err).Msg("GetBlockHeight RPC error")
continue
Expand All @@ -101,16 +109,21 @@ func GenerateTss(
if currentBlock > lastBlock {
lastBlock = currentBlock
keygenLogger.Info().
Msgf("Waiting For Keygen Block to arrive or new keygen block to be set. Keygen Block : %d Current Block : %d ChainID %s ", keyGen.BlockNumber, currentBlock, appContext.Config().ChainID)
Msgf("Waiting For Keygen Block to arrive or new keygen block to be set. Keygen Block : %d Current Block : %d ChainID %s ", keyGen.BlockNumber, currentBlock, app.Config().ChainID)
}
continue
}
// Try keygen only once at a particular block, irrespective of whether it is successful or failure
triedKeygenAtBlock = true
err = keygenTss(keyGen, tss, keygenLogger)
err = keygenTss(ctx, keyGen, tss, keygenLogger)
if err != nil {
keygenLogger.Error().Err(err).Msg("keygenTss error")
tssFailedVoteHash, err := client.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_failed)
tssFailedVoteHash, err := client.PostVoteTSS(
ctx,
"",
keyGen.BlockNumber,
chains.ReceiveStatus_failed,
)
if err != nil {
keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore")
return nil, err
Expand All @@ -128,7 +141,8 @@ func GenerateTss(
}

// If TSS is successful , broadcast the vote to zetacore and set Pubkey
tssSuccessVoteHash, err := client.SetTSS(
tssSuccessVoteHash, err := client.PostVoteTSS(
ctx,
newTss.CurrentPubkey,
keyGen.BlockNumber,
chains.ReceiveStatus_success,
Expand All @@ -155,7 +169,7 @@ func GenerateTss(
return nil, errors.New("unexpected state for TSS generation")
}

func keygenTss(keyGen observertypes.Keygen, tss *mc.TSS, keygenLogger zerolog.Logger) error {
func keygenTss(ctx context.Context, keyGen observertypes.Keygen, tss *mc.TSS, keygenLogger zerolog.Logger) error {
keygenLogger.Info().Msgf("Keygen at blocknum %d , TSS signers %s ", keyGen.BlockNumber, keyGen.GranteePubkeys)
var req keygen.Request
req = keygen.NewRequest(keyGen.GranteePubkeys, keyGen.BlockNumber, "0.14.0")
Expand All @@ -168,7 +182,12 @@ func keygenTss(keyGen observertypes.Keygen, tss *mc.TSS, keygenLogger zerolog.Lo
return err
}
index := fmt.Sprintf("keygen-%s-%d", digest, keyGen.BlockNumber)
zetaHash, err := tss.ZetacoreClient.PostBlameData(&res.Blame, tss.ZetacoreClient.Chain().ChainId, index)
zetaHash, err := tss.ZetacoreClient.PostVoteBlameData(
ctx,
&res.Blame,
tss.ZetacoreClient.Chain().ChainId,
index,
)
if err != nil {
keygenLogger.Error().Err(err).Msg("error sending blame data to core")
return err
Expand Down
Loading

0 comments on commit 7c37f77

Please sign in to comment.