diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4d7cfbf9..c1ecca978e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Additions and Improvements - Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569) +- Add Blob Transaction Metrics [#7622](https://github.com/hyperledger/besu/pull/7622) ### Bug fixes - Fix mounted data path directory permissions for besu user [#7575](https://github.com/hyperledger/besu/pull/7575) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 1bd4f851f5..f699321efb 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -28,7 +28,6 @@ | Matthew Whitehead| matthew1001 | matthew.whitehead | | Meredith Baxter | mbaxter | mbaxter | | Stefan Pingel | pinges | pinges | -| Danno Ferrin | shemnon | shemnon | | Simon Dudley | siladu | siladu | | Usman Saleem | usmansaleem | usmansaleem | @@ -52,6 +51,7 @@ | Rai Sur | RatanRSur | ratanraisur | | Rob Dawson | rojotek | RobDawson | | Sajida Zouarhi | sajz | SajidaZ | +| Danno Ferrin | shemnon | shemnon | | Taccat Isid | taccatisid | taccatisid | | Tim Beiko | timbeiko | timbeiko | | Vijay Michalik | vmichalik | VijayMichalik | diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/BlobCache.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/BlobCache.java index 3d3a435f1f..1cca3f5ee2 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/BlobCache.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/BlobCache.java @@ -91,4 +91,8 @@ public class BlobCache { public BlobsWithCommitments.BlobQuad get(final VersionedHash vh) { return cache.getIfPresent(vh); } + + public long size() { + return cache.estimatedSize(); + } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index 315f82921b..7bbf1abe3b 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -129,6 +129,7 @@ public class TransactionPool implements BlockAddedObserver { this.blockAddedEventOrderedProcessor = ethContext.getScheduler().createOrderedProcessor(this::processBlockAddedEvent); this.cacheForBlobsOfTransactionsAddedToABlock = blobCache; + initializeBlobMetrics(); initLogForReplay(); subscribePendingTransactions(this::mapBlobsOnTransactionAdded); subscribeDroppedTransactions(this::unmapBlobsOnTransactionDropped); @@ -686,6 +687,19 @@ public class TransactionPool implements BlockAddedObserver { return isPoolEnabled.get(); } + public int getBlobCacheSize() { + return (int) cacheForBlobsOfTransactionsAddedToABlock.size(); + } + + public int getBlobMapSize() { + return mapOfBlobsInTransactionPool.size(); + } + + private void initializeBlobMetrics() { + metrics.createBlobCacheSizeMetric(this::getBlobCacheSize); + metrics.createBlobMapSizeMetric(this::getBlobMapSize); + } + class PendingTransactionsListenersProxy { private final Subscribers onAddedListeners = Subscribers.create(); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolMetrics.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolMetrics.java index e08805551f..fac9b3174d 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolMetrics.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolMetrics.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.plugin.services.metrics.LabelledMetric; import java.util.HashMap; import java.util.Map; import java.util.function.DoubleSupplier; +import java.util.function.IntSupplier; import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; @@ -285,4 +286,20 @@ public class TransactionPoolMetrics { private String priority(final boolean hasPriority) { return hasPriority ? "yes" : "no"; } + + public void createBlobCacheSizeMetric(final IntSupplier sizeSupplier) { + metricsSystem.createIntegerGauge( + BesuMetricCategory.TRANSACTION_POOL, + "blob_cache_size", + "Current size of the blob cache", + sizeSupplier); + } + + public void createBlobMapSizeMetric(final IntSupplier sizeSupplier) { + metricsSystem.createIntegerGauge( + BesuMetricCategory.TRANSACTION_POOL, + "blob_map_size", + "Current size of the blob map", + sizeSupplier); + } }