From feb17641998214285b8b4ad6c9773ff6748930d8 Mon Sep 17 00:00:00 2001 From: Suraneti Date: Sat, 16 Mar 2024 07:42:53 +0700 Subject: [PATCH] feat: add fixed basefee options (#6562) * feat: add fixed basefee options Signed-off-by: Suraneti Rodsuwan * Refactor zero base fee to be extension of fixed base fee Signed-off-by: Matthew Whitehead * feat: use MiningParameters to fixed base fee Signed-off-by: Suraneti Rodsuwan * feat: add mining parameters arg on protocol schedule builder * feat: add miningParameters on gray glacier and prague Signed-off-by: Suraneti Rodsuwan * feat: add miningParameters on gray glacier and prague Signed-off-by: Suraneti Rodsuwan * feat: add miningParameters on paris,shanghai,future,experimental Signed-off-by: Suraneti Rodsuwan --------- Signed-off-by: Suraneti Rodsuwan Signed-off-by: Matthew Whitehead Signed-off-by: Suraneti Co-authored-by: Matthew Whitehead Co-authored-by: Sally MacFarlane --- .../CliqueBesuControllerBuilder.java | 1 + .../controller/IbftBesuControllerBuilder.java | 1 + .../MainnetBesuControllerBuilder.java | 1 + .../MergeBesuControllerBuilder.java | 6 +- .../controller/QbftBesuControllerBuilder.java | 1 + .../besu/ForkIdsNetworkConfigTest.java | 7 +- .../besu/config/GenesisConfigOptions.java | 7 + .../besu/config/JsonGenesisConfigOptions.java | 10 ++ .../besu/config/StubGenesisConfigOptions.java | 17 ++ .../besu/config/GenesisConfigOptionsTest.java | 21 +++ .../clique/CliqueProtocolSchedule.java | 7 + .../clique/CliqueProtocolScheduleTest.java | 6 + .../blockcreation/CliqueBlockCreatorTest.java | 1 + .../CliqueMinerExecutorTest.java | 1 + .../bft/BaseBftProtocolScheduleBuilder.java | 4 + .../CombinedProtocolScheduleFactoryTest.java | 2 + .../BaseBftProtocolScheduleBuilderTest.java | 2 + .../ibft/support/TestContextBuilder.java | 1 + .../ibft/IbftProtocolScheduleBuilder.java | 7 + .../ibft/IbftProtocolScheduleTest.java | 2 + .../blockcreation/BftBlockCreatorTest.java | 1 + .../IbftBlockHeightManagerTest.java | 2 + .../merge/MergeProtocolSchedule.java | 13 +- .../merge/TransitionProtocolSchedule.java | 11 +- .../merge/MergeProtocolScheduleTest.java | 18 ++- .../MergeGenesisConfigHelper.java | 6 +- .../qbft/support/TestContextBuilder.java | 12 ++ .../qbft/test/ValidatorContractTest.java | 51 ++++++ .../qbft/QbftProtocolScheduleBuilder.java | 10 ++ .../qbft/QbftProtocolScheduleTest.java | 2 + .../QbftBlockHeightManagerTest.java | 2 + .../api/jsonrpc/BlockchainImporter.java | 5 +- .../JsonRpcHttpServiceHostAllowlistTest.java | 1 + .../jsonrpc/JsonRpcHttpServiceLoginTest.java | 3 +- .../jsonrpc/JsonRpcHttpServiceTestBase.java | 1 + .../JsonRpcHttpServiceTlsClientAuthTest.java | 1 + ...RpcHttpServiceTlsMisconfigurationTest.java | 1 + .../jsonrpc/JsonRpcHttpServiceTlsTest.java | 1 + .../websocket/WebSocketServiceLoginTest.java | 5 +- .../AbstractBlockCreatorTest.java | 1 + .../AbstractBlockTransactionSelectorTest.java | 1 + ...FeeMarketBlockTransactionSelectorTest.java | 2 + ...FeeMarketBlockTransactionSelectorTest.java | 1 + .../blockcreation/PoWBlockCreatorTest.java | 4 + .../FixedDifficultyProtocolSchedule.java | 14 +- .../mainnet/MainnetProtocolSchedule.java | 36 ++++- .../mainnet/MainnetProtocolSpecFactory.java | 33 ++-- .../mainnet/MainnetProtocolSpecs.java | 62 ++++--- .../mainnet/ProtocolScheduleBuilder.java | 11 +- .../ethereum/mainnet/feemarket/FeeMarket.java | 4 + .../mainnet/feemarket/FixedBaseFeeMarket.java | 41 +++++ .../mainnet/feemarket/LondonFeeMarket.java | 2 +- .../mainnet/feemarket/ZeroBaseFeeMarket.java | 16 +- .../ethereum/core/BlockchainSetupUtil.java | 5 +- .../core/ExecutionContextTestFixture.java | 1 + .../core/ProtocolScheduleFixture.java | 1 + .../fixed/FixedProtocolScheduleTest.java | 2 + .../mainnet/DefaultProtocolScheduleTest.java | 2 + .../mainnet/MainnetProtocolScheduleTest.java | 5 + .../mainnet/ProtocolScheduleBuilderTest.java | 3 + .../feemarket/FixedBaseFeeMarketTest.java | 152 ++++++++++++++++++ ...BlockHeaderGasPriceValidationRuleTest.java | 25 +++ ...yValidationRuleFixedBaseFeeMarketTest.java | 75 +++++++++ .../trie/bonsai/AbstractIsolationTests.java | 4 +- .../eth/messages/BlockBodiesMessageTest.java | 2 + .../eth/messages/BlockHeadersMessageTest.java | 2 + .../eth/sync/ChainHeadTrackerTest.java | 2 + .../backwardsync/BackwardSyncContextTest.java | 4 +- .../backwardsync/BackwardSyncStepTest.java | 4 +- .../backwardsync/ForwardSyncStepTest.java | 4 +- .../AbstractTransactionPoolTest.java | 2 + .../ethereum/eth/transactions/TestNode.java | 1 + .../TransactionPoolFactoryTest.java | 1 + .../evmtool/MainnetGenesisFileModule.java | 4 +- .../ReferenceTestProtocolSchedules.java | 2 + .../mainnet/DifficultyCalculatorTests.java | 29 ++-- .../ethereum/retesteth/RetestethContext.java | 2 +- 77 files changed, 726 insertions(+), 87 deletions(-) create mode 100644 ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarket.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarketTest.java create mode 100644 ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitElasticityValidationRuleFixedBaseFeeMarketTest.java diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java index 88a675d4f1..7b13a211a7 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java @@ -130,6 +130,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java index c4a412e4dc..6ab517efd6 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java @@ -286,6 +286,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { isRevertReasonEnabled, bftExtraDataCodec().get(), evmConfiguration, + miningParameters, badBlockManager); } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java index fc25858309..4c2e0ee47a 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java @@ -95,6 +95,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java index 62bce6ac69..623aa2918f 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java @@ -173,7 +173,11 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { @Override protected ProtocolSchedule createProtocolSchedule() { return MergeProtocolSchedule.create( - configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled, badBlockManager); + configOptionsSupplier.get(), + privacyParameters, + isRevertReasonEnabled, + miningParameters, + badBlockManager); } @Override diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java index a622001ef8..747949aac1 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java @@ -326,6 +326,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { isRevertReasonEnabled, bftExtraDataCodec().get(), evmConfiguration, + miningParameters, badBlockManager); } diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java index ea82011bb5..bd396228ad 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.forkid.ForkId; import org.hyperledger.besu.ethereum.forkid.ForkIdManager; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -188,11 +189,13 @@ public class ForkIdsNetworkConfigTest { MilestoneStreamingProtocolSchedule preMergeProtocolSchedule = new MilestoneStreamingProtocolSchedule( (DefaultProtocolSchedule) - MainnetProtocolSchedule.fromConfig(configOptions, new BadBlockManager())); + MainnetProtocolSchedule.fromConfig( + configOptions, MiningParameters.MINING_DISABLED, new BadBlockManager())); MilestoneStreamingProtocolSchedule postMergeProtocolSchedule = new MilestoneStreamingProtocolSchedule( (DefaultProtocolSchedule) - MergeProtocolSchedule.create(configOptions, false, new BadBlockManager())); + MergeProtocolSchedule.create( + configOptions, false, MiningParameters.MINING_DISABLED, new BadBlockManager())); final MilestoneStreamingTransitionProtocolSchedule schedule = new MilestoneStreamingTransitionProtocolSchedule( preMergeProtocolSchedule, postMergeProtocolSchedule); diff --git a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java index e3c935eca6..1645688f09 100644 --- a/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java @@ -504,6 +504,13 @@ public interface GenesisConfigOptions { */ boolean isZeroBaseFee(); + /** + * Force a Base Fee as Gas Price network to used with London/EIP-1559. + * + * @return true, if you want the next block to use the base fee as gas price. + */ + boolean isFixedBaseFee(); + /** * The deposit contract address that should be in the logger field in Receipt of Deposit * transaction diff --git a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java index d2ce8401fc..5c1a203701 100644 --- a/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java @@ -47,6 +47,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions { private static final String DISCOVERY_CONFIG_KEY = "discovery"; private static final String CHECKPOINT_CONFIG_KEY = "checkpoint"; private static final String ZERO_BASE_FEE_KEY = "zerobasefee"; + private static final String FIXED_BASE_FEE_KEY = "fixedbasefee"; private static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress"; private final ObjectNode configRoot; @@ -421,6 +422,11 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions { return getOptionalBoolean(ZERO_BASE_FEE_KEY).orElse(false); } + @Override + public boolean isFixedBaseFee() { + return getOptionalBoolean(FIXED_BASE_FEE_KEY).orElse(false); + } + @Override public Optional
getDepositContractAddress() { Optional inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY); @@ -492,6 +498,10 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions { builder.put("zeroBaseFee", true); } + if (isFixedBaseFee()) { + builder.put("fixedBaseFee", true); + } + return builder.build(); } diff --git a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java index d3705487cd..3b8562533b 100644 --- a/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java +++ b/config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java @@ -78,6 +78,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable private TransitionsConfigOptions transitions = TransitionsConfigOptions.DEFAULT; private static final DiscoveryOptions DISCOVERY_OPTIONS = DiscoveryOptions.DEFAULT; private boolean zeroBaseFee = false; + private boolean fixedBaseFee = false; @Override public StubGenesisConfigOptions clone() { @@ -424,6 +425,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable return zeroBaseFee; } + @Override + public boolean isFixedBaseFee() { + return fixedBaseFee; + } + @Override public List getForkBlockNumbers() { return Collections.emptyList(); @@ -704,6 +710,17 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable return this; } + /** + * Fixed base fee per gas stub genesis config options. + * + * @param fixedBaseFee the zero base fee override + * @return the stub genesis config options + */ + public StubGenesisConfigOptions fixedBaseFee(final boolean fixedBaseFee) { + this.fixedBaseFee = fixedBaseFee; + return this; + } + /** * Classic fork block stub genesis config options. * diff --git a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java index 0300723359..bb4a8f94a9 100644 --- a/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java +++ b/config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java @@ -295,6 +295,27 @@ class GenesisConfigOptionsTest { assertThat(config.asMap()).containsOnlyKeys("zeroBaseFee").containsValue(true); } + @Test + void isFixedBaseFeeShouldDefaultToFalse() { + final GenesisConfigOptions config = GenesisConfigFile.fromConfig("{}").getConfigOptions(); + + assertThat(config.isFixedBaseFee()).isFalse(); + } + + @Test + void isFixedBaseFeeParsedCorrectly() { + final GenesisConfigOptions config = fromConfigOptions(Map.of("fixedbasefee", true)); + + assertThat(config.isFixedBaseFee()).isTrue(); + } + + @Test + void asMapIncludesFixedBaseFee() { + final GenesisConfigOptions config = fromConfigOptions(Map.of("fixedbasefee", true)); + + assertThat(config.asMap()).containsOnlyKeys("fixedBaseFee").containsValue(true); + } + @Test void shouldGetDepositContractAddress() { final GenesisConfigOptions config = diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java index 5f1351c40a..18bd44f440 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; @@ -58,6 +59,7 @@ public class CliqueProtocolSchedule { * @param privacyParameters the privacy parameters * @param isRevertReasonEnabled the is revert reason enabled * @param evmConfiguration the evm configuration + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -68,6 +70,7 @@ public class CliqueProtocolSchedule { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions(); @@ -103,6 +106,7 @@ public class CliqueProtocolSchedule { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager) .createProtocolSchedule(); } @@ -115,6 +119,7 @@ public class CliqueProtocolSchedule { * @param nodeKey the node key * @param isRevertReasonEnabled the is revert reason enabled * @param evmConfiguration the evm configuration + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -125,6 +130,7 @@ public class CliqueProtocolSchedule { final NodeKey nodeKey, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return create( config, @@ -133,6 +139,7 @@ public class CliqueProtocolSchedule { PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java index a6eefb9411..30a3967da9 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java @@ -32,6 +32,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -66,6 +67,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1)); @@ -89,6 +91,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .getByBlockHeader(blockHeader(0)); @@ -112,6 +115,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager())) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Epoch length in config must be greater than zero"); @@ -131,6 +135,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager())) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Epoch length in config must be greater than zero"); @@ -154,6 +159,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); BlockHeader emptyFrontierParent = diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java index b6edc93047..7dcbfa34ba 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java @@ -106,6 +106,7 @@ public class CliqueBlockCreatorTest { proposerNodeKey, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey()); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java index 185674aa90..9ff2b713ce 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java @@ -104,6 +104,7 @@ public class CliqueMinerExecutorTest { proposerNodeKey, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS); blockHeaderBuilder = new BlockHeaderTestFixture(); diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java index 2a334f8b03..2578a80568 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java @@ -19,6 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.consensus.common.ForksSchedule; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -52,6 +53,7 @@ public abstract class BaseBftProtocolScheduleBuilder { * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -62,6 +64,7 @@ public abstract class BaseBftProtocolScheduleBuilder { final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { final Map> specMap = new HashMap<>(); @@ -83,6 +86,7 @@ public abstract class BaseBftProtocolScheduleBuilder { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager) .createProtocolSchedule(); return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule); diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java index f310912c59..1d1d21e33f 100644 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java +++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -175,6 +176,7 @@ public class CombinedProtocolScheduleFactoryTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); return new BftProtocolSchedule( diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java index 9734468e06..9b05bd7a36 100644 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java +++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -243,6 +244,7 @@ public class BaseBftProtocolScheduleBuilderTest { false, bftExtraDataCodec, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java index cd34570827..55a2f3551a 100644 --- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java +++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java @@ -332,6 +332,7 @@ public class TestContextBuilder { forksSchedule, IBFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); ///////////////////////////////////////////////////////////////////////////////////// diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java index bc4e6982ed..4f2e4da434 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; @@ -41,6 +42,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -51,6 +53,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return new IbftProtocolScheduleBuilder() .createProtocolSchedule( @@ -60,6 +63,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration, + miningParameters, badBlockManager); } @@ -70,6 +74,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param forksSchedule the forks schedule * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -78,6 +83,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule forksSchedule, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return create( config, @@ -86,6 +92,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder false, bftExtraDataCodec, evmConfiguration, + miningParameters, badBlockManager); } diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java index de8ead1d23..5ff7d2b533 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java @@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; @@ -101,6 +102,7 @@ public class IbftProtocolScheduleTest { false, bftExtraDataCodec, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java index 621340d829..25c5c1d10b 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java @@ -120,6 +120,7 @@ public class BftBlockCreatorTest { false, bftExtraDataEncoder, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final ProtocolContext protContext = new ProtocolContext( diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java index 2521737f81..feb5bbc97d 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java @@ -69,6 +69,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -179,6 +180,7 @@ public class IbftBlockHeightManagerTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); ProtocolSchedule protocolSchedule = diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java index 506dc217a3..ab1c940a8e 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.consensus.merge; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -43,14 +44,21 @@ public class MergeProtocolSchedule { * * @param config the config * @param isRevertReasonEnabled the is revert reason enabled + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ public static ProtocolSchedule create( final GenesisConfigOptions config, final boolean isRevertReasonEnabled, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { - return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, badBlockManager); + return create( + config, + PrivacyParameters.DEFAULT, + isRevertReasonEnabled, + miningParameters, + badBlockManager); } /** @@ -59,6 +67,7 @@ public class MergeProtocolSchedule { * @param config the config * @param privacyParameters the privacy parameters * @param isRevertReasonEnabled the is revert reason enabled + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -66,6 +75,7 @@ public class MergeProtocolSchedule { final GenesisConfigOptions config, final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { Map> postMergeModifications = @@ -84,6 +94,7 @@ public class MergeProtocolSchedule { privacyParameters, isRevertReasonEnabled, EvmConfiguration.DEFAULT, + miningParameters, badBlockManager) .createProtocolSchedule(); } diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java index bae3e518d9..f15f0c1e9f 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java @@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; @@ -62,15 +63,19 @@ public class TransitionProtocolSchedule implements ProtocolSchedule { * * @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the * milestone starting points + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return an initialised TransitionProtocolSchedule using post-merge defaults */ public static TransitionProtocolSchedule fromConfig( - final GenesisConfigOptions genesisConfigOptions, final BadBlockManager badBlockManager) { + final GenesisConfigOptions genesisConfigOptions, + final MiningParameters miningParameters, + final BadBlockManager badBlockManager) { ProtocolSchedule preMergeProtocolSchedule = - MainnetProtocolSchedule.fromConfig(genesisConfigOptions, badBlockManager); + MainnetProtocolSchedule.fromConfig(genesisConfigOptions, miningParameters, badBlockManager); ProtocolSchedule postMergeProtocolSchedule = - MergeProtocolSchedule.create(genesisConfigOptions, false, badBlockManager); + MergeProtocolSchedule.create( + genesisConfigOptions, false, miningParameters, badBlockManager); return new TransitionProtocolSchedule( preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get()); } diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java index 5f6c38a34f..a4a07054d3 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -46,7 +47,8 @@ public class MergeProtocolScheduleTest { final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); final ProtocolSchedule protocolSchedule = - MergeProtocolSchedule.create(config, false, new BadBlockManager()); + MergeProtocolSchedule.create( + config, false, MiningParameters.MINING_DISABLED, new BadBlockManager()); final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1)); final ProtocolSpec londonSpec = protocolSchedule.getByBlockHeader(blockHeader(1559)); @@ -61,7 +63,8 @@ public class MergeProtocolScheduleTest { final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); final ProtocolSchedule protocolSchedule = - MergeProtocolSchedule.create(config, false, new BadBlockManager()); + MergeProtocolSchedule.create( + config, false, MiningParameters.MINING_DISABLED, new BadBlockManager()); final long lastParisBlockNumber = 17034869L; final ProtocolSpec parisSpec = @@ -96,7 +99,8 @@ public class MergeProtocolScheduleTest { final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); final ProtocolSchedule protocolSchedule = - MergeProtocolSchedule.create(config, false, new BadBlockManager()); + MergeProtocolSchedule.create( + config, false, MiningParameters.MINING_DISABLED, new BadBlockManager()); final ProtocolSpec parisSpec = protocolSchedule.getByBlockHeader( @@ -123,7 +127,8 @@ public class MergeProtocolScheduleTest { public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis() { final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); final ProtocolSchedule protocolSchedule = - MergeProtocolSchedule.create(config, false, new BadBlockManager()); + MergeProtocolSchedule.create( + config, false, MiningParameters.MINING_DISABLED, new BadBlockManager()); final long lastParisBlockNumber = 17034869L; final ProtocolSpec parisSpec = @@ -152,7 +157,10 @@ public class MergeProtocolScheduleTest { public void parametersAlignWithMainnetWithAdjustments() { final ProtocolSpec london = MergeProtocolSchedule.create( - GenesisConfigFile.DEFAULT.getConfigOptions(), false, new BadBlockManager()) + GenesisConfigFile.DEFAULT.getConfigOptions(), + false, + MiningParameters.MINING_DISABLED, + new BadBlockManager()) .getByBlockHeader(blockHeader(0)); assertThat(london.getName()).isEqualTo("Paris"); diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java index d7fcec771a..80615552e7 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import java.io.IOException; @@ -59,6 +60,9 @@ public interface MergeGenesisConfigHelper { default ProtocolSchedule getMergeProtocolSchedule() { return MergeProtocolSchedule.create( - getPosGenesisConfigFile().getConfigOptions(), false, new BadBlockManager()); + getPosGenesisConfigFile().getConfigOptions(), + false, + MiningParameters.MINING_DISABLED, + new BadBlockManager()); } } diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java index dcfb049dad..f66973ef6a 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java +++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java @@ -150,6 +150,7 @@ public class TestContextBuilder { private boolean useLondonMilestone = false; private boolean useShanghaiMilestone = false; private boolean useZeroBaseFee = false; + private boolean useFixedBaseFee = false; public static final int EPOCH_LENGTH = 10_000; public static final int BLOCK_TIMER_SEC = 3; public static final int ROUND_TIMER_SEC = 12; @@ -227,6 +228,11 @@ public class TestContextBuilder { return this; } + public TestContextBuilder useFixedBaseFee(final boolean useFixedBaseFee) { + this.useFixedBaseFee = useFixedBaseFee; + return this; + } + public TestContextBuilder qbftForks(final List qbftForks) { this.qbftForks = qbftForks; return this; @@ -294,6 +300,7 @@ public class TestContextBuilder { useLondonMilestone, useShanghaiMilestone, useZeroBaseFee, + useFixedBaseFee, qbftForks); // Add each networkNode to the Multicaster (such that each can receive msgs from local node). @@ -375,6 +382,7 @@ public class TestContextBuilder { final boolean useLondonMilestone, final boolean useShanghaiMilestone, final boolean useZeroBaseFee, + final boolean useFixedBaseFee, final List qbftForks) { final MiningParameters miningParams = @@ -407,6 +415,9 @@ public class TestContextBuilder { if (useZeroBaseFee) { genesisConfigOptions.zeroBaseFee(true); } + if (useFixedBaseFee) { + genesisConfigOptions.fixedBaseFee(true); + } genesisConfigOptions.qbftConfigOptions( new JsonQbftConfigOptions(JsonUtil.objectNodeFromMap(qbftConfigValues))); genesisConfigOptions.transitions(TestTransitions.createQbftTestTransitions(qbftForks)); @@ -425,6 +436,7 @@ public class TestContextBuilder { forksSchedule, BFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks); diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java index b1949e7917..c597856006 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java +++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java @@ -167,6 +167,57 @@ public class ValidatorContractTest { assertThat(validatorProvider.getValidatorsForBlock(block1)).containsExactly(NODE_ADDRESS); } + @Test + public void retrievesValidatorsFromValidatorContract_LondonFork_FixedBaseFee() { + // Using London on a free gas network + final TestContext context = + new TestContextBuilder() + .indexOfFirstLocallyProposedBlock(0) + .nodeParams( + List.of(new NodeParams(NODE_ADDRESS, NodeKeyUtils.createFrom(NODE_PRIVATE_KEY)))) + .clock(TestClock.fixed()) + .genesisFile(Resources.getResource("genesis_validator_contract_london.json").getFile()) + .useValidatorContract(true) + .useLondonMilestone(true) + .useFixedBaseFee(true) + .buildAndStart(); + + createNewBlockAsProposer(context, 1); + + final ValidatorProvider validatorProvider = context.getValidatorProvider(); + final BlockHeader genesisBlock = context.getBlockchain().getBlockHeader(0).get(); + final BlockHeader block1 = context.getBlockchain().getBlockHeader(1).get(); + assertThat(validatorProvider.getValidatorsForBlock(genesisBlock)).containsExactly(NODE_ADDRESS); + assertThat(validatorProvider.getValidatorsForBlock(block1)).containsExactly(NODE_ADDRESS); + } + + @Test + public void retrievesValidatorsFromValidatorContract_ShanghaiFork_FixedBaseFee() { + // Using Shanghai on a free gas network + final TestContext context = + new TestContextBuilder() + .indexOfFirstLocallyProposedBlock(0) + .nodeParams( + List.of(new NodeParams(NODE_ADDRESS, NodeKeyUtils.createFrom(NODE_PRIVATE_KEY)))) + .clock(TestClock.fixed()) + .genesisFile( + Resources.getResource("genesis_validator_contract_shanghai.json").getFile()) + .useValidatorContract(true) + .useShanghaiMilestone(true) + .useFixedBaseFee(true) + .buildAndStart(); + + createNewBlockAsProposerFixedTime( + context, 1, + 266L); // 10s ahead of genesis timestamp in genesis_validator_contract_shanghai.json + + final ValidatorProvider validatorProvider = context.getValidatorProvider(); + final BlockHeader genesisBlock = context.getBlockchain().getBlockHeader(0).get(); + final BlockHeader block1 = context.getBlockchain().getBlockHeader(1).get(); + assertThat(validatorProvider.getValidatorsForBlock(genesisBlock)).containsExactly(NODE_ADDRESS); + assertThat(validatorProvider.getValidatorsForBlock(block1)).containsExactly(NODE_ADDRESS); + } + @Test public void transitionsFromBlockHeaderModeToValidatorContractMode() { final List qbftForks = diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java index 01d87b7cd9..d611e82372 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java @@ -24,6 +24,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -45,6 +46,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration + * @param miningParameters The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -55,6 +57,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return new QbftProtocolScheduleBuilder() .createProtocolSchedule( @@ -64,6 +67,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration, + miningParameters, badBlockManager); } @@ -74,6 +78,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param qbftForksSchedule the qbft forks schedule * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration + * @param miningParameters The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -82,6 +87,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule qbftForksSchedule, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return create( config, @@ -90,6 +96,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder false, bftExtraDataCodec, evmConfiguration, + miningParameters, badBlockManager); } @@ -100,6 +107,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param qbftForksSchedule the qbft forks schedule * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec + * @param miningParameters The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return the protocol schedule */ @@ -108,6 +116,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule qbftForksSchedule, final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return create( config, @@ -116,6 +125,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, EvmConfiguration.DEFAULT, + miningParameters, badBlockManager); } diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java index 16a5f4ca31..3243484152 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; @@ -136,6 +137,7 @@ public class QbftProtocolScheduleTest { false, bftExtraDataCodec, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java index b582f1a9b8..4a2dd5b9b8 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java @@ -68,6 +68,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -179,6 +180,7 @@ public class QbftBlockHeightManagerTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); ProtocolSchedule protocolSchedule = diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java index a3ad8d4d69..2a62331d33 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java @@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; @@ -43,7 +44,9 @@ public class BlockchainImporter { public BlockchainImporter(final URL blocksUrl, final String genesisJson) throws Exception { protocolSchedule = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(), new BadBlockManager()); + GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(), + MiningParameters.newDefault(), + new BadBlockManager()); final BlockHeaderFunctions blockHeaderFunctions = ScheduleBasedBlockHeaderFunctions.create(protocolSchedule); blocks = new ArrayList<>(); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java index 797129710e..a261ff2351 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java @@ -108,6 +108,7 @@ public class JsonRpcHttpServiceHostAllowlistTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), + MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java index 357f41b8e4..2b8b1ae347 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java @@ -137,7 +137,8 @@ public class JsonRpcHttpServiceLoginTest { peerDiscoveryMock, blockchainQueries, synchronizer, - MainnetProtocolSchedule.fromConfig(genesisConfigOptions, new BadBlockManager()), + MainnetProtocolSchedule.fromConfig( + genesisConfigOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java index 0ce460866e..a5f90791ce 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java @@ -118,6 +118,7 @@ public class JsonRpcHttpServiceTestBase { MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java index edea0a4315..2f62e490be 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java @@ -122,6 +122,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), + MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java index 0f20776e45..2ff0833bc6 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java @@ -110,6 +110,7 @@ class JsonRpcHttpServiceTlsMisconfigurationTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), + MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java index 0a43cd0e37..e650f9d490 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java @@ -111,6 +111,7 @@ public class JsonRpcHttpServiceTlsTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), + MiningParameters.MINING_DISABLED, new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java index 9b5c688ddd..bedd7aa4c3 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java @@ -173,7 +173,10 @@ public class WebSocketServiceLoginTest { peerDiscoveryMock, blockchainQueries, synchronizer, - MainnetProtocolSchedule.fromConfig(genesisConfigOptions, new BadBlockManager()), + MainnetProtocolSchedule.fromConfig( + genesisConfigOptions, + MiningParameters.MINING_DISABLED, + new BadBlockManager()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index 3e8cc8a685..560c149877 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -364,6 +364,7 @@ abstract class AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule()) .build(); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java index a3b657dbc3..a7dab2f124 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java @@ -221,6 +221,7 @@ public abstract class AbstractBlockTransactionSelectorTest { FixedDifficultyProtocolSchedule.create( GenesisConfigFile.development().getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final MainnetTransactionProcessor mainnetTransactionProcessor = protocolSchedule.getByBlockHeader(blockHeader(0)).getTransactionProcessor(); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java index 10d54576b4..39db9c05cf 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; @@ -59,6 +60,7 @@ public class LegacyFeeMarketBlockTransactionSelectorTest new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java index 4a961d07e8..8250039b2b 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java @@ -71,6 +71,7 @@ public class LondonFeeMarketBlockTransactionSelectorTest new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java index ad3ce47887..f7fd4486d1 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java @@ -93,6 +93,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule()) .build(); @@ -148,6 +149,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule()) .build(); @@ -193,6 +195,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); final ExecutionContextTestFixture executionContextTestFixture = @@ -261,6 +264,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); final ExecutionContextTestFixture executionContextTestFixture = diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java index f92f0813fc..b7f8395d92 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.difficulty.fixed; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; @@ -30,6 +31,7 @@ public class FixedDifficultyProtocolSchedule { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return new ProtocolScheduleBuilder( config, @@ -40,6 +42,7 @@ public class FixedDifficultyProtocolSchedule { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager) .createProtocolSchedule(); } @@ -48,19 +51,28 @@ public class FixedDifficultyProtocolSchedule { final GenesisConfigOptions config, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return create( config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } public static ProtocolSchedule create( final GenesisConfigOptions config, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { - return create(config, PrivacyParameters.DEFAULT, false, evmConfiguration, badBlockManager); + return create( + config, + PrivacyParameters.DEFAULT, + false, + evmConfiguration, + miningParameters, + badBlockManager); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java index 6982d28d4e..794f96cfb3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; @@ -37,6 +38,7 @@ public class MainnetProtocolSchedule { * @param privacyParameters the parameters set for private transactions * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param evmConfiguration how to configure the EVMs jumpdest cache + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return A configured mainnet protocol schedule */ @@ -45,10 +47,16 @@ public class MainnetProtocolSchedule { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) { return FixedDifficultyProtocolSchedule.create( - config, privacyParameters, isRevertReasonEnabled, evmConfiguration, badBlockManager); + config, + privacyParameters, + isRevertReasonEnabled, + evmConfiguration, + miningParameters, + badBlockManager); } return new ProtocolScheduleBuilder( config, @@ -57,6 +65,7 @@ public class MainnetProtocolSchedule { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager) .createProtocolSchedule(); } @@ -68,6 +77,7 @@ public class MainnetProtocolSchedule { * starting points * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param evmConfiguration how to configure the EVMs jumpdest cache + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return A configured mainnet protocol schedule */ @@ -75,12 +85,14 @@ public class MainnetProtocolSchedule { final GenesisConfigOptions config, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { return fromConfig( config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } @@ -90,14 +102,22 @@ public class MainnetProtocolSchedule { * @param config {@link GenesisConfigOptions} containing the config options for the milestone * starting points * @param evmConfiguration size of + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return A configured mainnet protocol schedule */ public static ProtocolSchedule fromConfig( final GenesisConfigOptions config, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { - return fromConfig(config, PrivacyParameters.DEFAULT, false, evmConfiguration, badBlockManager); + return fromConfig( + config, + PrivacyParameters.DEFAULT, + false, + evmConfiguration, + miningParameters, + badBlockManager); } /** @@ -105,12 +125,20 @@ public class MainnetProtocolSchedule { * * @param config {@link GenesisConfigOptions} containing the config options for the milestone * starting points + * @param miningParameters the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @return A configured mainnet protocol schedule */ public static ProtocolSchedule fromConfig( - final GenesisConfigOptions config, final BadBlockManager badBlockManager) { + final GenesisConfigOptions config, + final MiningParameters miningParameters, + final BadBlockManager badBlockManager) { return fromConfig( - config, PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, badBlockManager); + config, + PrivacyParameters.DEFAULT, + false, + EvmConfiguration.DEFAULT, + miningParameters, + badBlockManager); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java index de7f92465b..06bc45084a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; import java.math.BigInteger; @@ -30,6 +31,7 @@ public class MainnetProtocolSpecFactory { private final boolean isRevertReasonEnabled; private final OptionalLong ecip1017EraRounds; private final EvmConfiguration evmConfiguration; + private final MiningParameters miningParameters; public MainnetProtocolSpecFactory( final Optional chainId, @@ -37,13 +39,15 @@ public class MainnetProtocolSpecFactory { final OptionalInt evmStackSize, final boolean isRevertReasonEnabled, final OptionalLong ecip1017EraRounds, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { this.chainId = chainId; this.contractSizeLimit = contractSizeLimit; this.evmStackSize = evmStackSize; this.isRevertReasonEnabled = isRevertReasonEnabled; this.ecip1017EraRounds = ecip1017EraRounds; this.evmConfiguration = evmConfiguration; + this.miningParameters = miningParameters; } public ProtocolSpecBuilder frontierDefinition() { @@ -113,7 +117,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder arrowGlacierDefinition( @@ -124,7 +129,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder grayGlacierDefinition( @@ -135,7 +141,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) { @@ -145,7 +152,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) { @@ -155,7 +163,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisConfigOptions) { @@ -165,7 +174,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisConfigOptions) { @@ -175,7 +185,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } /** @@ -196,7 +207,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } /** @@ -217,7 +229,8 @@ public class MainnetProtocolSpecFactory { evmStackSize, isRevertReasonEnabled, genesisConfigOptions, - evmConfiguration); + evmConfiguration, + miningParameters); } //////////////////////////////////////////////////////////////////////////////////////////////// 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 2e5f114157..ca22648411 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 @@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.MainnetBlockValidator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -433,7 +434,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { final int contractSizeLimit = configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); @@ -442,7 +444,10 @@ public abstract class MainnetProtocolSpecs { final BaseFeeMarket londonFeeMarket = genesisConfigOptions.isZeroBaseFee() ? FeeMarket.zeroBaseFee(londonForkBlockNumber) - : FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); + : genesisConfigOptions.isFixedBaseFee() + ? FeeMarket.fixedBaseFee( + londonForkBlockNumber, miningParameters.getMinTransactionGasPrice()) + : FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); return berlinDefinition( chainId, configContractSizeLimit, @@ -515,14 +520,16 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { return londonDefinition( chainId, configContractSizeLimit, configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) .difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER) .name("ArrowGlacier"); } @@ -533,14 +540,16 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { return arrowGlacierDefinition( chainId, configContractSizeLimit, configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) .difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER) .name("GrayGlacier"); } @@ -551,7 +560,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { return grayGlacierDefinition( chainId, @@ -559,7 +569,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) .evmBuilder( (gasCalculator, jdCacheConfig) -> MainnetEVMs.paris(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration)) @@ -577,7 +588,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { // extra variables need to support flipping the warm coinbase flag. final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); @@ -588,7 +600,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) // gas calculator has new code to support EIP-3860 limit and meter initcode .gasCalculator(ShanghaiGasCalculator::new) // EVM has a new operation for EIP-3855 PUSH0 instruction @@ -638,14 +651,18 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L); final BaseFeeMarket cancunFeeMarket = genesisConfigOptions.isZeroBaseFee() ? FeeMarket.zeroBaseFee(londonForkBlockNumber) - : FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); + : genesisConfigOptions.isFixedBaseFee() + ? FeeMarket.fixedBaseFee( + londonForkBlockNumber, miningParameters.getMinTransactionGasPrice()) + : FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); return shanghaiDefinition( chainId, @@ -653,7 +670,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) .feeMarket(cancunFeeMarket) // gas calculator for EIP-4844 blob gas .gasCalculator(CancunGasCalculator::new) @@ -710,7 +728,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { final int contractSizeLimit = configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); @@ -720,7 +739,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) // EVM changes to support EOF EIPs (3670, 4200, 4750, 5450) .gasCalculator(PragueGasCalculator::new) .evmBuilder( @@ -749,7 +769,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { final int contractSizeLimit = configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); return pragueDefinition( @@ -758,7 +779,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) // Use Future EIP configured EVM .evmBuilder( (gasCalculator, jdCacheConfig) -> @@ -786,7 +808,8 @@ public abstract class MainnetProtocolSpecs { final OptionalInt configStackSizeLimit, final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, - final EvmConfiguration evmConfiguration) { + final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters) { final Address depositContractAddress = genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); @@ -797,7 +820,8 @@ public abstract class MainnetProtocolSpecs { configStackSizeLimit, enableRevertReason, genesisConfigOptions, - evmConfiguration) + evmConfiguration, + miningParameters) .evmBuilder( (gasCalculator, jdCacheConfig) -> MainnetEVMs.experimentalEips( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java index 14fcedba2f..58db065155 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -40,6 +41,7 @@ public class ProtocolScheduleBuilder { private final PrivacyParameters privacyParameters; private final boolean isRevertReasonEnabled; private final EvmConfiguration evmConfiguration; + private final MiningParameters miningParameters; private final BadBlockManager badBlockManager; private DefaultProtocolSchedule protocolSchedule; @@ -51,6 +53,7 @@ public class ProtocolScheduleBuilder { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { this( config, @@ -59,6 +62,7 @@ public class ProtocolScheduleBuilder { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } @@ -68,6 +72,7 @@ public class ProtocolScheduleBuilder { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { this( config, @@ -76,6 +81,7 @@ public class ProtocolScheduleBuilder { privacyParameters, isRevertReasonEnabled, evmConfiguration, + miningParameters, badBlockManager); } @@ -86,6 +92,7 @@ public class ProtocolScheduleBuilder { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, + final MiningParameters miningParameters, final BadBlockManager badBlockManager) { this.config = config; this.protocolSpecAdapters = protocolSpecAdapters; @@ -93,6 +100,7 @@ public class ProtocolScheduleBuilder { this.isRevertReasonEnabled = isRevertReasonEnabled; this.evmConfiguration = evmConfiguration; this.defaultChainId = defaultChainId; + this.miningParameters = miningParameters; this.badBlockManager = badBlockManager; } @@ -113,7 +121,8 @@ public class ProtocolScheduleBuilder { config.getEvmStackSize(), isRevertReasonEnabled, config.getEcip1017EraRounds(), - evmConfiguration); + evmConfiguration, + miningParameters); validateForkOrdering(); 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 637ffb471e..fc5defbd10 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 @@ -53,6 +53,10 @@ public interface FeeMarket { return new ZeroBaseFeeMarket(londonForkBlockNumber); } + static BaseFeeMarket fixedBaseFee(final long londonForkBlockNumber, final Wei fixedBaseFee) { + return new FixedBaseFeeMarket(londonForkBlockNumber, fixedBaseFee); + } + static FeeMarket legacy() { return new LegacyFeeMarket(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarket.java new file mode 100644 index 0000000000..5aeddd0672 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarket.java @@ -0,0 +1,41 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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.ethereum.mainnet.feemarket; + +import org.hyperledger.besu.datatypes.Wei; + +import java.util.Optional; + +public class FixedBaseFeeMarket extends LondonFeeMarket { + + public FixedBaseFeeMarket(final long londonForkBlockNumber, final Wei fixedBaseFee) { + super(londonForkBlockNumber, Optional.of(fixedBaseFee)); + } + + @Override + public Wei computeBaseFee( + final long blockNumber, + final Wei parentBaseFee, + final long parentBlockGasUsed, + final long targetGasUsed) { + + return baseFeeInitialValue; + } + + @Override + public ValidationMode baseFeeValidationMode(final long blockNumber) { + return ValidationMode.NONE; + } +} 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 2fff3a629f..d1a148ceed 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 @@ -35,7 +35,7 @@ public class LondonFeeMarket implements BaseFeeMarket { private static final Wei DEFAULT_BASEFEE_FLOOR = Wei.of(7L); - private final Wei baseFeeInitialValue; + protected final Wei baseFeeInitialValue; private final long londonForkBlockNumber; private final TransactionPriceCalculator txPriceCalculator; private final Wei baseFeeFloor; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/ZeroBaseFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/ZeroBaseFeeMarket.java index c2f406cad0..7b32e3f84c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/ZeroBaseFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/ZeroBaseFeeMarket.java @@ -16,22 +16,10 @@ package org.hyperledger.besu.ethereum.mainnet.feemarket; import org.hyperledger.besu.datatypes.Wei; -import java.util.Optional; - -public class ZeroBaseFeeMarket extends LondonFeeMarket { +public class ZeroBaseFeeMarket extends FixedBaseFeeMarket { public ZeroBaseFeeMarket(final long londonForkBlockNumber) { - super(londonForkBlockNumber, Optional.of(Wei.ZERO)); - } - - @Override - public Wei computeBaseFee( - final long blockNumber, - final Wei parentBaseFee, - final long parentBlockGasUsed, - final long targetGasUsed) { - - return Wei.ZERO; + super(londonForkBlockNumber, Wei.ZERO); } @Override diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index cf142eb2ed..f0ffbb9862 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -142,7 +142,10 @@ public class BlockchainSetupUtil { private static ProtocolSchedule mainnetProtocolScheduleProvider( final GenesisConfigFile genesisConfigFile) { return MainnetProtocolSchedule.fromConfig( - genesisConfigFile.getConfigOptions(), EvmConfiguration.DEFAULT, new BadBlockManager()); + genesisConfigFile.getConfigOptions(), + EvmConfiguration.DEFAULT, + MiningParameters.newDefault(), + new BadBlockManager()); } private static ProtocolContext mainnetProtocolContextProvider( diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java index 25c65b357f..40f4c8c931 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java @@ -140,6 +140,7 @@ public class ExecutionContextTestFixture { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java index b0292fda05..0df40c56da 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java @@ -39,6 +39,7 @@ public class ProtocolScheduleFixture { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.newDefault(), new BadBlockManager()); private static GenesisConfigOptions getMainnetConfigOptions() { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java index f4b589cf60..afb0e195f3 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java @@ -20,6 +20,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -34,6 +35,7 @@ public class FixedProtocolScheduleTest { FixedDifficultyProtocolSchedule.create( GenesisConfigFile.development().getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java index 91bece386e..b68104d81b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java @@ -23,6 +23,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -60,6 +61,7 @@ public class DefaultProtocolScheduleTest { privacyParameters, isRevertReasonEnabled, evmConfiguration, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java index 60406fa05e..a8b5b772f8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -74,6 +75,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig("{}").getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); Assertions.assertThat(sched.getByBlockHeader(blockHeader(1L)).getName()).isEqualTo("Frontier"); Assertions.assertThat(sched.getByBlockHeader(blockHeader(Long.MAX_VALUE)).getName()) @@ -88,6 +90,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); Assertions.assertThat(sched.getByBlockHeader(blockHeader(1)).getName()).isEqualTo("Frontier"); Assertions.assertThat(sched.getByBlockHeader(blockHeader(2)).getName()).isEqualTo("Homestead"); @@ -119,6 +122,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager())); } @@ -131,6 +135,7 @@ public class MainnetProtocolScheduleTest { this.getClass().getResource("/goerli.json"), StandardCharsets.UTF_8)) .getConfigOptions(), EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); Assertions.assertThat(sched.getByBlockHeader(blockHeader(0L)).getName()) .isEqualTo("Petersburg"); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java index ab1c64d274..c7be26039e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java @@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -59,6 +60,7 @@ class ProtocolScheduleBuilderTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } @@ -213,6 +215,7 @@ class ProtocolScheduleBuilderTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); return new MilestoneStreamingProtocolSchedule( diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarketTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarketTest.java new file mode 100644 index 0000000000..0e0873b39c --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarketTest.java @@ -0,0 +1,152 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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.ethereum.mainnet.feemarket; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.hyperledger.besu.crypto.KeyPair; +import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; +import org.hyperledger.besu.datatypes.BlobGas; +import org.hyperledger.besu.datatypes.TransactionType; +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.core.TransactionTestFixture; + +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FixedBaseFeeMarketTest { + + private static final KeyPair KEY_PAIR1 = + SignatureAlgorithmFactory.getInstance().generateKeyPair(); + private static final long FORK_BLOCK = 0; + private FixedBaseFeeMarket fixedBaseFeeMarket; + + @BeforeEach + public void setUp() throws Exception { + fixedBaseFeeMarket = new FixedBaseFeeMarket(FORK_BLOCK, Wei.ONE); + } + + @Test + public void getBasefeeMaxChangeDenominatorShouldUseLondonDefault() { + assertThat(fixedBaseFeeMarket.getBasefeeMaxChangeDenominator()) + .isEqualTo(LondonFeeMarket.DEFAULT_BASEFEE_MAX_CHANGE_DENOMINATOR); + } + + @Test + public void getInitialBasefeeShouldBeZero() { + assertThat(fixedBaseFeeMarket.getInitialBasefee()).isEqualTo(Wei.ONE); + } + + @Test + public void getSlackCoefficientShouldUseLondonDefault() { + assertThat(fixedBaseFeeMarket.getSlackCoefficient()) + .isEqualTo(LondonFeeMarket.DEFAULT_SLACK_COEFFICIENT); + } + + @Test + public void getTransactionPriceCalculatorShouldBeEIP1559() { + // only eip1559 will read the fee per gas values + final Transaction transaction = + new TransactionTestFixture() + .type(TransactionType.EIP1559) + .maxFeePerGas(Optional.of(Wei.of(8))) + .maxPriorityFeePerGas(Optional.of(Wei.of(8))) + .gasPrice(null) + .createTransaction(KEY_PAIR1); + + assertThat( + fixedBaseFeeMarket + .getTransactionPriceCalculator() + .price(transaction, Optional.of(Wei.ZERO))) + .isEqualTo(Wei.of(8)); + } + + @Test + public void satisfiesFloorTxCostWhenGasFeeIsNonZero() { + final Transaction transaction = + new TransactionTestFixture() + .type(TransactionType.FRONTIER) + .gasPrice(Wei.of(7)) + .createTransaction(KEY_PAIR1); + assertThat(fixedBaseFeeMarket.satisfiesFloorTxFee(transaction)).isTrue(); + } + + @Test + public void satisfiesFloorTxCostWhenGasFeeIsZero() { + final Transaction transaction = + new TransactionTestFixture() + .type(TransactionType.EIP1559) + .maxFeePerGas(Optional.of(Wei.ZERO)) + .maxPriorityFeePerGas(Optional.of(Wei.ZERO)) + .gasPrice(null) + .createTransaction(KEY_PAIR1); + assertThat(fixedBaseFeeMarket.satisfiesFloorTxFee(transaction)).isFalse(); + } + + @Test + public void computeBaseFeeReturnsFixedValue() { + assertThat(fixedBaseFeeMarket.computeBaseFee(1L, Wei.of(1), 1L, 2L)).isEqualTo(Wei.ONE); + } + + @Test + public void baseFeeValidationModeShouldBeNoneWhenIsForkBlock() { + assertThat(fixedBaseFeeMarket.baseFeeValidationMode(FORK_BLOCK)) + .isEqualTo(BaseFeeMarket.ValidationMode.NONE); + } + + @Test + public void baseFeeValidationModeShouldBeNoneWhenIsNotForkBlock() { + assertThat(fixedBaseFeeMarket.baseFeeValidationMode(FORK_BLOCK + 1)) + .isEqualTo(BaseFeeMarket.ValidationMode.NONE); + } + + @Test + public void gasLimitValidationModeShouldBeInitialWhenIsForkBlock() { + assertThat(fixedBaseFeeMarket.gasLimitValidationMode(FORK_BLOCK)) + .isEqualTo(BaseFeeMarket.ValidationMode.INITIAL); + } + + @Test + public void gasLimitValidationModeShouldBeOngoingWhenIsNotForkBlock() { + assertThat(fixedBaseFeeMarket.gasLimitValidationMode(FORK_BLOCK + 1)) + .isEqualTo(BaseFeeMarket.ValidationMode.ONGOING); + } + + @Test + public void isBeforeForkBlockShouldBeTrue() { + final FixedBaseFeeMarket fixedBaseFeeMarket = new FixedBaseFeeMarket(10, Wei.ONE); + assertThat(fixedBaseFeeMarket.isBeforeForkBlock(9)).isTrue(); + } + + @Test + public void isBeforeForkBlockShouldBeFalse() { + final FixedBaseFeeMarket fixedBaseFeeMarket = new FixedBaseFeeMarket(10, Wei.ONE); + assertThat(fixedBaseFeeMarket.isBeforeForkBlock(10)).isFalse(); + assertThat(fixedBaseFeeMarket.isBeforeForkBlock(11)).isFalse(); + } + + @Test + public void implementsDataFeedShouldReturnFalse() { + assertThat(fixedBaseFeeMarket.implementsDataFee()).isFalse(); + } + + @Test + public void dataPriceShouldReturnsZero() { + assertThat(fixedBaseFeeMarket.blobGasPricePerGas(BlobGas.ONE)).isEqualTo(Wei.ZERO); + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRuleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRuleTest.java index ca2cfe4d56..2cd1936b3a 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRuleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRuleTest.java @@ -128,4 +128,29 @@ public class BaseFeeMarketBlockHeaderGasPriceValidationRuleTest { blockHeader(FORK_BLOCK - 1, 0, Optional.of(londonFeeMarketBaseFee)))) .isTrue(); } + + @Test + public void shouldReturnTrueIfUsingFixedBaseFeeMarket() { + final BaseFeeMarket fixedBaseFeeMarket = FeeMarket.fixedBaseFee(FORK_BLOCK, Wei.ONE); + final var validationRule = + new BaseFeeMarketBlockHeaderGasPriceValidationRule(fixedBaseFeeMarket); + assertThat( + validationRule.validate( + blockHeader(FORK_BLOCK + 2, 0, Optional.of(fixedBaseFeeMarket.getInitialBasefee())), + blockHeader(FORK_BLOCK + 1, 0, Optional.of(feeMarket.getInitialBasefee()), 2))) + .isTrue(); + } + + @Test + public void shouldReturnTrueIfUsingFixedBaseFeeMarketOnNonZeroLondonForkBlock() { + final BaseFeeMarket zeroBaseFeeMarket = FeeMarket.fixedBaseFee(FORK_BLOCK, Wei.ONE); + final var validationRule = + new BaseFeeMarketBlockHeaderGasPriceValidationRule(zeroBaseFeeMarket); + final Wei londonFeeMarketBaseFee = feeMarket.getInitialBasefee(); + assertThat( + validationRule.validate( + blockHeader(FORK_BLOCK, 0, Optional.of(londonFeeMarketBaseFee)), + blockHeader(FORK_BLOCK - 1, 0, Optional.of(londonFeeMarketBaseFee)))) + .isTrue(); + } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitElasticityValidationRuleFixedBaseFeeMarketTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitElasticityValidationRuleFixedBaseFeeMarketTest.java new file mode 100644 index 0000000000..7f2387cdca --- /dev/null +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitElasticityValidationRuleFixedBaseFeeMarketTest.java @@ -0,0 +1,75 @@ +/* + * Copyright Hyperledger Besu Contributors. + * + * 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.ethereum.mainnet.headervalidationrules; + +import static java.lang.Long.MAX_VALUE; +import static org.assertj.core.api.Assertions.assertThat; + +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; +import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; +import org.hyperledger.besu.ethereum.mainnet.feemarket.FixedBaseFeeMarket; + +import java.util.Optional; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +public class GasLimitElasticityValidationRuleFixedBaseFeeMarketTest { + + private static final Optional fixedBaseFeeMarket = + Optional.of(new FixedBaseFeeMarket(10, Wei.ONE)); + + public GasLimitRangeAndDeltaValidationRule uut = + new GasLimitRangeAndDeltaValidationRule(5000, MAX_VALUE, fixedBaseFeeMarket); + + @ParameterizedTest + @CsvSource({ + "20000000, 10000000, 10, true", + "20019530, 10000000, 10, true", + "20019531, 10000000, 10, false", + "19980470, 10000000, 10, true", + "19980469, 10000000, 10, false", + "20000000, 20000000, 11, true", + "20019530, 20000000, 11, true", + "20019531, 20000000, 11, false", + "19980470, 20000000, 11, true", + "19980469, 20000000, 11, false", + "40039061, 40000000, 11, true", + "40039062, 40000000, 11, false", + "39960939, 40000000, 11, true", + "39960938, 40000000, 11, false", + "4999, 40000000, 11, false" + }) + public void test( + final long headerGasLimit, + final long parentGasLimit, + final long headerNumber, + final boolean expectedResult) { + + final BlockHeaderTestFixture blockHeaderBuilder = new BlockHeaderTestFixture(); + + blockHeaderBuilder.number(headerNumber); + blockHeaderBuilder.gasLimit(headerGasLimit); + final BlockHeader header = blockHeaderBuilder.buildHeader(); + + blockHeaderBuilder.number(headerNumber - 1); + blockHeaderBuilder.gasLimit(parentGasLimit); + final BlockHeader parent = blockHeaderBuilder.buildHeader(); + + assertThat(uut.validate(header, parent)).isEqualTo(expectedResult); + } +} diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java index 33710bd4a4..2d18bee326 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java @@ -105,7 +105,9 @@ public abstract class AbstractIsolationTests { .createKeyPair(SECPPrivateKey.create(Bytes32.fromHexString(key), "ECDSA")); protected final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( - GenesisConfigFile.development().getConfigOptions(), new BadBlockManager()); + GenesisConfigFile.development().getConfigOptions(), + MiningParameters.MINING_DISABLED, + new BadBlockManager()); protected final GenesisState genesisState = GenesisState.fromConfig(GenesisConfigFile.development(), protocolSchedule); protected final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java index 67a81b4518..1a69dd1dab 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; @@ -58,6 +59,7 @@ public final class BlockBodiesMessageTest { GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java index f1720c61c5..08d2262c2d 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java @@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.eth.messages; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; @@ -65,6 +66,7 @@ public final class BlockHeadersMessageTest { GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager())); for (int i = 0; i < 50; ++i) { diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java index 808005f858..9912d66f38 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java @@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.eth.manager.ChainState; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -55,6 +56,7 @@ public class ChainHeadTrackerTest { GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); private final TrailingPeerLimiter trailingPeerLimiter = mock(TrailingPeerLimiter.class); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java index 5ee3192fa0..622d66587c 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java @@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -94,7 +95,8 @@ public class BackwardSyncContextTest { @Spy private ProtocolSchedule protocolSchedule = - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()); + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions(), MiningParameters.MINING_DISABLED, new BadBlockManager()); @Spy private ProtocolSpec protocolSpec = diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java index 1656d7a7b4..a506e7fa3f 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -68,7 +69,8 @@ public class BackwardSyncStepTest { private BackwardSyncContext context; private final ProtocolSchedule protocolSchedule = - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()); + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions(), MiningParameters.MINING_DISABLED, new BadBlockManager()); private final DeterministicEthScheduler ethScheduler = new DeterministicEthScheduler(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java index e8ae62d40b..cb5cb0aed1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java @@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -74,7 +75,8 @@ public class ForwardSyncStepTest { private RespondingEthPeer peer; private final ProtocolSchedule protocolSchedule = - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()); + MainnetProtocolSchedule.fromConfig( + new StubGenesisConfigOptions(), MiningParameters.MINING_DISABLED, new BadBlockManager()); private MutableBlockchain localBlockchain; GenericKeyValueStorageFacade headersStorage; GenericKeyValueStorageFacade blocksStorage; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTest.java index e811df51f1..082b50796e 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTest.java @@ -60,6 +60,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -195,6 +196,7 @@ public abstract class AbstractTransactionPoolTest { new PrivacyParameters(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); final ExecutionContextTestFixture executionContextTestFixture = 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 762e7cf7a9..62dde1f8f4 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 @@ -116,6 +116,7 @@ public class TestNode implements Closeable { GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()); final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule); 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 422f21a870..5410cfc92d 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 @@ -366,6 +366,7 @@ public class TransactionPoolFactoryTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java index 8f18a79659..5b5f2e0fb8 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.crypto.SignatureAlgorithmType; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; @@ -76,7 +77,7 @@ class MainnetGenesisFileModule extends GenesisFileModule { } } return MainnetProtocolSchedule.fromConfig( - configOptions, evmConfiguration, new BadBlockManager()); + configOptions, evmConfiguration, MiningParameters.newDefault(), new BadBlockManager()); } public static Map> createSchedules() { @@ -134,6 +135,7 @@ class MainnetGenesisFileModule extends GenesisFileModule { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); } diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java index dae9badfd1..0a137c4ea8 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java @@ -18,6 +18,7 @@ package org.hyperledger.besu.ethereum.referencetests; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; @@ -106,6 +107,7 @@ public class ReferenceTestProtocolSchedules { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, + MiningParameters.MINING_DISABLED, new BadBlockManager()) .createProtocolSchedule(); } diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java index df9fac4bdc..6377b1ae3b 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java @@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; +import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.log.LogsBloomFilter; @@ -58,64 +59,64 @@ public class DifficultyCalculatorTests { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.mainnet() .getConfigOptions(postMergeOverrides), - EvmConfiguration.DEFAULT, new BadBlockManager())), + EvmConfiguration.DEFAULT, MiningParameters.newDefault(), new BadBlockManager())), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierForkBlock.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff1.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff2.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfByzantium/difficultyByzantium.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfConstantinople/difficultyConstantinople.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384_random.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384_random_to20M.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfFrontier/difficultyFrontier.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), MiningParameters.newDefault(), new BadBlockManager()) ), Arguments.of( "/DifficultyTests/dfHomestead/difficultyHomestead.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), new BadBlockManager()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), MiningParameters.newDefault(), new BadBlockManager()) )); } 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 a9b5050be3..e34d9f4473 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 @@ -158,7 +158,7 @@ public class RetestethContext { JsonUtil.getObjectNode(genesisConfig, "config").get()); protocolSchedule = MainnetProtocolSchedule.fromConfig( - jsonGenesisConfigOptions, EvmConfiguration.DEFAULT, badBlockManager); + jsonGenesisConfigOptions, EvmConfiguration.DEFAULT, miningParameters, badBlockManager); if ("NoReward".equalsIgnoreCase(sealEngine)) { protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule, badBlockManager); }