From 7edcf0880522a6a00270c0e3682503f976e5a14a Mon Sep 17 00:00:00 2001 From: batphonghan Date: Fri, 16 Feb 2024 18:33:22 +0700 Subject: [PATCH 1/2] Wait for clients sync --- stader/node/node.go | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/stader/node/node.go b/stader/node/node.go index 373f1913..5b789334 100644 --- a/stader/node/node.go +++ b/stader/node/node.go @@ -404,19 +404,41 @@ func run(c *cli.Context) error { go func() { defer wg.Done() - privateKey, err := w.GetNodePrivateKey() - if err != nil { - errorLog.Printlnf("Error GetNodePrivateKey %+v", err) - return - } + for { + // Check the EC status + err := services.WaitEthClientSynced(c, false) // Force refresh the primary / fallback EC status + if err != nil { + errorLog.Println(err) + time.Sleep(nodeDiversityTrackerCooldown) - cfg, err := services.GetConfig(c) - if err != nil { - errorLog.Printlnf("Error getconfig %+v", err) - return - } + continue + } + + // Check the BC status + err = services.WaitBeaconClientSynced(c, false) // Force refresh the primary / fallback BC status + if err != nil { + errorLog.Println(err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } + + privateKey, err := w.GetNodePrivateKey() + if err != nil { + errorLog.Printlnf("Error GetNodePrivateKey %+v", err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } + + cfg, err := services.GetConfig(c) + if err != nil { + errorLog.Printlnf("Error getconfig %+v", err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } - for { infoLog.Printlnf("Running the node diversity tracker daemon") message, err := makeNodeDiversityMessage(ec, bc, pnr, w, cfg) From 58bae8361677831d2e78960eb68c6d0f12fc7b75 Mon Sep 17 00:00:00 2001 From: batphonghan Date: Fri, 16 Feb 2024 19:18:31 +0700 Subject: [PATCH 2/2] Add some log --- stader/node/node.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stader/node/node.go b/stader/node/node.go index 5b789334..2d2f72de 100644 --- a/stader/node/node.go +++ b/stader/node/node.go @@ -405,6 +405,8 @@ func run(c *cli.Context) error { defer wg.Done() for { + + infoLog.Println("Start checking node diversity metrics") // Check the EC status err := services.WaitEthClientSynced(c, false) // Force refresh the primary / fallback EC status if err != nil { @@ -472,6 +474,7 @@ func run(c *cli.Context) error { errorLog.Println("Failed to send the NodeDiversity message with err: %s\n", response.Error) } + infoLog.Println("Done checking node diversity metrics") time.Sleep(nodeDiversityTracker) } }()