From de39ccb43ef6d66cf526b6aaf8887fab1a8f825c Mon Sep 17 00:00:00 2001 From: Itay Date: Sun, 2 Jul 2023 11:48:59 +0300 Subject: [PATCH] feat: Add Continuous Status Monitoring for DA LC and sequencer (#137) --- cmd/consts/consts.go | 8 +++++++- cmd/run/services_status.go | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cmd/consts/consts.go b/cmd/consts/consts.go index 5016df97..b6269831 100644 --- a/cmd/consts/consts.go +++ b/cmd/consts/consts.go @@ -1,6 +1,9 @@ package consts -import "fmt" +import ( + "fmt" + "math/big" +) const binsDir = "/usr/local/bin" @@ -88,3 +91,6 @@ const DefaultRollappRPC = "http://localhost:26657" const DefaultDALCRPC = "http://localhost:26659" const CelestiaRestApiEndpoint = "https://api-arabica-8.consensus.celestia-arabica.com" const DefaultCelestiaRPC = "consensus-full-arabica-8.celestia-arabica.com" + +// TODO: Check DA LC write price on arabica and update this value. +var OneDAWritePrice = big.NewInt(1) diff --git a/cmd/run/services_status.go b/cmd/run/services_status.go index 0bd00e01..7f30683a 100644 --- a/cmd/run/services_status.go +++ b/cmd/run/services_status.go @@ -29,22 +29,33 @@ func processDataResults(results chan fetchResult, size int, logger *log.Logger) return data } +func activeIfSufficientBalance(currentBalance, threshold *big.Int) string { + if currentBalance.Cmp(threshold) >= 0 { + return "Active" + } else { + return "Stopped" + } +} + func buildServiceData(data []*utils.AccountData, rollappConfig utils.RollappConfig) []ServiceData { + rolRlyData := data[2] return []ServiceData{ { Name: "Sequencer", Balance: data[0].Balance.String() + consts.Denoms.Hub, - Status: "Active", + // TODO: for now, we just check if the balance of the rollapp relayer is greater than 0 + // in the future, we should have a better way to check the rollapp health. + Status: activeIfSufficientBalance(rolRlyData.Balance, big.NewInt(1)), }, { Name: "DA Light Client", Balance: data[3].Balance.String() + consts.Denoms.Celestia, - Status: "Active", + Status: activeIfSufficientBalance(data[3].Balance, consts.OneDAWritePrice), }, { Name: "Relayer", Balance: data[1].Balance.String() + consts.Denoms.Hub + ", " + - data[2].Balance.String() + rollappConfig.Denom, + rolRlyData.Balance.String() + rollappConfig.Denom, Status: "Starting...", }, }