Skip to content

Commit

Permalink
Adopt engineGetBlobs (#8663)
Browse files Browse the repository at this point in the history
* initial implementation

* improve

* better debug logging

* improve tests

* better error handling

* better error msg

* add changelog line

* missed toString change
  • Loading branch information
tbenr authored Oct 2, 2024
1 parent 210674e commit 4b204e4
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Updated LUKSO configuration with Deneb fork scheduled for epoch 123075 (November 20, 2024, 16:20:00 UTC)
- Support for `IDONTWANT` libp2p protocol messages
- `/eth/v1/node/peers` endpoint now populates `enr` field of the peer whenever is possible
- Support for `engine_getBlobsV1` to retrieve blobs using local execution layer. This will improve block import time when blobs are published late.

### Bug Fixes
- Removed a warning from logs about non blinded blocks being requested (#8562)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,19 @@ public SignedBeaconBlock randomSignedBeaconBlockWithCommitments(final int count)
return randomSignedBeaconBlockWithCommitments(randomBlobKzgCommitments(count));
}

public SignedBeaconBlock randomSignedBeaconBlockWithCommitments(
final UInt64 slot, final int count) {
return randomSignedBeaconBlockWithCommitments(slot, randomBlobKzgCommitments(count));
}

public SignedBeaconBlock randomSignedBeaconBlockWithCommitments(
final SszList<SszKZGCommitment> commitments) {
return randomSignedBeaconBlockWithCommitments(randomUInt64(), commitments);
}

public SignedBeaconBlock randomSignedBeaconBlockWithCommitments(
final UInt64 slot, final SszList<SszKZGCommitment> commitments) {
final UInt64 proposerIndex = randomUInt64();
final UInt64 slot = randomUInt64();
final Bytes32 stateRoot = randomBytes32();
final Bytes32 parentRoot = randomBytes32();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ interface ReceivedBlobSidecarListener {

enum RemoteOrigin {
RPC,
GOSSIP
GOSSIP,
LOCAL_EL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class BlockBlobSidecarsTracker {
private static final Logger LOG = LogManager.getLogger();
private static final UInt64 CREATION_TIMING_IDX = UInt64.MAX_VALUE;
private static final UInt64 BLOCK_ARRIVAL_TIMING_IDX = CREATION_TIMING_IDX.decrement();
private static final UInt64 FETCH_TIMING_IDX = BLOCK_ARRIVAL_TIMING_IDX.decrement();
private static final UInt64 RPC_FETCH_TIMING_IDX = BLOCK_ARRIVAL_TIMING_IDX.decrement();
private static final UInt64 LOCAL_EL_FETCH_TIMING_IDX = RPC_FETCH_TIMING_IDX.decrement();

private final SlotAndBlockRoot slotAndBlockRoot;
private final UInt64 maxBlobsPerBlock;
Expand All @@ -55,7 +56,8 @@ public class BlockBlobSidecarsTracker {
private final NavigableMap<UInt64, BlobSidecar> blobSidecars = new ConcurrentSkipListMap<>();
private final SafeFuture<Void> blobSidecarsComplete = new SafeFuture<>();

private volatile boolean fetchTriggered = false;
private volatile boolean rpcFetchTriggered = false;
private volatile boolean localElFetchTriggered = false;

private final Optional<Map<UInt64, Long>> maybeDebugTimings;

Expand Down Expand Up @@ -245,14 +247,24 @@ public boolean isCompleted() {
return blobSidecarsComplete.isDone();
}

public boolean isFetchTriggered() {
return fetchTriggered;
public boolean isRpcFetchTriggered() {
return rpcFetchTriggered;
}

public void setFetchTriggered() {
this.fetchTriggered = true;
public void setRpcFetchTriggered() {
this.rpcFetchTriggered = true;
maybeDebugTimings.ifPresent(
debugTimings -> debugTimings.put(FETCH_TIMING_IDX, System.currentTimeMillis()));
debugTimings -> debugTimings.put(RPC_FETCH_TIMING_IDX, System.currentTimeMillis()));
}

public boolean isLocalElFetchTriggered() {
return localElFetchTriggered;
}

public void setLocalElFetchTriggered() {
this.localElFetchTriggered = true;
maybeDebugTimings.ifPresent(
debugTimings -> debugTimings.put(LOCAL_EL_FETCH_TIMING_IDX, System.currentTimeMillis()));
}

private boolean areBlobsComplete() {
Expand Down Expand Up @@ -303,13 +315,22 @@ private void printDebugTimings(final Map<UInt64, Long> debugTimings) {
.append(debugTimings.getOrDefault(BLOCK_ARRIVAL_TIMING_IDX, 0L) - creationTime)
.append("ms - ");

if (debugTimings.containsKey(FETCH_TIMING_IDX)) {
if (debugTimings.containsKey(LOCAL_EL_FETCH_TIMING_IDX)) {
timingsReport
.append("Local EL fetch delay ")
.append(debugTimings.get(LOCAL_EL_FETCH_TIMING_IDX) - creationTime)
.append("ms - ");
} else {
timingsReport.append("Local EL fetch wasn't required - ");
}

if (debugTimings.containsKey(RPC_FETCH_TIMING_IDX)) {
timingsReport
.append("Fetch delay ")
.append(debugTimings.get(FETCH_TIMING_IDX) - creationTime)
.append("RPC fetch delay ")
.append(debugTimings.get(RPC_FETCH_TIMING_IDX) - creationTime)
.append("ms");
} else {
timingsReport.append("Fetch wasn't required");
timingsReport.append("RPC fetch wasn't required");
}

LOG.debug(timingsReport.toString());
Expand All @@ -321,7 +342,8 @@ public String toString() {
.add("slotAndBlockRoot", slotAndBlockRoot)
.add("isBlockPresent", block.get().isPresent())
.add("isCompleted", isCompleted())
.add("fetchTriggered", fetchTriggered)
.add("rpcFetchTriggered", rpcFetchTriggered)
.add("localElFetchTriggered", localElFetchTriggered)
.add("blockImportOnCompletionEnabled", blockImportOnCompletionEnabled.get())
.add(
"blobSidecars",
Expand Down
Loading

0 comments on commit 4b204e4

Please sign in to comment.