From 4fc5dbc15fff4bad2e44e0ab19c729230103bf4d Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 26 Apr 2024 14:12:53 +0200 Subject: [PATCH] review comments --- zetaclient/bitcoin/bitcoin_client.go | 12 ++---------- zetaclient/config/types_test.go | 1 + zetaclient/evm/evm_client.go | 2 ++ zetaclient/evm/evm_signer.go | 5 +++-- zetaclient/interfaces/signer.go | 2 ++ zetaclient/keys/keys.go | 13 ------------- zetaclient/keys/keys_test.go | 12 ++++++++++++ zetaclient/supplychecker/validate.go | 8 ++------ 8 files changed, 24 insertions(+), 31 deletions(-) create mode 100644 zetaclient/config/types_test.go diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index ffe22c008f..4f57bc2a7a 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -62,6 +62,8 @@ const ( var _ interfaces.ChainClient = &BTCChainClient{} // BTCLogger contains list of loggers used by Bitcoin chain client +// TODO: Merge this logger with the one in evm +// https://github.com/zeta-chain/node/issues/2022 type BTCLogger struct { // Chain is the parent logger for the chain Chain zerolog.Logger @@ -453,16 +455,6 @@ func (ob *BTCChainClient) ObserveInTx() error { ob.logger.InTx.Info().Msgf("observeInTxBTC: block %d has %d txs, current block %d, last block %d", blockNumber, len(res.Block.Tx), cnt, lastScanned) - // print some debug information - if len(res.Block.Tx) > 1 { - for idx, tx := range res.Block.Tx { - ob.logger.InTx.Debug().Msgf("BTC InTX | %d: %s\n", idx, tx.Txid) - for vidx, vout := range tx.Vout { - ob.logger.InTx.Debug().Msgf("vout %d \n value: %v\n scriptPubKey: %v\n", vidx, vout.Value, vout.ScriptPubKey.Hex) - } - } - } - // add block header to zetabridge // TODO: consider having a separate ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 diff --git a/zetaclient/config/types_test.go b/zetaclient/config/types_test.go new file mode 100644 index 0000000000..d7b82b3200 --- /dev/null +++ b/zetaclient/config/types_test.go @@ -0,0 +1 @@ +package config_test diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 878fb8e6b7..f86211fe60 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -48,6 +48,8 @@ import ( ) // Logger is the logger for evm chains +// TODO: Merge this logger with the one in bitcoin +// https://github.com/zeta-chain/node/issues/2022 type Logger struct { // Chain is the parent logger for the chain Chain zerolog.Logger diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index 1d441eaa55..9c2b0e1716 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -559,6 +559,9 @@ func (signer *Signer) SignWhitelistTx( // Exported for unit tests +// GetReportedTxList returns a list of outTxHash being reported +// TODO: investigate pointer usage +// https://github.com/zeta-chain/node/issues/2084 func (signer *Signer) GetReportedTxList() *map[string]bool { return &signer.outTxHashBeingReported } @@ -571,8 +574,6 @@ func (signer *Signer) EvmSigner() ethtypes.Signer { return signer.ethSigner } -// ________________________ - func IsSenderZetaChain(cctx *types.CrossChainTx, zetaBridge interfaces.ZetaCoreBridger, flags *observertypes.CrosschainFlags) bool { return cctx.InboundTxParams.SenderChainId == zetaBridge.ZetaChain().ChainId && cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound && flags.IsOutboundEnabled } diff --git a/zetaclient/interfaces/signer.go b/zetaclient/interfaces/signer.go index f9ed6227b4..11142f8087 100644 --- a/zetaclient/interfaces/signer.go +++ b/zetaclient/interfaces/signer.go @@ -19,6 +19,8 @@ type TSSSigner interface { // Sign signs the data // Note: it specifies optionalPubkey to use a different pubkey than the current pubkey set during keygen + // TODO: check if optionalPubkey is needed + // https://github.com/zeta-chain/node/issues/2085 Sign(data []byte, height uint64, nonce uint64, chain *chains.Chain, optionalPubkey string) ([65]byte, error) EVMAddress() ethcommon.Address diff --git a/zetaclient/keys/keys.go b/zetaclient/keys/keys.go index 3e8009acbe..4c3a4c48c1 100644 --- a/zetaclient/keys/keys.go +++ b/zetaclient/keys/keys.go @@ -14,7 +14,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/rs/zerolog/log" - "github.com/zeta-chain/zetacore/cmd" "github.com/zeta-chain/zetacore/pkg/cosmos" zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -164,18 +163,6 @@ func (k *Keys) GetHotkeyPassword() string { return "" } -func SetupConfigForTest() { - testConfig := sdk.GetConfig() - testConfig.SetBech32PrefixForAccount(cmd.Bech32PrefixAccAddr, cmd.Bech32PrefixAccPub) - testConfig.SetBech32PrefixForValidator(cmd.Bech32PrefixValAddr, cmd.Bech32PrefixValPub) - testConfig.SetBech32PrefixForConsensusNode(cmd.Bech32PrefixConsAddr, cmd.Bech32PrefixConsPub) - //config.SetCoinType(cmd.MetaChainCoinType) - testConfig.SetFullFundraiserPath(cmd.ZetaChainHDPath) - sdk.SetCoinDenomRegex(func() string { - return cmd.DenomRegex - }) -} - // getKeybase will create an instance of Keybase func getKeybase(zetaCoreHome string, reader io.Reader, keyringBackend config.KeyringBackend) (ckeys.Keyring, error) { cliDir := zetaCoreHome diff --git a/zetaclient/keys/keys_test.go b/zetaclient/keys/keys_test.go index 347195869f..0a0d2d7f6c 100644 --- a/zetaclient/keys/keys_test.go +++ b/zetaclient/keys/keys_test.go @@ -110,3 +110,15 @@ func (ks *KeysSuite) TestNewKeys(c *C) { c.Assert(err, IsNil) c.Assert(pubKey.VerifySignature([]byte(msg), signedMsg), Equals, true) } + +func SetupConfigForTest() { + testConfig := sdk.GetConfig() + testConfig.SetBech32PrefixForAccount(cmd.Bech32PrefixAccAddr, cmd.Bech32PrefixAccPub) + testConfig.SetBech32PrefixForValidator(cmd.Bech32PrefixValAddr, cmd.Bech32PrefixValPub) + testConfig.SetBech32PrefixForConsensusNode(cmd.Bech32PrefixConsAddr, cmd.Bech32PrefixConsPub) + //config.SetCoinType(cmd.MetaChainCoinType) + testConfig.SetFullFundraiserPath(cmd.ZetaChainHDPath) + sdk.SetCoinDenomRegex(func() string { + return cmd.DenomRegex + }) +} diff --git a/zetaclient/supplychecker/validate.go b/zetaclient/supplychecker/validate.go index 36c2ed68a5..089a34777e 100644 --- a/zetaclient/supplychecker/validate.go +++ b/zetaclient/supplychecker/validate.go @@ -24,11 +24,7 @@ func ValidateZetaSupply(logger zerolog.Logger, abortedTxAmounts, zetaInTransit, RHS: rhs, } defer logs.LogOutput() - if !lhs.Equal(rhs) { - logs.SupplyCheckSuccess = false - return false - } - logs.SupplyCheckSuccess = true - return true + logs.SupplyCheckSuccess = lhs.Equal(rhs) + return logs.SupplyCheckSuccess }