mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 13:58:02 -05:00
block header cache not initialized before used (#7601)
Signed-off-by: Luis Pinto <luis.pinto@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
@@ -116,6 +116,37 @@ public class DefaultBlockchain implements MutableBlockchain {
|
||||
chainHeadTransactionCount = chainHeadBody.getTransactions().size();
|
||||
chainHeadOmmerCount = chainHeadBody.getOmmers().size();
|
||||
|
||||
this.reorgLoggingThreshold = reorgLoggingThreshold;
|
||||
this.blockChoiceRule = heaviestChainBlockChoiceRule;
|
||||
this.numberOfBlocksToCache = numberOfBlocksToCache;
|
||||
|
||||
if (numberOfBlocksToCache != 0) {
|
||||
blockHeadersCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
blockBodiesCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
transactionReceiptsCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
totalDifficultyCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
CacheMetricsCollector cacheMetrics = new CacheMetricsCollector();
|
||||
cacheMetrics.addCache("blockHeaders", blockHeadersCache.get());
|
||||
cacheMetrics.addCache("blockBodies", blockBodiesCache.get());
|
||||
cacheMetrics.addCache("transactionReceipts", transactionReceiptsCache.get());
|
||||
cacheMetrics.addCache("totalDifficulty", totalDifficultyCache.get());
|
||||
if (metricsSystem instanceof PrometheusMetricsSystem prometheusMetricsSystem)
|
||||
prometheusMetricsSystem.addCollector(BesuMetricCategory.BLOCKCHAIN, () -> cacheMetrics);
|
||||
} else {
|
||||
blockHeadersCache = Optional.empty();
|
||||
blockBodiesCache = Optional.empty();
|
||||
transactionReceiptsCache = Optional.empty();
|
||||
totalDifficultyCache = Optional.empty();
|
||||
}
|
||||
|
||||
metricsSystem.createLongGauge(
|
||||
BesuMetricCategory.ETHEREUM,
|
||||
"blockchain_height",
|
||||
@@ -179,37 +210,6 @@ public class DefaultBlockchain implements MutableBlockchain {
|
||||
"chain_head_ommer_count",
|
||||
"Number of ommers in the current chain head block",
|
||||
() -> chainHeadOmmerCount);
|
||||
|
||||
this.reorgLoggingThreshold = reorgLoggingThreshold;
|
||||
this.blockChoiceRule = heaviestChainBlockChoiceRule;
|
||||
this.numberOfBlocksToCache = numberOfBlocksToCache;
|
||||
|
||||
if (numberOfBlocksToCache != 0) {
|
||||
blockHeadersCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
blockBodiesCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
transactionReceiptsCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
totalDifficultyCache =
|
||||
Optional.of(
|
||||
CacheBuilder.newBuilder().recordStats().maximumSize(numberOfBlocksToCache).build());
|
||||
CacheMetricsCollector cacheMetrics = new CacheMetricsCollector();
|
||||
cacheMetrics.addCache("blockHeaders", blockHeadersCache.get());
|
||||
cacheMetrics.addCache("blockBodies", blockBodiesCache.get());
|
||||
cacheMetrics.addCache("transactionReceipts", transactionReceiptsCache.get());
|
||||
cacheMetrics.addCache("totalDifficulty", totalDifficultyCache.get());
|
||||
if (metricsSystem instanceof PrometheusMetricsSystem prometheusMetricsSystem)
|
||||
prometheusMetricsSystem.addCollector(BesuMetricCategory.BLOCKCHAIN, () -> cacheMetrics);
|
||||
} else {
|
||||
blockHeadersCache = Optional.empty();
|
||||
blockBodiesCache = Optional.empty();
|
||||
transactionReceiptsCache = Optional.empty();
|
||||
totalDifficultyCache = Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public static MutableBlockchain createMutable(
|
||||
|
||||
Reference in New Issue
Block a user