diff --git a/gradle.properties b/gradle.properties index aa3f2215..9b84605e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ releaseVersion=0.8.0-rc4.1 -besuVersion=24.10-local +besuVersion=24.11-delivery37 arithmetizationVersion=0.8.0-rc4 besuArtifactGroup=io.consensys.linea-besu distributionIdentifier=linea-sequencer diff --git a/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityCliOptions.java b/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityCliOptions.java index 037c4a90..037b63f3 100644 --- a/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityCliOptions.java +++ b/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityCliOptions.java @@ -57,6 +57,12 @@ public class LineaProfitabilityCliOptions implements LineaCliOptions { "--plugin-linea-extra-data-set-min-gas-price-enabled"; public static final boolean DEFAULT_EXTRA_DATA_SET_MIN_GAS_PRICE_ENABLED = true; + public static final String PROFITABILITY_METRICS_BUCKETS = + "--plugin-linea-profitability-metrics-buckets"; + public static final double[] DEFAULT_PROFITABILITY_METRICS_BUCKETS = { + 0.9, 1.0, 1.2, 2, 5, 10, 100, 1000 + }; + @Positive @CommandLine.Option( names = {FIXED_GAS_COST_WEI}, @@ -135,6 +141,16 @@ public class LineaProfitabilityCliOptions implements LineaCliOptions { "Enable setting min gas price runtime value via extra data field (default: ${DEFAULT-VALUE})") private boolean extraDataSetMinGasPriceEnabled = DEFAULT_EXTRA_DATA_SET_MIN_GAS_PRICE_ENABLED; + @CommandLine.Option( + names = {PROFITABILITY_METRICS_BUCKETS}, + arity = "1..*", + split = ",", + hidden = true, + paramLabel = "", + description = + "List of buckets to use to create the histogram for profitability metrics (default: ${DEFAULT-VALUE})") + private double[] profitabilityMetricsBuckets = DEFAULT_PROFITABILITY_METRICS_BUCKETS; + private LineaProfitabilityCliOptions() {} /** @@ -164,6 +180,7 @@ public static LineaProfitabilityCliOptions fromConfig( options.txPoolCheckP2pEnabled = config.txPoolCheckP2pEnabled(); options.extraDataPricingEnabled = config.extraDataPricingEnabled(); options.extraDataSetMinGasPriceEnabled = config.extraDataSetMinGasPriceEnabled(); + options.profitabilityMetricsBuckets = config.profitabilityMetricsBuckets(); return options; } @@ -184,6 +201,7 @@ public LineaProfitabilityConfiguration toDomainObject() { .txPoolCheckP2pEnabled(txPoolCheckP2pEnabled) .extraDataPricingEnabled(extraDataPricingEnabled) .extraDataSetMinGasPriceEnabled(extraDataSetMinGasPriceEnabled) + .profitabilityMetricsBuckets(profitabilityMetricsBuckets) .build(); } @@ -199,6 +217,7 @@ public String toString() { .add(TX_POOL_ENABLE_CHECK_P2P, txPoolCheckP2pEnabled) .add(EXTRA_DATA_PRICING_ENABLED, extraDataPricingEnabled) .add(EXTRA_DATA_SET_MIN_GAS_PRICE_ENABLED, extraDataSetMinGasPriceEnabled) + .add(PROFITABILITY_METRICS_BUCKETS, profitabilityMetricsBuckets) .toString(); } } diff --git a/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java b/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java index 6aa5af24..012ad4d7 100644 --- a/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java +++ b/sequencer/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java @@ -33,6 +33,7 @@ public class LineaProfitabilityConfiguration implements LineaOptionsConfiguratio /** It is safe to keep this as long, since it will store value <= max_int * 1000 */ private long variableCostWei; + /** It is safe to keep this as long, since it will store value <= max_int * 1000 */ private long ethGasPriceWei; private double minMargin; @@ -42,6 +43,7 @@ public class LineaProfitabilityConfiguration implements LineaOptionsConfiguratio private boolean txPoolCheckP2pEnabled; private boolean extraDataPricingEnabled; private boolean extraDataSetMinGasPriceEnabled; + private double[] profitabilityMetricsBuckets; /** * These 2 parameters must be atomically updated diff --git a/sequencer/src/main/java/net/consensys/linea/metrics/HistogramMetrics.java b/sequencer/src/main/java/net/consensys/linea/metrics/HistogramMetrics.java index 0bcd51f3..87572463 100644 --- a/sequencer/src/main/java/net/consensys/linea/metrics/HistogramMetrics.java +++ b/sequencer/src/main/java/net/consensys/linea/metrics/HistogramMetrics.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.function.DoubleSupplier; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -32,16 +33,14 @@ @Slf4j public class HistogramMetrics { - public interface LabelValue { String value(); } - private static final double[] DEFAULT_HISTOGRAM_BUCKETS = {0.9, 1.0, 1.2, 2, 5, 10, 100, 1000}; private static final String LABEL_VALUES_SEPARATOR = "\u2060"; private final LabelledMetric histogram; - private final Map mins; - private final Map maxs; + private final Map mins; + private final Map maxs; @SafeVarargs public HistogramMetrics( @@ -49,6 +48,7 @@ public HistogramMetrics( final LineaMetricCategory category, final String name, final String help, + final double[] buckets, final Class... labels) { final var labelNames = getLabelNames(labels); @@ -64,19 +64,17 @@ public HistogramMetrics( maxs = HashMap.newHashMap(combinations.size()); for (final var combination : combinations) { final var key = String.join(LABEL_VALUES_SEPARATOR, combination); - mins.put(key, Double.POSITIVE_INFINITY); - minRatio.labels(() -> mins.get(key), combination); - maxs.put(key, 0.0); - maxRatio.labels(() -> maxs.get(key), combination); + final var minSupplier = new MutableDoubleSupplier(Double.POSITIVE_INFINITY); + mins.put(key, minSupplier); + minRatio.labels(minSupplier, combination); + final var maxSupplier = new MutableDoubleSupplier(Double.NEGATIVE_INFINITY); + maxs.put(key, maxSupplier); + maxRatio.labels(maxSupplier, combination); } this.histogram = metricsSystem.createLabelledHistogram( - category, - name, - StringUtils.capitalize(help) + " buckets", - DEFAULT_HISTOGRAM_BUCKETS, - labelNames); + category, name, StringUtils.capitalize(help) + " buckets", buckets, labelNames); } @SafeVarargs @@ -115,15 +113,40 @@ private List getLabelValuesCombinations(final Class Math.min(currMin, value)); + mins.get(key).set(min); // Update highest seen - maxs.compute(key, (unused, currMax) -> Math.max(currMax, value)); + maxs.get(key).set(max); + } - // Record the observation - histogram.labels(labelValues).observe(value); + private static class MutableDoubleSupplier implements DoubleSupplier { + private final double initialValue; + private volatile double value; + + public MutableDoubleSupplier(final double initialValue) { + this.initialValue = initialValue; + this.value = initialValue; + } + + @Override + public double getAsDouble() { + return value; + } + + public void set(final double value) { + this.value = value; + } + + public void reset() { + value = initialValue; + } } } diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/metrics/TransactionPoolProfitabilityMetrics.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/metrics/TransactionPoolProfitabilityMetrics.java index fb4d1122..fccc65fa 100644 --- a/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/metrics/TransactionPoolProfitabilityMetrics.java +++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txpoolvalidation/metrics/TransactionPoolProfitabilityMetrics.java @@ -16,6 +16,8 @@ import static net.consensys.linea.metrics.LineaMetricCategory.TX_POOL_PROFITABILITY; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import net.consensys.linea.bl.TransactionProfitabilityCalculator; import net.consensys.linea.config.LineaProfitabilityConfiguration; @@ -60,23 +62,40 @@ public TransactionPoolProfitabilityMetrics( this.blockchainService = blockchainService; this.histogramMetrics = new HistogramMetrics( - metricsSystem, TX_POOL_PROFITABILITY, "ratio", "transaction pool profitability ratio"); + metricsSystem, + TX_POOL_PROFITABILITY, + "ratio", + "transaction pool profitability ratio", + profitabilityConf.profitabilityMetricsBuckets()); } public void update() { final long startTime = System.currentTimeMillis(); final var txPoolContent = transactionPoolService.getPendingTransactions(); - txPoolContent.parallelStream() - .map(PendingTransaction::getTransaction) - .forEach(this::handleTransaction); + + final var ratioStats = + txPoolContent.parallelStream() + .map(PendingTransaction::getTransaction) + .map( + tx -> { + final var ratio = handleTransaction(tx); + histogramMetrics.track(ratio); + log.trace("Recorded profitability ratio {} for tx {}", ratio, tx.getHash()); + return ratio; + }) + .collect(Collectors.summarizingDouble(Double::doubleValue)); + + histogramMetrics.setMinMax(ratioStats.getMin(), ratioStats.getMax()); + log.atDebug() - .setMessage("Transaction pool profitability metrics processed {}txs in {}ms") + .setMessage("Transaction pool profitability metrics processed {}txs in {}ms, statistics {}") .addArgument(txPoolContent::size) .addArgument(() -> System.currentTimeMillis() - startTime) + .addArgument(ratioStats) .log(); } - private void handleTransaction(final Transaction transaction) { + private double handleTransaction(final Transaction transaction) { final Wei actualPriorityFeePerGas; if (transaction.getMaxPriorityFeePerGas().isEmpty()) { actualPriorityFeePerGas = @@ -102,8 +121,6 @@ private void handleTransaction(final Transaction transaction) { actualPriorityFeePerGas.toBigInteger().doubleValue() / profitablePriorityFeePerGas.toBigInteger().doubleValue(); - histogramMetrics.track(ratio); - - log.trace("Recorded profitability ratio {} for tx {}", ratio, transaction.getHash()); + return ratio; } } diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorFactory.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorFactory.java index 5f7da97c..529e9bb0 100644 --- a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorFactory.java +++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorFactory.java @@ -22,11 +22,10 @@ import net.consensys.linea.config.LineaTracerConfiguration; import net.consensys.linea.config.LineaTransactionSelectorConfiguration; import net.consensys.linea.jsonrpc.JsonRpcManager; +import net.consensys.linea.metrics.HistogramMetrics; import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedConfiguration; import net.consensys.linea.sequencer.txselection.selectors.LineaTransactionSelector; import org.hyperledger.besu.plugin.services.BlockchainService; -import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelectorFactory; @@ -41,8 +40,7 @@ public class LineaTransactionSelectorFactory implements PluginTransactionSelecto private final LineaL1L2BridgeSharedConfiguration l1L2BridgeConfiguration; private final LineaProfitabilityConfiguration profitabilityConfiguration; private final LineaTracerConfiguration tracerConfiguration; - private final MetricsSystem metricsSystem; - private final MetricCategoryRegistry metricCategoryRegistry; + private final Optional maybeProfitabilityMetrics; private final Map limitsMap; @@ -54,8 +52,7 @@ public LineaTransactionSelectorFactory( final LineaTracerConfiguration tracerConfiguration, final Map limitsMap, final Optional rejectedTxJsonRpcManager, - final MetricsSystem metricsSystem, - final MetricCategoryRegistry metricCategoryRegistry) { + final Optional maybeProfitabilityMetrics) { this.blockchainService = blockchainService; this.txSelectorConfiguration = txSelectorConfiguration; this.l1L2BridgeConfiguration = l1L2BridgeConfiguration; @@ -63,8 +60,7 @@ public LineaTransactionSelectorFactory( this.tracerConfiguration = tracerConfiguration; this.limitsMap = limitsMap; this.rejectedTxJsonRpcManager = rejectedTxJsonRpcManager; - this.metricsSystem = metricsSystem; - this.metricCategoryRegistry = metricCategoryRegistry; + this.maybeProfitabilityMetrics = maybeProfitabilityMetrics; } @Override @@ -77,7 +73,6 @@ public PluginTransactionSelector create() { tracerConfiguration, limitsMap, rejectedTxJsonRpcManager, - metricsSystem, - metricCategoryRegistry); + maybeProfitabilityMetrics); } } diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java index 76bb677d..98c90c0f 100644 --- a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java +++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/LineaTransactionSelectorPlugin.java @@ -26,6 +26,8 @@ import net.consensys.linea.config.LineaRejectedTxReportingConfiguration; import net.consensys.linea.config.LineaTransactionSelectorConfiguration; import net.consensys.linea.jsonrpc.JsonRpcManager; +import net.consensys.linea.metrics.HistogramMetrics; +import net.consensys.linea.sequencer.txselection.selectors.ProfitableTransactionSelector; import org.hyperledger.besu.plugin.BesuContext; import org.hyperledger.besu.plugin.BesuPlugin; import org.hyperledger.besu.plugin.services.BesuConfiguration; @@ -85,6 +87,18 @@ public void start() { lineaRejectedTxReportingConfiguration) .start()); + final Optional maybeProfitabilityMetrics = + metricCategoryRegistry.isMetricCategoryEnabled(SEQUENCER_PROFITABILITY) + ? Optional.of( + new HistogramMetrics( + metricsSystem, + SEQUENCER_PROFITABILITY, + "ratio", + "sequencer profitability ratio", + profitabilityConfiguration().profitabilityMetricsBuckets(), + ProfitableTransactionSelector.Phase.class)) + : Optional.empty(); + transactionSelectionService.registerPluginTransactionSelectorFactory( new LineaTransactionSelectorFactory( blockchainService, @@ -94,8 +108,7 @@ public void start() { tracerConfiguration(), createLimitModules(tracerConfiguration()), rejectedTxJsonRpcManager, - metricsSystem, - metricCategoryRegistry)); + maybeProfitabilityMetrics)); } @Override diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java index 78e1d3c3..ce99b671 100644 --- a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java +++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/LineaTransactionSelector.java @@ -25,13 +25,12 @@ import net.consensys.linea.config.LineaTransactionSelectorConfiguration; import net.consensys.linea.jsonrpc.JsonRpcManager; import net.consensys.linea.jsonrpc.JsonRpcRequestBuilder; +import net.consensys.linea.metrics.HistogramMetrics; import net.consensys.linea.plugins.config.LineaL1L2BridgeSharedConfiguration; import org.hyperledger.besu.datatypes.PendingTransaction; import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.BlockchainService; -import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; import org.hyperledger.besu.plugin.services.tracer.BlockAwareOperationTracer; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext; @@ -52,8 +51,7 @@ public LineaTransactionSelector( final LineaTracerConfiguration tracerConfiguration, final Map limitsMap, final Optional rejectedTxJsonRpcManager, - final MetricsSystem metricsSystem, - final MetricCategoryRegistry metricCategoryRegistry) { + final Optional maybeProfitabilityMetrics) { this.rejectedTxJsonRpcManager = rejectedTxJsonRpcManager; selectors = createTransactionSelectors( @@ -63,8 +61,7 @@ public LineaTransactionSelector( profitabilityConfiguration, tracerConfiguration, limitsMap, - metricsSystem, - metricCategoryRegistry); + maybeProfitabilityMetrics); } /** @@ -74,7 +71,7 @@ public LineaTransactionSelector( * @param txSelectorConfiguration The configuration to use. * @param profitabilityConfiguration The profitability configuration. * @param limitsMap The limits map. - * @param metricCategoryRegistry + * @param maybeProfitabilityMetrics The optional profitability metrics * @return A list of selectors. */ private List createTransactionSelectors( @@ -84,8 +81,7 @@ private List createTransactionSelectors( final LineaProfitabilityConfiguration profitabilityConfiguration, final LineaTracerConfiguration tracerConfiguration, final Map limitsMap, - final MetricsSystem metricsSystem, - final MetricCategoryRegistry metricCategoryRegistry) { + final Optional maybeProfitabilityMetrics) { traceLineLimitTransactionSelector = new TraceLineLimitTransactionSelector( @@ -102,8 +98,7 @@ private List createTransactionSelectors( blockchainService, txSelectorConfiguration, profitabilityConfiguration, - metricsSystem, - metricCategoryRegistry), + maybeProfitabilityMetrics), traceLineLimitTransactionSelector); } diff --git a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelector.java b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelector.java index 08ba5714..8c9c4f3a 100644 --- a/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelector.java +++ b/sequencer/src/main/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelector.java @@ -14,14 +14,15 @@ */ package net.consensys.linea.sequencer.txselection.selectors; -import static net.consensys.linea.metrics.LineaMetricCategory.SEQUENCER_PROFITABILITY; import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.TX_UNPROFITABLE; import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.TX_UNPROFITABLE_RETRY_LIMIT; import static net.consensys.linea.sequencer.txselection.LineaTransactionSelectionResult.TX_UNPROFITABLE_UPFRONT; import static org.hyperledger.besu.plugin.data.TransactionSelectionResult.SELECTED; +import java.util.EnumMap; import java.util.LinkedHashSet; import java.util.Locale; +import java.util.Map; import java.util.Optional; import java.util.Set; @@ -39,8 +40,6 @@ import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.BlockchainService; -import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.hyperledger.besu.plugin.services.metrics.MetricCategoryRegistry; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.hyperledger.besu.plugin.services.txselection.TransactionEvaluationContext; @@ -55,7 +54,29 @@ */ @Slf4j public class ProfitableTransactionSelector implements PluginTransactionSelector { + public enum Phase implements LabelValue { + PRE_PROCESSING, + POST_PROCESSING; + + final String value; + + Phase() { + this.value = name().toLowerCase(Locale.ROOT); + } + + @Override + public String value() { + return value; + } + } + @VisibleForTesting protected static Set unprofitableCache = new LinkedHashSet<>(); + protected static Map lastBlockMinRatios = new EnumMap<>(Phase.class); + protected static Map lastBlockMaxRatios = new EnumMap<>(Phase.class); + + static { + resetMinMaxRatios(); + } private final LineaTransactionSelectorConfiguration txSelectorConf; private final LineaProfitabilityConfiguration profitabilityConf; @@ -69,22 +90,29 @@ public ProfitableTransactionSelector( final BlockchainService blockchainService, final LineaTransactionSelectorConfiguration txSelectorConf, final LineaProfitabilityConfiguration profitabilityConf, - final MetricsSystem metricsSystem, - final MetricCategoryRegistry metricCategoryRegistry) { + final Optional maybeProfitabilityMetrics) { this.txSelectorConf = txSelectorConf; this.profitabilityConf = profitabilityConf; this.transactionProfitabilityCalculator = new TransactionProfitabilityCalculator(profitabilityConf); - this.maybeProfitabilityMetrics = - metricCategoryRegistry.isMetricCategoryEnabled(SEQUENCER_PROFITABILITY) - ? Optional.of( - new HistogramMetrics( - metricsSystem, - SEQUENCER_PROFITABILITY, - "ratio", - "sequencer profitability ratio", - Phase.class)) - : Optional.empty(); + this.maybeProfitabilityMetrics = maybeProfitabilityMetrics; + maybeProfitabilityMetrics.ifPresent( + histogramMetrics -> { + histogramMetrics.setMinMax( + lastBlockMinRatios.get(Phase.PRE_PROCESSING), + lastBlockMaxRatios.get(Phase.PRE_PROCESSING), + Phase.PRE_PROCESSING.value()); + histogramMetrics.setMinMax( + lastBlockMinRatios.get(Phase.POST_PROCESSING), + lastBlockMaxRatios.get(Phase.POST_PROCESSING), + Phase.POST_PROCESSING.value()); + log.atTrace() + .setMessage("Setting profitability ratio metrics for last block to min={}, max={}") + .addArgument(lastBlockMinRatios) + .addArgument(lastBlockMaxRatios) + .log(); + resetMinMaxRatios(); + }); this.baseFee = blockchainService @@ -259,6 +287,13 @@ private void updateMetric( histogramMetrics.track(ratio, label.value()); + if (ratio < lastBlockMinRatios.get(label)) { + lastBlockMinRatios.put(label, ratio); + } + if (ratio > lastBlockMaxRatios.get(label)) { + lastBlockMaxRatios.put(label, ratio); + } + log.atTrace() .setMessage( "POST_PROCESSING: block[{}] tx {} , baseFee {}, effectiveGasPrice {}, ratio (effectivePayingPriorityFee {} / calculatedProfitablePriorityFee {}) {}") @@ -273,19 +308,10 @@ private void updateMetric( }); } - enum Phase implements LabelValue { - PRE_PROCESSING, - POST_PROCESSING; - - final String value; - - Phase() { - this.value = name().toLowerCase(Locale.ROOT); - } - - @Override - public String value() { - return value; - } + private static void resetMinMaxRatios() { + lastBlockMinRatios.put(Phase.PRE_PROCESSING, Double.POSITIVE_INFINITY); + lastBlockMinRatios.put(Phase.POST_PROCESSING, Double.POSITIVE_INFINITY); + lastBlockMaxRatios.put(Phase.PRE_PROCESSING, Double.NEGATIVE_INFINITY); + lastBlockMaxRatios.put(Phase.POST_PROCESSING, Double.NEGATIVE_INFINITY); } } diff --git a/sequencer/src/test/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelectorTest.java b/sequencer/src/test/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelectorTest.java index 31ab5c33..ff3b08b9 100644 --- a/sequencer/src/test/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelectorTest.java +++ b/sequencer/src/test/java/net/consensys/linea/sequencer/txselection/selectors/ProfitableTransactionSelectorTest.java @@ -28,6 +28,7 @@ import net.consensys.linea.config.LineaProfitabilityConfiguration; import net.consensys.linea.config.LineaTransactionSelectorCliOptions; import net.consensys.linea.config.LineaTransactionSelectorConfiguration; +import net.consensys.linea.metrics.HistogramMetrics; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.bouncycastle.crypto.digests.KeccakDigest; @@ -35,12 +36,10 @@ import org.hyperledger.besu.datatypes.PendingTransaction; import org.hyperledger.besu.datatypes.Transaction; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.data.ProcessableBlockHeader; import org.hyperledger.besu.plugin.data.TransactionProcessingResult; import org.hyperledger.besu.plugin.data.TransactionSelectionResult; import org.hyperledger.besu.plugin.services.BlockchainService; -import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.txselection.PluginTransactionSelector; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -64,7 +63,6 @@ public class ProfitableTransactionSelectorTest { .variableCostWei(VARIABLE_GAS_COST_WEI) .build(); private TestableProfitableTransactionSelector transactionSelector; - private MetricsSystem metricsSystem = new NoOpMetricsSystem(); @BeforeEach public void initialize() { @@ -76,7 +74,7 @@ private TestableProfitableTransactionSelector newSelectorForNewBlock() { final var blockchainService = mock(BlockchainService.class); when(blockchainService.getNextBlockBaseFee()).thenReturn(Optional.of(BASE_FEE)); return new TestableProfitableTransactionSelector( - blockchainService, txSelectorConf, profitabilityConf, metricsSystem); + blockchainService, txSelectorConf, profitabilityConf, Optional.empty()); } @Test @@ -414,13 +412,8 @@ private static class TestableProfitableTransactionSelector extends ProfitableTra final BlockchainService blockchainService, final LineaTransactionSelectorConfiguration txSelectorConf, final LineaProfitabilityConfiguration profitabilityConf, - final MetricsSystem metricsSystem) { - super( - blockchainService, - txSelectorConf, - profitabilityConf, - metricsSystem, - metricCategoryRegistry); + final Optional maybeProfitabilityMetrics) { + super(blockchainService, txSelectorConf, profitabilityConf, maybeProfitabilityMetrics); } boolean isUnprofitableTxCached(final Hash txHash) {