feat: add fixed basefee options (#6562)

* feat: add fixed basefee options

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>

* Refactor zero base fee to be extension of fixed base fee

Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>

* feat: use MiningParameters to fixed base fee

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>

* feat: add mining parameters arg on protocol schedule builder

* feat: add miningParameters on gray glacier and prague

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>

* feat: add miningParameters on gray glacier and prague

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>

* feat: add miningParameters on paris,shanghai,future,experimental

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>

---------

Signed-off-by: Suraneti Rodsuwan <suraneti.rod@gmail.com>
Signed-off-by: Matthew Whitehead <matthew1001@gmail.com>
Signed-off-by: Suraneti <suraneti.rod@gmail.com>
Co-authored-by: Matthew Whitehead <matthew1001@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/6748/head
Suraneti 8 months ago committed by GitHub
parent de0704afbf
commit feb1764199
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
  2. 1
      besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
  3. 1
      besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
  4. 6
      besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java
  5. 1
      besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
  6. 7
      besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java
  7. 7
      config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java
  8. 10
      config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java
  9. 17
      config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java
  10. 21
      config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java
  11. 7
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
  12. 6
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
  13. 1
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
  14. 1
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
  15. 4
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java
  16. 2
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java
  17. 2
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java
  18. 1
      consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
  19. 7
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java
  20. 2
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
  21. 1
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
  22. 2
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java
  23. 13
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java
  24. 11
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java
  25. 18
      consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java
  26. 6
      consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java
  27. 12
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  28. 51
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java
  29. 10
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java
  30. 2
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java
  31. 2
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java
  32. 5
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/BlockchainImporter.java
  33. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
  34. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
  35. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
  36. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
  37. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
  38. 1
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
  39. 5
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
  40. 1
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java
  41. 1
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java
  42. 2
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java
  43. 1
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java
  44. 4
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java
  45. 14
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
  46. 36
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
  47. 33
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
  48. 62
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  49. 11
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  50. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FeeMarket.java
  51. 41
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarket.java
  52. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java
  53. 16
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/ZeroBaseFeeMarket.java
  54. 5
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java
  55. 1
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java
  56. 1
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java
  57. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java
  58. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java
  59. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
  60. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java
  61. 152
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/feemarket/FixedBaseFeeMarketTest.java
  62. 25
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/BaseFeeMarketBlockHeaderGasPriceValidationRuleTest.java
  63. 75
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/headervalidationrules/GasLimitElasticityValidationRuleFixedBaseFeeMarketTest.java
  64. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/bonsai/AbstractIsolationTests.java
  65. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java
  66. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java
  67. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java
  68. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java
  69. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java
  70. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java
  71. 2
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTest.java
  72. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java
  73. 1
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java
  74. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java
  75. 2
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  76. 29
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java
  77. 2
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java

@ -130,6 +130,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -286,6 +286,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -95,6 +95,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -173,7 +173,11 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
@Override @Override
protected ProtocolSchedule createProtocolSchedule() { protected ProtocolSchedule createProtocolSchedule() {
return MergeProtocolSchedule.create( return MergeProtocolSchedule.create(
configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled, badBlockManager); configOptionsSupplier.get(),
privacyParameters,
isRevertReasonEnabled,
miningParameters,
badBlockManager);
} }
@Override @Override

@ -326,6 +326,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec().get(), bftExtraDataCodec().get(),
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.ForkId;
import org.hyperledger.besu.ethereum.forkid.ForkIdManager; import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -188,11 +189,13 @@ public class ForkIdsNetworkConfigTest {
MilestoneStreamingProtocolSchedule preMergeProtocolSchedule = MilestoneStreamingProtocolSchedule preMergeProtocolSchedule =
new MilestoneStreamingProtocolSchedule( new MilestoneStreamingProtocolSchedule(
(DefaultProtocolSchedule) (DefaultProtocolSchedule)
MainnetProtocolSchedule.fromConfig(configOptions, new BadBlockManager())); MainnetProtocolSchedule.fromConfig(
configOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()));
MilestoneStreamingProtocolSchedule postMergeProtocolSchedule = MilestoneStreamingProtocolSchedule postMergeProtocolSchedule =
new MilestoneStreamingProtocolSchedule( new MilestoneStreamingProtocolSchedule(
(DefaultProtocolSchedule) (DefaultProtocolSchedule)
MergeProtocolSchedule.create(configOptions, false, new BadBlockManager())); MergeProtocolSchedule.create(
configOptions, false, MiningParameters.MINING_DISABLED, new BadBlockManager()));
final MilestoneStreamingTransitionProtocolSchedule schedule = final MilestoneStreamingTransitionProtocolSchedule schedule =
new MilestoneStreamingTransitionProtocolSchedule( new MilestoneStreamingTransitionProtocolSchedule(
preMergeProtocolSchedule, postMergeProtocolSchedule); preMergeProtocolSchedule, postMergeProtocolSchedule);

@ -504,6 +504,13 @@ public interface GenesisConfigOptions {
*/ */
boolean isZeroBaseFee(); 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 * The deposit contract address that should be in the logger field in Receipt of Deposit
* transaction * transaction

@ -47,6 +47,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
private static final String DISCOVERY_CONFIG_KEY = "discovery"; private static final String DISCOVERY_CONFIG_KEY = "discovery";
private static final String CHECKPOINT_CONFIG_KEY = "checkpoint"; private static final String CHECKPOINT_CONFIG_KEY = "checkpoint";
private static final String ZERO_BASE_FEE_KEY = "zerobasefee"; 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 static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress";
private final ObjectNode configRoot; private final ObjectNode configRoot;
@ -421,6 +422,11 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
return getOptionalBoolean(ZERO_BASE_FEE_KEY).orElse(false); return getOptionalBoolean(ZERO_BASE_FEE_KEY).orElse(false);
} }
@Override
public boolean isFixedBaseFee() {
return getOptionalBoolean(FIXED_BASE_FEE_KEY).orElse(false);
}
@Override @Override
public Optional<Address> getDepositContractAddress() { public Optional<Address> getDepositContractAddress() {
Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY); Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY);
@ -492,6 +498,10 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
builder.put("zeroBaseFee", true); builder.put("zeroBaseFee", true);
} }
if (isFixedBaseFee()) {
builder.put("fixedBaseFee", true);
}
return builder.build(); return builder.build();
} }

