Skip to content

Commit

Permalink
Merge branch 'develop' into fix/query-rate-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Jun 24, 2024
2 parents 87af9b4 + 562a534 commit abc0deb
Show file tree
Hide file tree
Showing 174 changed files with 2,235 additions and 3,291 deletions.
20 changes: 20 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
reviews:
path_filters:
- "**/*.pb.go"
- "**/*.pb.gw.go"
path_instructions:
- path: '**/*.go'
instructions: >-
Review the Go code, point out issues relative to principles of clean
code, expressiveness, and performance.
- path: '**/*.proto'
instructions: >-
Review the Protobuf definitions, point out issues relative to
compatibility, and expressiveness.
- path: '**/*.sh'
instructions: >-
Review the shell scripts, point out issues relative to security,
performance, and maintainability.
auto_review:
base_branches:
- develop
5 changes: 2 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ jobs:

- name: Run golangci-lint
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.59
skip-cache: true
args: --out-format=json

- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/sast-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ jobs:
go-version: '1.20'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54
version: v1.59
skip-cache: true
args: --out-format=json

nosec_alert:
runs-on: ubuntu-22.04
Expand Down
37 changes: 25 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
run:
go: '1.20' # as in go.mod
timeout: 5m
tests: false # exclude test from linting

linters:
disable-all: true
enable:
Expand All @@ -18,24 +23,32 @@ linters:
- bodyclose
- unconvert
- unused
- gci
- gofmt
- whitespace

linters-settings:
gocyclo:
min-complexity: 11
errcheck:
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
golint:
min-confidence: 1.1
exclude-functions:
- fmt:.*
- io/ioutil:^Read.*,
- github.com/spf13/cobra:MarkFlagRequired
- github.com/spf13/viper:BindPFlag
exhaustive:
check-generated: false
exhaustivestruct:
check-generated: false
gci:
# Gci controls Go package import order and makes it always deterministic
# https://golangci-lint.run/usage/linters/#gci
sections:
- standard
- default
- prefix(github.com/zeta-chain/zetacore)
skip-generated: true

issues:
exclude-generated: strict
exclude:
- composite
run:
tests: false
deadline: 15m
timeout: 5m
skip-files:
- ".*\\.pb\\.go$"

exclude-dirs: [ ".git", ".github" ]
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,8 @@ gosec:
### Formatting ###
###############################################################################

fmt-import:
@bash ./scripts/fmt-imports.sh
@PHONY: fmt-import

fmt-golines:
@echo "--> Formatting Go lines"
@bash ./scripts/fmt-golines.sh
.PHONY: fmt-golines
fmt:
@bash ./scripts/fmt.sh

###############################################################################
### Generation commands ###
Expand Down Expand Up @@ -199,7 +193,7 @@ mocks:
.PHONY: mocks

# generate also includes Go code formatting
generate: proto-gen openapi specs typescript docs-zetacored mocks fmt-import fmt-golines
generate: proto-gen openapi specs typescript docs-zetacored mocks fmt
.PHONY: generate

