Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Apr 26, 2024
1 parent 0120722 commit 4fc5dbc
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 31 deletions.
12 changes: 2 additions & 10 deletions zetaclient/bitcoin/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions zetaclient/config/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package config_test
2 changes: 2 additions & 0 deletions zetaclient/evm/evm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions zetaclient/evm/evm_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions zetaclient/interfaces/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions zetaclient/keys/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions zetaclient/keys/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
8 changes: 2 additions & 6 deletions zetaclient/supplychecker/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 4fc5dbc

Please sign in to comment.