Skip to content

Commit

Permalink
add fields to log prints in method ValidateAddresses
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Sep 24, 2024
1 parent 7c5fbb9 commit 3a111e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions zetaclient/tss/tss_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,23 +415,26 @@ 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()
blankAddress := ethcommon.Address{}
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 {
address, err := tss.BTCAddress(chainID)
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
Expand Down
2 changes: 2 additions & 0 deletions zetaclient/tss/tss_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3a111e0

Please sign in to comment.