Skip to content

Commit

Permalink
feat: Add Continuous Status Monitoring for DA LC and sequencer (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayLevyOfficial authored Jul 2, 2023
1 parent 998f4e4 commit de39ccb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cmd/consts/consts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package consts

import "fmt"
import (
"fmt"
"math/big"
)

const binsDir = "/usr/local/bin"

Expand Down Expand Up @@ -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)
17 changes: 14 additions & 3 deletions cmd/run/services_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
},
}
Expand Down

0 comments on commit de39ccb

Please sign in to comment.