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
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public Task<ResultWrapper<IEnumerable<BlobAndProofV2>>> HandleAsync(byte[][] req
return ResultWrapper<IEnumerable<BlobAndProofV2>>.Fail(error, MergeErrorCodes.TooLargeRequest);
}

Metrics.NumberOfRequestedBlobs += request.Length;
Metrics.GetBlobsRequestsTotal += request.Length;

var count = txPool.GetBlobCounts(request);
Metrics.GetBlobsRequestsInBlobpoolTotal += count;

// quick fail if we don't have some blob
if (!txPool.AreBlobsAvailable(request))
if (count != request.Length)
{
return ReturnEmptyArray();
}
Expand All @@ -46,14 +49,13 @@ public Task<ResultWrapper<IEnumerable<BlobAndProofV2>>> HandleAsync(byte[][] req
}
}

Metrics.NumberOfSentBlobs += request.Length;
Metrics.NumberOfGetBlobsSuccesses++;
Metrics.GetBlobsRequestsSuccessTotal++;
return ResultWrapper<IEnumerable<BlobAndProofV2>>.Success(response.ToList());
}

private ResultWrapper<IEnumerable<BlobAndProofV2>> ReturnEmptyArray()
{
Metrics.NumberOfGetBlobsFailures++;
Metrics.GetBlobsRequestsFailureTotal++;
return ResultWrapper<IEnumerable<BlobAndProofV2>>.Success([]);
}
}
16 changes: 14 additions & 2 deletions src/Nethermind/Nethermind.Merge.Plugin/Metrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,22 @@ public static class Metrics

[GaugeMetric]
[Description("Number of responses to engine_getBlobsV1 and engine_getBlobsV2 with all requested blobs")]
public static int NumberOfGetBlobsSuccesses { get; set; }
public static int GetBlobsRequestsSuccessTotal { get; set; }

[GaugeMetric]
[Description("Number of responses to engine_getBlobsV1 and engine_getBlobsV2 without all requested blobs")]
public static int NumberOfGetBlobsFailures { get; set; }
public static int GetBlobsRequestsFailureTotal { get; set; }

[CounterMetric]
[Description("Number of Blobs requested by engine_getBlobsV2")]
public static int GetBlobsRequestsTotal { get; set; }

[CounterMetric]
[Description("Number of Blobs requested by engine_getBlobsV2 that are present in the blobpool")]
public static int GetBlobsRequestsInBlobpoolTotal { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have similar metrics already - GetBlobsRequestsTotal is like NumberOfRequestedBlobs and GetBlobsRequestsInBlobpoolTotal is like NumberOfSentBlobs.
But I think it is reasonable to introduce new, standardized metrics for engine_getBlobsV2, while keep using old ones only for engine_getBlobsV1


[GaugeMetric]
[Description("Time taken to return the blobs from engine_getBlobsV2 request")]
public static long GetBlobsRequestDurationSeconds { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@ public bool TryGetBlobAndProofV2(byte[] requestedBlobVersionedHash,
return false;
}

public bool AreBlobsAvailable(byte[][] requestedBlobVersionedHashes)
public int GetBlobCounts(byte[][] requestedBlobVersionedHashes)
{
using var lockRelease = Lock.Acquire();
int count = 0;

foreach (byte[] requestedBlobVersionedHash in requestedBlobVersionedHashes)
{
if (!BlobIndex.TryGetValue(requestedBlobVersionedHash, out _))
if (BlobIndex.ContainsKey(requestedBlobVersionedHash))
{
return false;
count += 1;
}
}

return true;
return count;
}

protected override bool InsertCore(ValueHash256 key, Transaction value, AddressAsKey groupKey)
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.TxPool/ITxPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ bool TryGetBlobAndProof(byte[] blobVersionedHash,
bool TryGetBlobAndProofV2(byte[] blobVersionedHash,
[NotNullWhen(true)] out byte[]? blob,
[NotNullWhen(true)] out byte[][]? cellProofs);
bool AreBlobsAvailable(byte[][] blobVersionedHashes);
int GetBlobCounts(byte[][] blobVersionedHashes);
UInt256 GetLatestPendingNonce(Address address);
event EventHandler<TxEventArgs> NewDiscovered;
event EventHandler<TxEventArgs> NewPending;
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.TxPool/NullTxPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public bool TryGetBlobAndProofV2(byte[] blobVersionedHash,
return false;
}

public bool AreBlobsAvailable(byte[][] blobVersionedHashes) => false;
public int GetBlobCounts(byte[][] blobVersionedHashes) => 0;

public UInt256 GetLatestPendingNonce(Address address) => 0;

Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.TxPool/TxPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public bool TryGetBlobAndProofV2(byte[] blobVersionedHash,
[NotNullWhen(true)] out byte[][]? cellProofs)
=> _blobTransactions.TryGetBlobAndProofV2(blobVersionedHash, out blob, out cellProofs);

public bool AreBlobsAvailable(byte[][] blobVersionedHashes)
=> _blobTransactions.AreBlobsAvailable(blobVersionedHashes);
public int GetBlobCounts(byte[][] blobVersionedHashes)
=> _blobTransactions.GetBlobCounts(blobVersionedHashes);

private void OnRemovedTx(object? sender, SortedPool<ValueHash256, Transaction, AddressAsKey>.SortedPoolRemovedEventArgs args)
{
Expand Down