Skip to content

Commit

Permalink
[CORE-666] - Implement liquidations healthcheck (#738)
Browse files Browse the repository at this point in the history
Implement healthcheck in liquidations daemon, downgrade stale health from unhealthy to healthy + error log.
  • Loading branch information
clemire authored Nov 9, 2023
1 parent 52c8fb7 commit 410f73f
Show file tree
Hide file tree
Showing 11 changed files with 761 additions and 531 deletions.
7 changes: 4 additions & 3 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ type App struct {
// can correctly operate.
startDaemons func()

PriceFeedClient *pricefeedclient.Client
PriceFeedClient *pricefeedclient.Client
LiquidationsClient *liquidationclient.Client
}

// assertAppPreconditions assert invariants required for an application to start.
Expand Down Expand Up @@ -602,14 +603,14 @@ func New(
app.Server.ExpectLiquidationsDaemon(
daemonservertypes.MaximumAcceptableUpdateDelay(daemonFlags.Liquidation.LoopDelayMs),
)
app.LiquidationsClient = liquidationclient.NewClient(logger)
go func() {
if err := liquidationclient.Start(
if err := app.LiquidationsClient.Start(
// The client will use `context.Background` so that it can have a different context from
// the main application.
context.Background(),
daemonFlags,
appFlags,
logger,
&daemontypes.GrpcClientImpl{},
); err != nil {
panic(err)
Expand Down
16 changes: 11 additions & 5 deletions protocol/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ func TestAppIsFullyInitialized(t *testing.T) {
tApp.InitChain()
uninitializedFields := getUninitializedStructFields(reflect.ValueOf(*tApp.App))

// Note that the PriceFeedClient is currently hard coded as disabled in GetDefaultTestAppOptions.
// Normally it would be only disabled for non-validating full nodes or for nodes where the
// price feed client is explicitly disabled.
if idx := slices.Index(uninitializedFields, "PriceFeedClient"); idx >= 0 {
slices.Remove(&uninitializedFields, idx)
// Note that the daemon clients are currently hard coded as disabled in GetDefaultTestAppOptions.
// Normally they would be only disabled for non-validating full nodes or for nodes where any
// daemon is explicitly disabled.
expectedUninitializedFields := []string{
"PriceFeedClient",
"LiquidationsClient",
}
for _, field := range expectedUninitializedFields {
if idx := slices.Index(uninitializedFields, field); idx >= 0 {
slices.Remove(&uninitializedFields, idx)
}
}

require.Len(
Expand Down
Loading

0 comments on commit 410f73f

Please sign in to comment.