From 3a111e0f83c488e04fec081cc97bb56634b51ada Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Tue, 24 Sep 2024 12:56:21 -0500 Subject: [PATCH] add fields to log prints in method ValidateAddresses --- zetaclient/tss/tss_signer.go | 9 ++++++--- zetaclient/tss/tss_signer_test.go | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index cfd958f8fb..0c7daa98e7 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -415,7 +415,10 @@ func (tss *TSS) SignBatch( // ValidateAddresses try deriving both the EVM and BTC addresses from the pubkey and make sure they are valid. func (tss *TSS) ValidateAddresses(btcChainIDs []int64) error { - tss.logger.Info().Msgf("tss.pubkey: %s", tss.CurrentPubkey) + logger := tss.logger.With(). + Str("method", "ValidateAddresses"). + Str("tss.pubkey", tss.CurrentPubkey). + Logger() // validate TSS EVM address evmAddress := tss.EVMAddress() @@ -423,7 +426,7 @@ func (tss *TSS) ValidateAddresses(btcChainIDs []int64) error { if evmAddress == blankAddress { return fmt.Errorf("blank tss evm address: %s", evmAddress.String()) } - tss.logger.Info().Msgf("tss.eth: %s", tss.EVMAddress().String()) + logger.Info().Msgf("tss.eth: %s", evmAddress.String()) // validate TSS BTC address for each btc chain for _, chainID := range btcChainIDs { @@ -431,7 +434,7 @@ func (tss *TSS) ValidateAddresses(btcChainIDs []int64) error { if err != nil { return fmt.Errorf("cannot derive btc address for chain %d from tss pubkey %s", chainID, tss.CurrentPubkey) } - tss.logger.Info().Msgf("tss.btc [chain %d]: %s", chainID, address.EncodeAddress()) + logger.Info().Msgf("tss.btc [chain %d]: %s", chainID, address.EncodeAddress()) } return nil diff --git a/zetaclient/tss/tss_signer_test.go b/zetaclient/tss/tss_signer_test.go index c17caf8b63..8db9e64704 100644 --- a/zetaclient/tss/tss_signer_test.go +++ b/zetaclient/tss/tss_signer_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/rs/zerolog" + "github.com/rs/zerolog/log" "github.com/stretchr/testify/require" "github.com/zeta-chain/node/cmd" @@ -208,6 +209,7 @@ func Test_ValidateAddresses(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { tss := TSS{ + logger: log.Logger, CurrentPubkey: tc.tssPubkey, } err := tss.ValidateAddresses(tc.btcChainIDs)