###############################################################################
Expand Down
1 change: 0 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ func New(
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {

appCodec := encodingConfig.Codec
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
Expand Down
1 change: 0 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
func (app *App) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
) (servertypes.ExportedApp, error) {

// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
* [2317](https://github.com/zeta-chain/node/pull/2317) - add ValidateOutbound method for cctx orchestrator
* [2340](https://github.com/zeta-chain/node/pull/2340) - add ValidateInbound method for cctx orchestrator
* [2344](https://github.com/zeta-chain/node/pull/2344) - group common data of EVM/Bitcoin signer and observer using base structs
* [2357](https://github.com/zeta-chain/node/pull/2357) - integrate base Signer structure into EVM/Bitcoin Signer
* [2375](https://github.com/zeta-chain/node/pull/2375) - improve & speedup code formatting

### Tests

Expand All @@ -65,6 +67,9 @@
* [2299](https://github.com/zeta-chain/node/pull/2299) - add `zetae2e` command to deploy test contracts
* [2360](https://github.com/zeta-chain/node/pull/2360) - add stateful e2e tests.
* [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


### Fixes

Expand All @@ -75,6 +80,7 @@
* [2243](https://github.com/zeta-chain/node/pull/2243) - fix incorrect bitcoin outbound height in the CCTX outbound parameter
* [2256](https://github.com/zeta-chain/node/pull/2256) - fix rate limiter falsely included reverted non-withdraw cctxs
* [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

### CI

Expand Down
6 changes: 0 additions & 6 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"io"
"strconv"
"strings"
"sync"
Expand All @@ -13,7 +12,6 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/rs/zerolog"
"github.com/spf13/cobra"

"github.com/zeta-chain/zetacore/pkg/chains"
Expand Down Expand Up @@ -61,7 +59,6 @@ func DebugCmd() *cobra.Command {
}
inboundHash := args[0]
var ballotIdentifier string
chainLogger := zerolog.New(io.Discard).Level(zerolog.Disabled)

// create a new zetacore client
client, err := zetacore.NewClient(
Expand Down Expand Up @@ -93,7 +90,6 @@ func DebugCmd() *cobra.Command {
Mu: &sync.Mutex{},
}
evmObserver.WithZetacoreClient(client)
evmObserver.WithLogger(chainLogger)
var ethRPC *ethrpc.EthRPC
var client *ethclient.Client
coinType := coin.CoinType_Cmd
Expand Down Expand Up @@ -172,7 +168,6 @@ func DebugCmd() *cobra.Command {
Mu: &sync.Mutex{},
}
btcObserver.WithZetacoreClient(client)
btcObserver.WithLogger(chainLogger)
btcObserver.WithChain(*chains.GetChainFromChainID(chainID))
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
Expand All @@ -192,7 +187,6 @@ func DebugCmd() *cobra.Command {
if err != nil {
return err
}

}
fmt.Println("BallotIdentifier : ", ballotIdentifier)

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/gen_pre_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var GenPrePramsCmd = &cobra.Command{
Use: "gen-pre-params <path>",
Short: "Generate pre parameters for TSS",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
startTime := time.Now()
preParams, err := keygen.GeneratePreParams(time.Second * 300)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ func SetTSSPubKey(tss *mc.TSS, logger zerolog.Logger) error {
}
logger.Info().Msgf("TSS address in hex: %s", tss.EVMAddress().Hex())
return nil

}
func TestTSS(tss *mc.TSS, logger zerolog.Logger) error {
keygenLogger := logger.With().Str("module", "test-keygen").Logger()
Expand Down
1 change: 0 additions & 1 deletion cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ func SetupConfigForTest() {
})

rand.Seed(time.Now().UnixNano())

}
2 changes: 0 additions & 2 deletions cmd/zetaclientd/p2p_diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func RunDiagnostics(
hotkeyPk cryptotypes.PrivKey,
cfg config.Config,
) error {

startLogger.Warn().Msg("P2P Diagnostic mode enabled")
startLogger.Warn().Msgf("seed peer: %s", peers)
priKey := secp256k1.PrivKey(hotkeyPk.Bytes()[:32])
Expand All @@ -46,7 +45,6 @@ func RunDiagnostics(
var s *metrics.TelemetryServer
if len(peers) == 0 {
startLogger.Warn().Msg("No seed peer specified; assuming I'm the host")

}
p2pPriKey, err := crypto.UnmarshalSecp256k1PrivateKey(priKey[:])
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ func CreateZetacoreClient(
return client, nil
}

// CreateSignerMap creates a map of ChainSigners for all chains in the config
func CreateSignerMap(
appContext *context.AppContext,
tss interfaces.TSSSigner,
logger base.Logger,
ts *metrics.TelemetryServer,
) (map[int64]interfaces.ChainSigner, error) {
coreContext := appContext.ZetacoreContext()
zetacoreContext := appContext.ZetacoreContext()
signerMap := make(map[int64]interfaces.ChainSigner)

// EVM signers
for _, evmConfig := range appContext.Config().GetAllEVMConfigs() {
if evmConfig.Chain.IsZetaChain() {
continue
}
evmChainParams, found := coreContext.GetEVMChainParams(evmConfig.Chain.ChainId)
evmChainParams, found := zetacoreContext.GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
logger.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
Expand All @@ -77,15 +78,15 @@ func CreateSignerMap(
erc20CustodyAddress := ethcommon.HexToAddress(evmChainParams.Erc20CustodyContractAddress)
signer, err := evmsigner.NewSigner(
evmConfig.Chain,
evmConfig.Endpoint,
zetacoreContext,
tss,
ts,
logger,
evmConfig.Endpoint,
config.GetConnectorABI(),
config.GetERC20CustodyABI(),
mpiAddress,
erc20CustodyAddress,
coreContext,
logger,
ts)
erc20CustodyAddress)
if err != nil {
logger.Std.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
continue
Expand All @@ -95,7 +96,7 @@ func CreateSignerMap(
// BTC signer
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
if enabled {
signer, err := btcsigner.NewSigner(btcConfig, tss, logger, ts, coreContext)
signer, err := btcsigner.NewSigner(btcChain, zetacoreContext, tss, ts, logger, btcConfig)
if err != nil {
logger.Std.Error().Err(err).Msgf("NewBTCSigner error for chain %s", btcChain.String())
} else {
Expand Down Expand Up @@ -139,7 +140,6 @@ func CreateChainObserverMap(
co, err := btcobserver.NewObserver(appContext, btcChain, zetacoreClient, tss, dbpath, logger, btcConfig, ts)
if err != nil {
logger.Std.Error().Err(err).Msgf("NewObserver error for bitcoin chain %s", btcChain.String())

} else {
observerMap[btcChain.ChainId] = co
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/zetacored/add_observer_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func AddObserverListCmd() *cobra.Command {
ObserverBalance := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, observerTokens))
// Generate the grant authorizations and created observer list for chain
for _, info := range observerInfo {

if isValidatorOnly(info.IsObserver) {
balances = append(balances, banktypes.Balance{
Address: info.ObserverAddress,
Expand Down Expand Up @@ -403,7 +402,6 @@ func addStakingGrants(grants []authz.GrantAuthorization, info ObserverInfoReader
})

return grants

}

func AddGenesisAccount(
Expand Down
1 change: 0 additions & 1 deletion cmd/zetacored/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func main() {
rootCmd, _ := NewRootCmd()

if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {

switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)
Expand Down
1 change: 0 additions & 1 deletion cmd/zetacored/parse_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func ImportDataIntoFile(
cdc codec.Codec,
modifyEnabled bool,
) error {

appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc)
if err != nil {
return err
Expand Down
12 changes: 0 additions & 12 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package local

import (
"fmt"
"runtime"
"time"

"github.com/fatih/color"
Expand All @@ -20,17 +19,6 @@ func adminTestRoutine(
testNames ...string,
) func() error {
return func() (err error) {
// return an error on panic
// https://github.com/zeta-chain/node/issues/1500
defer func() {
if r := recover(); r != nil {
// print stack trace
stack := make([]byte, 4096)
n := runtime.Stack(stack, false)
err = fmt.Errorf("admin panic: %v, stack trace %s", r, stack[:n])
}
}()

// initialize runner for erc20 advanced test
adminRunner, err := initTestRunner(
"admin",
Expand Down
Loading

0 comments on commit abc0deb

Please sign in to comment.