Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@

### Bug Fixes
- Added a startup script for unix systems to ensure that when jemalloc is installed the script sets the LD_PRELOAD environment variable to the use the jemalloc library
- Set `is_syncing` to `false` instead of `true` for the `/eth/v1/node/syncing` API endpoint when the head is optimistic and the sync distance is 0
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ public SyncStatusData(
final ExecutionClientDataProvider executionClientDataProvider) {
final SyncingStatus status = syncProvider.getSyncingStatus();
final SyncState syncState = syncProvider.getCurrentSyncState();
this.isSyncing = !syncState.isInSync();
this.slotsBehind = calculateSlotsBehind(status, syncState);
this.isSyncing = !slotsBehind.isZero();
this.elOffline = Optional.of(!executionClientDataProvider.isExecutionClientAvailable());
this.isOptimistic = Optional.of(syncState.isOptimistic());
this.currentSlot = status.getCurrentSlot();
// do this last, after isSyncing is calculated
this.slotsBehind = calculateSlotsBehind(status);
}

SyncStatusData(
Expand Down Expand Up @@ -138,8 +137,9 @@ public UInt64 getSlotsBehind() {
return slotsBehind;
}

private UInt64 calculateSlotsBehind(final SyncingStatus syncingStatus) {
if (isSyncing && syncingStatus.getHighestSlot().isPresent()) {
private UInt64 calculateSlotsBehind(
final SyncingStatus syncingStatus, final SyncState syncState) {
if (!syncState.isInSync() && syncingStatus.getHighestSlot().isPresent()) {
final UInt64 highestSlot = syncingStatus.getHighestSlot().get();
return highestSlot.minusMinZero(syncingStatus.getCurrentSlot());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ public void shouldGetSyncStatusInSync() throws Exception {
.isEqualTo(new GetSyncing.SyncStatusData(false, false, false, 10, 0));
}

@Test
public void shouldGetSyncStatusInSyncWhenHeadIsOptimistic() throws Exception {
when(syncService.getSyncStatus()).thenReturn(getSyncStatus(false, 1, 10, 10));
when(syncService.getCurrentSyncState()).thenReturn(SyncState.OPTIMISTIC_SYNCING);

handler.handleRequest(request);
assertThat(request.getResponseCode()).isEqualTo(SC_OK);
assertThat(request.getResponseBody())
.isEqualTo(new GetSyncing.SyncStatusData(false, true, false, 10, 0));
}

@Test
public void shouldGetElOffline() throws Exception {
when(syncService.getSyncStatus()).thenReturn(getSyncStatus(false, 1, 10, 11));
Expand Down
Loading