Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tss metrics #1163

Merged
merged 27 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8035ebb
modify config for mainnet
kingpinXD Sep 15, 2023
5e39da3
Modify MinObserverDelegation to 1000000000000000000000
kingpinXD Sep 15, 2023
346f553
set chain id to 70000
kingpinXD Sep 15, 2023
1df15f8
add mainnet config
kingpinXD Sep 15, 2023
fdd1848
add mainnet config
kingpinXD Sep 15, 2023
91c5c3c
add mock mainnet config
kingpinXD Sep 18, 2023
8a842c0
modify confirmation times for BSC
kingpinXD Sep 18, 2023
b356dd1
Merge branch 'develop' into mocknet-testing
kingpinXD Sep 19, 2023
adf447e
Merge branch 'develop' into mocknet-testing
kingpinXD Sep 19, 2023
131e355
remove zetachain from config (#1148)
kingpinXD Sep 20, 2023
9128af6
Merge branch 'develop' into mocknet-testing
kingpinXD Sep 20, 2023
f433749
add nosec rule for config
kingpinXD Sep 20, 2023
396187e
Merge branch 'develop' into mocknet-testing
kingpinXD Sep 20, 2023
04958c8
removed check for ZetaTokenContractAddress if receiver chain is ZetaC…
kingpinXD Sep 21, 2023
cf24d77
Merge branch 'develop' into mocknet-testing
kingpinXD Sep 21, 2023
83c7867
skip stopping chain client for zetachain
kingpinXD Sep 21, 2023
a35e398
Merge remote-tracking branch 'origin/mocknet-testing' into mocknet-te…
kingpinXD Sep 21, 2023
4db69ab
skip stopping chain client for zetachain
kingpinXD Sep 21, 2023
c03e0d4
Merge branch 'develop' into fix/tss-metrics
kingpinXD Sep 21, 2023
3b6087b
add chainm id to log line for keygen
kingpinXD Sep 21, 2023
9b6438e
Merge remote-tracking branch 'origin/fix/tss-metrics' into fix/tss-me…
kingpinXD Sep 21, 2023
edddfd8
update zetabridge chain id from core
kingpinXD Sep 21, 2023
652dc3a
fix logic for query retries
kingpinXD Sep 21, 2023
76a959a
fix logic for query retries
kingpinXD Sep 21, 2023
085ba36
fix lint
kingpinXD Sep 21, 2023
03df870
fix stoping core observers
kingpinXD Sep 21, 2023
5e0172d
Merge branch 'develop' into fix/tss-metrics
kingpinXD Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import (
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
mc "github.com/zeta-chain/zetacore/zetaclient"
"github.com/zeta-chain/zetacore/zetaclient/config"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
tsscommon "gitlab.com/thorchain/tss/go-tss/common"
"gitlab.com/thorchain/tss/go-tss/keygen"
"gitlab.com/thorchain/tss/go-tss/p2p"
)

func GenerateTss(logger zerolog.Logger, cfg *config.Config, zetaBridge *mc.ZetaCoreBridge, peers p2p.AddrList, priKey secp256k1.PrivKey, ts *mc.TelemetryServer, tssHistoricalList []types.TSS) (*mc.TSS, error) {
func GenerateTss(logger zerolog.Logger, cfg *config.Config, zetaBridge *mc.ZetaCoreBridge, peers p2p.AddrList, priKey secp256k1.PrivKey, ts *mc.TelemetryServer, tssHistoricalList []types.TSS, metrics *metrics.Metrics) (*mc.TSS, error) {
keygenLogger := logger.With().Str("module", "keygen").Logger()
tss, err := mc.NewTSS(peers, priKey, preParams, cfg, zetaBridge, tssHistoricalList)
tss, err := mc.NewTSS(peers, priKey, preParams, cfg, zetaBridge, tssHistoricalList, metrics)
if err != nil {
keygenLogger.Error().Err(err).Msg("NewTSS error")
return nil, err
Expand Down Expand Up @@ -69,7 +70,7 @@ func GenerateTss(logger zerolog.Logger, cfg *config.Config, zetaBridge *mc.ZetaC
if currentBlock != keyGen.BlockNumber {
if currentBlock > lastBlock {
lastBlock = currentBlock
keygenLogger.Info().Msgf("Waiting For Keygen Block to arrive or new keygen block to be set. Keygen Block : %d Current Block : %d", keyGen.BlockNumber, currentBlock)
keygenLogger.Info().Msgf("Waiting For Keygen Block to arrive or new keygen block to be set. Keygen Block : %d Current Block : %d ChainID %s ", keyGen.BlockNumber, currentBlock, cfg.ChainID)
}
continue
}
Expand Down
31 changes: 13 additions & 18 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func start(_ *cobra.Command, _ []string) error {
if strings.Compare(res.GetDefaultNodeInfo().Network, cfg.ChainID) != 0 {
startLogger.Warn().Msgf("chain id mismatch, zeta-core chain id %s, zeta client chain id %s; reset zeta client chain id", res.GetDefaultNodeInfo().Network, cfg.ChainID)
cfg.ChainID = res.GetDefaultNodeInfo().Network
zetaBridge.UpdateChainID(cfg.ChainID)
}

// CreateAuthzSigner : which is used to sign all authz messages . All votes broadcast to zetacore are wrapped in authz exec .
Expand Down Expand Up @@ -135,14 +136,22 @@ func start(_ *cobra.Command, _ []string) error {
startLogger.Error().Err(err).Msg("telemetryServer error")
}
}()

metrics, err := metrics2.NewMetrics()
if err != nil {
log.Error().Err(err).Msg("NewMetrics")
return err
}
metrics.Start()

var tssHistoricalList []types.TSS
tssHistoricalList, err = zetaBridge.GetTssHistory()
if err != nil {
startLogger.Error().Err(err).Msg("GetTssHistory error")
}

telemetryServer.SetIPAddress(cfg.PublicIP)
tss, err := GenerateTss(masterLogger, cfg, zetaBridge, peers, priKey, telemetryServer, tssHistoricalList)
tss, err := GenerateTss(masterLogger, cfg, zetaBridge, peers, priKey, telemetryServer, tssHistoricalList, metrics)
if err != nil {
return err
}
Expand Down Expand Up @@ -204,23 +213,9 @@ func start(_ *cobra.Command, _ []string) error {
return err
}

metrics, err := metrics2.NewMetrics()
if err != nil {
log.Error().Err(err).Msg("NewMetrics")
return err
}
metrics.Start()

userDir, _ := os.UserHomeDir()
dbpath := filepath.Join(userDir, ".zetaclient/chainobserver")

// Register zetaclient.TSS prometheus metrics
err = tss.RegisterMetrics(metrics)
if err != nil {
startLogger.Err(err).Msg("tss.RegisterMetrics")
return err
}

// CreateChainClientMap : This creates a map of all chain clients . Each chain client is responsible for listening to events on the chain and processing them
chainClientMap, err := CreateChainClientMap(zetaBridge, tss, dbpath, metrics, masterLogger, cfg, telemetryServer)
if err != nil {
Expand All @@ -244,10 +239,10 @@ func start(_ *cobra.Command, _ []string) error {
// stop zetacore observer
for _, chain := range cfg.GetEnabledChains() {
// zeta chain does not have a chain client
if chain.IsZetaChain() {
continue
if chain.IsExternalChain() {
(chainClientMap)[chain].Stop()
}
(chainClientMap)[chain].Stop()

}
zetaBridge.Stop()

Expand Down
21 changes: 13 additions & 8 deletions zetaclient/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ func (b *ZetaCoreBridge) GetCctxByNonce(chainID int64, nonce uint64) (*types.Cro

func (b *ZetaCoreBridge) GetObserverList(chain common.Chain) ([]string, error) {
client := zetaObserverTypes.NewQueryClient(b.grpcConn)
resp, err := client.ObserversByChain(context.Background(), &zetaObserverTypes.QueryObserversByChainRequest{
ObservationChain: chain.ChainName.String(),
})
err := error(nil)
for i := 0; i <= DefaultRetryCount; i++ {
resp, err := client.ObserversByChain(context.Background(), &zetaObserverTypes.QueryObserversByChainRequest{ObservationChain: chain.ChainName.String()})
if err == nil {
return resp.Observers, nil
}
Expand Down Expand Up @@ -166,8 +165,9 @@ func (b *ZetaCoreBridge) GetLatestZetaBlock() (*tmtypes.Block, error) {

func (b *ZetaCoreBridge) GetNodeInfo() (*tmservice.GetNodeInfoResponse, error) {
client := tmservice.NewServiceClient(b.grpcConn)
res, err := client.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
err := error(nil)
for i := 0; i <= DefaultRetryCount; i++ {
res, err := client.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
if err == nil {
return res, nil
}
Expand Down Expand Up @@ -215,11 +215,16 @@ func (b *ZetaCoreBridge) GetAllNodeAccounts() ([]*zetaObserverTypes.NodeAccount,

func (b *ZetaCoreBridge) GetKeyGen() (*zetaObserverTypes.Keygen, error) {
client := zetaObserverTypes.NewQueryClient(b.grpcConn)
resp, err := client.Keygen(context.Background(), &zetaObserverTypes.QueryGetKeygenRequest{})
if err != nil {
return nil, err
err := error(nil)
for i := 0; i <= ExtendedRetryCount; i++ {
resp, err := client.Keygen(context.Background(), &zetaObserverTypes.QueryGetKeygenRequest{})
if err == nil {
return resp.Keygen, nil
}
time.Sleep(DefaultRetryInterval * time.Second)
}
return resp.Keygen, nil
return nil, fmt.Errorf("failed to get keygen | err %s", err.Error())

}

func (b *ZetaCoreBridge) GetCurrentTss() (*types.TSS, error) {
Expand Down
8 changes: 7 additions & 1 deletion zetaclient/tss_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string) (*btcutil.AddressWitnessPu
return addr, nil
}

func NewTSS(peer p2p.AddrList, privkey tmcrypto.PrivKey, preParams *keygen.LocalPreParams, cfg *config.Config, bridge *ZetaCoreBridge, tssHistoricalList []types.TSS) (*TSS, error) {
func NewTSS(peer p2p.AddrList, privkey tmcrypto.PrivKey, preParams *keygen.LocalPreParams, cfg *config.Config, bridge *ZetaCoreBridge, tssHistoricalList []types.TSS, metrics *metrics.Metrics) (*TSS, error) {
server, err := SetupTSSServer(peer, privkey, preParams, cfg)
if err != nil {
return nil, fmt.Errorf("SetupTSSServer error: %w", err)
Expand All @@ -390,6 +390,12 @@ func NewTSS(peer p2p.AddrList, privkey tmcrypto.PrivKey, preParams *keygen.Local
if err != nil {
bridge.logger.Error().Err(err).Msg("VerifyKeysharesForPubkeys fail")
}
err = newTss.RegisterMetrics(metrics)
if err != nil {
bridge.logger.Err(err).Msg("tss.RegisterMetrics")
return nil, err
}

return &newTss, nil
}

Expand Down
1 change: 1 addition & 0 deletions zetaclient/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
DefaultGasLimit = 200_000
PostProveOutboundTxGasLimit = 400_000
DefaultRetryCount = 5
ExtendedRetryCount = 15
DefaultRetryInterval = 5
)

Expand Down
8 changes: 7 additions & 1 deletion zetaclient/zetabridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ func MakeLegacyCodec() *codec.LegacyAmino {
return cdc
}

func (b *ZetaCoreBridge) UpdateChainID(chainID string) {
if b.zetaChainID != chainID {
b.zetaChainID = chainID
}
}

func (b *ZetaCoreBridge) Stop() {
b.logger.Info().Msgf("ZetaBridge is stopping")
close(b.stop) // this notifies all configupdater to stop
Expand Down Expand Up @@ -146,7 +152,7 @@ func (b *ZetaCoreBridge) WaitForCoreToCreateBlocks() {
}
retryCount++
b.logger.Debug().Msgf("Failed to get latest Block , Retry : %d/%d", retryCount, DefaultRetryCount)
if retryCount > DefaultRetryCount {
if retryCount > ExtendedRetryCount {
panic(fmt.Sprintf("ZetaCore is not ready , Waited for %d seconds", DefaultRetryCount*DefaultRetryInterval))
}
time.Sleep(DefaultRetryInterval * time.Second)
Expand Down
Loading