@ -78,6 +78,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
private TransitionsConfigOptions transitions = TransitionsConfigOptions.DEFAULT; private TransitionsConfigOptions transitions = TransitionsConfigOptions.DEFAULT;
private static final DiscoveryOptions DISCOVERY_OPTIONS = DiscoveryOptions.DEFAULT; private static final DiscoveryOptions DISCOVERY_OPTIONS = DiscoveryOptions.DEFAULT;
private boolean zeroBaseFee = false; private boolean zeroBaseFee = false;
private boolean fixedBaseFee = false;
@Override @Override
public StubGenesisConfigOptions clone() { public StubGenesisConfigOptions clone() {
@ -424,6 +425,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
return zeroBaseFee; return zeroBaseFee;
} }
@Override
public boolean isFixedBaseFee() {
return fixedBaseFee;
}
@Override @Override
public List<Long> getForkBlockNumbers() { public List<Long> getForkBlockNumbers() {
return Collections.emptyList(); return Collections.emptyList();
@ -704,6 +710,17 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
return this; 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. * Classic fork block stub genesis config options.
* *

@ -295,6 +295,27 @@ class GenesisConfigOptionsTest {
assertThat(config.asMap()).containsOnlyKeys("zeroBaseFee").containsValue(true); 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 @Test
void shouldGetDepositContractAddress() { void shouldGetDepositContractAddress() {
final GenesisConfigOptions config = final GenesisConfigOptions config =

@ -22,6 +22,7 @@ import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
@ -58,6 +59,7 @@ public class CliqueProtocolSchedule {
* @param privacyParameters the privacy parameters * @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -68,6 +70,7 @@ public class CliqueProtocolSchedule {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions(); final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
@ -103,6 +106,7 @@ public class CliqueProtocolSchedule {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager) badBlockManager)
.createProtocolSchedule(); .createProtocolSchedule();
} }
@ -115,6 +119,7 @@ public class CliqueProtocolSchedule {
* @param nodeKey the node key * @param nodeKey the node key
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -125,6 +130,7 @@ public class CliqueProtocolSchedule {
final NodeKey nodeKey, final NodeKey nodeKey,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create( return create(
config, config,
@ -133,6 +139,7 @@ public class CliqueProtocolSchedule {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -32,6 +32,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@ -66,6 +67,7 @@ public class CliqueProtocolScheduleTest {
NODE_KEY, NODE_KEY,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1)); final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
@ -89,6 +91,7 @@ public class CliqueProtocolScheduleTest {
NODE_KEY, NODE_KEY,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.getByBlockHeader(blockHeader(0)); .getByBlockHeader(blockHeader(0));
@ -112,6 +115,7 @@ public class CliqueProtocolScheduleTest {
NODE_KEY, NODE_KEY,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager())) new BadBlockManager()))
.isInstanceOf(IllegalArgumentException.class) .isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero"); .hasMessage("Epoch length in config must be greater than zero");
@ -131,6 +135,7 @@ public class CliqueProtocolScheduleTest {
NODE_KEY, NODE_KEY,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager())) new BadBlockManager()))
.isInstanceOf(IllegalArgumentException.class) .isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero"); .hasMessage("Epoch length in config must be greater than zero");
@ -154,6 +159,7 @@ public class CliqueProtocolScheduleTest {
NODE_KEY, NODE_KEY,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
BlockHeader emptyFrontierParent = BlockHeader emptyFrontierParent =

@ -106,6 +106,7 @@ public class CliqueBlockCreatorTest {
proposerNodeKey, proposerNodeKey,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey()); final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());

@ -104,6 +104,7 @@ public class CliqueMinerExecutorTest {
proposerNodeKey, proposerNodeKey,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS); cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS);
blockHeaderBuilder = new BlockHeaderTestFixture(); blockHeaderBuilder = new BlockHeaderTestFixture();

@ -19,6 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule; import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -52,6 +53,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -62,6 +64,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>(); final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
@ -83,6 +86,7 @@ public abstract class BaseBftProtocolScheduleBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager) badBlockManager)
.createProtocolSchedule(); .createProtocolSchedule();
return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule); return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule);

