From de6014f60a57511692d63a3032575b764303053a Mon Sep 17 00:00:00 2001 From: Volodymyr Kravets Date: Wed, 16 Oct 2024 14:10:08 +0300 Subject: [PATCH] feat(stableMinGasPrice): add extra logs to MinimumGasPriceCalculator --- .../src/main/java/co/rsk/mine/BlockGasPriceRange.java | 5 +++++ .../main/java/co/rsk/mine/MinimumGasPriceCalculator.java | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java b/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java index e69c688ffd1..340a83b9b12 100644 --- a/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java +++ b/rskj-core/src/main/java/co/rsk/mine/BlockGasPriceRange.java @@ -51,4 +51,9 @@ public Coin getUpperLimit() { public Coin getLowerLimit() { return lowerLimit; } + + @Override + public String toString() { + return "[" + lowerLimit + "; " + upperLimit + "]"; + } } diff --git a/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java b/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java index eff3c8e9341..c0569a9f443 100644 --- a/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java +++ b/rskj-core/src/main/java/co/rsk/mine/MinimumGasPriceCalculator.java @@ -20,6 +20,8 @@ import co.rsk.core.Coin; import co.rsk.mine.gas.provider.MinGasPriceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is the implementation of RSKIP-09 @@ -27,6 +29,8 @@ */ public class MinimumGasPriceCalculator { + private static final Logger logger = LoggerFactory.getLogger(MinimumGasPriceCalculator.class); + private final MinGasPriceProvider minGasPriceProvider; public MinimumGasPriceCalculator(MinGasPriceProvider minGasPriceProvider) { @@ -37,14 +41,16 @@ public Coin calculate(Coin previousMGP) { BlockGasPriceRange priceRange = new BlockGasPriceRange(previousMGP); Coin targetMGP = minGasPriceProvider.getMinGasPriceAsCoin(); if (priceRange.inRange(targetMGP)) { + logger.debug("Previous MGP: {}. Target MGP: {} is in range: {}. Returning target MGP", previousMGP, targetMGP, priceRange); return targetMGP; } if (previousMGP.compareTo(targetMGP) < 0) { + logger.debug("Previous MGP: {}. Target MGP: {} is not in range: {}. Returning upper boundary: {}", previousMGP, targetMGP, priceRange, priceRange.getUpperLimit()); return priceRange.getUpperLimit(); } + logger.debug("Previous MGP: {}. Target MGP: {} is not in range: {}. Returning lower boundary: {}", previousMGP, targetMGP, priceRange, priceRange.getLowerLimit()); return priceRange.getLowerLimit(); } - }