diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java index f4822ea111f..acd92c126a2 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/BeaconNodeReadinessManager.java @@ -77,6 +77,10 @@ public Iterator getFailoversInOrderOfReadin .iterator(); } + public SafeFuture performPrimaryReadinessCheck() { + return performReadinessCheck(primaryBeaconNodeApi, true); + } + @Override protected SafeFuture doStart() { return performReadinessCheckAgainstAllNodes(); @@ -136,10 +140,6 @@ private SafeFuture performReadinessCheckAgainstAllNodes() { return SafeFuture.allOf(primaryReadinessCheck, SafeFuture.allOf(failoverReadinessChecks)); } - private SafeFuture performPrimaryReadinessCheck() { - return performReadinessCheck(primaryBeaconNodeApi, true); - } - private SafeFuture performFailoverReadinessCheck(final RemoteValidatorApiChannel failover) { return performReadinessCheck(failover, false); } diff --git a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java index dd3abeddd3c..a3cebd8817c 100644 --- a/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java +++ b/validator/remote/src/main/java/tech/pegasys/teku/validator/remote/eventsource/EventSourceBeaconChainEventAdapter.java @@ -180,16 +180,22 @@ private synchronized void switchToFailoverEventStreamIfAvailable() { private void findReadyFailoverAndSwitch() { failoverBeaconNodeApis.stream() .filter(beaconNodeReadinessManager::isReady) + .filter(failover -> !currentEventStreamHasSameEndpoint(failover)) .findFirst() .ifPresentOrElse( this::switchToFailoverEventStream, - validatorLogger::noFailoverBeaconNodesAvailableForEventStreaming); + () -> { + validatorLogger.noFailoverBeaconNodesAvailableForEventStreaming(); + // if no failover switching is available, and we are currently connected to a failover + // event stream which has issues, trigger the readiness check against the primary BN + // immediately in the background + if (!currentEventStreamHasSameEndpoint(primaryBeaconNodeApi)) { + beaconNodeReadinessManager.performPrimaryReadinessCheck(); + } + }); } private void switchToFailoverEventStream(final RemoteValidatorApiChannel beaconNodeApi) { - if (currentEventStreamHasSameEndpoint(beaconNodeApi)) { - return; - } eventSource.close(); eventSource = createEventSource(beaconNodeApi); currentBeaconNodeUsedForEventStreaming = beaconNodeApi;