From 0a04d8454127b7145f55d5f8a950d8ee695ca710 Mon Sep 17 00:00:00 2001 From: matkt Date: Tue, 27 Jul 2021 20:18:19 +0200 Subject: [PATCH] EIP1559 Cleanup : remove experimental flags (#2577) Signed-off-by: Karim TAAM Co-authored-by: garyschulte --- .../config/experimental/ExperimentalEIPs.java | 12 --------- .../besu/ethereum/core/fees/BaseFee.java | 3 ++- .../besu/ethereum/core/fees/EIP1559.java | 3 ++- .../fees => mainnet/feemarket}/FeeMarket.java | 11 ++++---- .../feemarket/LondonFeeMarket.java} | 27 +++++++++---------- .../besu/ethereum/core/fees/EIP1559Test.java | 4 ++- ...BlockHeaderGasPriceValidationRuleTest.java | 4 +-- 7 files changed, 26 insertions(+), 38 deletions(-) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{core/fees => mainnet/feemarket}/FeeMarket.java (76%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/{core/fees/FeeMarketConfig.java => mainnet/feemarket/LondonFeeMarket.java} (56%) diff --git a/config/src/main/java/org/hyperledger/besu/config/experimental/ExperimentalEIPs.java b/config/src/main/java/org/hyperledger/besu/config/experimental/ExperimentalEIPs.java index f9b88cb1f2..b08b027f2b 100644 --- a/config/src/main/java/org/hyperledger/besu/config/experimental/ExperimentalEIPs.java +++ b/config/src/main/java/org/hyperledger/besu/config/experimental/ExperimentalEIPs.java @@ -24,21 +24,9 @@ public class ExperimentalEIPs { // To make it easier for tests to reset the value to default public static final long EIP1559_BASEFEE_DEFAULT_VALUE = 1000000000L; - @Option( - hidden = true, - names = {"--Xeip1559-basefee-max-change-denominator"}, - arity = "1") - public static Long basefeeMaxChangeDenominator = 8L; - @Option( hidden = true, names = {"--Xeip1559-initial-base-fee"}, arity = "1") public static Long initialBasefee = EIP1559_BASEFEE_DEFAULT_VALUE; - - @Option( - hidden = true, - names = {"--Xeip1559-slack-coefficient"}, - arity = "1") - public static Long slackCoefficient = 2L; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/BaseFee.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/BaseFee.java index b349a6bb74..e030a595b5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/BaseFee.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/BaseFee.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.core.fees; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Wei; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import java.util.Optional; import java.util.function.Supplier; @@ -41,7 +42,7 @@ public class BaseFee { Optional minBaseFeeInNextBlock = Optional.empty(); if (baseFee.isPresent()) { minBaseFeeInNextBlock = - Optional.of(new BaseFee(FeeMarket.eip1559(), baseFee.get()).getMinNextValue()); + Optional.of(new BaseFee(FeeMarket.london(), baseFee.get()).getMinNextValue()); } return calculator.price(transaction, minBaseFeeInNextBlock); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java index c910fe412e..fe52042222 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/EIP1559.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.core.fees; import static java.lang.Math.max; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import java.math.BigInteger; @@ -28,7 +29,7 @@ public class EIP1559 { private final long initialForkBlknum; - private final FeeMarket feeMarket = FeeMarket.eip1559(); + private final FeeMarket feeMarket = FeeMarket.london(); public EIP1559(final long forkBlockNumber) { initialForkBlknum = forkBlockNumber; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java similarity index 76% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java index b3d88aaee5..5166ce5a74 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java @@ -12,22 +12,21 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core.fees; +package org.hyperledger.besu.ethereum.mainnet.feemarket; import org.hyperledger.besu.config.experimental.ExperimentalEIPs; public interface FeeMarket { + long EIP1559_BASEFEE_DEFAULT_VALUE = 1000000000L; + long getBasefeeMaxChangeDenominator(); long getInitialBasefee(); long getSlackCoefficient(); - static FeeMarket eip1559() { - return new FeeMarketConfig( - ExperimentalEIPs.basefeeMaxChangeDenominator, - ExperimentalEIPs.initialBasefee, - ExperimentalEIPs.slackCoefficient); + static FeeMarket london() { + return new LondonFeeMarket(ExperimentalEIPs.initialBasefee); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java similarity index 56% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index 7e8b4a4afc..6f11dd4ed6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketConfig.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -12,34 +12,31 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core.fees; +package org.hyperledger.besu.ethereum.mainnet.feemarket; -public class FeeMarketConfig implements FeeMarket { - private final long basefeeMaxChangeDenominator; - private final long initialBasefee; - private final long slackCoefficient; +public class LondonFeeMarket implements FeeMarket { + private final Long BASEFEE_MAX_CHANGE_DENOMINATOR = 8L; - public FeeMarketConfig( - final long basefeeMaxChangeDenominator, - final long initialBasefee, - final long slackCoefficient) { - this.basefeeMaxChangeDenominator = basefeeMaxChangeDenominator; - this.initialBasefee = initialBasefee; - this.slackCoefficient = slackCoefficient; + private final Long SLACK_COEFFICIENT = 2L; + + private final Long initialBaseFee; + + public LondonFeeMarket(final Long initialBaseFee) { + this.initialBaseFee = initialBaseFee; } @Override public long getBasefeeMaxChangeDenominator() { - return basefeeMaxChangeDenominator; + return BASEFEE_MAX_CHANGE_DENOMINATOR; } @Override public long getInitialBasefee() { - return initialBasefee; + return initialBaseFee; } @Override public long getSlackCoefficient() { - return slackCoefficient; + return SLACK_COEFFICIENT; } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/fees/EIP1559Test.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/fees/EIP1559Test.java index 25f2e5a37c..5799037e2a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/fees/EIP1559Test.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/fees/EIP1559Test.java @@ -16,13 +16,15 @@ package org.hyperledger.besu.ethereum.core.fees; import static org.assertj.core.api.Assertions.assertThat; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; + import org.junit.Test; public class EIP1559Test { private static final long FORK_BLOCK = 783L; private final EIP1559 eip1559 = new EIP1559(FORK_BLOCK); - private final FeeMarket feeMarket = FeeMarket.eip1559(); + private final FeeMarket feeMarket = FeeMarket.london(); private static final long TARGET_GAS_USED = 10000000L; @Test diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/EIP1559BlockHeaderGasPriceValidationRuleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/EIP1559BlockHeaderGasPriceValidationRuleTest.java index 7d4adaa5c3..634b30525e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/EIP1559BlockHeaderGasPriceValidationRuleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/EIP1559BlockHeaderGasPriceValidationRuleTest.java @@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.mainnet.headervalidationrules.EIP1559Helper.blockHeader; import org.hyperledger.besu.ethereum.core.fees.EIP1559; -import org.hyperledger.besu.ethereum.core.fees.FeeMarket; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import java.util.Optional; @@ -30,7 +30,7 @@ public class EIP1559BlockHeaderGasPriceValidationRuleTest { private static final long FORK_BLOCK = 800L; private final EIP1559 eip1559 = new EIP1559(FORK_BLOCK); private EIP1559BlockHeaderGasPriceValidationRule validationRule; - private final FeeMarket feeMarket = FeeMarket.eip1559(); + private final FeeMarket feeMarket = FeeMarket.london(); @Before public void setUp() {