@ -21,6 +21,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -175,6 +176,7 @@ public class CombinedProtocolScheduleFactoryTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
return new BftProtocolSchedule( return new BftProtocolSchedule(

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -243,6 +244,7 @@ public class BaseBftProtocolScheduleBuilderTest {
false, false,
bftExtraDataCodec, bftExtraDataCodec,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }

@ -332,6 +332,7 @@ public class TestContextBuilder {
forksSchedule, forksSchedule,
IBFT_EXTRA_DATA_ENCODER, IBFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////

@ -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.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; 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 isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -51,6 +53,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return new IbftProtocolScheduleBuilder() return new IbftProtocolScheduleBuilder()
.createProtocolSchedule( .createProtocolSchedule(
@ -60,6 +63,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec, bftExtraDataCodec,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -70,6 +74,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param forksSchedule the forks schedule * @param forksSchedule the forks schedule
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -78,6 +83,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule<BftConfigOptions> forksSchedule, final ForksSchedule<BftConfigOptions> forksSchedule,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create( return create(
config, config,
@ -86,6 +92,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
false, false,
bftExtraDataCodec, bftExtraDataCodec,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
@ -101,6 +102,7 @@ public class IbftProtocolScheduleTest {
false, false,
bftExtraDataCodec, bftExtraDataCodec,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }

@ -120,6 +120,7 @@ public class BftBlockCreatorTest {
false, false,
bftExtraDataEncoder, bftExtraDataEncoder,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final ProtocolContext protContext = final ProtocolContext protContext =
new ProtocolContext( new ProtocolContext(

@ -69,6 +69,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -179,6 +180,7 @@ public class IbftBlockHeightManagerTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
ProtocolSchedule protocolSchedule = ProtocolSchedule protocolSchedule =

@ -17,6 +17,7 @@ package org.hyperledger.besu.consensus.merge;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -43,14 +44,21 @@ public class MergeProtocolSchedule {
* *
* @param config the config * @param config the config
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
public static ProtocolSchedule create( public static ProtocolSchedule create(
final GenesisConfigOptions config, final GenesisConfigOptions config,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { 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 config the config
* @param privacyParameters the privacy parameters * @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -66,6 +75,7 @@ public class MergeProtocolSchedule {
final GenesisConfigOptions config, final GenesisConfigOptions config,
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications = Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications =
@ -84,6 +94,7 @@ public class MergeProtocolSchedule {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
miningParameters,
badBlockManager) badBlockManager)
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Difficulty; 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.PermissionTransactionFilter;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; 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 * @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the
* milestone starting points * milestone starting points
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return an initialised TransitionProtocolSchedule using post-merge defaults * @return an initialised TransitionProtocolSchedule using post-merge defaults
*/ */
public static TransitionProtocolSchedule fromConfig( public static TransitionProtocolSchedule fromConfig(
final GenesisConfigOptions genesisConfigOptions, final BadBlockManager badBlockManager) { final GenesisConfigOptions genesisConfigOptions,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) {
ProtocolSchedule preMergeProtocolSchedule = ProtocolSchedule preMergeProtocolSchedule =
MainnetProtocolSchedule.fromConfig(genesisConfigOptions, badBlockManager); MainnetProtocolSchedule.fromConfig(genesisConfigOptions, miningParameters, badBlockManager);
ProtocolSchedule postMergeProtocolSchedule = ProtocolSchedule postMergeProtocolSchedule =
MergeProtocolSchedule.create(genesisConfigOptions, false, badBlockManager); MergeProtocolSchedule.create(
genesisConfigOptions, false, miningParameters, badBlockManager);
return new TransitionProtocolSchedule( return new TransitionProtocolSchedule(
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get()); preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
} }

@ -22,6 +22,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.MainnetBlockProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@ -46,7 +47,8 @@ public class MergeProtocolScheduleTest {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
final ProtocolSchedule protocolSchedule = 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 homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
final ProtocolSpec londonSpec = protocolSchedule.getByBlockHeader(blockHeader(1559)); final ProtocolSpec londonSpec = protocolSchedule.getByBlockHeader(blockHeader(1559));
@ -61,7 +63,8 @@ public class MergeProtocolScheduleTest {
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
final ProtocolSchedule protocolSchedule = final ProtocolSchedule protocolSchedule =
MergeProtocolSchedule.create(config, false, new BadBlockManager()); MergeProtocolSchedule.create(
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
final long lastParisBlockNumber = 17034869L; final long lastParisBlockNumber = 17034869L;
final ProtocolSpec parisSpec = final ProtocolSpec parisSpec =
@ -96,7 +99,8 @@ public class MergeProtocolScheduleTest {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions(); final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
final ProtocolSchedule protocolSchedule = final ProtocolSchedule protocolSchedule =
MergeProtocolSchedule.create(config, false, new BadBlockManager()); MergeProtocolSchedule.create(
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
final ProtocolSpec parisSpec = final ProtocolSpec parisSpec =
protocolSchedule.getByBlockHeader( protocolSchedule.getByBlockHeader(
@ -123,7 +127,8 @@ public class MergeProtocolScheduleTest {
public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis() { public void mergeSpecificModificationsAreUnappliedForAllMainnetForksAfterParis() {
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions(); final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
final ProtocolSchedule protocolSchedule = final ProtocolSchedule protocolSchedule =
MergeProtocolSchedule.create(config, false, new BadBlockManager()); MergeProtocolSchedule.create(
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
final long lastParisBlockNumber = 17034869L; final long lastParisBlockNumber = 17034869L;
final ProtocolSpec parisSpec = final ProtocolSpec parisSpec =
@ -152,7 +157,10 @@ public class MergeProtocolScheduleTest {
public void parametersAlignWithMainnetWithAdjustments() { public void parametersAlignWithMainnetWithAdjustments() {
final ProtocolSpec london = final ProtocolSpec london =
MergeProtocolSchedule.create( MergeProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(), false, new BadBlockManager()) GenesisConfigFile.DEFAULT.getConfigOptions(),
false,
MiningParameters.MINING_DISABLED,
new BadBlockManager())
.getByBlockHeader(blockHeader(0)); .getByBlockHeader(blockHeader(0));
assertThat(london.getName()).isEqualTo("Paris"); assertThat(london.getName()).isEqualTo("Paris");

@ -21,6 +21,7 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule; import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import java.io.IOException; import java.io.IOException;
@ -59,6 +60,9 @@ public interface MergeGenesisConfigHelper {
default ProtocolSchedule getMergeProtocolSchedule() { default ProtocolSchedule getMergeProtocolSchedule() {
return MergeProtocolSchedule.create( return MergeProtocolSchedule.create(
getPosGenesisConfigFile().getConfigOptions(), false, new BadBlockManager()); getPosGenesisConfigFile().getConfigOptions(),
false,
MiningParameters.MINING_DISABLED,
new BadBlockManager());
} }
} }

@ -150,6 +150,7 @@ public class TestContextBuilder {
private boolean useLondonMilestone = false; private boolean useLondonMilestone = false;
private boolean useShanghaiMilestone = false; private boolean useShanghaiMilestone = false;
private boolean useZeroBaseFee = false; private boolean useZeroBaseFee = false;
private boolean useFixedBaseFee = false;
public static final int EPOCH_LENGTH = 10_000; public static final int EPOCH_LENGTH = 10_000;
public static final int BLOCK_TIMER_SEC = 3; public static final int BLOCK_TIMER_SEC = 3;
public static final int ROUND_TIMER_SEC = 12; public static final int ROUND_TIMER_SEC = 12;
@ -227,6 +228,11 @@ public class TestContextBuilder {
return this; return this;
} }
public TestContextBuilder useFixedBaseFee(final boolean useFixedBaseFee) {
this.useFixedBaseFee = useFixedBaseFee;
return this;
}
public TestContextBuilder qbftForks(final List<QbftFork> qbftForks) { public TestContextBuilder qbftForks(final List<QbftFork> qbftForks) {
this.qbftForks = qbftForks; this.qbftForks = qbftForks;
return this; return this;
@ -294,6 +300,7 @@ public class TestContextBuilder {
useLondonMilestone, useLondonMilestone,
useShanghaiMilestone, useShanghaiMilestone,
useZeroBaseFee, useZeroBaseFee,
useFixedBaseFee,
qbftForks); qbftForks);
// Add each networkNode to the Multicaster (such that each can receive msgs from local node). // 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 useLondonMilestone,
final boolean useShanghaiMilestone, final boolean useShanghaiMilestone,
final boolean useZeroBaseFee, final boolean useZeroBaseFee,
final boolean useFixedBaseFee,
final List<QbftFork> qbftForks) { final List<QbftFork> qbftForks) {
final MiningParameters miningParams = final MiningParameters miningParams =
@ -407,6 +415,9 @@ public class TestContextBuilder {
if (useZeroBaseFee) { if (useZeroBaseFee) {
genesisConfigOptions.zeroBaseFee(true); genesisConfigOptions.zeroBaseFee(true);
} }
if (useFixedBaseFee) {
genesisConfigOptions.fixedBaseFee(true);
}
genesisConfigOptions.qbftConfigOptions( genesisConfigOptions.qbftConfigOptions(
new JsonQbftConfigOptions(JsonUtil.objectNodeFromMap(qbftConfigValues))); new JsonQbftConfigOptions(JsonUtil.objectNodeFromMap(qbftConfigValues)));
genesisConfigOptions.transitions(TestTransitions.createQbftTestTransitions(qbftForks)); genesisConfigOptions.transitions(TestTransitions.createQbftTestTransitions(qbftForks));
@ -425,6 +436,7 @@ public class TestContextBuilder {
forksSchedule, forksSchedule,
BFT_EXTRA_DATA_ENCODER, BFT_EXTRA_DATA_ENCODER,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks); final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks);

@ -167,6 +167,57 @@ public class ValidatorContractTest {
assertThat(validatorProvider.getValidatorsForBlock(block1)).containsExactly(NODE_ADDRESS); 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 @Test
public void transitionsFromBlockHeaderModeToValidatorContractMode() { public void transitionsFromBlockHeaderModeToValidatorContractMode() {
final List<QbftFork> qbftForks = final List<QbftFork> qbftForks =

@ -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.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -45,6 +46,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -55,6 +57,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return new QbftProtocolScheduleBuilder() return new QbftProtocolScheduleBuilder()
.createProtocolSchedule( .createProtocolSchedule(
@ -64,6 +67,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec, bftExtraDataCodec,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -74,6 +78,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param qbftForksSchedule the qbft forks schedule * @param qbftForksSchedule the qbft forks schedule
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param evmConfiguration the evm configuration * @param evmConfiguration the evm configuration
* @param miningParameters The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -82,6 +87,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule<QbftConfigOptions> qbftForksSchedule, final ForksSchedule<QbftConfigOptions> qbftForksSchedule,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create( return create(
config, config,
@ -90,6 +96,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
false, false,
bftExtraDataCodec, bftExtraDataCodec,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -100,6 +107,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
* @param qbftForksSchedule the qbft forks schedule * @param qbftForksSchedule the qbft forks schedule
* @param isRevertReasonEnabled the is revert reason enabled * @param isRevertReasonEnabled the is revert reason enabled
* @param bftExtraDataCodec the bft extra data codec * @param bftExtraDataCodec the bft extra data codec
* @param miningParameters The mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return the protocol schedule * @return the protocol schedule
*/ */
@ -108,6 +116,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
final ForksSchedule<QbftConfigOptions> qbftForksSchedule, final ForksSchedule<QbftConfigOptions> qbftForksSchedule,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec, final BftExtraDataCodec bftExtraDataCodec,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create( return create(
config, config,
@ -116,6 +125,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
isRevertReasonEnabled, isRevertReasonEnabled,
bftExtraDataCodec, bftExtraDataCodec,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
miningParameters,
badBlockManager); badBlockManager);
} }

@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
@ -136,6 +137,7 @@ public class QbftProtocolScheduleTest {
false, false,
bftExtraDataCodec, bftExtraDataCodec,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }

@ -68,6 +68,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
@ -179,6 +180,7 @@ public class QbftBlockHeightManagerTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
ProtocolSchedule protocolSchedule = ProtocolSchedule protocolSchedule =

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.chain.GenesisState;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; 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.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
@ -43,7 +44,9 @@ public class BlockchainImporter {
public BlockchainImporter(final URL blocksUrl, final String genesisJson) throws Exception { public BlockchainImporter(final URL blocksUrl, final String genesisJson) throws Exception {
protocolSchedule = protocolSchedule =
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(), new BadBlockManager()); GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(),
MiningParameters.newDefault(),
new BadBlockManager());
final BlockHeaderFunctions blockHeaderFunctions = final BlockHeaderFunctions blockHeaderFunctions =
ScheduleBasedBlockHeaderFunctions.create(protocolSchedule); ScheduleBasedBlockHeaderFunctions.create(protocolSchedule);
blocks = new ArrayList<>(); blocks = new ArrayList<>();

@ -108,6 +108,7 @@ public class JsonRpcHttpServiceHostAllowlistTest {
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
MiningParameters.MINING_DISABLED,
new BadBlockManager()), new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),

@ -137,7 +137,8 @@ public class JsonRpcHttpServiceLoginTest {
peerDiscoveryMock, peerDiscoveryMock,
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig(genesisConfigOptions, new BadBlockManager()), MainnetProtocolSchedule.fromConfig(
genesisConfigOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),
mock(TransactionPool.class), mock(TransactionPool.class),

@ -118,6 +118,7 @@ public class JsonRpcHttpServiceTestBase {
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()), new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),

@ -122,6 +122,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
MiningParameters.MINING_DISABLED,
new BadBlockManager()), new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),

@ -110,6 +110,7 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
MiningParameters.MINING_DISABLED,
new BadBlockManager()), new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),

@ -111,6 +111,7 @@ public class JsonRpcHttpServiceTlsTest {
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
MiningParameters.MINING_DISABLED,
new BadBlockManager()), new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),

@ -173,7 +173,10 @@ public class WebSocketServiceLoginTest {
peerDiscoveryMock, peerDiscoveryMock,
blockchainQueries, blockchainQueries,
synchronizer, synchronizer,
MainnetProtocolSchedule.fromConfig(genesisConfigOptions, new BadBlockManager()), MainnetProtocolSchedule.fromConfig(
genesisConfigOptions,
MiningParameters.MINING_DISABLED,
new BadBlockManager()),
mock(ProtocolContext.class), mock(ProtocolContext.class),
mock(FilterManager.class), mock(FilterManager.class),
mock(TransactionPool.class), mock(TransactionPool.class),

@ -364,6 +364,7 @@ abstract class AbstractBlockCreatorTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule()) .createProtocolSchedule())
.build(); .build();

@ -221,6 +221,7 @@ public abstract class AbstractBlockTransactionSelectorTest {
FixedDifficultyProtocolSchedule.create( FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final MainnetTransactionProcessor mainnetTransactionProcessor = final MainnetTransactionProcessor mainnetTransactionProcessor =
protocolSchedule.getByBlockHeader(blockHeader(0)).getTransactionProcessor(); protocolSchedule.getByBlockHeader(blockHeader(0)).getTransactionProcessor();

@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
@ -59,6 +60,7 @@ public class LegacyFeeMarketBlockTransactionSelectorTest
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -71,6 +71,7 @@ public class LondonFeeMarketBlockTransactionSelectorTest
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -93,6 +93,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule()) .createProtocolSchedule())
.build(); .build();
@ -148,6 +149,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule()) .createProtocolSchedule())
.build(); .build();
@ -193,6 +195,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
final ExecutionContextTestFixture executionContextTestFixture = final ExecutionContextTestFixture executionContextTestFixture =
@ -261,6 +264,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
final ExecutionContextTestFixture executionContextTestFixture = final ExecutionContextTestFixture executionContextTestFixture =

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.difficulty.fixed;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
@ -30,6 +31,7 @@ public class FixedDifficultyProtocolSchedule {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return new ProtocolScheduleBuilder( return new ProtocolScheduleBuilder(
config, config,
@ -40,6 +42,7 @@ public class FixedDifficultyProtocolSchedule {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager) badBlockManager)
.createProtocolSchedule(); .createProtocolSchedule();
} }
@ -48,19 +51,28 @@ public class FixedDifficultyProtocolSchedule {
final GenesisConfigOptions config, final GenesisConfigOptions config,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create( return create(
config, config,
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
public static ProtocolSchedule create( public static ProtocolSchedule create(
final GenesisConfigOptions config, final GenesisConfigOptions config,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return create(config, PrivacyParameters.DEFAULT, false, evmConfiguration, badBlockManager); return create(
config,
PrivacyParameters.DEFAULT,
false,
evmConfiguration,
miningParameters,
badBlockManager);
} }
} }

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
@ -37,6 +38,7 @@ public class MainnetProtocolSchedule {
* @param privacyParameters the parameters set for private transactions * @param privacyParameters the parameters set for private transactions
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache * @param evmConfiguration how to configure the EVMs jumpdest cache
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return A configured mainnet protocol schedule * @return A configured mainnet protocol schedule
*/ */
@ -45,10 +47,16 @@ public class MainnetProtocolSchedule {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) { if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
return FixedDifficultyProtocolSchedule.create( return FixedDifficultyProtocolSchedule.create(
config, privacyParameters, isRevertReasonEnabled, evmConfiguration, badBlockManager); config,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningParameters,
badBlockManager);
} }
return new ProtocolScheduleBuilder( return new ProtocolScheduleBuilder(
config, config,
@ -57,6 +65,7 @@ public class MainnetProtocolSchedule {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager) badBlockManager)
.createProtocolSchedule(); .createProtocolSchedule();
} }
@ -68,6 +77,7 @@ public class MainnetProtocolSchedule {
* starting points * starting points
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache * @param evmConfiguration how to configure the EVMs jumpdest cache
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return A configured mainnet protocol schedule * @return A configured mainnet protocol schedule
*/ */
@ -75,12 +85,14 @@ public class MainnetProtocolSchedule {
final GenesisConfigOptions config, final GenesisConfigOptions config,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
return fromConfig( return fromConfig(
config, config,
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -90,14 +102,22 @@ public class MainnetProtocolSchedule {
* @param config {@link GenesisConfigOptions} containing the config options for the milestone * @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points * starting points
* @param evmConfiguration size of * @param evmConfiguration size of
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return A configured mainnet protocol schedule * @return A configured mainnet protocol schedule
*/ */
public static ProtocolSchedule fromConfig( public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config, final GenesisConfigOptions config,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { 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 * @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points * starting points
* @param miningParameters the mining parameters
* @param badBlockManager the cache to use to keep invalid blocks * @param badBlockManager the cache to use to keep invalid blocks
* @return A configured mainnet protocol schedule * @return A configured mainnet protocol schedule
*/ */
public static ProtocolSchedule fromConfig( public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config, final BadBlockManager badBlockManager) { final GenesisConfigOptions config,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) {
return fromConfig( return fromConfig(
config, PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, badBlockManager); config,
PrivacyParameters.DEFAULT,
false,
EvmConfiguration.DEFAULT,
miningParameters,
badBlockManager);
} }
} }

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.mainnet; package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger; import java.math.BigInteger;
@ -30,6 +31,7 @@ public class MainnetProtocolSpecFactory {
private final boolean isRevertReasonEnabled; private final boolean isRevertReasonEnabled;
private final OptionalLong ecip1017EraRounds; private final OptionalLong ecip1017EraRounds;
private final EvmConfiguration evmConfiguration; private final EvmConfiguration evmConfiguration;
private final MiningParameters miningParameters;
public MainnetProtocolSpecFactory( public MainnetProtocolSpecFactory(
final Optional<BigInteger> chainId, final Optional<BigInteger> chainId,
@ -37,13 +39,15 @@ public class MainnetProtocolSpecFactory {
final OptionalInt evmStackSize, final OptionalInt evmStackSize,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final OptionalLong ecip1017EraRounds, final OptionalLong ecip1017EraRounds,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
this.chainId = chainId; this.chainId = chainId;
this.contractSizeLimit = contractSizeLimit; this.contractSizeLimit = contractSizeLimit;
this.evmStackSize = evmStackSize; this.evmStackSize = evmStackSize;
this.isRevertReasonEnabled = isRevertReasonEnabled; this.isRevertReasonEnabled = isRevertReasonEnabled;
this.ecip1017EraRounds = ecip1017EraRounds; this.ecip1017EraRounds = ecip1017EraRounds;
this.evmConfiguration = evmConfiguration; this.evmConfiguration = evmConfiguration;
this.miningParameters = miningParameters;
} }
public ProtocolSpecBuilder frontierDefinition() { public ProtocolSpecBuilder frontierDefinition() {
@ -113,7 +117,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder arrowGlacierDefinition( public ProtocolSpecBuilder arrowGlacierDefinition(
@ -124,7 +129,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder grayGlacierDefinition( public ProtocolSpecBuilder grayGlacierDefinition(
@ -135,7 +141,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) { public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) {
@ -145,7 +152,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) { public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) {
@ -155,7 +163,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisConfigOptions) { public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisConfigOptions) {
@ -165,7 +174,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisConfigOptions) { public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisConfigOptions) {
@ -175,7 +185,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
/** /**
@ -196,7 +207,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
/** /**
@ -217,7 +229,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize, evmStackSize,
isRevertReasonEnabled, isRevertReasonEnabled,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration); evmConfiguration,
miningParameters);
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////

@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.MainnetBlockValidator;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit; 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.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@ -433,7 +434,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
final int contractSizeLimit = final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
@ -442,7 +444,10 @@ public abstract class MainnetProtocolSpecs {
final BaseFeeMarket londonFeeMarket = final BaseFeeMarket londonFeeMarket =
genesisConfigOptions.isZeroBaseFee() genesisConfigOptions.isZeroBaseFee()
? FeeMarket.zeroBaseFee(londonForkBlockNumber) ? FeeMarket.zeroBaseFee(londonForkBlockNumber)
: FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); : genesisConfigOptions.isFixedBaseFee()
? FeeMarket.fixedBaseFee(
londonForkBlockNumber, miningParameters.getMinTransactionGasPrice())
: FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
return berlinDefinition( return berlinDefinition(
chainId, chainId,
configContractSizeLimit, configContractSizeLimit,
@ -515,14 +520,16 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
return londonDefinition( return londonDefinition(
chainId, chainId,
configContractSizeLimit, configContractSizeLimit,
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
.difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER) .difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER)
.name("ArrowGlacier"); .name("ArrowGlacier");
} }
@ -533,14 +540,16 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
return arrowGlacierDefinition( return arrowGlacierDefinition(
chainId, chainId,
configContractSizeLimit, configContractSizeLimit,
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
.difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER) .difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER)
.name("GrayGlacier"); .name("GrayGlacier");
} }
@ -551,7 +560,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
return grayGlacierDefinition( return grayGlacierDefinition(
chainId, chainId,
@ -559,7 +569,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
.evmBuilder( .evmBuilder(
(gasCalculator, jdCacheConfig) -> (gasCalculator, jdCacheConfig) ->
MainnetEVMs.paris(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration)) MainnetEVMs.paris(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
@ -577,7 +588,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
// extra variables need to support flipping the warm coinbase flag. // extra variables need to support flipping the warm coinbase flag.
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
@ -588,7 +600,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
// gas calculator has new code to support EIP-3860 limit and meter initcode // gas calculator has new code to support EIP-3860 limit and meter initcode
.gasCalculator(ShanghaiGasCalculator::new) .gasCalculator(ShanghaiGasCalculator::new)
// EVM has a new operation for EIP-3855 PUSH0 instruction // EVM has a new operation for EIP-3855 PUSH0 instruction
@ -638,14 +651,18 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE); final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L); final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L);
final BaseFeeMarket cancunFeeMarket = final BaseFeeMarket cancunFeeMarket =
genesisConfigOptions.isZeroBaseFee() genesisConfigOptions.isZeroBaseFee()
? FeeMarket.zeroBaseFee(londonForkBlockNumber) ? FeeMarket.zeroBaseFee(londonForkBlockNumber)
: FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); : genesisConfigOptions.isFixedBaseFee()
? FeeMarket.fixedBaseFee(
londonForkBlockNumber, miningParameters.getMinTransactionGasPrice())
: FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
return shanghaiDefinition( return shanghaiDefinition(
chainId, chainId,
@ -653,7 +670,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
.feeMarket(cancunFeeMarket) .feeMarket(cancunFeeMarket)
// gas calculator for EIP-4844 blob gas // gas calculator for EIP-4844 blob gas
.gasCalculator(CancunGasCalculator::new) .gasCalculator(CancunGasCalculator::new)
@ -710,7 +728,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
final int contractSizeLimit = final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
@ -720,7 +739,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
// EVM changes to support EOF EIPs (3670, 4200, 4750, 5450) // EVM changes to support EOF EIPs (3670, 4200, 4750, 5450)
.gasCalculator(PragueGasCalculator::new) .gasCalculator(PragueGasCalculator::new)
.evmBuilder( .evmBuilder(
@ -749,7 +769,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
final int contractSizeLimit = final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT); configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
return pragueDefinition( return pragueDefinition(
@ -758,7 +779,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
// Use Future EIP configured EVM // Use Future EIP configured EVM
.evmBuilder( .evmBuilder(
(gasCalculator, jdCacheConfig) -> (gasCalculator, jdCacheConfig) ->
@ -786,7 +808,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit, final OptionalInt configStackSizeLimit,
final boolean enableRevertReason, final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions, final GenesisConfigOptions genesisConfigOptions,
final EvmConfiguration evmConfiguration) { final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters) {
final Address depositContractAddress = final Address depositContractAddress =
genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);
@ -797,7 +820,8 @@ public abstract class MainnetProtocolSpecs {
configStackSizeLimit, configStackSizeLimit,
enableRevertReason, enableRevertReason,
genesisConfigOptions, genesisConfigOptions,
evmConfiguration) evmConfiguration,
miningParameters)
.evmBuilder( .evmBuilder(
(gasCalculator, jdCacheConfig) -> (gasCalculator, jdCacheConfig) ->
MainnetEVMs.experimentalEips( MainnetEVMs.experimentalEips(

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -40,6 +41,7 @@ public class ProtocolScheduleBuilder {
private final PrivacyParameters privacyParameters; private final PrivacyParameters privacyParameters;
private final boolean isRevertReasonEnabled; private final boolean isRevertReasonEnabled;
private final EvmConfiguration evmConfiguration; private final EvmConfiguration evmConfiguration;
private final MiningParameters miningParameters;
private final BadBlockManager badBlockManager; private final BadBlockManager badBlockManager;
private DefaultProtocolSchedule protocolSchedule; private DefaultProtocolSchedule protocolSchedule;
@ -51,6 +53,7 @@ public class ProtocolScheduleBuilder {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
this( this(
config, config,
@ -59,6 +62,7 @@ public class ProtocolScheduleBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -68,6 +72,7 @@ public class ProtocolScheduleBuilder {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
this( this(
config, config,
@ -76,6 +81,7 @@ public class ProtocolScheduleBuilder {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
miningParameters,
badBlockManager); badBlockManager);
} }
@ -86,6 +92,7 @@ public class ProtocolScheduleBuilder {
final PrivacyParameters privacyParameters, final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled, final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration, final EvmConfiguration evmConfiguration,
final MiningParameters miningParameters,
final BadBlockManager badBlockManager) { final BadBlockManager badBlockManager) {
this.config = config; this.config = config;
this.protocolSpecAdapters = protocolSpecAdapters; this.protocolSpecAdapters = protocolSpecAdapters;
@ -93,6 +100,7 @@ public class ProtocolScheduleBuilder {
this.isRevertReasonEnabled = isRevertReasonEnabled; this.isRevertReasonEnabled = isRevertReasonEnabled;
this.evmConfiguration = evmConfiguration; this.evmConfiguration = evmConfiguration;
this.defaultChainId = defaultChainId; this.defaultChainId = defaultChainId;
this.miningParameters = miningParameters;
this.badBlockManager = badBlockManager; this.badBlockManager = badBlockManager;
} }
@ -113,7 +121,8 @@ public class ProtocolScheduleBuilder {
config.getEvmStackSize(), config.getEvmStackSize(),
isRevertReasonEnabled, isRevertReasonEnabled,
config.getEcip1017EraRounds(), config.getEcip1017EraRounds(),
evmConfiguration); evmConfiguration,
miningParameters);
validateForkOrdering(); validateForkOrdering();

@ -53,6 +53,10 @@ public interface FeeMarket {
return new ZeroBaseFeeMarket(londonForkBlockNumber); return new ZeroBaseFeeMarket(londonForkBlockNumber);
} }
static BaseFeeMarket fixedBaseFee(final long londonForkBlockNumber, final Wei fixedBaseFee) {
return new FixedBaseFeeMarket(londonForkBlockNumber, fixedBaseFee);
}
static FeeMarket legacy() { static FeeMarket legacy() {
return new LegacyFeeMarket(); return new LegacyFeeMarket();
} }

@ -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;
}
}

@ -35,7 +35,7 @@ public class LondonFeeMarket implements BaseFeeMarket {
private static final Wei DEFAULT_BASEFEE_FLOOR = Wei.of(7L); private static final Wei DEFAULT_BASEFEE_FLOOR = Wei.of(7L);
private final Wei baseFeeInitialValue; protected final Wei baseFeeInitialValue;
private final long londonForkBlockNumber; private final long londonForkBlockNumber;
private final TransactionPriceCalculator txPriceCalculator; private final TransactionPriceCalculator txPriceCalculator;
private final Wei baseFeeFloor; private final Wei baseFeeFloor;

@ -16,22 +16,10 @@ package org.hyperledger.besu.ethereum.mainnet.feemarket;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import java.util.Optional; public class ZeroBaseFeeMarket extends FixedBaseFeeMarket {
public class ZeroBaseFeeMarket extends LondonFeeMarket {
public ZeroBaseFeeMarket(final long londonForkBlockNumber) { public ZeroBaseFeeMarket(final long londonForkBlockNumber) {
super(londonForkBlockNumber, Optional.of(Wei.ZERO)); super(londonForkBlockNumber, Wei.ZERO);
}
@Override
public Wei computeBaseFee(
final long blockNumber,
final Wei parentBaseFee,
final long parentBlockGasUsed,
final long targetGasUsed) {
return Wei.ZERO;
} }
@Override @Override

@ -142,7 +142,10 @@ public class BlockchainSetupUtil {
private static ProtocolSchedule mainnetProtocolScheduleProvider( private static ProtocolSchedule mainnetProtocolScheduleProvider(
final GenesisConfigFile genesisConfigFile) { final GenesisConfigFile genesisConfigFile) {
return MainnetProtocolSchedule.fromConfig( return MainnetProtocolSchedule.fromConfig(
genesisConfigFile.getConfigOptions(), EvmConfiguration.DEFAULT, new BadBlockManager()); genesisConfigFile.getConfigOptions(),
EvmConfiguration.DEFAULT,
MiningParameters.newDefault(),
new BadBlockManager());
} }
private static ProtocolContext mainnetProtocolContextProvider( private static ProtocolContext mainnetProtocolContextProvider(

@ -140,6 +140,7 @@ public class ExecutionContextTestFixture {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -39,6 +39,7 @@ public class ProtocolScheduleFixture {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.newDefault(),
new BadBlockManager()); new BadBlockManager());
private static GenesisConfigOptions getMainnetConfigOptions() { private static GenesisConfigOptions getMainnetConfigOptions() {

@ -20,6 +20,7 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -34,6 +35,7 @@ public class FixedProtocolScheduleTest {
FixedDifficultyProtocolSchedule.create( FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture(); final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();

@ -23,6 +23,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.PrivacyParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -60,6 +61,7 @@ public class DefaultProtocolScheduleTest {
privacyParameters, privacyParameters,
isRevertReasonEnabled, isRevertReasonEnabled,
evmConfiguration, evmConfiguration,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }

@ -18,6 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; 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.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -74,6 +75,7 @@ public class MainnetProtocolScheduleTest {
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{}").getConfigOptions(), GenesisConfigFile.fromConfig("{}").getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
Assertions.assertThat(sched.getByBlockHeader(blockHeader(1L)).getName()).isEqualTo("Frontier"); Assertions.assertThat(sched.getByBlockHeader(blockHeader(1L)).getName()).isEqualTo("Frontier");
Assertions.assertThat(sched.getByBlockHeader(blockHeader(Long.MAX_VALUE)).getName()) Assertions.assertThat(sched.getByBlockHeader(blockHeader(Long.MAX_VALUE)).getName())
@ -88,6 +90,7 @@ public class MainnetProtocolScheduleTest {
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions(), GenesisConfigFile.fromConfig(json).getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
Assertions.assertThat(sched.getByBlockHeader(blockHeader(1)).getName()).isEqualTo("Frontier"); Assertions.assertThat(sched.getByBlockHeader(blockHeader(1)).getName()).isEqualTo("Frontier");
Assertions.assertThat(sched.getByBlockHeader(blockHeader(2)).getName()).isEqualTo("Homestead"); Assertions.assertThat(sched.getByBlockHeader(blockHeader(2)).getName()).isEqualTo("Homestead");
@ -119,6 +122,7 @@ public class MainnetProtocolScheduleTest {
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions(), GenesisConfigFile.fromConfig(json).getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager())); new BadBlockManager()));
} }
@ -131,6 +135,7 @@ public class MainnetProtocolScheduleTest {
this.getClass().getResource("/goerli.json"), StandardCharsets.UTF_8)) this.getClass().getResource("/goerli.json"), StandardCharsets.UTF_8))
.getConfigOptions(), .getConfigOptions(),
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
Assertions.assertThat(sched.getByBlockHeader(blockHeader(0L)).getName()) Assertions.assertThat(sched.getByBlockHeader(blockHeader(0L)).getName())
.isEqualTo("Petersburg"); .isEqualTo("Petersburg");

@ -26,6 +26,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; 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.PrivacyParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -59,6 +60,7 @@ class ProtocolScheduleBuilderTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }
@ -213,6 +215,7 @@ class ProtocolScheduleBuilderTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
return new MilestoneStreamingProtocolSchedule( return new MilestoneStreamingProtocolSchedule(

@ -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);
}
}

@ -128,4 +128,29 @@ public class BaseFeeMarketBlockHeaderGasPriceValidationRuleTest {
blockHeader(FORK_BLOCK - 1, 0, Optional.of(londonFeeMarketBaseFee)))) blockHeader(FORK_BLOCK - 1, 0, Optional.of(londonFeeMarketBaseFee))))
.isTrue(); .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();
}
} }

@ -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<BaseFeeMarket> 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);
}
}

@ -105,7 +105,9 @@ public abstract class AbstractIsolationTests {
.createKeyPair(SECPPrivateKey.create(Bytes32.fromHexString(key), "ECDSA")); .createKeyPair(SECPPrivateKey.create(Bytes32.fromHexString(key), "ECDSA"));
protected final ProtocolSchedule protocolSchedule = protected final ProtocolSchedule protocolSchedule =
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.development().getConfigOptions(), new BadBlockManager()); GenesisConfigFile.development().getConfigOptions(),
MiningParameters.MINING_DISABLED,
new BadBlockManager());
protected final GenesisState genesisState = protected final GenesisState genesisState =
GenesisState.fromConfig(GenesisConfigFile.development(), protocolSchedule); GenesisState.fromConfig(GenesisConfigFile.development(), protocolSchedule);
protected final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock()); protected final MutableBlockchain blockchain = createInMemoryBlockchain(genesisState.getBlock());

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; 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.core.Transaction;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
@ -58,6 +59,7 @@ public final class BlockBodiesMessageTest {
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
} }

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.eth.messages;
import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.difficulty.fixed.FixedDifficultyProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
@ -65,6 +66,7 @@ public final class BlockHeadersMessageTest {
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager())); new BadBlockManager()));
for (int i = 0; i < 50; ++i) { for (int i = 0; i < 50; ++i) {

@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.Difficulty; 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.difficulty.fixed.FixedDifficultyProtocolSchedule;
import org.hyperledger.besu.ethereum.eth.manager.ChainState; import org.hyperledger.besu.ethereum.eth.manager.ChainState;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
@ -55,6 +56,7 @@ public class ChainHeadTrackerTest {
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
private final TrailingPeerLimiter trailingPeerLimiter = mock(TrailingPeerLimiter.class); private final TrailingPeerLimiter trailingPeerLimiter = mock(TrailingPeerLimiter.class);

@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
@ -94,7 +95,8 @@ public class BackwardSyncContextTest {
@Spy @Spy
private ProtocolSchedule protocolSchedule = private ProtocolSchedule protocolSchedule =
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()); MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions(), MiningParameters.MINING_DISABLED, new BadBlockManager());
@Spy @Spy
private ProtocolSpec protocolSpec = private ProtocolSpec protocolSpec =

@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
@ -68,7 +69,8 @@ public class BackwardSyncStepTest {
private BackwardSyncContext context; private BackwardSyncContext context;
private final ProtocolSchedule protocolSchedule = 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(); private final DeterministicEthScheduler ethScheduler = new DeterministicEthScheduler();

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; 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.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager;
@ -74,7 +75,8 @@ public class ForwardSyncStepTest {
private RespondingEthPeer peer; private RespondingEthPeer peer;
private final ProtocolSchedule protocolSchedule = private final ProtocolSchedule protocolSchedule =
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()); MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions(), MiningParameters.MINING_DISABLED, new BadBlockManager());
private MutableBlockchain localBlockchain; private MutableBlockchain localBlockchain;
GenericKeyValueStorageFacade<Hash, BlockHeader> headersStorage; GenericKeyValueStorageFacade<Hash, BlockHeader> headersStorage;
GenericKeyValueStorageFacade<Hash, Block> blocksStorage; GenericKeyValueStorageFacade<Hash, Block> blocksStorage;

@ -60,6 +60,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@ -195,6 +196,7 @@ public abstract class AbstractTransactionPoolTest {
new PrivacyParameters(), new PrivacyParameters(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
final ExecutionContextTestFixture executionContextTestFixture = final ExecutionContextTestFixture executionContextTestFixture =

@ -116,6 +116,7 @@ public class TestNode implements Closeable {
GenesisConfigFile.development().getConfigOptions(), GenesisConfigFile.development().getConfigOptions(),
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()); new BadBlockManager());
final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule); final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule);

@ -366,6 +366,7 @@ public class TransactionPoolFactoryTest {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();

@ -21,6 +21,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.crypto.SignatureAlgorithmType; import org.hyperledger.besu.crypto.SignatureAlgorithmType;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; 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.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
@ -76,7 +77,7 @@ class MainnetGenesisFileModule extends GenesisFileModule {
} }
} }
return MainnetProtocolSchedule.fromConfig( return MainnetProtocolSchedule.fromConfig(
configOptions, evmConfiguration, new BadBlockManager()); configOptions, evmConfiguration, MiningParameters.newDefault(), new BadBlockManager());
} }
public static Map<String, Supplier<ProtocolSchedule>> createSchedules() { public static Map<String, Supplier<ProtocolSchedule>> createSchedules() {
@ -134,6 +135,7 @@ class MainnetGenesisFileModule extends GenesisFileModule {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -18,6 +18,7 @@ package org.hyperledger.besu.ethereum.referencetests;
import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager; 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.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
@ -106,6 +107,7 @@ public class ReferenceTestProtocolSchedules {
PrivacyParameters.DEFAULT, PrivacyParameters.DEFAULT,
false, false,
EvmConfiguration.DEFAULT, EvmConfiguration.DEFAULT,
MiningParameters.MINING_DISABLED,
new BadBlockManager()) new BadBlockManager())
.createProtocolSchedule(); .createProtocolSchedule();
} }

@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty; 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.internal.EvmConfiguration;
import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.hyperledger.besu.evm.log.LogsBloomFilter;
@ -58,64 +59,64 @@ public class DifficultyCalculatorTests {
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.mainnet() GenesisConfigFile.mainnet()
.getConfigOptions(postMergeOverrides), .getConfigOptions(postMergeOverrides),
EvmConfiguration.DEFAULT, new BadBlockManager())), EvmConfiguration.DEFAULT, MiningParameters.newDefault(), new BadBlockManager())),
Arguments.of( Arguments.of(
"/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json", "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json", "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.json", "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().grayGlacierBlock(15050000), new BadBlockManager()) new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierForkBlock.json", "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierForkBlock.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff1.json", "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff1.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff2.json", "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff2.json",
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().arrowGlacierBlock(13773000), new BadBlockManager()) new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfByzantium/difficultyByzantium.json", "/DifficultyTests/dfByzantium/difficultyByzantium.json",
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), new BadBlockManager()) MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfConstantinople/difficultyConstantinople.json", "/DifficultyTests/dfConstantinople/difficultyConstantinople.json",
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), new BadBlockManager()) MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfEIP2384/difficultyEIP2384.json", "/DifficultyTests/dfEIP2384/difficultyEIP2384.json",
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), new BadBlockManager()) MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfEIP2384/difficultyEIP2384_random.json", "/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( Arguments.of(
"/DifficultyTests/dfEIP2384/difficultyEIP2384_random_to20M.json", "/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( Arguments.of(
"/DifficultyTests/dfFrontier/difficultyFrontier.json", "/DifficultyTests/dfFrontier/difficultyFrontier.json",
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), new BadBlockManager()) MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), MiningParameters.newDefault(), new BadBlockManager())
), ),
Arguments.of( Arguments.of(
"/DifficultyTests/dfHomestead/difficultyHomestead.json", "/DifficultyTests/dfHomestead/difficultyHomestead.json",
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), new BadBlockManager()) MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), MiningParameters.newDefault(), new BadBlockManager())
)); ));
} }

@ -158,7 +158,7 @@ public class RetestethContext {
JsonUtil.getObjectNode(genesisConfig, "config").get()); JsonUtil.getObjectNode(genesisConfig, "config").get());
protocolSchedule = protocolSchedule =
MainnetProtocolSchedule.fromConfig( MainnetProtocolSchedule.fromConfig(
jsonGenesisConfigOptions, EvmConfiguration.DEFAULT, badBlockManager); jsonGenesisConfigOptions, EvmConfiguration.DEFAULT, miningParameters, badBlockManager);
if ("NoReward".equalsIgnoreCase(sealEngine)) { if ("NoReward".equalsIgnoreCase(sealEngine)) {
protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule, badBlockManager); protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule, badBlockManager);
} }

Loading…
Cancel
Save