Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 8768-post
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone committed Dec 8, 2024
2 parents 4aed468 + 1b68e2b commit 54ed22d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ public synchronized boolean containsBlobSidecar(final BlobIdentifier blobIdentif
}

@Override
public Optional<BlobSidecar> getBlobSidecar(final Bytes32 blockRoot, final UInt64 index) {
public synchronized Optional<BlobSidecar> getBlobSidecar(
final Bytes32 blockRoot, final UInt64 index) {
return Optional.ofNullable(blockBlobSidecarsTrackers.get(blockRoot))
.flatMap(tracker -> tracker.getBlobSidecar(index));
}
Expand Down

0 comments on commit 54ed22d

Please sign in to comment.