diff --git a/arithmetization/src/main/java/net/consensys/linea/bl/TransactionProfitabilityCalculator.java b/arithmetization/src/main/java/net/consensys/linea/bl/TransactionProfitabilityCalculator.java index ec888b11..045a72f4 100644 --- a/arithmetization/src/main/java/net/consensys/linea/bl/TransactionProfitabilityCalculator.java +++ b/arithmetization/src/main/java/net/consensys/linea/bl/TransactionProfitabilityCalculator.java @@ -14,6 +14,8 @@ */ package net.consensys.linea.bl; +import static net.consensys.linea.config.LineaProfitabilityConfiguration.WEI_IN_KWEI; + import java.math.BigDecimal; import lombok.extern.slf4j.Slf4j; @@ -25,7 +27,6 @@ @Slf4j public class TransactionProfitabilityCalculator { - private static final long TO_WEI_MULTIPLIER = 1_000; private final LineaProfitabilityConfiguration profitabilityConf; public TransactionProfitabilityCalculator( @@ -37,19 +38,19 @@ public Wei profitablePriorityFeePerGas( final Transaction transaction, final double minMargin, final long gas, - final Wei minGasPrice) { + final Wei minGasPriceWei) { final int compressedTxSize = getCompressedTxSize(transaction); final long variableCostKWei = profitabilityConf.extraDataPricingEnabled() ? profitabilityConf.variableCostKWei() - : minGasPrice.divide(TO_WEI_MULTIPLIER).toLong(); + : minGasPriceWei.divide(WEI_IN_KWEI).toLong(); final var profitAtKWei = minMargin * (variableCostKWei * compressedTxSize / gas + profitabilityConf.fixedCostKWei()); final var profitAtWei = - Wei.ofNumber(BigDecimal.valueOf(profitAtKWei).toBigInteger()).multiply(TO_WEI_MULTIPLIER); + Wei.ofNumber(BigDecimal.valueOf(profitAtKWei).toBigInteger()).multiply(WEI_IN_KWEI); log.atDebug() .setMessage( @@ -73,10 +74,10 @@ public boolean isProfitable( final double minMargin, final Wei effectiveGasPrice, final long gas, - final Wei minGasPrice) { + final Wei minGasPriceWei) { final Wei profitablePriorityFee = - profitablePriorityFeePerGas(transaction, minMargin, gas, minGasPrice); + profitablePriorityFeePerGas(transaction, minMargin, gas, minGasPriceWei); if (effectiveGasPrice.lessThan(profitablePriorityFee)) { log( @@ -87,7 +88,7 @@ public boolean isProfitable( effectiveGasPrice, profitablePriorityFee, gas, - minGasPrice); + minGasPriceWei); return false; } @@ -99,7 +100,7 @@ public boolean isProfitable( effectiveGasPrice, profitablePriorityFee, gas, - minGasPrice); + minGasPriceWei); return true; } @@ -116,7 +117,7 @@ private void log( final Wei effectiveGasPrice, final Wei profitableGasPrice, final long gasUsed, - final Wei minGasPrice) { + final Wei minGasPriceWei) { leb.setMessage( "Context {}. Transaction {} has a margin of {}, minMargin={}, effectiveGasPrice={}," @@ -136,7 +137,7 @@ private void log( () -> profitabilityConf.extraDataPricingEnabled() ? profitabilityConf.variableCostKWei() - : minGasPrice.divide(TO_WEI_MULTIPLIER).toLong()) + : minGasPriceWei.divide(WEI_IN_KWEI).toLong()) .addArgument(gasUsed) .log(); } diff --git a/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java b/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java index 4ed9fb94..5b5f6e7c 100644 --- a/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java +++ b/arithmetization/src/main/java/net/consensys/linea/config/LineaProfitabilityConfiguration.java @@ -26,6 +26,8 @@ @Getter @ToString public class LineaProfitabilityConfiguration { + public static final int WEI_IN_KWEI = 1_000; + private long fixedCostKWei; private long variableCostKWei; private double minMargin; diff --git a/arithmetization/src/main/java/net/consensys/linea/extradata/LineaExtraDataHandler.java b/arithmetization/src/main/java/net/consensys/linea/extradata/LineaExtraDataHandler.java index 913a45c1..0d5d6c5d 100644 --- a/arithmetization/src/main/java/net/consensys/linea/extradata/LineaExtraDataHandler.java +++ b/arithmetization/src/main/java/net/consensys/linea/extradata/LineaExtraDataHandler.java @@ -15,6 +15,8 @@ package net.consensys.linea.extradata; +import static net.consensys.linea.config.LineaProfitabilityConfiguration.WEI_IN_KWEI; + import java.util.function.Consumer; import java.util.function.Function; @@ -119,7 +121,7 @@ public synchronized void parse(final Bytes extraData) { } void updateMinGasPrice(final Long minGasPriceKWei) { - final var minGasPriceWei = Wei.of(minGasPriceKWei).multiply(1000); + final var minGasPriceWei = Wei.of(minGasPriceKWei).multiply(WEI_IN_KWEI); final var resp = rpcEndpointService.call( "miner_setMinGasPrice", new Object[] {minGasPriceWei.toShortHexString()});