Skip to content

Commit

Permalink
Implemented status fetching for roller run
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayLevyOfficial committed Jun 29, 2023
1 parent 17698eb commit 70fc7d0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/.vscode
build/
*
!*/
!*.*
*.exe
\.*
/.vscode
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)
19 changes: 15 additions & 4 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 All @@ -65,7 +76,7 @@ func PrintServicesStatus(rollappConfig utils.RollappConfig) {
ui.Render(p, table)

events := ui.PollEvents()
ticker := time.NewTicker(time.Second * 5).C
ticker := time.NewTicker(time.Second * 1).C

config := ServiceStatusConfig{
rollappConfig: rollappConfig,
Expand Down

0 comments on commit 70fc7d0

Please sign in to comment.