Skip to content

Commit

Permalink
ran make generate and addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinssgh committed Feb 7, 2024
1 parent 974cd8d commit 4226bfa
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
### Refactoring

* [1628](https://github.com/zeta-chain/node/pull/1628) optimize return and simplify code
* [1640](https://github.com/zeta-chain/node/pull/1640) zetaclient re-organization
* [1640](https://github.com/zeta-chain/node/pull/1640) reorganize zetaclient into subpackages

### Refactoring
* [1619](https://github.com/zeta-chain/node/pull/1619) - Add evm fee calculation to tss migration of evm chains
Expand Down
3 changes: 1 addition & 2 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import (
"sync"

"github.com/zeta-chain/zetacore/zetaclient/bitcoin"
"github.com/zeta-chain/zetacore/zetaclient/evm"
"github.com/zeta-chain/zetacore/zetaclient/keys"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"

"github.com/zeta-chain/zetacore/zetaclient/evm"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
Expand Down
12 changes: 6 additions & 6 deletions contrib/localnet/orchestrator/smoketest/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/rs/zerolog/log"
"github.com/zeta-chain/zetacore/common"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
zc_btc "github.com/zeta-chain/zetacore/zetaclient/bitcoin"
zetabitcoin "github.com/zeta-chain/zetacore/zetaclient/bitcoin"
)

var blockHeaderBTCTimeout = 5 * time.Minute
Expand Down Expand Up @@ -55,7 +55,7 @@ func (sm *SmokeTestRunner) DepositBTCWithAmount(amount float64) (txHash *chainha
sm.Logger.Info(" spendableUTXOs: %d", spendableUTXOs)
sm.Logger.Info("Now sending two txs to TSS address...")

amount = amount + zc_btc.BtcDepositorFeeMin
amount = amount + zetabitcoin.BtcDepositorFeeMin
txHash, err = sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount, utxos, sm.BtcRPCClient, sm.BTCDeployerAddress)
if err != nil {
panic(err)
Expand Down Expand Up @@ -101,12 +101,12 @@ func (sm *SmokeTestRunner) DepositBTC(testHeader bool) {
sm.Logger.Info("Now sending two txs to TSS address...")

// send two transactions to the TSS address
amount1 := 1.1 + zc_btc.BtcDepositorFeeMin
amount1 := 1.1 + zetabitcoin.BtcDepositorFeeMin
txHash1, err := sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount1, utxos[:2], btc, sm.BTCDeployerAddress)
if err != nil {
panic(err)
}
amount2 := 0.05 + zc_btc.BtcDepositorFeeMin
amount2 := 0.05 + zetabitcoin.BtcDepositorFeeMin
txHash2, err := sm.SendToTSSFromDeployerToDeposit(sm.BTCTSSAddress, amount2, utxos[2:4], btc, sm.BTCDeployerAddress)
if err != nil {
panic(err)
Expand All @@ -119,7 +119,7 @@ func (sm *SmokeTestRunner) DepositBTC(testHeader bool) {
0.11,
utxos[4:5],
btc,
[]byte(zc_btc.DonationMessage),
[]byte(zetabitcoin.DonationMessage),
sm.BTCDeployerAddress,
)
if err != nil {
Expand Down Expand Up @@ -270,7 +270,7 @@ func (sm *SmokeTestRunner) SendToTSSFromDeployerWithMemo(
if err != nil {
panic(err)
}
events := zc_btc.FilterAndParseIncomingTx(
events := zetabitcoin.FilterAndParseIncomingTx(
[]btcjson.TxRawResult{*rawtx},
0,
sm.BTCTSSAddress.EncodeAddress(),
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/bitcoin/bitcoin_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (signer *BTCSigner) Broadcast(signedTx *wire.MsgTx) error {

func (signer *BTCSigner) TryProcessOutTx(
cctx *types.CrossChainTx,
outTxMan *outtxprocessor.Manager,
outTxMan *outtxprocessor.Processor,
outTxID string,
chainclient interfaces.ChainClient,
zetaBridge interfaces.ZetaCoreBridger,
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/evm/evm_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func (signer *Signer) SignCommandTx(

func (signer *Signer) TryProcessOutTx(
cctx *types.CrossChainTx,
outTxMan *outtxprocessor.Manager,
outTxMan *outtxprocessor.Processor,
outTxID string,
chainclient interfaces.ChainClient,
zetaBridge interfaces.ZetaCoreBridger,
Expand Down
2 changes: 1 addition & 1 deletion zetaclient/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ChainClient interface {
type ChainSigner interface {
TryProcessOutTx(
send *crosschaintypes.CrossChainTx,
outTxMan *outtxprocessor.Manager,
outTxMan *outtxprocessor.Processor,
outTxID string,
evmClient ChainClient,
zetaBridge ZetaCoreBridger,
Expand Down
20 changes: 10 additions & 10 deletions zetaclient/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ import (
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
ckeys "github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/rs/zerolog/log"
"github.com/zeta-chain/zetacore/cmd"
"github.com/zeta-chain/zetacore/common"
"github.com/zeta-chain/zetacore/common/cosmos"
"github.com/zeta-chain/zetacore/zetaclient/config"
errors2 "github.com/zeta-chain/zetacore/zetaclient/errors"
zetaerrors "github.com/zeta-chain/zetacore/zetaclient/errors"
)

// Keys manages all the keys used by zeta client
type Keys struct {
signerName string
kb ckeys.Keyring
OperatorAddress sdkTypes.AccAddress
OperatorAddress sdk.AccAddress
hotkeyPassword string
}

// NewKeysWithKeybase create a new instance of Keys
func NewKeysWithKeybase(kb ckeys.Keyring, granterAddress sdkTypes.AccAddress, granteeName string, hotkeyPassword string) *Keys {
func NewKeysWithKeybase(kb ckeys.Keyring, granterAddress sdk.AccAddress, granteeName string, hotkeyPassword string) *Keys {
return &Keys{
signerName: granteeName,
kb: kb,
Expand Down Expand Up @@ -102,7 +102,7 @@ func getKeybase(zetaCoreHome string, reader io.Reader, keyringBackend config.Key
backend = ckeys.BackendFile
}

return ckeys.New(sdkTypes.KeyringServiceName(), backend, cliDir, reader, cdc)
return ckeys.New(sdk.KeyringServiceName(), backend, cliDir, reader, cdc)
}

// GetSignerInfo return signer info
Expand All @@ -115,11 +115,11 @@ func (k *Keys) GetSignerInfo() *ckeys.Record {
return info
}

func (k *Keys) GetOperatorAddress() sdkTypes.AccAddress {
func (k *Keys) GetOperatorAddress() sdk.AccAddress {
return k.OperatorAddress
}

func (k *Keys) GetAddress() sdkTypes.AccAddress {
func (k *Keys) GetAddress() sdk.AccAddress {
signer := GetGranteeKeyName(k.signerName)
info, err := k.kb.Key(signer)
if err != nil {
Expand Down Expand Up @@ -164,11 +164,11 @@ func (k *Keys) GetPubKeySet(password string) (common.PubKeySet, error) {

s, err := cosmos.Bech32ifyPubKey(cosmos.Bech32PubKeyTypeAccPub, pK.PubKey())
if err != nil {
return pubkeySet, errors2.ErrBech32ifyPubKey
return pubkeySet, zetaerrors.ErrBech32ifyPubKey
}
pubkey, err := common.NewPubKey(s)
if err != nil {
return pubkeySet, errors2.ErrNewPubKey
return pubkeySet, zetaerrors.ErrNewPubKey
}
pubkeySet.Secp256k1 = pubkey
return pubkeySet, nil
Expand All @@ -190,7 +190,7 @@ func SetupConfigForTest() {
config.SetBech32PrefixForConsensusNode(cmd.Bech32PrefixConsAddr, cmd.Bech32PrefixConsPub)
//config.SetCoinType(cmd.MetaChainCoinType)
config.SetFullFundraiserPath(cmd.ZetaChainHDPath)
sdkTypes.SetCoinDenomRegex(func() string {
sdk.SetCoinDenomRegex(func() string {
return cmd.DenomRegex
})
}
14 changes: 7 additions & 7 deletions zetaclient/outtxprocessor/out_tx_processor_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog"
)

type Manager struct {
type Processor struct {
outTxStartTime map[string]time.Time
outTxEndTime map[string]time.Time
outTxActive map[string]struct{}
Expand All @@ -17,8 +17,8 @@ type Manager struct {
numActiveProcessor int64
}

func NewOutTxProcessorManager(logger zerolog.Logger) *Manager {
return &Manager{
func NewOutTxProcessorManager(logger zerolog.Logger) *Processor {
return &Processor{
outTxStartTime: make(map[string]time.Time),
outTxEndTime: make(map[string]time.Time),
outTxActive: make(map[string]struct{}),
Expand All @@ -28,7 +28,7 @@ func NewOutTxProcessorManager(logger zerolog.Logger) *Manager {
}
}

func (outTxMan *Manager) StartTryProcess(outTxID string) {
func (outTxMan *Processor) StartTryProcess(outTxID string) {
outTxMan.mu.Lock()
defer outTxMan.mu.Unlock()
outTxMan.outTxStartTime[outTxID] = time.Now()
Expand All @@ -37,7 +37,7 @@ func (outTxMan *Manager) StartTryProcess(outTxID string) {
outTxMan.Logger.Info().Msgf("StartTryProcess %s, numActiveProcessor %d", outTxID, outTxMan.numActiveProcessor)
}

func (outTxMan *Manager) EndTryProcess(outTxID string) {
func (outTxMan *Processor) EndTryProcess(outTxID string) {
outTxMan.mu.Lock()
defer outTxMan.mu.Unlock()
outTxMan.outTxEndTime[outTxID] = time.Now()
Expand All @@ -46,14 +46,14 @@ func (outTxMan *Manager) EndTryProcess(outTxID string) {
outTxMan.Logger.Info().Msgf("EndTryProcess %s, numActiveProcessor %d, time elapsed %s", outTxID, outTxMan.numActiveProcessor, time.Since(outTxMan.outTxStartTime[outTxID]))
}

func (outTxMan *Manager) IsOutTxActive(outTxID string) bool {
func (outTxMan *Processor) IsOutTxActive(outTxID string) bool {
outTxMan.mu.Lock()
defer outTxMan.mu.Unlock()
_, found := outTxMan.outTxActive[outTxID]
return found
}

func (outTxMan *Manager) TimeInTryProcess(outTxID string) time.Duration {
func (outTxMan *Processor) TimeInTryProcess(outTxID string) time.Duration {
outTxMan.mu.Lock()
defer outTxMan.mu.Unlock()
if _, found := outTxMan.outTxActive[outTxID]; found {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zetasupplychecker
package supplychecker

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package zetasupplychecker_test
package supplychecker

import (
"os"
"testing"

"github.com/zeta-chain/zetacore/zetaclient/zetasupplychecker"

sdkmath "cosmossdk.io/math"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -48,7 +46,7 @@ func TestZetaSupplyChecker_ValidateZetaSupply(t *testing.T) {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
tc.validate(t, zetasupplychecker.ValidateZetaSupply(logger, tc.abortedTxAmount, tc.zetaInTransit, tc.genesisAmounts, tc.externalChainTotalSupply, tc.zetaTokenSupplyOnNode, tc.ethLockedAmount))
tc.validate(t, ValidateZetaSupply(logger, tc.abortedTxAmount, tc.zetaInTransit, tc.genesisAmounts, tc.externalChainTotalSupply, tc.zetaTokenSupplyOnNode, tc.ethLockedAmount))
})
}
}
10 changes: 5 additions & 5 deletions zetaclient/tss/tss_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
zcommon "github.com/zeta-chain/zetacore/common/cosmos"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
metricsPkg "github.com/zeta-chain/zetacore/zetaclient/metrics"
zetametrics "github.com/zeta-chain/zetacore/zetaclient/metrics"
)

const (
Expand Down Expand Up @@ -73,7 +73,7 @@ type TSS struct {
logger zerolog.Logger
Signers []string
CoreBridge interfaces.ZetaCoreBridger
Metrics *metricsPkg.ChainMetrics
Metrics *zetametrics.ChainMetrics

// TODO: support multiple Bitcoin network, not just one network
// https://github.com/zeta-chain/node/issues/1397
Expand All @@ -88,7 +88,7 @@ func NewTSS(
cfg *config.Config,
bridge interfaces.ZetaCoreBridger,
tssHistoricalList []observertypes.TSS,
metrics *metricsPkg.Metrics,
metrics *zetametrics.Metrics,
bitcoinChainID int64,
tssPassword string,
hotkeyPassword string,
Expand Down Expand Up @@ -427,8 +427,8 @@ func (tss *TSS) InsertPubKey(pk string) error {
return nil
}

func (tss *TSS) RegisterMetrics(metrics *metricsPkg.Metrics) error {
tss.Metrics = metricsPkg.NewChainMetrics("tss", metrics)
func (tss *TSS) RegisterMetrics(metrics *zetametrics.Metrics) error {
tss.Metrics = zetametrics.NewChainMetrics("tss", metrics)
keygenRes, err := tss.CoreBridge.GetKeyGen()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/zetacore_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (co *CoreObserver) startCctxScheduler() {

// scheduleCctxEVM schedules evm outtx keysign on each ZetaChain block (the ticker)
func (co *CoreObserver) scheduleCctxEVM(
outTxMan *outtxprocessor.Manager,
outTxMan *outtxprocessor.Processor,
zetaHeight uint64,
chainID int64,
cctxList []*types.CrossChainTx,
Expand Down Expand Up @@ -311,7 +311,7 @@ func (co *CoreObserver) scheduleCctxEVM(
// 2. schedule keysign only when nonce-mark UTXO is available
// 3. stop keysign when lookahead is reached
func (co *CoreObserver) scheduleCctxBTC(
outTxMan *outtxprocessor.Manager,
outTxMan *outtxprocessor.Processor,
zetaHeight uint64,
chainID int64,
cctxList []*types.CrossChainTx,
Expand Down

0 comments on commit 4226bfa

Please sign in to comment.