diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 114dfe72f2..3dcc1baa45 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -78,7 +78,6 @@ import org.hyperledger.besu.cli.util.VersionProvider; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GoQuorumOptions; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.controller.BesuControllerBuilder; import org.hyperledger.besu.controller.TargetingGasLimitCalculator; @@ -1181,7 +1180,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .setCaseInsensitiveEnumValuesAllowed(true); handleStableOptions(); - enableExperimentalEIPs(); addSubCommands(resultHandler, in); registerConverters(); handleUnstableOptions(); @@ -1228,11 +1226,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { this.pluginCommonConfiguration = pluginCommonConfiguration; } - private void enableExperimentalEIPs() { - // Usage of static command line flags is strictly reserved for experimental EIPs - commandLine.addMixin("experimentalEIPs", ExperimentalEIPs.class); - } - private void addSubCommands( final AbstractParseResultHandler> resultHandler, final InputStream in) { commandLine.addSubcommand( diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java index 6f247580cd..e9adee23e8 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java @@ -19,7 +19,6 @@ import static org.hyperledger.besu.cli.subcommands.RetestethSubCommand.COMMAND_N import org.hyperledger.besu.BesuInfo; import org.hyperledger.besu.cli.DefaultCommandValues; import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration; import org.hyperledger.besu.ethereum.retesteth.RetestethService; @@ -32,7 +31,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.Configurator; import picocli.CommandLine.Command; -import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; @Command( @@ -53,8 +51,6 @@ public class RetestethSubCommand implements Runnable { */ public static final int RETESTETH_PORT = 47710; - @Mixin private final ExperimentalEIPs experimentalEIPs = new ExperimentalEIPs(); - @Option( names = {"--data-path"}, paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP, diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 85a307b316..a56638c504 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -17,7 +17,6 @@ package org.hyperledger.besu.controller; import static com.google.common.base.Preconditions.checkNotNull; import org.hyperledger.besu.config.GenesisConfigFile; -import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.crypto.NodeKey; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; @@ -33,7 +32,6 @@ import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; -import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -299,14 +297,6 @@ public abstract class BesuControllerBuilder { final SyncState syncState = new SyncState(blockchain, ethPeers); final boolean fastSyncEnabled = SyncMode.FAST.equals(syncConfig.getSyncMode()); - final Optional eip1559; - final GenesisConfigOptions genesisConfigOptions = - genesisConfig.getConfigOptions(genesisConfigOverrides); - if (genesisConfigOptions.getEIP1559BlockNumber().isPresent()) { - eip1559 = Optional.of(new EIP1559(genesisConfigOptions.getEIP1559BlockNumber().getAsLong())); - } else { - eip1559 = Optional.empty(); - } final TransactionPool transactionPool = TransactionPoolFactory.createTransactionPool( protocolSchedule, @@ -316,8 +306,7 @@ public abstract class BesuControllerBuilder { metricsSystem, syncState, miningParameters.getMinTransactionGasPrice(), - transactionPoolConfiguration, - eip1559); + transactionPoolConfiguration); final EthProtocolManager ethProtocolManager = createEthProtocolManager( diff --git a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java index b6f3a71d89..6e0abe4bd0 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java @@ -53,6 +53,7 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -129,6 +130,8 @@ public class BesuEventsImplTest { when(mockProtocolContext.getWorldStateArchive()).thenReturn(mockWorldStateArchive); when(mockProtocolSchedule.getByBlockNumber(anyLong())).thenReturn(mockProtocolSpec); when(mockProtocolSpec.getTransactionValidator()).thenReturn(mockTransactionValidator); + when(mockProtocolSpec.getEip1559()).thenReturn(Optional.of(new EIP1559(0L))); + when(mockProtocolSpec.getFeeMarket()).thenReturn(Optional.of(FeeMarket.london())); when(mockTransactionValidator.validate(any(), any(Optional.class), any())) .thenReturn(ValidationResult.valid()); when(mockTransactionValidator.validateForSender(any(), any(), any())) @@ -150,8 +153,7 @@ public class BesuEventsImplTest { new NoOpMetricsSystem(), syncState, Wei.ZERO, - txPoolConfig, - Optional.of(new EIP1559(0))); + txPoolConfig); serviceImpl = new BesuEventsImpl(blockchain, blockBroadcaster, transactionPool, syncState); } diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java index 9bbce7b827..376a32a589 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigFile.java @@ -17,8 +17,6 @@ package org.hyperledger.besu.config; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hyperledger.besu.config.JsonUtil.normalizeKeys; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; - import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -129,11 +127,6 @@ public class GenesisConfigFile { .map(baseFeeStr -> parseLong("baseFeePerGas", baseFeeStr)); } - public Optional getGenesisBaseFeePerGas() { - return Optional.of(getBaseFeePerGas().orElse(ExperimentalEIPs.initialBasefee)) - .filter(z -> 0L == getConfigOptions().getEIP1559BlockNumber().orElse(-1L)); - } - public String getMixHash() { return JsonUtil.getString(configRoot, "mixhash", ""); } 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 deleted file mode 100644 index b08b027f2b..0000000000 --- a/config/src/main/java/org/hyperledger/besu/config/experimental/ExperimentalEIPs.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.config.experimental; - -import picocli.CommandLine.Option; - -/** - * Flags defined in this class must be used with caution, and strictly reserved to experimental - * EIPs. - */ -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-initial-base-fee"}, - arity = "1") - public static Long initialBasefee = EIP1559_BASEFEE_DEFAULT_VALUE; -} diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java index e36a194c53..9f96c38b2f 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigFileTest.java @@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hyperledger.besu.config.GenesisConfigFile.fromConfig; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; - import java.io.IOException; import java.math.BigInteger; import java.nio.charset.StandardCharsets; @@ -150,8 +148,6 @@ public class GenesisConfigFileTest { GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0},\"baseFeePerGas\":\"0xa\"}"); assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isPresent(); assertThat(withBaseFeeAtGenesis.getBaseFeePerGas().get()).isEqualTo(10L); - assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas()).isPresent(); - assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas().get()).isEqualTo(10L); } @Test @@ -159,15 +155,11 @@ public class GenesisConfigFileTest { GenesisConfigFile withBaseFeeAtGenesis = GenesisConfigFile.fromConfig("{\"config\":{\"londonBlock\":0}}"); assertThat(withBaseFeeAtGenesis.getBaseFeePerGas()).isNotPresent(); - assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas()).isPresent(); - assertThat(withBaseFeeAtGenesis.getGenesisBaseFeePerGas().get()) - .isEqualTo(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE); } @Test public void shouldNotGetBaseFeeAtGenesis() { assertThat(EMPTY_CONFIG.getBaseFeePerGas()).isNotPresent(); - assertThat(EMPTY_CONFIG.getGenesisBaseFeePerGas()).isNotPresent(); } @Test diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java index 67cfa0b3e0..e508d829fe 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java @@ -127,7 +127,6 @@ public class EthGetFilterChangesIntegrationTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), TransactionPoolConfiguration.DEFAULT); final BlockchainQueries blockchainQueries = new BlockchainQueries(blockchain, protocolContext.getWorldStateArchive()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistoryTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistoryTest.java index 6ca74ee874..de16767d9d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistoryTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthFeeHistoryTest.java @@ -22,7 +22,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; @@ -39,6 +38,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import java.util.List; import java.util.Optional; @@ -145,7 +145,7 @@ public class EthFeeHistoryTest { (FeeHistory.FeeHistoryResult) ((JsonRpcSuccessResponse) feeHistoryRequest(1, "latest")).getResult(); assertThat(Long.decode(result.getBaseFeePerGas().get(1))) - .isEqualTo(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE); + .isEqualTo(FeeMarket.london().getInitialBasefee()); } @Test diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java index 5e02ee6f07..e52a3e598f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java @@ -108,6 +108,7 @@ public class EthGetTransactionReceiptTest { null, TransactionPriceCalculator.frontier(), Optional.empty(), + Optional.empty(), null, Optional.of(PoWHasher.ETHASH_LIGHT)); private final ProtocolSpec statusTransactionTypeSpec = @@ -133,6 +134,7 @@ public class EthGetTransactionReceiptTest { null, TransactionPriceCalculator.frontier(), Optional.empty(), + Optional.empty(), null, Optional.of(PoWHasher.ETHASH_LIGHT)); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index d1e126747c..08ecada493 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -259,7 +259,8 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { difficultyCalculator.nextDifficulty(timestamp, parentHeader, protocolContext); Long baseFee = null; - if (protocolSpec.isEip1559()) { + if (protocolSpec.hasFeeMarket()) { + // TODO roll eip1559 into feeMarket final EIP1559 eip1559 = protocolSpec.getEip1559().orElseThrow(); if (eip1559.isForkBlock(newBlockNumber)) { gasLimit = gasLimit * eip1559.getFeeMarket().getSlackCoefficient(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index 736468a630..44cbb367bf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -156,7 +156,7 @@ public final class GenesisState { .mixHash(parseMixHash(genesis)) .nonce(parseNonce(genesis)) .blockHeaderFunctions(ScheduleBasedBlockHeaderFunctions.create(protocolSchedule)) - .baseFee(genesis.getGenesisBaseFeePerGas().orElse(null)) + .baseFee(genesis.getBaseFeePerGas().orElse(null)) .buildBlockHeader(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index 53aeb0c8db..941b43cd19 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -375,7 +375,7 @@ public class Transaction .map( maybeNegativeEffectivePriorityFeePerGas -> Math.max(0, maybeNegativeEffectivePriorityFeePerGas)) - .orElseGet(() -> getGasPrice().get().getValue().longValue()); + .orElseGet(() -> getGasPrice().map(Wei::getValue).map(Number::longValue).orElse(0L)); } /** * Returns the transaction gas limit. 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 e030a595b5..80e17888e5 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 @@ -36,13 +36,13 @@ public class BaseFee { public static Wei minTransactionPriceInNextBlock( final Transaction transaction, + final FeeMarket feeMarket, final TransactionPriceCalculator calculator, final Supplier> baseFeeSupplier) { final Optional baseFee = baseFeeSupplier.get(); Optional minBaseFeeInNextBlock = Optional.empty(); if (baseFee.isPresent()) { - minBaseFeeInNextBlock = - Optional.of(new BaseFee(FeeMarket.london(), baseFee.get()).getMinNextValue()); + minBaseFeeInNextBlock = Optional.of(new BaseFee(feeMarket, 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 fe52042222..3a1283aa8c 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 @@ -29,10 +29,11 @@ public class EIP1559 { private final long initialForkBlknum; - private final FeeMarket feeMarket = FeeMarket.london(); + private final FeeMarket feeMarket; public EIP1559(final long forkBlockNumber) { - initialForkBlknum = forkBlockNumber; + this.initialForkBlknum = forkBlockNumber; + this.feeMarket = FeeMarket.london(); } public long computeBaseFee( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/LondonFeeMarketException.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketException.java similarity index 64% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/LondonFeeMarketException.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketException.java index bbf4db9319..77974e8665 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/LondonFeeMarketException.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/FeeMarketException.java @@ -14,18 +14,18 @@ */ package org.hyperledger.besu.ethereum.core.fees; -public class LondonFeeMarketException extends Exception { +public class FeeMarketException extends Exception { - public static LondonFeeMarketException MissingBaseFeeFromBlockHeader() { - return new LondonFeeMarketException("Invalid block header: basefee should be specified"); + public static FeeMarketException MissingBaseFeeFromBlockHeader() { + return new FeeMarketException("Invalid block header: basefee should be specified"); } - public static LondonFeeMarketException BaseFeePresentBeforeForkBlock() { - return new LondonFeeMarketException( - "Invalid block header: basefee should not be present before London fork block"); + public static FeeMarketException BaseFeePresentBeforeForkBlock() { + return new FeeMarketException( + "Invalid block header: basefee should not be present before fee market fork block"); } - private LondonFeeMarketException(final String reason) { + private FeeMarketException(final String reason) { super(reason); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/TransactionPriceCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/TransactionPriceCalculator.java index 415ee7f007..f1eae5a487 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/TransactionPriceCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/fees/TransactionPriceCalculator.java @@ -24,14 +24,14 @@ public interface TransactionPriceCalculator { Wei price(Transaction transaction, Optional baseFee); static TransactionPriceCalculator frontier() { - return (transaction, baseFee) -> transaction.getGasPrice().get(); + return (transaction, baseFee) -> transaction.getGasPrice().orElse(Wei.ZERO); } static TransactionPriceCalculator eip1559() { return (transaction, maybeBaseFee) -> { final Wei baseFee = Wei.of(maybeBaseFee.orElseThrow()); if (!transaction.getType().supports1559FeeMarket()) { - return transaction.getGasPrice().get(); + return transaction.getGasPrice().orElse(Wei.ZERO); } final Wei maxPriorityFeePerGas = transaction.getMaxPriorityFeePerGas().orElseThrow(); final Wei maxFeePerGas = transaction.getMaxFeePerGas().orElseThrow(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index 6901f150c0..dc8dbe3489 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -37,6 +37,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockProcessorB import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockValidatorBuilder; import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; import org.hyperledger.besu.ethereum.mainnet.contractvalidation.PrefixCodeRule; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; @@ -517,6 +518,7 @@ public abstract class MainnetProtocolSpecs { MainnetEvmRegistries.london(gasCalculator, chainId.orElse(BigInteger.ZERO))) .transactionPriceCalculator(transactionPriceCalculator.orElseThrow()) .eip1559(Optional.of(eip1559)) + .feeMarket(Optional.of(FeeMarket.london())) .difficultyCalculator(MainnetDifficultyCalculators.LONDON) .blockHeaderValidatorBuilder(MainnetBlockHeaderValidator.createEip1559Validator(eip1559)) .ommerHeaderValidatorBuilder( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSchedule.java index 845666e5e2..fc4979f06b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSchedule.java @@ -25,7 +25,7 @@ public interface ProtocolSchedule { ProtocolSpec getByBlockNumber(long number); - public Stream streamMilestoneBlocks(); + Stream streamMilestoneBlocks(); Optional getChainId(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java index 6eee1bf4d5..834df4c30a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.vm.EVM; import org.hyperledger.besu.ethereum.vm.GasCalculator; @@ -69,6 +70,8 @@ public class ProtocolSpec { private final TransactionPriceCalculator transactionPriceCalculator; + private final Optional feeMarket; + private final Optional eip1559; private final BadBlockManager badBlockManager; @@ -98,6 +101,7 @@ public class ProtocolSpec { * @param skipZeroBlockRewards should rewards be skipped if it is zero * @param gasCalculator the gas calculator to use. * @param transactionPriceCalculator the transaction price calculator to use. + * @param feeMarket an {@link Optional} wrapping {@link FeeMarket} class if appropriate. * @param eip1559 an {@link Optional} wrapping {@link EIP1559} manager class if appropriate. * @param badBlockManager the cache to use to keep invalid blocks * @param powHasher the proof-of-work hasher @@ -123,6 +127,7 @@ public class ProtocolSpec { final boolean skipZeroBlockRewards, final GasCalculator gasCalculator, final TransactionPriceCalculator transactionPriceCalculator, + final Optional feeMarket, final Optional eip1559, final BadBlockManager badBlockManager, final Optional powHasher) { @@ -146,6 +151,7 @@ public class ProtocolSpec { this.skipZeroBlockRewards = skipZeroBlockRewards; this.gasCalculator = gasCalculator; this.transactionPriceCalculator = transactionPriceCalculator; + this.feeMarket = feeMarket; this.eip1559 = eip1559; this.badBlockManager = badBlockManager; this.powHasher = powHasher; @@ -327,8 +333,17 @@ public class ProtocolSpec { return eip1559; } - public boolean isEip1559() { - return eip1559.isPresent(); + /** + * Returns the Fee Market used in this specification. + * + * @return the {@link Optional} wrapping Fee Market implementation. + */ + public Optional getFeeMarket() { + return feeMarket; + } + + public boolean hasFeeMarket() { + return feeMarket.isPresent(); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index 377d25940d..ca98b56257 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Wei; import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.core.fees.TransactionPriceCalculator; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnChainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; @@ -68,6 +69,7 @@ public class ProtocolSpecBuilder { private PrivateTransactionValidatorBuilder privateTransactionValidatorBuilder; private TransactionPriceCalculator transactionPriceCalculator = TransactionPriceCalculator.frontier(); + private Optional feeMarket = Optional.empty(); private Optional eip1559 = Optional.empty(); private BadBlockManager badBlockManager; private PoWHasher powHasher = PoWHasher.ETHASH_LIGHT; @@ -221,6 +223,11 @@ public class ProtocolSpecBuilder { return this; } + public ProtocolSpecBuilder feeMarket(final Optional feeMarket) { + this.feeMarket = feeMarket; + return this; + } + public ProtocolSpecBuilder eip1559(final Optional eip1559) { this.eip1559 = eip1559; return this; @@ -260,6 +267,7 @@ public class ProtocolSpecBuilder { checkNotNull(protocolSchedule, "Missing protocol schedule"); checkNotNull(privacyParameters, "Missing privacy parameters"); checkNotNull(transactionPriceCalculator, "Missing transaction price calculator"); + checkNotNull(feeMarket, "Missing fee market optional wrapper"); checkNotNull(eip1559, "Missing eip1559 optional wrapper"); checkNotNull(badBlockManager, "Missing bad blocks manager"); @@ -365,6 +373,7 @@ public class ProtocolSpecBuilder { skipZeroBlockRewards, gasCalculator, transactionPriceCalculator, + feeMarket, eip1559, badBlockManager, Optional.ofNullable(powHasher)); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java index 5166ce5a74..2118340384 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java @@ -14,12 +14,8 @@ */ 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(); @@ -27,6 +23,6 @@ public interface FeeMarket { long getSlackCoefficient(); static FeeMarket london() { - return new LondonFeeMarket(ExperimentalEIPs.initialBasefee); + return new LondonFeeMarket(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index 6f11dd4ed6..4a311a3053 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -15,28 +15,22 @@ package org.hyperledger.besu.ethereum.mainnet.feemarket; public class LondonFeeMarket implements FeeMarket { - private final Long BASEFEE_MAX_CHANGE_DENOMINATOR = 8L; - - private final Long SLACK_COEFFICIENT = 2L; - - private final Long initialBaseFee; - - public LondonFeeMarket(final Long initialBaseFee) { - this.initialBaseFee = initialBaseFee; - } + static final Long DEFAULT_BASEFEE_INITIAL_VALUE = 1000000000L; + static final Long DEFAULT_BASEFEE_MAX_CHANGE_DENOMINATOR = 8L; + static final Long DEFAULT_SLACK_COEFFICIENT = 2L; @Override public long getBasefeeMaxChangeDenominator() { - return BASEFEE_MAX_CHANGE_DENOMINATOR; + return DEFAULT_BASEFEE_MAX_CHANGE_DENOMINATOR; } @Override public long getInitialBasefee() { - return initialBaseFee; + return DEFAULT_BASEFEE_INITIAL_VALUE; } @Override public long getSlackCoefficient() { - return SLACK_COEFFICIENT; + return DEFAULT_SLACK_COEFFICIENT; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/LondonFeeMarketBlockHeaderGasPriceValidationRule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/LondonFeeMarketBlockHeaderGasPriceValidationRule.java index c822fba5c1..811eed369e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/LondonFeeMarketBlockHeaderGasPriceValidationRule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/LondonFeeMarketBlockHeaderGasPriceValidationRule.java @@ -14,11 +14,11 @@ */ package org.hyperledger.besu.ethereum.mainnet.headervalidationrules; -import static org.hyperledger.besu.ethereum.core.fees.LondonFeeMarketException.MissingBaseFeeFromBlockHeader; +import static org.hyperledger.besu.ethereum.core.fees.FeeMarketException.MissingBaseFeeFromBlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.fees.EIP1559; -import org.hyperledger.besu.ethereum.core.fees.LondonFeeMarketException; +import org.hyperledger.besu.ethereum.core.fees.FeeMarketException; import org.hyperledger.besu.ethereum.mainnet.DetachedBlockHeaderValidationRule; import org.apache.logging.log4j.LogManager; @@ -38,7 +38,7 @@ public class LondonFeeMarketBlockHeaderGasPriceValidationRule try { if (!eip1559.isEIP1559(header.getNumber())) { if (header.getBaseFee().isPresent()) { - throw LondonFeeMarketException.BaseFeePresentBeforeForkBlock(); + throw FeeMarketException.BaseFeePresentBeforeForkBlock(); } return true; } @@ -64,7 +64,7 @@ public class LondonFeeMarketBlockHeaderGasPriceValidationRule } return true; - } catch (final LondonFeeMarketException e) { + } catch (final FeeMarketException e) { LOG.info("Invalid block header: " + e.getMessage()); return false; } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java index d70621576a..459ab69f5a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java @@ -327,8 +327,8 @@ public class PoWSolverTest { Thread.sleep(200); assertThat(solver.submitSolution(expectedSecondOutput)).isTrue(); - PoWSolution result1 = soln1.get(1, TimeUnit.SECONDS); - PoWSolution result2 = soln2.get(1, TimeUnit.SECONDS); + PoWSolution result1 = soln1.get(3, TimeUnit.SECONDS); + PoWSolution result2 = soln2.get(3, TimeUnit.SECONDS); assertThat(result1.getMixHash()).isEqualTo(expectedFirstOutput.getMixHash()); assertThat(result2.getMixHash()).isEqualTo(expectedSecondOutput.getMixHash()); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index 166e8dac48..0f7d3775d3 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -38,8 +38,10 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransactions.TransactionAddedStatus; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.data.TransactionType; @@ -78,7 +80,6 @@ public class TransactionPool implements BlockAddedObserver { private final LabelledMetric duplicateTransactionCounter; private final PeerTransactionTracker peerTransactionTracker; private final PeerPendingTransactionTracker peerPendingTransactionTracker; - private final Optional eip1559; private final TransactionPriceCalculator frontierPriceCalculator = TransactionPriceCalculator.frontier(); private final TransactionPriceCalculator eip1559PriceCalculator = @@ -97,7 +98,6 @@ public class TransactionPool implements BlockAddedObserver { final PeerPendingTransactionTracker peerPendingTransactionTracker, final Wei minTransactionGasPrice, final MetricsSystem metricsSystem, - final Optional eip1559, final TransactionPoolConfiguration configuration) { this.pendingTransactions = pendingTransactions; this.protocolSchedule = protocolSchedule; @@ -108,7 +108,6 @@ public class TransactionPool implements BlockAddedObserver { this.peerTransactionTracker = peerTransactionTracker; this.peerPendingTransactionTracker = peerPendingTransactionTracker; this.minTransactionGasPrice = minTransactionGasPrice; - this.eip1559 = eip1559; this.configuration = configuration; duplicateTransactionCounter = @@ -259,13 +258,14 @@ public class TransactionPool implements BlockAddedObserver { "Transaction gas limit of %s exceeds block gas limit of %s", transaction.getGasLimit(), chainHeadBlockHeader.getGasLimit())); } - if (transaction.getType().equals(TransactionType.EIP1559) - && !eip1559 - .map(eip1559 -> eip1559.isEIP1559(chainHeadBlockHeader.getNumber())) - .orElse(false)) { - return ValidationResult.invalid( - TransactionInvalidReason.INVALID_TRANSACTION_FORMAT, - "EIP-1559 transaction are not allowed yet"); + if (transaction.getType().equals(TransactionType.EIP1559)) { + final long blknum = chainHeadBlockHeader.getNumber(); + ProtocolSpec spec = protocolSchedule.getByBlockNumber(blknum); + if (!spec.getEip1559().map(eip1559 -> eip1559.isEIP1559(blknum)).orElse(false)) { + return ValidationResult.invalid( + TransactionInvalidReason.INVALID_TRANSACTION_FORMAT, + "EIP-1559 transaction are not allowed yet"); + } } return protocolContext @@ -298,9 +298,17 @@ public class TransactionPool implements BlockAddedObserver { private Wei minTransactionGasPrice(final Transaction transaction) { final BlockHeader chainHeadBlockHeader = getChainHeadBlockHeader(); // Compute transaction price using EIP-1559 rules if chain head is after fork - if (eip1559.isPresent() && eip1559.get().isEIP1559(chainHeadBlockHeader.getNumber())) { + ProtocolSpec spec = protocolSchedule.getByBlockNumber(chainHeadBlockHeader.getNumber()); + Optional feeMarket = spec.getFeeMarket(); + // TODO: remove once eip1559 is part of FeeMarket + Optional eip1559 = spec.getEip1559(); + + if (feeMarket + .flatMap(fm -> eip1559.map(e -> e.isEIP1559(chainHeadBlockHeader.getNumber()))) + .orElse(Boolean.FALSE)) { + // TODO: remove eip1559PriceCalculator once it is rolled into fee market return BaseFee.minTransactionPriceInNextBlock( - transaction, eip1559PriceCalculator, chainHeadBlockHeader::getBaseFee); + transaction, feeMarket.get(), eip1559PriceCalculator, chainHeadBlockHeader::getBaseFee); } else { // Use frontier rules otherwise return frontierPriceCalculator.price(transaction, Optional.empty()); } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java index 1e1a960563..42b73c05ba 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java @@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.eth.transactions; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.Wei; -import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.messages.EthPV62; import org.hyperledger.besu.ethereum.eth.messages.EthPV65; @@ -26,7 +25,6 @@ import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.services.MetricsSystem; import java.time.Clock; -import java.util.Optional; public class TransactionPoolFactory { @@ -38,8 +36,7 @@ public class TransactionPoolFactory { final MetricsSystem metricsSystem, final SyncState syncState, final Wei minTransactionGasPrice, - final TransactionPoolConfiguration transactionPoolConfiguration, - final Optional eip1559) { + final TransactionPoolConfiguration transactionPoolConfiguration) { final PendingTransactions pendingTransactions = new PendingTransactions( @@ -72,8 +69,7 @@ public class TransactionPoolFactory { transactionTracker, transactionsMessageSender, pendingTransactionTracker, - pendingTransactionsMessageSender, - eip1559); + pendingTransactionsMessageSender); } static TransactionPool createTransactionPool( @@ -88,8 +84,7 @@ public class TransactionPoolFactory { final PeerTransactionTracker transactionTracker, final TransactionsMessageSender transactionsMessageSender, final PeerPendingTransactionTracker pendingTransactionTracker, - final PendingTransactionsMessageSender pendingTransactionsMessageSender, - final Optional eip1559) { + final PendingTransactionsMessageSender pendingTransactionsMessageSender) { final TransactionPool transactionPool = new TransactionPool( pendingTransactions, @@ -104,7 +99,6 @@ public class TransactionPoolFactory { pendingTransactionTracker, minTransactionGasPrice, metricsSystem, - eip1559, transactionPoolConfiguration); final TransactionsMessageHandler transactionsMessageHandler = new TransactionsMessageHandler( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java index 874bbb5b8b..8ad9f14219 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java @@ -76,7 +76,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -1009,8 +1008,7 @@ public final class EthProtocolManagerTest { metricsSystem, mock(SyncState.class), Wei.ZERO, - TransactionPoolConfiguration.DEFAULT, - Optional.empty()); + TransactionPoolConfiguration.DEFAULT); // Send just a transaction message. final PeerConnection peer = setupPeer(ethManager, (cap, msg, connection) -> {}); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java index 02d88575f0..d779893ef2 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java @@ -43,7 +43,6 @@ import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.testutil.TestClock; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -101,8 +100,7 @@ public abstract class AbstractMessageTaskTest { metricsSystem, syncState, Wei.of(1), - TransactionPoolConfiguration.DEFAULT, - Optional.empty()); + TransactionPoolConfiguration.DEFAULT); ethProtocolManager = EthProtocolManagerTestUtil.create( blockchain, diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java index 37b2aeaeec..54e9a069da 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java @@ -65,7 +65,6 @@ import java.math.BigInteger; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.concurrent.CompletableFuture; import io.vertx.core.Vertx; @@ -137,8 +136,7 @@ public class TestNode implements Closeable { metricsSystem, syncState, Wei.ZERO, - TransactionPoolConfiguration.DEFAULT, - Optional.empty()); + TransactionPoolConfiguration.DEFAULT); final EthProtocolManager ethProtocolManager = new EthProtocolManager( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java index 693f8a5814..240037f7a4 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java @@ -92,8 +92,7 @@ public class TransactionPoolFactoryTest { peerTransactionTracker, transactionsMessageSender, peerPendingTransactionTracker, - pendingTransactionsMessageSender, - Optional.empty()); + pendingTransactionsMessageSender); final EthProtocolManager ethProtocolManager = new EthProtocolManager( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java index 08e0a645f8..5646a8333a 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java @@ -65,6 +65,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.data.TransactionType; @@ -133,6 +134,7 @@ public class TransactionPoolTest { TransactionPoolConfiguration.DEFAULT_PRICE_BUMP); when(protocolSchedule.getByBlockNumber(anyLong())).thenReturn(protocolSpec); when(protocolSpec.getTransactionValidator()).thenReturn(transactionValidator); + when(protocolSpec.getFeeMarket()).thenReturn(Optional.of(FeeMarket.london())); genesisBlockGasLimit = executionContext.getGenesis().getHeader().getGasLimit(); syncState = mock(SyncState.class); when(syncState.isInSync(anyLong())).thenReturn(true); @@ -154,7 +156,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.of(2), metricsSystem, - Optional.empty(), TransactionPoolConfiguration.DEFAULT); blockchain.observeBlockAdded(transactionPool); } @@ -431,7 +432,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), TransactionPoolConfiguration.DEFAULT); when(pendingTransactions.containsTransaction(transaction1.getHash())).thenReturn(true); @@ -571,7 +571,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), TransactionPoolConfiguration.DEFAULT); final TransactionTestFixture builder = new TransactionTestFixture(); @@ -643,7 +642,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), TransactionPoolConfiguration.DEFAULT); final TransactionTestFixture builder = new TransactionTestFixture(); @@ -705,7 +703,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ZERO).build()); when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any())) .thenReturn(valid()); @@ -743,7 +740,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ONE).build()); when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any())) .thenReturn(valid()); @@ -786,8 +782,8 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.of(new EIP1559(100)), ImmutableTransactionPoolConfiguration.builder().txFeeCap(Wei.ONE).build()); + when(protocolSpec.getEip1559()).thenReturn(Optional.of(new EIP1559(100L))); when(transactionValidator.validate(any(Transaction.class), any(Optional.class), any())) .thenReturn(valid()); when(transactionValidator.validateForSender( @@ -830,7 +826,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), ImmutableTransactionPoolConfiguration.builder().txFeeCap(twoEthers).build()); final TransactionTestFixture builder = new TransactionTestFixture(); @@ -870,7 +865,6 @@ public class TransactionPoolTest { peerPendingTransactionTracker, Wei.ZERO, metricsSystem, - Optional.empty(), ImmutableTransactionPoolConfiguration.builder().txFeeCap(twoEthers).build()); final Transaction transaction37 = diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java index 895e7ad59a..b4d6e3198f 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java @@ -18,7 +18,6 @@ package org.hyperledger.besu.evmtool; import static picocli.CommandLine.ScopeType.INHERIT; import org.hyperledger.besu.cli.config.NetworkName; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Address; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -159,11 +158,8 @@ public class EvmToolCommand implements Runnable { out = resultHandler.out(); final CommandLine commandLine = new CommandLine(this); commandLine.addMixin("Dagger Options", daggerOptions); - // Usage of static command line flags is strictly reserved for experimental EIPs - commandLine.addMixin("Experimental EIPs", ExperimentalEIPs.class); // add sub commands here - commandLine.registerConverter(Address.class, Address::fromHexString); commandLine.registerConverter(Bytes.class, Bytes::fromHexString); commandLine.registerConverter(Gas.class, (arg) -> Gas.of(Long.parseUnsignedLong(arg))); diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java index be2afac2e0..84e7f8ec68 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java @@ -77,6 +77,7 @@ public class NoRewardProtocolScheduleWrapper implements ProtocolSchedule { original.isSkipZeroBlockRewards(), original.getGasCalculator(), original.getTransactionPriceCalculator(), + original.getFeeMarket(), original.getEip1559(), original.getBadBlocksManager(), Optional.empty()); diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java index 62d9ff39e4..b4fafbd7f7 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java @@ -32,7 +32,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Wei; -import org.hyperledger.besu.ethereum.core.fees.EIP1559; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthMessages; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; @@ -206,11 +205,7 @@ public class RetestethContext { metricsSystem, syncState, Wei.ZERO, - transactionPoolConfiguration, - jsonGenesisConfigOptions.getEIP1559BlockNumber().isPresent() - ? Optional.of( - new EIP1559(jsonGenesisConfigOptions.getEIP1559BlockNumber().getAsLong())) - : Optional.empty()); + transactionPoolConfiguration); LOG.trace("Genesis Block {} ", genesisState::getBlock); diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java index 2bc1f5e23e..d52009d60e 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java @@ -14,7 +14,6 @@ */ package org.hyperledger.besu.ethereum.retesteth.methods; -import org.hyperledger.besu.config.experimental.ExperimentalEIPs; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; @@ -133,16 +132,7 @@ public class TestSetChainParams implements JsonRpcMethod { maybeMove(genesis, "nonce", chainParamsJson, "nonce"); maybeMove(genesis, "timestamp", chainParamsJson, "timestamp"); maybeMove(chainParamsJson, "accounts", chainParamsJson, "alloc"); - - if (params.containsKey("londonForkBlock")) { - JsonObject genesisConfig = chainParamsJson.getJsonObject("genesis", new JsonObject()); - ExperimentalEIPs.initialBasefee = - Optional.ofNullable( - genesisConfig.getString("baseFeePerGas", genesisConfig.getString("baseFee"))) - .map(Long::decode) - .orElse(ExperimentalEIPs.EIP1559_BASEFEE_DEFAULT_VALUE); - } - + maybeMove(genesis, "baseFeePerGas", chainParamsJson, "baseFeePerGas"); maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock"); // strip out precompiles with zero balance diff --git a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json b/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json index d20b2ca252..95535e269f 100644 --- a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json +++ b/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json @@ -3,7 +3,7 @@ "author" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", "difficulty" : "0x020000", "gasLimit" : "0x04d2", - "baseFee" : "0x3039", + "baseFeePerGas" : "0x3039", "extraData" : "0x00", "timestamp" : "0x00", "nonce" : "0x0000000000000000",