diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 000000000..7b88a8437 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,50 @@ +--- +name: Bug Report +about: necessary information to help us resolve the issue +title: '' +labels: 'bug' +assignees: '' + +--- + + + + + + + + + +### Steps to Reproduce +1. [Step 1] +2. [Step 2] +3. [Step ...] + +**Expected behavior:** [What you expect to happen] + +**Actual behavior:** [What actually happens] + +**Frequency:** [What percentage of the time does it occur?] + +### Logs +Please post relevant logs from Besu (and the consensus client, if running proof of stake) from before and after the issue. + +### Versions (Add all that apply) +* Software version: [`besu --version`] +* Java version: [`java -version`] +* OS Name & Version: [`cat /etc/*release`] +* Kernel Version: [`uname -a`] +* Virtual Machine software & version: [`vmware -v`] +* Docker Version: [`docker version`] +* Cloud VM, type, size: [Amazon Web Services I3-large] +* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar] + +### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information) +* Solidity version [`solc --version`] +* Repo with minimal set of deployable/reproducible contract code - please provide a link +* Please include specifics on how you are deploying/calling the contract +* Have you reproduced the issue on other eth clients + +### Additional Information (Add any of the following or anything else that may be relevant) +* Besu setup info - genesis file, config options +* System info - memory, CPU diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 000000000..73ebe5f06 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,45 @@ +--- +name: Feature Request +about: suggesting new or altered functionality +title: '' +labels: '' +assignees: '' + +--- + + + + + + + +### Description +As an [Actor], I want [feature] so that [why]. + +### Acceptance Criteria +* [Criteria 1] +* [Criteria 2] +* [Criteria 3...] + +### Logs (if a change in behavior) +Please post relevant logs from Besu (and the consensus client, if running proof of stake) illustrating behavior to be altered + +### Versions (Add all that apply) +* Software version: [`besu --version`] +* Java version: [`java -version`] +* OS Name & Version: [`cat /etc/*release`] +* Kernel Version: [`uname -a`] +* Virtual Machine software & version: [`vmware -v`] +* Docker Version: [`docker version`] +* Cloud VM, type, size: [Amazon Web Services I3-large] +* Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar] + +### Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information) +* Solidity version [`solc --version`] +* Repo with minimal set of deployable/reproducible contract code - please provide a link +* Please include specifics on how you are deploying/calling the contract +* Have you reproduced the issue on other eth clients + +### Additional Information (Add any of the following or anything else that may be relevant) +* Besu setup info - genesis file, config options +* System info - memory, CPU diff --git a/CHANGELOG.md b/CHANGELOG.md index 26342cf7b..41aea176d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Added isLabelsObserved to LabelledGauge in plugin-api. Default implementation returns false. ### Breaking Changes +- Removed Retesteth rpc service and commands [#7833](https://github.com/hyperledger/besu/pull/7783) ### Upcoming Breaking Changes diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java index 21ca45070..76e18812b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java @@ -27,7 +27,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; @@ -101,7 +101,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable private final boolean revertReasonEnabled; private final String name; - private MiningParameters miningParameters; + private MiningConfiguration miningConfiguration; private TransactionPoolConfiguration txPoolConfiguration; private final List runCommand; private PrivacyParameters privacyParameters = PrivacyParameters.DEFAULT; @@ -139,7 +139,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable public BesuNode( final String name, final Optional dataPath, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final TransactionPoolConfiguration txPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, @@ -191,7 +191,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable }, () -> this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory)); this.name = name; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.txPoolConfiguration = txPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; @@ -678,12 +678,12 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable this.bootnodes.addAll(bootnodes); } - public MiningParameters getMiningParameters() { - return miningParameters; + public MiningConfiguration getMiningParameters() { + return miningConfiguration; } - public void setMiningParameters(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public void setMiningParameters(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } public TransactionPoolConfiguration getTransactionPoolConfiguration() { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java index 42c0df73c..a76a3e6dc 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java @@ -36,8 +36,8 @@ import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginConfiguration; import org.hyperledger.besu.ethereum.core.plugins.PluginInfo; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; @@ -57,6 +57,7 @@ import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.MetricsSystemModule; import org.hyperledger.besu.metrics.ObservableMetricsSystem; +import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.plugin.data.EnodeURL; import org.hyperledger.besu.plugin.services.BesuConfiguration; @@ -406,9 +407,18 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { } } + @Module + public static class ThreadBesuNodeRunnerModule { + @Provides + @Singleton + public ThreadBesuNodeRunner provideThreadBesuNodeRunner() { + return new ThreadBesuNodeRunner(); + } + } + @Module @SuppressWarnings("CloseableProvides") - static class BesuControllerModule { + public static class BesuControllerModule { @Provides @Singleton public SynchronizerConfiguration provideSynchronizationConfiguration() { @@ -438,7 +448,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final BesuControllerBuilder builder, final MetricsSystem metricsSystem, final KeyValueStorageProvider storageProvider, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { builder .synchronizerConfiguration(synchronizerConfiguration) @@ -451,7 +461,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { .evmConfiguration(EvmConfiguration.DEFAULT) .maxPeers(25) .maxRemotelyInitiatedPeers(15) - .miningParameters(miningParameters) + .miningParameters(miningConfiguration) .randomPeerPriority(false) .besuComponent(null); return builder.build(); @@ -554,11 +564,11 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { } @Provides - public MiningParameters provideMiningParameters( + public MiningConfiguration provideMiningParameters( final TransactionSelectionServiceImpl transactionSelectionServiceImpl, final BesuNode node) { final var miningParameters = - ImmutableMiningParameters.builder() + ImmutableMiningConfiguration.builder() .from(node.getMiningParameters()) .transactionSelectionService(transactionSelectionServiceImpl) .build(); @@ -569,17 +579,26 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { @Provides @Inject BesuConfiguration provideBesuConfiguration( - final Path dataDir, final MiningParameters miningParameters, final BesuNode node) { + final Path dataDir, final MiningConfiguration miningConfiguration, final BesuNode node) { final BesuConfigurationImpl commonPluginConfiguration = new BesuConfigurationImpl(); commonPluginConfiguration.init( dataDir, dataDir.resolve(DATABASE_PATH), node.getDataStorageConfiguration()); - commonPluginConfiguration.withMiningParameters(miningParameters); + commonPluginConfiguration.withMiningParameters(miningConfiguration); return commonPluginConfiguration; } } @Module - static class MockBesuCommandModule { + public static class ObservableMetricsSystemModule { + @Provides + @Singleton + public ObservableMetricsSystem provideObservableMetricsSystem() { + return new NoOpMetricsSystem(); + } + } + + @Module + public static class MockBesuCommandModule { @Provides BesuCommand provideBesuCommand(final BesuPluginContextImpl pluginContext) { @@ -610,6 +629,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { modules = { ThreadBesuNodeRunner.BesuControllerModule.class, ThreadBesuNodeRunner.MockBesuCommandModule.class, + ThreadBesuNodeRunner.ObservableMetricsSystemModule.class, + ThreadBesuNodeRunnerModule.class, BonsaiCachedMerkleTrieLoaderModule.class, MetricsSystemModule.class, ThreadBesuNodeRunner.BesuNodeProviderModule.class, @@ -625,5 +646,9 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { RpcEndpointServiceImpl rpcEndpointService(); BlockchainServiceImpl blockchainService(); + + ObservableMetricsSystem getObservableMetricsSystem(); + + ThreadBesuNodeRunner getThreadBesuNodeRunner(); } } diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java index ba69e4ddd..5840f1e4f 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.InProcessRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; @@ -40,7 +40,7 @@ public class BesuNodeConfiguration { private final String name; private final Optional dataPath; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; private final TransactionPoolConfiguration transactionPoolConfiguration; private final JsonRpcConfiguration jsonRpcConfiguration; private final Optional engineRpcConfiguration; @@ -78,7 +78,7 @@ public class BesuNodeConfiguration { BesuNodeConfiguration( final String name, final Optional dataPath, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final TransactionPoolConfiguration transactionPoolConfiguration, final JsonRpcConfiguration jsonRpcConfiguration, final Optional engineRpcConfiguration, @@ -113,7 +113,7 @@ public class BesuNodeConfiguration { final boolean strictTxReplayProtectionEnabled, final Map environment) { this.name = name; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.transactionPoolConfiguration = transactionPoolConfiguration; this.jsonRpcConfiguration = jsonRpcConfiguration; this.engineRpcConfiguration = engineRpcConfiguration; @@ -154,8 +154,8 @@ public class BesuNodeConfiguration { return name; } - public MiningParameters getMiningParameters() { - return miningParameters; + public MiningConfiguration getMiningParameters() { + return miningConfiguration; } public TransactionPoolConfiguration getTransactionPoolConfiguration() { diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java index ead01ce97..9b000f56f 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java @@ -33,9 +33,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.api.tls.FileBasedPasswordProvider; import org.hyperledger.besu.ethereum.core.AddressHelpers; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; @@ -61,8 +61,8 @@ public class BesuNodeConfigurationBuilder { private String name; private Optional dataPath = Optional.empty(); - private MiningParameters miningParameters = - ImmutableMiningParameters.builder() + private MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder().coinbase(AddressHelpers.ofValue(1)).build()) .build(); @@ -125,13 +125,14 @@ public class BesuNodeConfigurationBuilder { } public BesuNodeConfigurationBuilder miningEnabled(final boolean enabled) { - this.miningParameters = miningParameters.setMiningEnabled(enabled); + this.miningConfiguration = miningConfiguration.setMiningEnabled(enabled); this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name()); return this; } - public BesuNodeConfigurationBuilder miningConfiguration(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public BesuNodeConfigurationBuilder miningConfiguration( + final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; this.jsonRpcConfiguration.addRpcApi(RpcApis.MINER.name()); return this; } @@ -527,7 +528,7 @@ public class BesuNodeConfigurationBuilder { return new BesuNodeConfiguration( name, dataPath, - miningParameters, + miningConfiguration, transactionPoolConfiguration, jsonRpcConfiguration, Optional.of(engineRpcConfiguration), diff --git a/acceptance-tests/tests/build.gradle b/acceptance-tests/tests/build.gradle index fdc773545..b6c388172 100644 --- a/acceptance-tests/tests/build.gradle +++ b/acceptance-tests/tests/build.gradle @@ -31,6 +31,7 @@ dependencies { api 'org.slf4j:slf4j-api' implementation project(':crypto:algorithms') + implementation project(':ethereum:eth') testImplementation project(':acceptance-tests:dsl') testImplementation project(':acceptance-tests:test-plugins') @@ -42,6 +43,7 @@ dependencies { testImplementation project(':ethereum:api') testImplementation project(':ethereum:core') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') + testImplementation project(':ethereum:eth') testImplementation project(':ethereum:p2p') testImplementation project(':ethereum:permissioning') testImplementation project(':ethereum:rlp') @@ -78,6 +80,8 @@ dependencies { testImplementation 'org.web3j:besu' testImplementation 'org.web3j:core' testImplementation 'org.wiremock:wiremock' + testImplementation 'com.google.dagger:dagger' + testAnnotationProcessor 'com.google.dagger:dagger-compiler' testImplementation project(path: ':acceptance-tests:tests:shanghai') } diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java index 1e741a5cc..177987aaa 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftMiningAcceptanceTest.java @@ -17,9 +17,9 @@ package org.hyperledger.besu.tests.acceptance.bft; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.AddressHelpers; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.account.Account; import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; @@ -62,8 +62,8 @@ public class BftMiningAcceptanceTest extends ParameterizedBftTestBase { final String testName, final BftAcceptanceTestParameterization nodeFactory) throws Exception { setUp(testName, nodeFactory); final BesuNode minerNode = nodeFactory.createNode(besu, "miner1"); - final MiningParameters zeroGasMiningParams = - ImmutableMiningParameters.builder() + final MiningConfiguration zeroGasMiningParams = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .isMiningEnabled(true) diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 96eef547f..d6619d6c1 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -70,7 +70,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; @@ -773,7 +773,7 @@ public class RunnerBuilder { final TransactionPool transactionPool = besuController.getTransactionPool(); final MiningCoordinator miningCoordinator = besuController.getMiningCoordinator(); - final MiningParameters miningParameters = besuController.getMiningParameters(); + final MiningConfiguration miningConfiguration = besuController.getMiningParameters(); final BlockchainQueries blockchainQueries = new BlockchainQueries( @@ -783,7 +783,7 @@ public class RunnerBuilder { Optional.of(dataDir.resolve(CACHE_PATH)), Optional.of(besuController.getProtocolManager().ethContext().getScheduler()), apiConfiguration, - miningParameters); + miningConfiguration); final PrivacyParameters privacyParameters = besuController.getPrivacyParameters(); @@ -802,7 +802,7 @@ public class RunnerBuilder { Optional stratumServer = Optional.empty(); - if (miningParameters.isStratumMiningEnabled()) { + if (miningConfiguration.isStratumMiningEnabled()) { if (!(miningCoordinator instanceof PoWMiningCoordinator powMiningCoordinator)) { throw new IllegalArgumentException( "Stratum mining requires the network option(--network) to be set to CLASSIC. Stratum server requires a PoWMiningCoordinator not " @@ -813,9 +813,9 @@ public class RunnerBuilder { new StratumServer( vertx, powMiningCoordinator, - miningParameters.getStratumPort(), - miningParameters.getStratumNetworkInterface(), - miningParameters.getUnstable().getStratumExtranonce(), + miningConfiguration.getStratumPort(), + miningConfiguration.getStratumNetworkInterface(), + miningConfiguration.getUnstable().getStratumExtranonce(), metricsSystem)); miningCoordinator.addEthHashObserver(stratumServer.get()); LOG.debug("added ethash observer: {}", stratumServer.get()); @@ -849,7 +849,7 @@ public class RunnerBuilder { blockchainQueries, synchronizer, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, @@ -896,7 +896,7 @@ public class RunnerBuilder { blockchainQueries, synchronizer, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, @@ -989,7 +989,7 @@ public class RunnerBuilder { blockchainQueries, synchronizer, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, @@ -1070,7 +1070,7 @@ public class RunnerBuilder { blockchainQueries, synchronizer, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, @@ -1111,7 +1111,7 @@ public class RunnerBuilder { blockchainQueries, synchronizer, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, @@ -1273,7 +1273,7 @@ public class RunnerBuilder { final BlockchainQueries blockchainQueries, final Synchronizer synchronizer, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MiningCoordinator miningCoordinator, final ObservableMetricsSystem metricsSystem, final Set supportedCapabilities, @@ -1308,7 +1308,7 @@ public class RunnerBuilder { protocolContext, filterManager, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, supportedCapabilities, diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index bf79da288..b974dcd31 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -74,7 +74,6 @@ import org.hyperledger.besu.cli.presynctasks.PreSynchronizationTaskRunner; import org.hyperledger.besu.cli.presynctasks.PrivateDatabaseMigrationPreSyncTask; import org.hyperledger.besu.cli.subcommands.PasswordSubCommand; import org.hyperledger.besu.cli.subcommands.PublicKeySubCommand; -import org.hyperledger.besu.cli.subcommands.RetestethSubCommand; import org.hyperledger.besu.cli.subcommands.TxParseSubCommand; import org.hyperledger.besu.cli.subcommands.ValidateConfigSubCommand; import org.hyperledger.besu.cli.subcommands.blocks.BlocksSubCommand; @@ -114,7 +113,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MiningParametersMetrics; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.VersionMetadata; @@ -339,7 +338,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { Suppliers.memoize(this::readGenesisConfigFile); private final Supplier genesisConfigOptionsSupplier = Suppliers.memoize(this::readGenesisConfigOptions); - private final Supplier miningParametersSupplier = + private final Supplier miningParametersSupplier = Suppliers.memoize(this::getMiningParameters); private RocksDBPlugin rocksDBPlugin; @@ -1105,7 +1104,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { PublicKeySubCommand.COMMAND_NAME, new PublicKeySubCommand(commandLine.getOut())); commandLine.addSubcommand( PasswordSubCommand.COMMAND_NAME, new PasswordSubCommand(commandLine.getOut())); - commandLine.addSubcommand(RetestethSubCommand.COMMAND_NAME, new RetestethSubCommand()); commandLine.addSubcommand( RLPSubCommand.COMMAND_NAME, new RLPSubCommand(commandLine.getOut(), in)); commandLine.addSubcommand( @@ -2119,7 +2117,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return txPoolConfBuilder.build(); } - private MiningParameters getMiningParameters() { + private MiningConfiguration getMiningParameters() { miningOptions.setTransactionSelectionService(transactionSelectionServiceImpl); final var miningParameters = miningOptions.toDomainObject(); getGenesisBlockPeriodSeconds(genesisConfigOptionsSupplier.get()) @@ -2171,8 +2169,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return dataStorageConfiguration; } - private void initMiningParametersMetrics(final MiningParameters miningParameters) { - new MiningParametersMetrics(getMetricsSystem(), miningParameters); + private void initMiningParametersMetrics(final MiningConfiguration miningConfiguration) { + new MiningParametersMetrics(getMetricsSystem(), miningConfiguration); } private OptionalInt getGenesisBlockPeriodSeconds( diff --git a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java index a884edfe3..fa0cf4dc0 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/options/MiningOptions.java @@ -17,27 +17,27 @@ package org.hyperledger.besu.cli.options; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME; -import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_EXTRA_DATA; -import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO; -import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS; -import static org.hyperledger.besu.ethereum.core.MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_MAX_OMMERS_DEPTH; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POW_JOB_TTL; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_EXTRA_DATA; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_PRIORITY_FEE_PER_GAS; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_MAX_OMMERS_DEPTH; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POW_JOB_TTL; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL; import org.hyperledger.besu.cli.converter.PositiveNumberConverter; import org.hyperledger.besu.cli.util.CommandLineUtils; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.plugin.services.TransactionSelectionService; import org.hyperledger.besu.util.number.PositiveNumber; @@ -50,7 +50,7 @@ import picocli.CommandLine.Option; import picocli.CommandLine.ParameterException; /** The Mining CLI options. */ -public class MiningOptions implements CLIOptions { +public class MiningOptions implements CLIOptions { @Option( names = {"--miner-enabled"}, @@ -300,43 +300,45 @@ public class MiningOptions implements CLIOptions { } } - static MiningOptions fromConfig(final MiningParameters miningParameters) { + static MiningOptions fromConfig(final MiningConfiguration miningConfiguration) { final MiningOptions miningOptions = MiningOptions.create(); - miningOptions.setTransactionSelectionService(miningParameters.getTransactionSelectionService()); - miningOptions.isMiningEnabled = miningParameters.isMiningEnabled(); - miningOptions.iStratumMiningEnabled = miningParameters.isStratumMiningEnabled(); - miningOptions.stratumNetworkInterface = miningParameters.getStratumNetworkInterface(); - miningOptions.stratumPort = miningParameters.getStratumPort(); - miningOptions.extraData = miningParameters.getExtraData(); - miningOptions.minTransactionGasPrice = miningParameters.getMinTransactionGasPrice(); - miningOptions.minPriorityFeePerGas = miningParameters.getMinPriorityFeePerGas(); - miningOptions.minBlockOccupancyRatio = miningParameters.getMinBlockOccupancyRatio(); + miningOptions.setTransactionSelectionService( + miningConfiguration.getTransactionSelectionService()); + miningOptions.isMiningEnabled = miningConfiguration.isMiningEnabled(); + miningOptions.iStratumMiningEnabled = miningConfiguration.isStratumMiningEnabled(); + miningOptions.stratumNetworkInterface = miningConfiguration.getStratumNetworkInterface(); + miningOptions.stratumPort = miningConfiguration.getStratumPort(); + miningOptions.extraData = miningConfiguration.getExtraData(); + miningOptions.minTransactionGasPrice = miningConfiguration.getMinTransactionGasPrice(); + miningOptions.minPriorityFeePerGas = miningConfiguration.getMinPriorityFeePerGas(); + miningOptions.minBlockOccupancyRatio = miningConfiguration.getMinBlockOccupancyRatio(); miningOptions.nonPoaBlockTxsSelectionMaxTime = - miningParameters.getNonPoaBlockTxsSelectionMaxTime(); - miningOptions.poaBlockTxsSelectionMaxTime = miningParameters.getPoaBlockTxsSelectionMaxTime(); + miningConfiguration.getNonPoaBlockTxsSelectionMaxTime(); + miningOptions.poaBlockTxsSelectionMaxTime = + miningConfiguration.getPoaBlockTxsSelectionMaxTime(); miningOptions.unstableOptions.remoteSealersLimit = - miningParameters.getUnstable().getRemoteSealersLimit(); + miningConfiguration.getUnstable().getRemoteSealersLimit(); miningOptions.unstableOptions.remoteSealersTimeToLive = - miningParameters.getUnstable().getRemoteSealersTimeToLive(); + miningConfiguration.getUnstable().getRemoteSealersTimeToLive(); miningOptions.unstableOptions.powJobTimeToLive = - miningParameters.getUnstable().getPowJobTimeToLive(); + miningConfiguration.getUnstable().getPowJobTimeToLive(); miningOptions.unstableOptions.maxOmmersDepth = - miningParameters.getUnstable().getMaxOmmerDepth(); + miningConfiguration.getUnstable().getMaxOmmerDepth(); miningOptions.unstableOptions.stratumExtranonce = - miningParameters.getUnstable().getStratumExtranonce(); + miningConfiguration.getUnstable().getStratumExtranonce(); miningOptions.unstableOptions.posBlockCreationMaxTime = - miningParameters.getUnstable().getPosBlockCreationMaxTime(); + miningConfiguration.getUnstable().getPosBlockCreationMaxTime(); miningOptions.unstableOptions.posBlockCreationRepetitionMinDuration = - miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration(); + miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration(); - miningParameters.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase); - miningParameters.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl); + miningConfiguration.getCoinbase().ifPresent(coinbase -> miningOptions.coinbase = coinbase); + miningConfiguration.getTargetGasLimit().ifPresent(tgl -> miningOptions.targetGasLimit = tgl); return miningOptions; } @Override - public MiningParameters toDomainObject() { + public MiningConfiguration toDomainObject() { checkNotNull( transactionSelectionService, "transactionSelectionService must be set before using this object"); @@ -356,7 +358,7 @@ public class MiningOptions implements CLIOptions { updatableInitValuesBuilder.coinbase(coinbase); } - return ImmutableMiningParameters.builder() + return ImmutableMiningConfiguration.builder() .transactionSelectionService(transactionSelectionService) .mutableInitValues(updatableInitValuesBuilder.build()) .isStratumMiningEnabled(iStratumMiningEnabled) @@ -365,7 +367,7 @@ public class MiningOptions implements CLIOptions { .nonPoaBlockTxsSelectionMaxTime(nonPoaBlockTxsSelectionMaxTime) .poaBlockTxsSelectionMaxTime(poaBlockTxsSelectionMaxTime) .unstable( - ImmutableMiningParameters.Unstable.builder() + ImmutableMiningConfiguration.Unstable.builder() .remoteSealersLimit(unstableOptions.remoteSealersLimit) .remoteSealersTimeToLive(unstableOptions.remoteSealersTimeToLive) .powJobTimeToLive(unstableOptions.powJobTimeToLive) diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java deleted file mode 100644 index 67af49c40..000000000 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/RetestethSubCommand.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.cli.subcommands; - -import static org.hyperledger.besu.cli.subcommands.RetestethSubCommand.COMMAND_NAME; - -import org.hyperledger.besu.BesuInfo; -import org.hyperledger.besu.cli.DefaultCommandValues; -import org.hyperledger.besu.cli.custom.JsonRPCAllowlistHostsProperty; -import org.hyperledger.besu.cli.options.stable.LoggingLevelOption; -import org.hyperledger.besu.cli.util.VersionProvider; -import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; -import org.hyperledger.besu.ethereum.retesteth.RetestethConfiguration; -import org.hyperledger.besu.ethereum.retesteth.RetestethService; -import org.hyperledger.besu.util.LogConfigurator; - -import java.net.InetAddress; -import java.nio.file.Path; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import picocli.CommandLine.Command; -import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; - -/** Subcommand to run a Retesteth compatible server for reference tests. */ -@Command( - name = COMMAND_NAME, - description = "Run a Retesteth compatible server for reference tests.", - mixinStandardHelpOptions = true, - versionProvider = VersionProvider.class) -@SuppressWarnings("unused") -public class RetestethSubCommand implements Runnable { - - private static final Logger LOG = LoggerFactory.getLogger(RetestethSubCommand.class); - - /** The constant COMMAND_NAME. */ - public static final String COMMAND_NAME = "retesteth"; - - /** - * Using a distinct port for retesteth will result in less testing collisions and accidental RPC - * calls. This is 0xba5e in hex, a hex speak play on the english translation of - * "Besu." - */ - public static final int RETESTETH_PORT = 47710; - - @Option( - names = {"--data-path"}, - paramLabel = DefaultCommandValues.MANDATORY_PATH_FORMAT_HELP, - description = "The path to Besu data directory (default: ${DEFAULT-VALUE})") - private final Path dataPath = DefaultCommandValues.getDefaultBesuDataPath(this); - - @Mixin private LoggingLevelOption loggingLevelOption; - - @SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"}) // PicoCLI requires non-final Strings. - @Option( - names = {"--rpc-http-host"}, - paramLabel = DefaultCommandValues.MANDATORY_HOST_FORMAT_HELP, - description = "Host for Retesteth JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})", - arity = "1") - private String rpcHttpHost = autoDiscoverDefaultIP().getHostAddress(); - - @Option( - names = {"--rpc-http-port"}, - paramLabel = DefaultCommandValues.MANDATORY_PORT_FORMAT_HELP, - description = "Port for Retesteth JSON-RPC HTTP to listen on (default: ${DEFAULT-VALUE})", - arity = "1") - private final Integer rpcHttpPort = RETESTETH_PORT; - - @Option( - names = {"--host-allowlist", "--host-whitelist"}, - paramLabel = "[,...]... or * or all", - description = - "Comma separated list of hostnames to allow for RPC access, or * to accept any host (default: ${DEFAULT-VALUE})", - defaultValue = "localhost,127.0.0.1") - private final JsonRPCAllowlistHostsProperty hostsAllowlist = new JsonRPCAllowlistHostsProperty(); - - private InetAddress autoDiscoveredDefaultIP; - - /** Default Constructor. */ - public RetestethSubCommand() {} - - // Used to discover the default IP of the client. - // Loopback IP is used by default as this is how smokeTests require it to be - // and it's probably a good security behaviour to default only on the localhost. - private InetAddress autoDiscoverDefaultIP() { - - if (autoDiscoveredDefaultIP != null) { - return autoDiscoveredDefaultIP; - } - - autoDiscoveredDefaultIP = InetAddress.getLoopbackAddress(); - - return autoDiscoveredDefaultIP; - } - - private void prepareLogging() { - // set log level per CLI flags - final String logLevel = loggingLevelOption.getLogLevel(); - if (logLevel != null) { - System.out.println("Setting logging level to " + logLevel); - LogConfigurator.setLevel("", logLevel); - } - } - - @Override - public void run() { - prepareLogging(); - - final RetestethConfiguration retestethConfiguration = new RetestethConfiguration(dataPath); - final JsonRpcConfiguration jsonRpcConfiguration = JsonRpcConfiguration.createDefault(); - jsonRpcConfiguration.setHost(rpcHttpHost); - jsonRpcConfiguration.setPort(rpcHttpPort); - jsonRpcConfiguration.setHostsAllowlist(hostsAllowlist); - - final RetestethService retestethService = - new RetestethService(BesuInfo.version(), retestethConfiguration, jsonRpcConfiguration); - - Runtime.getRuntime() - .addShutdownHook( - new Thread( - () -> { - try { - retestethService.close(); - LogConfigurator.shutdown(); - } catch (final Exception e) { - LOG.error("Failed to stop Besu Retesteth"); - } - })); - retestethService.start(); - try { - Thread.sleep(Long.MAX_VALUE); // Is there a better way? - } catch (final InterruptedException e) { - // e.printStackTrace(); - } - } -} diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java index 5bd0aacee..95617fe8c 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/blocks/BlocksSubCommand.java @@ -31,9 +31,9 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.IncrementingNonceGenerator; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.metrics.MetricsService; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -265,12 +265,12 @@ public class BlocksSubCommand implements Runnable { } } - private MiningParameters getMiningParameters() { + private MiningConfiguration getMiningParameters() { final Wei minTransactionGasPrice = Wei.ZERO; // Extradata and coinbase can be configured on a per-block level via the json file final Address coinbase = Address.ZERO; final Bytes extraData = Bytes.EMPTY; - return ImmutableMiningParameters.builder() + return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .nonceGenerator(new IncrementingNonceGenerator(0)) @@ -377,7 +377,7 @@ public class BlocksSubCommand implements Runnable { return parentCommand .parentCommand .setupControllerBuilder() - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .build(); } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java index faf792871..d2361d65d 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java @@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; @@ -71,7 +71,7 @@ public class BesuController implements java.io.Closeable { private final MiningCoordinator miningCoordinator; private final PrivacyParameters privacyParameters; private final List closeables; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; private final PluginServiceFactory additionalPluginServices; private final SyncState syncState; private final EthPeers ethPeers; @@ -91,7 +91,7 @@ public class BesuController implements java.io.Closeable { * @param transactionPool the transaction pool * @param miningCoordinator the mining coordinator * @param privacyParameters the privacy parameters - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param additionalJsonRpcMethodsFactory the additional json rpc methods factory * @param nodeKey the node key * @param closeables the closeables @@ -111,7 +111,7 @@ public class BesuController implements java.io.Closeable { final TransactionPool transactionPool, final MiningCoordinator miningCoordinator, final PrivacyParameters privacyParameters, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final JsonRpcMethods additionalJsonRpcMethodsFactory, final NodeKey nodeKey, final List closeables, @@ -132,7 +132,7 @@ public class BesuController implements java.io.Closeable { this.miningCoordinator = miningCoordinator; this.privacyParameters = privacyParameters; this.closeables = closeables; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.additionalPluginServices = additionalPluginServices; this.ethPeers = ethPeers; this.storageProvider = storageProvider; @@ -265,8 +265,8 @@ public class BesuController implements java.io.Closeable { * * @return the mining parameters */ - public MiningParameters getMiningParameters() { - return miningParameters; + public MiningConfiguration getMiningParameters() { + return miningConfiguration; } /** diff --git a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java index 6a4cc203a..5eb5e1214 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -43,7 +43,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.VariablesStorage; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; @@ -144,7 +144,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides protected BigInteger networkId; /** The Mining parameters. */ - protected MiningParameters miningParameters; + protected MiningConfiguration miningConfiguration; /** The Metrics system. */ protected ObservableMetricsSystem metricsSystem; @@ -296,11 +296,11 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides /** * Mining parameters besu controller builder. * - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @return the besu controller builder */ - public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; return this; } @@ -543,7 +543,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides checkNotNull(syncConfig, "Missing sync config"); checkNotNull(ethereumWireProtocolConfiguration, "Missing ethereum protocol configuration"); checkNotNull(networkId, "Missing network ID"); - checkNotNull(miningParameters, "Missing mining parameters"); + checkNotNull(miningConfiguration, "Missing mining parameters"); checkNotNull(metricsSystem, "Missing metrics system"); checkNotNull(privacyParameters, "Missing privacy parameters"); checkNotNull(dataDirectory, "Missing data directory"); // Why do we need this? @@ -680,7 +680,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides syncState, transactionPoolConfiguration, besuComponent.map(BesuComponent::getBlobCache).orElse(new BlobCache()), - miningParameters); + miningConfiguration); final List peerValidators = createPeerValidators(protocolSchedule); @@ -734,7 +734,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides protocolSchedule, protocolContext, transactionPool, - miningParameters, + miningConfiguration, syncState, ethProtocolManager); @@ -745,7 +745,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides createSubProtocolConfiguration(ethProtocolManager, maybeSnapProtocolManager); final JsonRpcMethods additionalJsonRpcMethodFactory = - createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters); + createAdditionalJsonRpcMethodFactory( + protocolContext, protocolSchedule, miningConfiguration); if (DataStorageFormat.BONSAI.equals(dataStorageConfiguration.getDataStorageFormat())) { final DiffBasedSubStorageConfiguration subStorageConfiguration = @@ -779,7 +780,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides transactionPool, miningCoordinator, privacyParameters, - miningParameters, + miningConfiguration, additionalJsonRpcMethodFactory, nodeKey, closeables, @@ -938,13 +939,13 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides * * @param protocolContext the protocol context * @param protocolSchedule the protocol schedule - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @return the json rpc methods */ protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return apis -> Collections.emptyMap(); } @@ -972,7 +973,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides * @param protocolSchedule the protocol schedule * @param protocolContext the protocol context * @param transactionPool the transaction pool - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param syncState the sync state * @param ethProtocolManager the eth protocol manager * @return the mining coordinator @@ -981,7 +982,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides ProtocolSchedule protocolSchedule, ProtocolContext protocolContext, TransactionPool transactionPool, - MiningParameters miningParameters, + MiningConfiguration miningConfiguration, SyncState syncState, EthProtocolManager ethProtocolManager); diff --git a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java index b4ada6054..19840fb73 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; @@ -74,8 +74,8 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { - return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningParameters); + final MiningConfiguration miningConfiguration) { + return new CliqueJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration); } @Override @@ -83,7 +83,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { final CliqueMinerExecutor miningExecutor = @@ -92,7 +92,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { protocolSchedule, transactionPool, nodeKey, - miningParameters, + miningConfiguration, new CliqueBlockScheduler( clock, protocolContext.getConsensusContext(CliqueContext.class).getValidatorProvider(), @@ -113,7 +113,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { .getBlockchain() .observeBlockAdded( o -> - miningParameters.setBlockPeriodSeconds( + miningConfiguration.setBlockPeriodSeconds( forksSchedule .getFork(o.getBlock().getHeader().getNumber() + 1) .getValue() @@ -132,10 +132,9 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { genesisConfigOptions, forksSchedule, nodeKey, - privacyParameters, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -172,7 +171,7 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder { } @Override - public MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) { + public MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) { // Clique mines by default, reflect that with in the mining parameters: return fromCli.setMiningEnabled(true); } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java index 0d0f8d2fd..3ecd5a6c4 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/ConsensusScheduleBesuControllerBuilder.java @@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -128,7 +128,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { @@ -143,7 +143,7 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde protocolSchedule, protocolContext, transactionPool, - miningParameters, + miningConfiguration, syncState, ethProtocolManager))) .collect(Collectors.toList()); @@ -206,10 +206,11 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return besuControllerBuilderSchedule .get(0L) - .createAdditionalJsonRpcMethodFactory(protocolContext, protocolSchedule, miningParameters); + .createAdditionalJsonRpcMethodFactory( + protocolContext, protocolSchedule, miningConfiguration); } @Override @@ -297,9 +298,9 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde } @Override - public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { - besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningParameters)); - return super.miningParameters(miningParameters); + public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) { + besuControllerBuilderSchedule.values().forEach(b -> b.miningParameters(miningConfiguration)); + return super.miningParameters(miningConfiguration); } @Override diff --git a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java index 738dcfc59..ae08b11cc 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java @@ -60,7 +60,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.SnapProtocol; @@ -114,8 +114,8 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { - return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningParameters); + final MiningConfiguration miningConfiguration) { + return new IbftJsonRpcMethods(protocolContext, protocolSchedule, miningConfiguration); } @Override @@ -141,7 +141,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { final MutableBlockchain blockchain = protocolContext.getBlockchain(); @@ -156,7 +156,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { protocolContext, bftProtocolSchedule, forksSchedule, - miningParameters, + miningConfiguration, localAddress, bftExtraDataCodec().get(), ethProtocolManager.ethContext().getScheduler()); @@ -247,7 +247,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { .getBlockchain() .observeBlockAdded( o -> - miningParameters.setBlockPeriodSeconds( + miningConfiguration.setBlockPeriodSeconds( forksSchedule .getFork(o.getBlock().getHeader().getNumber() + 1) .getValue() @@ -303,7 +303,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder { isRevertReasonEnabled, bftExtraDataCodec().get(), evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java index e0fbed608..a642539ac 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.blockcreation.PoWMinerExecutor; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -31,6 +31,8 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import java.util.Optional; + /** The Mainnet besu controller builder. */ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { @@ -44,7 +46,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { @@ -53,7 +55,7 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { protocolContext, protocolSchedule, transactionPool, - miningParameters, + miningConfiguration, new DefaultBlockScheduler( MainnetBlockHeaderValidator.MINIMUM_SECONDS_SINCE_PARENT, MainnetBlockHeaderValidator.TIMESTAMP_TOLERANCE_S, @@ -66,11 +68,11 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { protocolContext.getBlockchain(), executor, syncState, - miningParameters.getUnstable().getRemoteSealersLimit(), - miningParameters.getUnstable().getRemoteSealersTimeToLive()); + miningConfiguration.getUnstable().getRemoteSealersLimit(), + miningConfiguration.getUnstable().getRemoteSealersTimeToLive()); miningCoordinator.addMinedBlockObserver(ethProtocolManager); - miningCoordinator.setStratumMiningEnabled(miningParameters.isStratumMiningEnabled()); - if (miningParameters.isMiningEnabled()) { + miningCoordinator.setStratumMiningEnabled(miningConfiguration.isStratumMiningEnabled()); + if (miningConfiguration.isMiningEnabled()) { miningCoordinator.enable(); } @@ -95,10 +97,10 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder { protected ProtocolSchedule createProtocolSchedule() { return MainnetProtocolSchedule.fromConfig( genesisConfigOptions, - privacyParameters, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, + Optional.of(privacyParameters), + Optional.of(isRevertReasonEnabled), + Optional.of(evmConfiguration), + super.miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java index f5fc75959..e7c1a5c40 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/MergeBesuControllerBuilder.java @@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthMessages; @@ -67,14 +67,14 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { return createTransitionMiningCoordinator( protocolSchedule, protocolContext, transactionPool, - miningParameters, + miningConfiguration, syncState, new BackwardSyncContext( protocolContext, @@ -140,7 +140,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { * @param protocolSchedule the protocol schedule * @param protocolContext the protocol context * @param transactionPool the transaction pool - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param syncState the sync state * @param backwardSyncContext the backward sync context * @param ethScheduler the scheduler @@ -150,7 +150,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final BackwardSyncContext backwardSyncContext, final EthScheduler ethScheduler) { @@ -165,7 +165,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { protocolSchedule, ethScheduler, transactionPool, - miningParameters, + miningConfiguration, backwardSyncContext, depositContractAddress); } @@ -176,7 +176,7 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder { genesisConfigOptions, privacyParameters, isRevertReasonEnabled, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java index e4cebc0d6..ae2ae250b 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/MiningParameterOverrides.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.controller; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; /** * This interface wraps the provided MiningParameters to enable controller-specific parameter @@ -27,7 +27,7 @@ public interface MiningParameterOverrides { * @param fromCli The mining parameters that contains original values. * @return MiningParameters constructed from provided param with additional overridden parameters. */ - default MiningParameters getMiningParameterOverrides(final MiningParameters fromCli) { + default MiningConfiguration getMiningParameterOverrides(final MiningConfiguration fromCli) { return fromCli; } } diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java index 498435e4a..75aff3087 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java @@ -69,7 +69,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.SnapProtocol; @@ -130,12 +130,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { protected JsonRpcMethods createAdditionalJsonRpcMethodFactory( final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return new QbftJsonRpcMethods( protocolContext, protocolSchedule, - miningParameters, + miningConfiguration, createReadOnlyValidatorProvider(protocolContext.getBlockchain()), bftConfigOptions); } @@ -181,7 +181,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { final MutableBlockchain blockchain = protocolContext.getBlockchain(); @@ -196,7 +196,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { protocolContext, bftProtocolSchedule, qbftForksSchedule, - miningParameters, + miningConfiguration, localAddress, bftExtraDataCodec().get(), ethProtocolManager.ethContext().getScheduler()); @@ -289,12 +289,12 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { .getBlockchain() .observeBlockAdded( o -> { - miningParameters.setBlockPeriodSeconds( + miningConfiguration.setBlockPeriodSeconds( qbftForksSchedule .getFork(o.getBlock().getHeader().getNumber() + 1) .getValue() .getBlockPeriodSeconds()); - miningParameters.setEmptyBlockPeriodSeconds( + miningConfiguration.setEmptyBlockPeriodSeconds( qbftForksSchedule .getFork(o.getBlock().getHeader().getNumber() + 1) .getValue() @@ -351,7 +351,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { isRevertReasonEnabled, bftExtraDataCodec().get(), evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java index 703592f90..3530621fc 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/TransitionBesuControllerBuilder.java @@ -30,8 +30,8 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -102,7 +102,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final SyncState syncState, final EthProtocolManager ethProtocolManager) { @@ -112,8 +112,8 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder { // PoA consensus mines by default, get consensus-specific mining parameters for // TransitionCoordinator: - MiningParameters transitionMiningParameters = - preMergeBesuControllerBuilder.getMiningParameterOverrides(miningParameters); + MiningConfiguration transitionMiningConfiguration = + preMergeBesuControllerBuilder.getMiningParameterOverrides(miningConfiguration); // construct a transition backward sync context BackwardSyncContext transitionBackwardsSyncContext = @@ -131,10 +131,10 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder { transitionProtocolSchedule.getPreMergeSchedule(), protocolContext, transactionPool, - ImmutableMiningParameters.builder() - .from(miningParameters) + ImmutableMiningConfiguration.builder() + .from(miningConfiguration) .mutableInitValues( - ImmutableMiningParameters.MutableInitValues.builder() + ImmutableMiningConfiguration.MutableInitValues.builder() .isMiningEnabled(false) .build()) .build(), @@ -144,7 +144,7 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder { transitionProtocolSchedule, protocolContext, transactionPool, - transitionMiningParameters, + transitionMiningConfiguration, syncState, transitionBackwardsSyncContext, ethProtocolManager.ethContext().getScheduler())); @@ -329,9 +329,9 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder { } @Override - public BesuControllerBuilder miningParameters(final MiningParameters miningParameters) { - super.miningParameters(miningParameters); - return propagateConfig(z -> z.miningParameters(miningParameters)); + public BesuControllerBuilder miningParameters(final MiningConfiguration miningConfiguration) { + super.miningParameters(miningConfiguration); + return propagateConfig(z -> z.miningParameters(miningConfiguration)); } @Override diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java index 0adbda23b..39db58ee4 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuConfigurationImpl.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.services; import org.hyperledger.besu.cli.options.stable.JsonRpcHttpOptions; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.plugin.services.BesuConfiguration; import org.hyperledger.besu.plugin.services.storage.DataStorageFormat; @@ -31,7 +31,7 @@ public class BesuConfigurationImpl implements BesuConfiguration { private DataStorageConfiguration dataStorageConfiguration; // defaults - private MiningParameters miningParameters = MiningParameters.newDefault(); + private MiningConfiguration miningConfiguration; private Optional rpcHttpHost = Optional.of("http://localhost"); private Optional rpcHttpPort = Optional.of(8545); @@ -59,11 +59,11 @@ public class BesuConfigurationImpl implements BesuConfiguration { /** * Set the mining parameters * - * @param miningParameters configured mining parameters + * @param miningConfiguration configured mining parameters * @return BesuConfigurationImpl instance */ - public BesuConfigurationImpl withMiningParameters(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public BesuConfigurationImpl withMiningParameters(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; return this; } @@ -106,7 +106,7 @@ public class BesuConfigurationImpl implements BesuConfiguration { @Override public Wei getMinGasPrice() { - return miningParameters.getMinTransactionGasPrice(); + return miningConfiguration.getMinTransactionGasPrice(); } @Override diff --git a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java index a246d18d2..ff205e875 100644 --- a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -150,7 +150,7 @@ class FlexGroupPrivacyTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .dataStorageConfiguration(dataStorageConfiguration) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) diff --git a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java index 5a5809157..87bab916f 100644 --- a/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java +++ b/besu/src/test/java/org/hyperledger/besu/ForkIdsNetworkConfigTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.forkid.ForkId; import org.hyperledger.besu.ethereum.forkid.ForkIdManager; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -174,7 +174,7 @@ public class ForkIdsNetworkConfigTest { (DefaultProtocolSchedule) MainnetProtocolSchedule.fromConfig( configOptions, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())); @@ -184,7 +184,7 @@ public class ForkIdsNetworkConfigTest { MergeProtocolSchedule.create( configOptions, false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())); diff --git a/besu/src/test/java/org/hyperledger/besu/LineaTest.java b/besu/src/test/java/org/hyperledger/besu/LineaTest.java index c71bd3716..8f0ebc4c0 100644 --- a/besu/src/test/java/org/hyperledger/besu/LineaTest.java +++ b/besu/src/test/java/org/hyperledger/besu/LineaTest.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.ethereum.GasLimitCalculator; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; @@ -71,7 +71,7 @@ public class LineaTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.valueOf(23331)) - .miningParameters(ImmutableMiningParameters.newDefault()) + .miningParameters(ImmutableMiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .privacyParameters(mock(PrivacyParameters.class)) .metricsSystem(new NoOpMetricsSystem()) diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java index 6298b70a9..a79b66445 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java @@ -47,7 +47,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; @@ -547,7 +547,7 @@ public class PrivacyReorgTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) .dataDirectory(dataDir) diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java index 4d488ced3..305d786b8 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -125,7 +125,7 @@ class PrivacyTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .dataStorageConfiguration(dataStorageConfiguration) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java index 7c5579d47..230de6efd 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java @@ -49,7 +49,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -128,7 +128,7 @@ public final class RunnerBuilderTest { when(besuController.getProtocolContext()).thenReturn(protocolContext); when(besuController.getProtocolSchedule()).thenReturn(protocolSchedule); when(besuController.getNodeKey()).thenReturn(nodeKey); - when(besuController.getMiningParameters()).thenReturn(mock(MiningParameters.class)); + when(besuController.getMiningParameters()).thenReturn(mock(MiningConfiguration.class)); when(besuController.getPrivacyParameters()).thenReturn(mock(PrivacyParameters.class)); when(besuController.getTransactionPool()) .thenReturn(mock(TransactionPool.class, RETURNS_DEEP_STUBS)); diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java index 6324fabb7..4239cbdc3 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java @@ -46,7 +46,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.core.BlockSyncTestUtils; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -196,7 +196,7 @@ public final class RunnerTest { .isPeerTaskSystemEnabled(isPeerTaskSystemEnabled) .build(); final ObservableMetricsSystem noOpMetricsSystem = new NoOpMetricsSystem(); - final var miningParameters = MiningParameters.newDefault(); + final var miningParameters = MiningConfiguration.newDefault(); final var dataStorageConfiguration = DataStorageConfiguration.DEFAULT_FOREST_CONFIG; // Setup Runner with blocks final BesuController controllerAhead = @@ -415,11 +415,11 @@ public final class RunnerTest { final Path dataDir, final Path dbDir, final DataStorageConfiguration dataStorageConfiguration, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { final var besuConfiguration = new BesuConfigurationImpl(); besuConfiguration .init(dataDir, dbDir, dataStorageConfiguration) - .withMiningParameters(miningParameters); + .withMiningParameters(miningConfiguration); return new KeyValueStorageProviderBuilder() .withStorageFactory( new RocksDBKeyValueStorageFactory( @@ -488,14 +488,14 @@ public final class RunnerTest { final NodeKey nodeKey, final StorageProvider storageProvider, final ObservableMetricsSystem metricsSystem, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return new MainnetBesuControllerBuilder() .genesisConfigFile(genesisConfig) .synchronizerConfiguration(syncConfig) .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .dataDirectory(dataDir) .networkId(NETWORK_ID) - .miningParameters(miningParameters) + .miningParameters(miningConfiguration) .nodeKey(nodeKey) .storageProvider(storageProvider) .metricsSystem(metricsSystem) diff --git a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java index bbc7dea1a..e76c06fe2 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -94,7 +94,7 @@ public final class RlpBlockExporterTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) .privacyParameters(PrivacyParameters.DEFAULT) diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java index 7b1a4bc7d..2b534660e 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java @@ -17,9 +17,10 @@ package org.hyperledger.besu.chainimport; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.mock; +import org.hyperledger.besu.components.BesuCommandModule; import org.hyperledger.besu.components.BesuComponent; +import org.hyperledger.besu.components.BesuPluginContextModule; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.controller.BesuController; @@ -31,17 +32,21 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.ethereum.core.components.MiningParametersModule; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; +import org.hyperledger.besu.ethereum.eth.transactions.BlobCacheModule; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; +import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader; import org.hyperledger.besu.evm.internal.EvmConfiguration; +import org.hyperledger.besu.metrics.MetricsSystemModule; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.testutil.TestClock; @@ -52,9 +57,13 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import javax.inject.Singleton; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.io.Resources; +import dagger.Component; +import dagger.Module; +import dagger.Provides; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -449,7 +458,7 @@ public abstract class JsonBlockImporterTest { .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.valueOf(10)) .miningParameters( - ImmutableMiningParameters.builder() + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .isMiningEnabled(true) @@ -465,7 +474,28 @@ public abstract class JsonBlockImporterTest { .gasLimitCalculator(GasLimitCalculator.constant()) .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) - .besuComponent(mock(BesuComponent.class)) + .besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build()) .build(); } + + @Module + public static class JsonBlockImporterModule { + + @Provides + BonsaiCachedMerkleTrieLoader provideCachedMerkleTrieLoaderModule() { + return new BonsaiCachedMerkleTrieLoader(new NoOpMetricsSystem()); + } + } + + @Singleton + @Component( + modules = { + BesuCommandModule.class, + MiningParametersModule.class, + MetricsSystemModule.class, + JsonBlockImporterModule.class, + BesuPluginContextModule.class, + BlobCacheModule.class + }) + interface JsonBlockImportComponent extends BesuComponent {} } diff --git a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java index 2d9e587c3..9f405d4cb 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java @@ -26,7 +26,7 @@ import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; @@ -69,7 +69,7 @@ public final class RlpBlockImporterTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) .privacyParameters(PrivacyParameters.DEFAULT) @@ -103,7 +103,7 @@ public final class RlpBlockImporterTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) .privacyParameters(PrivacyParameters.DEFAULT) @@ -134,7 +134,7 @@ public final class RlpBlockImporterTest { .ethProtocolConfiguration(EthProtocolConfiguration.defaultConfig()) .storageProvider(new InMemoryKeyValueStorageProvider()) .networkId(BigInteger.ONE) - .miningParameters(MiningParameters.newDefault()) + .miningParameters(MiningConfiguration.newDefault()) .nodeKey(NodeKeyUtils.generate()) .metricsSystem(new NoOpMetricsSystem()) .privacyParameters(PrivacyParameters.DEFAULT) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index cf3c40860..ea06f406e 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -57,7 +57,7 @@ import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; @@ -277,8 +277,8 @@ public class BesuCommandTest extends CommandTestAbstract { verify(mockRunnerBuilder).build(); verify(mockControllerBuilderFactory).fromEthNetworkConfig(ethNetworkArg.capture(), any()); - final ArgumentCaptor miningArg = - ArgumentCaptor.forClass(MiningParameters.class); + final ArgumentCaptor miningArg = + ArgumentCaptor.forClass(MiningConfiguration.class); verify(mockControllerBuilder).synchronizerConfiguration(syncConfigurationCaptor.capture()); verify(mockControllerBuilder).dataDirectory(isNotNull()); verify(mockControllerBuilder).miningParameters(miningArg.capture()); diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java index 4cdd8163d..c14283881 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CascadingDefaultProviderTest.java @@ -33,7 +33,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; @@ -200,7 +200,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract { setEnvironmentVariable("BESU_MINER_COINBASE", expectedCoinbase); parseCommand("--config-file", configFile); - final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class); + final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class); verify(mockControllerBuilder).miningParameters(captMiningParameters.capture()); assertThat(captMiningParameters.getValue().getCoinbase()) @@ -219,7 +219,7 @@ public class CascadingDefaultProviderTest extends CommandTestAbstract { setEnvironmentVariable("BESU_MINER_COINBASE", "0x0000000000000000000000000000000000000004"); parseCommand("--config-file", configFile, "--miner-coinbase", expectedCoinbase); - final var captMiningParameters = ArgumentCaptor.forClass(MiningParameters.class); + final var captMiningParameters = ArgumentCaptor.forClass(MiningConfiguration.class); verify(mockControllerBuilder).miningParameters(captMiningParameters.capture()); assertThat(captMiningParameters.getValue().getCoinbase()) diff --git a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java index e32ff0e46..f94504ea4 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/options/MiningOptionsTest.java @@ -15,19 +15,19 @@ package org.hyperledger.besu.cli.options; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_POS_BLOCK_CREATION_MAX_TIME; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.verify; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.util.number.PositiveNumber; import java.io.IOException; @@ -42,7 +42,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class MiningOptionsTest extends AbstractCLIOptionsTest { +public class MiningOptionsTest extends AbstractCLIOptionsTest { @Test public void besuDoesNotStartInMiningModeIfCoinbaseNotSet() { @@ -390,13 +390,13 @@ public class MiningOptionsTest extends AbstractCLIOptionsTest bftBesuControllerBuilder.createAdditionalJsonRpcMethodFactory( - protocolContext, protocolSchedule, MiningParameters.newDefault())) + protocolContext, protocolSchedule, MiningConfiguration.newDefault())) .isInstanceOf(NullPointerException.class) .hasMessage("transactionValidatorProvider should have been initialised"); } diff --git a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java index 40d72e4ed..24b0133a0 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/TransitionControllerBuilderTest.java @@ -35,10 +35,10 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -84,7 +84,7 @@ public class TransitionControllerBuilderTest { CliqueBesuControllerBuilder cliqueBuilder = new CliqueBesuControllerBuilder(); BesuControllerBuilder powBuilder = new MainnetBesuControllerBuilder(); MergeBesuControllerBuilder postMergeBuilder = new MergeBesuControllerBuilder(); - MiningParameters miningParameters; + MiningConfiguration miningConfiguration; TransitionProtocolSchedule transitionProtocolSchedule; @@ -118,27 +118,27 @@ public class TransitionControllerBuilderTest { .thenReturn(mergeContext); when(ethProtocolManager.ethContext().getScheduler()) .thenReturn(new DeterministicEthScheduler()); - miningParameters = MiningParameters.newDefault(); + miningConfiguration = MiningConfiguration.newDefault(); } @Test public void assertCliqueMiningOverridePreMerge() { - assertThat(miningParameters.isMiningEnabled()).isFalse(); + assertThat(miningConfiguration.isMiningEnabled()).isFalse(); var transCoordinator = buildTransitionCoordinator(cliqueBuilder, postMergeBuilder); assertThat(transCoordinator.isMiningBeforeMerge()).isTrue(); } @Test public void assertPoWIsNotMiningPreMerge() { - assertThat(miningParameters.isMiningEnabled()).isFalse(); + assertThat(miningConfiguration.isMiningEnabled()).isFalse(); var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder); assertThat(transCoordinator.isMiningBeforeMerge()).isFalse(); } @Test public void assertPowMiningPreMerge() { - miningParameters = - ImmutableMiningParameters.builder() + miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues(MutableInitValues.builder().isMiningEnabled(true).build()) .build(); var transCoordinator = buildTransitionCoordinator(powBuilder, postMergeBuilder); @@ -273,7 +273,7 @@ public class TransitionControllerBuilderTest { transitionProtocolSchedule, protocolContext, transactionPool, - miningParameters, + miningConfiguration, syncState, ethProtocolManager); diff --git a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java index ddf68ba14..79885115f 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/BesuEventsImplTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; @@ -173,7 +173,7 @@ public class BesuEventsImplTest { syncState, txPoolConfig, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); serviceImpl = new BesuEventsImpl( diff --git a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java index 1e734f623..bcbf1c2fe 100644 --- a/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java +++ b/besu/src/test/java/org/hyperledger/besu/services/TraceServiceImplTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.worldstate.WorldView; @@ -80,7 +80,7 @@ class TraceServiceImplTest { blockchainSetupUtil.getProtocolSchedule(), blockchain, worldStateArchive, - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); traceService = new TraceServiceImpl(blockchainQueries, blockchainSetupUtil.getProtocolSchedule()); } diff --git a/config/build.gradle b/config/build.gradle index a78b9a710..e269ce51f 100644 --- a/config/build.gradle +++ b/config/build.gradle @@ -36,11 +36,13 @@ dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' + implementation 'com.google.dagger:dagger' implementation 'info.picocli:picocli' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-units' implementation "org.immutables:value-annotations" annotationProcessor "org.immutables:value" + annotationProcessor 'com.google.dagger:dagger-compiler' testImplementation project(':testutil') diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java index cd1975563..2ceedb718 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; @@ -63,7 +63,7 @@ public class CliqueProtocolSchedule { * @param privacyParameters the privacy parameters * @param isRevertReasonEnabled the is revert reason enabled * @param evmConfiguration the evm configuration - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -77,7 +77,7 @@ public class CliqueProtocolSchedule { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -110,12 +110,12 @@ public class CliqueProtocolSchedule { return new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), specAdapters, privacyParameters, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem) @@ -130,7 +130,7 @@ public class CliqueProtocolSchedule { * @param nodeKey the node key * @param isRevertReasonEnabled the is revert reason enabled * @param evmConfiguration the evm configuration - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -144,7 +144,7 @@ public class CliqueProtocolSchedule { final NodeKey nodeKey, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -155,7 +155,7 @@ public class CliqueProtocolSchedule { PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java index ed17529a9..18d3449ba 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreator.java @@ -29,7 +29,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -48,7 +48,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator { /** * Instantiates a new Clique block creator. * - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param extraDataCalculator the extra data calculator * @param transactionPool the pending transactions * @param protocolContext the protocol context @@ -58,7 +58,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator { * @param ethScheduler the scheduler for asynchronous block creation tasks */ public CliqueBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, final ProtocolContext protocolContext, @@ -67,7 +67,7 @@ public class CliqueBlockCreator extends AbstractBlockCreator { final EpochManager epochManager, final EthScheduler ethScheduler) { super( - miningParameters, + miningConfiguration, __ -> Util.publicKeyToAddress(nodeKey.getPublicKey()), extraDataCalculator, transactionPool, diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java index ef3d58fbf..998a237e9 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutor.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractMinerExecutor; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; import org.hyperledger.besu.ethereum.chain.PoWObserver; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -70,7 +70,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor final ProtocolSchedule protocolSchedule, final TransactionPool transactionPool, final NodeKey nodeKey, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final AbstractBlockScheduler blockScheduler, final EpochManager epochManager, final ForksSchedule forksSchedule, @@ -97,7 +97,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor final Function blockCreator = (header) -> new CliqueBlockCreator( - miningParameters, + miningConfiguration, this::calculateExtraData, transactionPool, protocolContext, @@ -119,7 +119,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor @Override public Optional
getCoinbase() { - return miningParameters.getCoinbase(); + return miningConfiguration.getCoinbase(); } /** @@ -134,7 +134,7 @@ public class CliqueMinerExecutor extends AbstractMinerExecutor final Bytes vanityDataToInsert = ConsensusHelpers.zeroLeftPad( - miningParameters.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH); + miningConfiguration.getExtraData(), CliqueExtraData.EXTRA_VANITY_LENGTH); // Building ON TOP of canonical head, if the next block is epoch, include validators. if (epochManager.isEpochBlock(parentHeader.getNumber() + 1)) { diff --git a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java index 762cce1c5..4e1e75f54 100644 --- a/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java +++ b/consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/jsonrpc/CliqueJsonRpcMethods.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; @@ -41,22 +41,22 @@ import java.util.Map; public class CliqueJsonRpcMethods extends ApiGroupJsonRpcMethods { private final ProtocolContext context; private final ProtocolSchedule protocolSchedule; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; /** * Instantiates a new Clique json rpc methods. * * @param context the protocol context * @param protocolSchedule the protocol schedule - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters */ public CliqueJsonRpcMethods( final ProtocolContext context, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this.context = context; this.protocolSchedule = protocolSchedule; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; } @Override @@ -69,7 +69,7 @@ public class CliqueJsonRpcMethods extends ApiGroupJsonRpcMethods { final MutableBlockchain blockchain = context.getBlockchain(); final WorldStateArchive worldStateArchive = context.getWorldStateArchive(); final BlockchainQueries blockchainQueries = - new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningParameters); + new BlockchainQueries(protocolSchedule, blockchain, worldStateArchive, miningConfiguration); final ValidatorProvider validatorProvider = context.getConsensusContext(CliqueContext.class).getValidatorProvider(); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java index 5cbdbb6d0..083604af6 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java @@ -32,7 +32,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -68,7 +68,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -94,7 +94,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -120,7 +120,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())) @@ -142,7 +142,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())) @@ -168,7 +168,7 @@ public class CliqueProtocolScheduleTest { NODE_KEY, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java index ca76517c6..fdc068dde 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java @@ -49,9 +49,9 @@ import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -106,7 +106,7 @@ public class CliqueBlockCreatorTest { proposerNodeKey, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -146,11 +146,11 @@ public class CliqueBlockCreatorTest { final Address coinbase = AddressHelpers.ofValue(1); - final MiningParameters miningParameters = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( - miningParameters, + miningConfiguration, parent -> extraData, createTransactionPool(), protocolContext, @@ -175,11 +175,11 @@ public class CliqueBlockCreatorTest { when(voteProvider.getVoteAfterBlock(any(), any())) .thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1))); - final MiningParameters miningParameters = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( - miningParameters, + miningConfiguration, parent -> extraData, createTransactionPool(), protocolContext, @@ -209,11 +209,11 @@ public class CliqueBlockCreatorTest { when(mockVoteProvider.getVoteAfterBlock(any(), any())) .thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, coinbase, a1))); - final MiningParameters miningParameters = createMiningParameters(extraData, coinbase); + final MiningConfiguration miningConfiguration = createMiningParameters(extraData, coinbase); final CliqueBlockCreator blockCreator = new CliqueBlockCreator( - miningParameters, + miningConfiguration, parent -> extraData, createTransactionPool(), protocolContext, @@ -252,10 +252,10 @@ public class CliqueBlockCreatorTest { return transactionPool; } - private static MiningParameters createMiningParameters( + private static MiningConfiguration createMiningParameters( final Bytes extraData, final Address coinbase) { - final MiningParameters miningParameters = - ImmutableMiningParameters.builder() + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .extraData(extraData) @@ -264,6 +264,6 @@ public class CliqueBlockCreatorTest { .coinbase(coinbase) .build()) .build(); - return miningParameters; + return miningConfiguration; } } diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java index 1aa2d75ef..3d6dbd77d 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java @@ -39,9 +39,9 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -105,7 +105,7 @@ public class CliqueMinerExecutorTest { proposerNodeKey, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -117,7 +117,7 @@ public class CliqueMinerExecutorTest { public void extraDataCreatedOnEpochBlocksContainsValidators() { final Bytes vanityData = generateRandomVanityData(); - final MiningParameters miningParameters = createMiningParameters(vanityData); + final MiningConfiguration miningConfiguration = createMiningParameters(vanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -125,7 +125,7 @@ public class CliqueMinerExecutorTest { cliqueProtocolSchedule, createTransactionPool(), proposerNodeKey, - miningParameters, + miningConfiguration, mock(CliqueBlockScheduler.class), new EpochManager(EPOCH_LENGTH), null, @@ -153,7 +153,7 @@ public class CliqueMinerExecutorTest { public void extraDataForNonEpochBlocksDoesNotContainValidaors() { final Bytes vanityData = generateRandomVanityData(); - final MiningParameters miningParameters = createMiningParameters(vanityData); + final MiningConfiguration miningConfiguration = createMiningParameters(vanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -161,7 +161,7 @@ public class CliqueMinerExecutorTest { cliqueProtocolSchedule, createTransactionPool(), proposerNodeKey, - miningParameters, + miningConfiguration, mock(CliqueBlockScheduler.class), new EpochManager(EPOCH_LENGTH), null, @@ -189,7 +189,7 @@ public class CliqueMinerExecutorTest { final Bytes initialVanityData = generateRandomVanityData(); final Bytes modifiedVanityData = generateRandomVanityData(); - final MiningParameters miningParameters = createMiningParameters(initialVanityData); + final MiningConfiguration miningConfiguration = createMiningParameters(initialVanityData); final CliqueMinerExecutor executor = new CliqueMinerExecutor( @@ -197,13 +197,13 @@ public class CliqueMinerExecutorTest { cliqueProtocolSchedule, createTransactionPool(), proposerNodeKey, - miningParameters, + miningConfiguration, mock(CliqueBlockScheduler.class), new EpochManager(EPOCH_LENGTH), null, ethScheduler); - miningParameters.setExtraData(modifiedVanityData); + miningConfiguration.setExtraData(modifiedVanityData); final Bytes extraDataBytes = executor.calculateExtraData(blockHeaderBuilder.buildHeader()); final CliqueExtraData cliqueExtraData = @@ -253,8 +253,8 @@ public class CliqueMinerExecutorTest { return Bytes.wrap(vanityData); } - private static MiningParameters createMiningParameters(final Bytes vanityData) { - return ImmutableMiningParameters.builder() + private static MiningConfiguration createMiningParameters(final Bytes vanityData) { + return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .extraData(vanityData) diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java index 311bf30fa..29ec30d66 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilder.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.consensus.common.ForksSchedule; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -38,6 +38,7 @@ import org.hyperledger.besu.plugin.services.MetricsSystem; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.function.Function; /** Defines the protocol behaviours for a blockchain using a BFT consensus mechanism. */ @@ -57,7 +58,7 @@ public abstract class BaseBftProtocolScheduleBuilder { * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @param metricsSystem metricsSystem A metricSystem instance to be able to expose metrics in the @@ -71,7 +72,7 @@ public abstract class BaseBftProtocolScheduleBuilder { final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -90,12 +91,12 @@ public abstract class BaseBftProtocolScheduleBuilder { final ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), specAdapters, privacyParameters, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem) diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java index 6bc0254b6..70d18fc3c 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreator.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -46,7 +46,7 @@ public class BftBlockCreator extends AbstractBlockCreator { /** * Instantiates a new Bft block creator. * - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param forksSchedule the forks schedule * @param localAddress the local address * @param extraDataCalculator the extra data calculator @@ -57,7 +57,7 @@ public class BftBlockCreator extends AbstractBlockCreator { * @param ethScheduler the scheduler for asynchronous block creation tasks */ public BftBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final ForksSchedule forksSchedule, final Address localAddress, final ExtraDataCalculator extraDataCalculator, @@ -67,7 +67,7 @@ public class BftBlockCreator extends AbstractBlockCreator { final BftExtraDataCodec bftExtraDataCodec, final EthScheduler ethScheduler) { super( - miningParameters.setCoinbase(localAddress), + miningConfiguration.setCoinbase(localAddress), miningBeneficiaryCalculator(localAddress, forksSchedule), extraDataCalculator, transactionPool, diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java index 7c679763b..1349bbf46 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/blockcreation/BftBlockCreatorFactory.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.BlockCreator; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.AbstractGasLimitSpecification; @@ -54,7 +54,7 @@ public class BftBlockCreatorFactory { protected final ForksSchedule forksSchedule; /** The Mining parameters */ - protected final MiningParameters miningParameters; + protected final MiningConfiguration miningConfiguration; private final TransactionPool transactionPool; @@ -89,7 +89,7 @@ public class BftBlockCreatorFactory { final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, final ForksSchedule forksSchedule, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final Address localAddress, final BftExtraDataCodec bftExtraDataCodec, final EthScheduler ethScheduler) { @@ -98,7 +98,7 @@ public class BftBlockCreatorFactory { this.protocolSchedule = protocolSchedule; this.forksSchedule = forksSchedule; this.localAddress = localAddress; - this.miningParameters = miningParams; + this.miningConfiguration = miningParams; this.bftExtraDataCodec = bftExtraDataCodec; this.ethScheduler = ethScheduler; } @@ -111,7 +111,7 @@ public class BftBlockCreatorFactory { */ public BlockCreator create(final int round) { return new BftBlockCreator( - miningParameters, + miningConfiguration, forksSchedule, localAddress, ph -> createExtraData(round, ph), @@ -128,7 +128,7 @@ public class BftBlockCreatorFactory { * @param minTransactionGasPrice the min transaction gas price */ public void setMinTransactionGasPrice(final Wei minTransactionGasPrice) { - miningParameters.setMinTransactionGasPrice(minTransactionGasPrice); + miningConfiguration.setMinTransactionGasPrice(minTransactionGasPrice); } /** @@ -137,7 +137,7 @@ public class BftBlockCreatorFactory { * @return the min transaction gas price */ public Wei getMinTransactionGasPrice() { - return miningParameters.getMinTransactionGasPrice(); + return miningConfiguration.getMinTransactionGasPrice(); } /** @@ -146,7 +146,7 @@ public class BftBlockCreatorFactory { * @return min priority fee per gas */ public Wei getMinPriorityFeePerGas() { - return miningParameters.getMinPriorityFeePerGas(); + return miningConfiguration.getMinPriorityFeePerGas(); } /** @@ -171,7 +171,7 @@ public class BftBlockCreatorFactory { final BftExtraData extraData = new BftExtraData( ConsensusHelpers.zeroLeftPad( - miningParameters.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH), + miningConfiguration.getExtraData(), BftExtraDataCodec.EXTRA_VANITY_LENGTH), Collections.emptyList(), toVote(proposal), round, @@ -187,7 +187,7 @@ public class BftBlockCreatorFactory { */ public void changeTargetGasLimit(final Long newTargetGasLimit) { if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) { - miningParameters.setTargetGasLimit(newTargetGasLimit); + miningConfiguration.setTargetGasLimit(newTargetGasLimit); } else { throw new UnsupportedOperationException("Specified target gas limit is invalid"); } diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java index 02689d52a..02da30f50 100644 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java +++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/CombinedProtocolScheduleFactoryTest.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -172,12 +172,12 @@ public class CombinedProtocolScheduleFactoryTest { final ProtocolScheduleBuilder protocolScheduleBuilder = new ProtocolScheduleBuilder( genesisConfigOptions, - BigInteger.ONE, + Optional.of(BigInteger.ONE), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java index e23664fd8..56a0e3398 100644 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java +++ b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleBuilderTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -245,7 +245,7 @@ public class BaseBftProtocolScheduleBuilderTest { false, bftExtraDataCodec, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/ibft/build.gradle b/consensus/ibft/build.gradle index da6304c4e..e95c86614 100644 --- a/consensus/ibft/build.gradle +++ b/consensus/ibft/build.gradle @@ -76,4 +76,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' + testImplementation 'com.google.dagger:dagger' + testAnnotationProcessor 'com.google.dagger:dagger-compiler' } diff --git a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java index 889673354..a5d24ff4d 100644 --- a/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java +++ b/consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java @@ -78,9 +78,9 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -310,8 +310,8 @@ public class TestContextBuilder { final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); - final MiningParameters miningParams = - ImmutableMiningParameters.builder() + final MiningConfiguration miningParams = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .isMiningEnabled(true) @@ -334,7 +334,7 @@ public class TestContextBuilder { forksSchedule, IBFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java index 3adf57189..adc4698e4 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleBuilder.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; @@ -46,7 +46,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -60,7 +60,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -72,7 +72,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -85,7 +85,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param forksSchedule the forks schedule * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -97,7 +97,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule forksSchedule, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -108,7 +108,7 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder false, bftExtraDataCodec, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java index 1afe06786..a777d7d17 100644 --- a/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java +++ b/consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/jsonrpc/IbftJsonRpcMethods.java @@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.ApiGroupJsonRpcMethods; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import java.util.Map; @@ -42,22 +42,22 @@ public class IbftJsonRpcMethods extends ApiGroupJsonRpcMethods { private final ProtocolContext context; private final ProtocolSchedule protocolSchedule; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; /** * Instantiates a new Ibft json rpc methods. * * @param context the protocol context * @param protocolSchedule the protocol schedule - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters */ public IbftJsonRpcMethods( final ProtocolContext context, final ProtocolSchedule protocolSchedule, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this.context = context; this.protocolSchedule = protocolSchedule; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; } @Override @@ -70,7 +70,7 @@ public class IbftJsonRpcMethods extends ApiGroupJsonRpcMethods { final MutableBlockchain blockchain = context.getBlockchain(); final BlockchainQueries blockchainQueries = new BlockchainQueries( - protocolSchedule, blockchain, context.getWorldStateArchive(), miningParameters); + protocolSchedule, blockchain, context.getWorldStateArchive(), miningConfiguration); final BftContext bftContext = context.getConsensusContext(BftContext.class); final BlockInterface blockInterface = bftContext.getBlockInterface(); final ValidatorProvider validatorProvider = diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java index e5551ff3f..9cb760551 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import org.hyperledger.besu.config.BftConfigOptions; -import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.config.JsonGenesisConfigOptions; import org.hyperledger.besu.config.JsonQbftConfigOptions; import org.hyperledger.besu.config.JsonUtil; @@ -40,31 +39,39 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; +import org.hyperledger.besu.ethereum.core.components.EthereumCoreComponent; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.math.BigInteger; -import java.util.Collection; import java.util.List; +import javax.inject.Singleton; +import dagger.Component; +import dagger.Module; +import dagger.Provides; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class IbftProtocolScheduleTest { - private final BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class); - private final BftExtraData bftExtraData = mock(BftExtraData.class); - private final NodeKey proposerNodeKey = NodeKeyUtils.generate(); - private final Address proposerAddress = Util.publicKeyToAddress(proposerNodeKey.getPublicKey()); - private final List
validators = singletonList(proposerAddress); + + private ProtocolContext protocolContext; + private List
validators; + private NodeKey proposerNodeKey; + private TestEthCoreComponent component; @BeforeEach public void setup() { - when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData); - when(bftExtraData.getValidators()).thenReturn(validators); + TestEthCoreComponent component = + DaggerIbftProtocolScheduleTest_TestEthCoreComponent.builder().build(); + this.component = component; + this.protocolContext = component.protocolContext(); + this.validators = component.validators(); + this.proposerNodeKey = component.nodeKey(); } @Test @@ -81,37 +88,16 @@ public class IbftProtocolScheduleTest { .buildHeader(); final BftProtocolSchedule schedule = - createProtocolSchedule( - JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode()), - List.of( - new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT), - new ForkSpec<>(1, arbitraryTransition), - new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT))); + createProtocolSchedule(component.bftExtraDataCodec(), arbitraryTransition); assertThat(new MilestoneStreamingProtocolSchedule(schedule).streamMilestoneBlocks().count()) .isEqualTo(3); - assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 0)).isTrue(); - assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 1)).isTrue(); - assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 2)).isTrue(); - } - - private BftProtocolSchedule createProtocolSchedule( - final GenesisConfigOptions genesisConfig, final List> forks) { - return IbftProtocolScheduleBuilder.create( - genesisConfig, - new ForksSchedule<>(forks), - PrivacyParameters.DEFAULT, - false, - bftExtraDataCodec, - EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, - new BadBlockManager(), - false, - new NoOpMetricsSystem()); + assertThat(validateHeader(schedule, parentHeader, blockHeader, 0)).isTrue(); + assertThat(validateHeader(schedule, parentHeader, blockHeader, 1)).isTrue(); + assertThat(validateHeader(schedule, parentHeader, blockHeader, 2)).isTrue(); } private boolean validateHeader( final BftProtocolSchedule schedule, - final List
validators, final BlockHeader parentHeader, final BlockHeader blockHeader, final int block) { @@ -119,14 +105,94 @@ public class IbftProtocolScheduleTest { .getByBlockNumberOrTimestamp(block, blockHeader.getTimestamp()) .getBlockHeaderValidator() .validateHeader( - blockHeader, parentHeader, protocolContext(validators), HeaderValidationMode.LIGHT); + blockHeader, parentHeader, this.protocolContext, HeaderValidationMode.LIGHT); } - private ProtocolContext protocolContext(final Collection
validators) { - return new ProtocolContext( - null, - null, - setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec), - new BadBlockManager()); + private BftProtocolSchedule createProtocolSchedule( + final BftExtraDataCodec bftExtraDataCodec, + final MutableBftConfigOptions arbitraryTransition) { + + var genesisConfig = JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode()); + ForksSchedule forkSched = + new ForksSchedule<>( + List.of( + new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT), + new ForkSpec<>(1, arbitraryTransition), + new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT))); + + return IbftProtocolScheduleBuilder.create( + genesisConfig, + forkSched, + PrivacyParameters.DEFAULT, + false, + bftExtraDataCodec, + EvmConfiguration.DEFAULT, + MiningConfiguration.MINING_DISABLED, + new BadBlockManager(), + false, + new NoOpMetricsSystem()); + } + + @Module + static class IbftProtocolScheduleModule { + @Provides + @Singleton + NodeKey nodeKey() { + return NodeKeyUtils.generate(); + } + + @Provides + Address provideProposerAddress(final NodeKey proposerNodeKey) { + return Util.publicKeyToAddress(proposerNodeKey.getPublicKey()); + } + + @Provides + List
provideValidators(final Address proposerAddress) { + return singletonList(proposerAddress); + } + + @Provides + public BftExtraData mockBftExtraData(final List
validators) { + BftExtraData bftExtraData = mock(BftExtraData.class); + when(bftExtraData.getValidators()).thenReturn(validators); + return bftExtraData; + } + + @Provides + public BftExtraDataCodec mockBftExtraDataCodec(final BftExtraData bftExtraData) { + BftExtraDataCodec bftExtraDataCodec = mock(BftExtraDataCodec.class); + when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData); + return bftExtraDataCodec; + } + + @Provides + ProtocolContext protocolContext( + final List
validators, final BftExtraDataCodec bftExtraDataCodec) { + return new ProtocolContext( + null, + null, + setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec), + new BadBlockManager()); + } + } + + @Singleton + @Component(modules = {NoMiningParamters.class, IbftProtocolScheduleModule.class}) + interface TestEthCoreComponent extends EthereumCoreComponent { + ProtocolContext protocolContext(); + + List
validators(); + + NodeKey nodeKey(); + + BftExtraDataCodec bftExtraDataCodec(); + } + + @Module + static class NoMiningParamters { + @Provides + MiningConfiguration provideMiningParameters() { + return MiningConfiguration.MINING_DISABLED; + } } } diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java index 5469717b1..df5a313ae 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java @@ -42,9 +42,9 @@ import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -122,7 +122,7 @@ public class BftBlockCreatorTest { false, bftExtraDataEncoder, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -159,8 +159,8 @@ public class BftBlockCreatorTest { transactionPool.setEnabled(); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder() + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .extraData( @@ -178,7 +178,7 @@ public class BftBlockCreatorTest { final BftBlockCreator blockCreator = new BftBlockCreator( - miningParameters, + miningConfiguration, forksSchedule, initialValidatorList.get(0), parent -> diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java index b9f57debb..79022b7d5 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/statemachine/IbftBlockHeightManagerTest.java @@ -70,7 +70,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; @@ -180,12 +180,12 @@ public class IbftBlockHeightManagerTest { final ProtocolScheduleBuilder protocolScheduleBuilder = new ProtocolScheduleBuilder( new StubGenesisConfigOptions(), - BigInteger.ONE, + Optional.empty(), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java index abbc3b130..a8c84d5a0 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/MergeProtocolSchedule.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.consensus.merge; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -48,7 +48,7 @@ public class MergeProtocolSchedule { * * @param config the config * @param isRevertReasonEnabled the is revert reason enabled - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return the protocol schedule @@ -56,7 +56,7 @@ public class MergeProtocolSchedule { public static ProtocolSchedule create( final GenesisConfigOptions config, final boolean isRevertReasonEnabled, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -64,7 +64,7 @@ public class MergeProtocolSchedule { config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -76,7 +76,7 @@ public class MergeProtocolSchedule { * @param config the config * @param privacyParameters the privacy parameters * @param isRevertReasonEnabled the is revert reason enabled - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return the protocol schedule @@ -85,7 +85,7 @@ public class MergeProtocolSchedule { final GenesisConfigOptions config, final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -101,12 +101,12 @@ public class MergeProtocolSchedule { return new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), new ProtocolSpecAdapters(postMergeModifications), privacyParameters, isRevertReasonEnabled, EvmConfiguration.DEFAULT, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem) diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java index e733cc800..44fd5f8ed 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/TransitionProtocolSchedule.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; @@ -65,21 +65,21 @@ public class TransitionProtocolSchedule implements ProtocolSchedule { * * @param genesisConfigOptions {@link GenesisConfigOptions} containing the config options for the * milestone starting points - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return an initialised TransitionProtocolSchedule using post-merge defaults */ public static TransitionProtocolSchedule fromConfig( final GenesisConfigOptions genesisConfigOptions, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { ProtocolSchedule preMergeProtocolSchedule = MainnetProtocolSchedule.fromConfig( genesisConfigOptions, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -87,7 +87,7 @@ public class TransitionProtocolSchedule implements ProtocolSchedule { MergeProtocolSchedule.create( genesisConfigOptions, false, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java index c56c62d80..56c78877a 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeBlockCreator.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.blockcreation.AbstractBlockCreator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; @@ -39,7 +39,7 @@ class MergeBlockCreator extends AbstractBlockCreator { /** * Instantiates a new Merge block creator. * - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param extraDataCalculator the extra data calculator * @param transactionPool the pending transactions * @param protocolContext the protocol context @@ -47,7 +47,7 @@ class MergeBlockCreator extends AbstractBlockCreator { * @param parentHeader the parent header */ public MergeBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, final ProtocolContext protocolContext, @@ -55,8 +55,8 @@ class MergeBlockCreator extends AbstractBlockCreator { final BlockHeader parentHeader, final EthScheduler ethScheduler) { super( - miningParameters, - __ -> miningParameters.getCoinbase().orElseThrow(), + miningConfiguration, + __ -> miningConfiguration.getCoinbase().orElseThrow(), extraDataCalculator, transactionPool, protocolContext, diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java index 877d7fb96..7570e97d4 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java @@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Withdrawal; @@ -81,7 +81,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene private static final long DEFAULT_TARGET_GAS_LIMIT = 30000000L; /** The Mining parameters. */ - protected final MiningParameters miningParameters; + protected final MiningConfiguration miningConfiguration; /** The Merge block creator factory. */ protected final MergeBlockCreatorFactory mergeBlockCreatorFactory; @@ -120,7 +120,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene final ProtocolSchedule protocolSchedule, final EthScheduler ethScheduler, final TransactionPool transactionPool, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final BackwardSyncContext backwardSyncContext, final Optional
depositContractAddress) { this.protocolContext = protocolContext; @@ -137,14 +137,14 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene } miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK); - this.miningParameters = miningParams; + this.miningConfiguration = miningParams; this.mergeBlockCreatorFactory = (parentHeader, address) -> { address.ifPresent(miningParams::setCoinbase); return new MergeBlockCreator( - miningParameters, - parent -> miningParameters.getExtraData(), + miningConfiguration, + parent -> miningConfiguration.getExtraData(), transactionPool, protocolContext, protocolSchedule, @@ -169,7 +169,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, final EthScheduler ethScheduler, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final BackwardSyncContext backwardSyncContext, final MergeBlockCreatorFactory mergeBlockCreatorFactory) { @@ -182,7 +182,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene miningParams.setTargetGasLimit(DEFAULT_TARGET_GAS_LIMIT); } miningParams.setMinBlockOccupancyRatio(TRY_FILL_BLOCK); - this.miningParameters = miningParams; + this.miningConfiguration = miningParams; this.mergeBlockCreatorFactory = mergeBlockCreatorFactory; @@ -215,17 +215,17 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene @Override public Wei getMinTransactionGasPrice() { - return miningParameters.getMinTransactionGasPrice(); + return miningConfiguration.getMinTransactionGasPrice(); } @Override public Wei getMinPriorityFeePerGas() { - return miningParameters.getMinPriorityFeePerGas(); + return miningConfiguration.getMinPriorityFeePerGas(); } @Override public Optional
getCoinbase() { - return miningParameters.getCoinbase(); + return miningConfiguration.getCoinbase(); } @Override @@ -244,7 +244,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene @Override public void changeTargetGasLimit(final Long newTargetGasLimit) { if (AbstractGasLimitSpecification.isValidTargetGasLimit(newTargetGasLimit)) { - this.miningParameters.setTargetGasLimit(newTargetGasLimit); + this.miningConfiguration.setTargetGasLimit(newTargetGasLimit); } else { throw new IllegalArgumentException("Specified target gas limit is invalid"); } @@ -383,13 +383,13 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene LOG.debug( "Block creation started for payload id {}, remaining time is {}ms", payloadIdentifier, - miningParameters.getUnstable().getPosBlockCreationMaxTime()); + miningConfiguration.getUnstable().getPosBlockCreationMaxTime()); ethScheduler .scheduleBlockCreationTask( () -> retryBlockCreationUntilUseful(payloadIdentifier, blockCreator)) .orTimeout( - miningParameters.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS) + miningConfiguration.getUnstable().getPosBlockCreationMaxTime(), TimeUnit.MILLISECONDS) .whenComplete( (unused, throwable) -> { if (throwable != null) { @@ -416,7 +416,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene final long waitBeforeRepetition = Math.max( 100, - miningParameters.getUnstable().getPosBlockCreationRepetitionMinDuration() + miningConfiguration.getUnstable().getPosBlockCreationRepetitionMinDuration() - lastDuration); LOG.debug("Waiting {}ms before repeating block creation", waitBeforeRepetition); Thread.sleep(waitBeforeRepetition); @@ -726,7 +726,7 @@ public class MergeCoordinator implements MergeMiningCoordinator, BadChainListene @Override public boolean isMiningBeforeMerge() { - return miningParameters.isMiningEnabled(); + return miningConfiguration.isMiningEnabled(); } private Optional findValidAncestor(final Blockchain chain, final Hash parentHash) { diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java index 0d4aede3a..ba83f8aad 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/MergeProtocolScheduleTest.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -51,7 +51,7 @@ public class MergeProtocolScheduleTest { MergeProtocolSchedule.create( config, false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -72,7 +72,7 @@ public class MergeProtocolScheduleTest { MergeProtocolSchedule.create( config, false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -113,7 +113,7 @@ public class MergeProtocolScheduleTest { MergeProtocolSchedule.create( config, false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -146,7 +146,7 @@ public class MergeProtocolScheduleTest { MergeProtocolSchedule.create( config, false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -180,7 +180,7 @@ public class MergeProtocolScheduleTest { MergeProtocolSchedule.create( GenesisConfigFile.DEFAULT.getConfigOptions(), false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java index 4efcdc1e0..23a5ae16b 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinatorTest.java @@ -55,10 +55,10 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.Unstable; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -135,8 +135,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { private final Address coinbase = genesisAllocations(getPosGenesisConfigFile()).findFirst().get(); - private MiningParameters miningParameters = - ImmutableMiningParameters.builder() + private MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build()) .unstable( Unstable.builder() @@ -228,7 +228,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { protocolSchedule, ethScheduler, transactionPool, - miningParameters, + miningConfiguration, backwardSyncContext, Optional.empty()); } @@ -273,7 +273,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { MergeBlockCreator beingSpiedOn = spy( new MergeBlockCreator( - miningParameters, + miningConfiguration, parent -> Bytes.EMPTY, transactionPool, protocolContext, @@ -302,7 +302,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { protocolContext, protocolSchedule, ethScheduler, - miningParameters, + miningConfiguration, backwardSyncContext, mergeBlockCreatorFactory)); @@ -543,9 +543,9 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { @Test public void shouldStopRetryBlockCreationIfTimeExpired() throws InterruptedException { final AtomicLong retries = new AtomicLong(0); - miningParameters = - ImmutableMiningParameters.builder() - .from(miningParameters) + miningConfiguration = + ImmutableMiningConfiguration.builder() + .from(miningConfiguration) .unstable(Unstable.builder().posBlockCreationMaxTime(100).build()) .build(); doAnswer( @@ -737,8 +737,8 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { public void shouldUseExtraDataFromMiningParameters() { final Bytes extraData = Bytes.fromHexString("0x1234"); - miningParameters = - ImmutableMiningParameters.builder() + miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues(MutableInitValues.builder().extraData(extraData).build()) .build(); @@ -748,7 +748,7 @@ public class MergeCoordinatorTest implements MergeGenesisConfigHelper { protocolSchedule, ethScheduler, transactionPool, - miningParameters, + miningConfiguration, backwardSyncContext, Optional.empty()); diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java index dcfe5f98e..582c8c5dd 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeGenesisConfigHelper.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.consensus.merge.MergeProtocolSchedule; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -56,7 +56,7 @@ public interface MergeGenesisConfigHelper { return MergeProtocolSchedule.create( getPosGenesisConfigFile().getConfigOptions(), false, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java index 7b111268e..22153eece 100644 --- a/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java +++ b/consensus/merge/src/test/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeReorgTest.java @@ -34,8 +34,8 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.sync.backwardsync.BackwardSyncContext; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -96,7 +96,7 @@ public class MergeReorgTest implements MergeGenesisConfigHelper { mockProtocolSchedule, ethScheduler, mockTransactionPool, - ImmutableMiningParameters.builder() + ImmutableMiningConfiguration.builder() .mutableInitValues(MutableInitValues.builder().coinbase(coinbase).build()) .build(), mock(BackwardSyncContext.class), diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java index d90d5a152..cc7066f17 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java +++ b/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java @@ -91,9 +91,9 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -387,8 +387,8 @@ public class TestContextBuilder { final boolean useFixedBaseFee, final List qbftForks) { - final MiningParameters miningParams = - ImmutableMiningParameters.builder() + final MiningConfiguration miningParams = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .isMiningEnabled(true) @@ -438,7 +438,7 @@ public class TestContextBuilder { forksSchedule, BFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java index e1cbc134b..473b99332 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleBuilder.java @@ -24,7 +24,7 @@ import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -50,7 +50,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration - * @param miningParameters The mining parameters + * @param miningConfiguration The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -64,7 +64,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -76,7 +76,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -89,7 +89,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param qbftForksSchedule the qbft forks schedule * @param bftExtraDataCodec the bft extra data codec * @param evmConfiguration the evm configuration - * @param miningParameters The mining parameters + * @param miningConfiguration The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -101,7 +101,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule qbftForksSchedule, final BftExtraDataCodec bftExtraDataCodec, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -112,7 +112,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder false, bftExtraDataCodec, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -125,7 +125,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder * @param qbftForksSchedule the qbft forks schedule * @param isRevertReasonEnabled the is revert reason enabled * @param bftExtraDataCodec the bft extra data codec - * @param miningParameters The mining parameters + * @param miningConfiguration The mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying @@ -137,7 +137,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder final ForksSchedule qbftForksSchedule, final boolean isRevertReasonEnabled, final BftExtraDataCodec bftExtraDataCodec, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -148,7 +148,7 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder isRevertReasonEnabled, bftExtraDataCodec, EvmConfiguration.DEFAULT, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java index 10f61713d..fc46b6c32 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreatorFa import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -52,7 +52,7 @@ public class QbftBlockCreatorFactory extends BftBlockCreatorFactory forksSchedule, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final Address localAddress, final BftExtraDataCodec bftExtraDataCodec, final EthScheduler ethScheduler) { @@ -74,7 +74,7 @@ public class QbftBlockCreatorFactory extends BftBlockCreatorFactory accountWhitelistController = @@ -198,7 +198,7 @@ public class JsonRpcTestMethodsFactory { context, filterManager, transactionPool, - miningParameters, + miningConfiguration, miningCoordinator, metricsSystem, new HashSet<>(), diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java index d4de40530..b238259d6 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthGetFilterChangesIntegrationTest.java @@ -45,7 +45,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -130,7 +130,7 @@ public class EthGetFilterChangesIntegrationTest { executionContext.getProtocolSchedule(), blockchain, protocolContext.getWorldStateArchive(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); filterManager = new FilterManagerBuilder() .blockchainQueries(blockchainQueries) diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java index 0c194ad22..fc5379f19 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthGetFilterChangesIntegrationTest.java @@ -45,7 +45,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -130,7 +130,7 @@ public class EthGetFilterChangesIntegrationTest { executionContext.getProtocolSchedule(), blockchain, protocolContext.getWorldStateArchive(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); filterManager = new FilterManagerBuilder() .blockchainQueries(blockchainQueries) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java index b433ed0b6..02d7bac98 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraData.java @@ -19,13 +19,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; public class MinerGetExtraData implements JsonRpcMethod { - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerGetExtraData(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerGetExtraData(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -36,6 +36,6 @@ public class MinerGetExtraData implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( - requestContext.getRequest().getId(), miningParameters.getExtraData().toShortHexString()); + requestContext.getRequest().getId(), miningConfiguration.getExtraData().toShortHexString()); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java index 07e8fdc9b..353125f84 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPrice.java @@ -20,13 +20,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; public class MinerGetMinGasPrice implements JsonRpcMethod { - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerGetMinGasPrice(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerGetMinGasPrice(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -38,6 +38,6 @@ public class MinerGetMinGasPrice implements JsonRpcMethod { public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), - Quantity.create(miningParameters.getMinTransactionGasPrice())); + Quantity.create(miningConfiguration.getMinTransactionGasPrice())); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java index d99d13de2..e12810b30 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFee.java @@ -20,13 +20,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; public class MinerGetMinPriorityFee implements JsonRpcMethod { - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerGetMinPriorityFee(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerGetMinPriorityFee(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -38,6 +38,6 @@ public class MinerGetMinPriorityFee implements JsonRpcMethod { public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return new JsonRpcSuccessResponse( requestContext.getRequest().getId(), - Quantity.create(miningParameters.getMinPriorityFeePerGas())); + Quantity.create(miningConfiguration.getMinPriorityFeePerGas())); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java index 51395e24f..7d5fa5b2e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraData.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import java.nio.charset.StandardCharsets; @@ -35,10 +35,10 @@ import org.slf4j.LoggerFactory; public class MinerSetExtraData implements JsonRpcMethod { private static final Logger LOG = LoggerFactory.getLogger(MinerSetExtraData.class); - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerSetExtraData(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerSetExtraData(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -53,7 +53,7 @@ public class MinerSetExtraData implements JsonRpcMethod { Bytes32.fromHexStringLenient( rawParam); // done for validation, we want a hex string and max 32 bytes final var extraData = Bytes.fromHexStringLenient(rawParam); - miningParameters.setExtraData(extraData); + miningConfiguration.setExtraData(extraData); LOG.atDebug() .setMessage("set extra data, raw=[{}] parsed=[{}], UTF-8=[{}]") .addArgument(rawParam) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java index 733ed3a8f..e932669b0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPrice.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,10 +33,10 @@ import org.slf4j.LoggerFactory; public class MinerSetMinGasPrice implements JsonRpcMethod { private static final Logger LOG = LoggerFactory.getLogger(MinerSetMinGasPrice.class); - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerSetMinGasPrice(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerSetMinGasPrice(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -49,7 +49,7 @@ public class MinerSetMinGasPrice implements JsonRpcMethod { try { final Wei minGasPrice = Wei.fromHexString(requestContext.getRequiredParameter(0, String.class)); - miningParameters.setMinTransactionGasPrice(minGasPrice); + miningConfiguration.setMinTransactionGasPrice(minGasPrice); LOG.debug("min gas price changed to {}", minGasPrice.toHumanReadableString()); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true); } catch (final IllegalArgumentException invalidJsonRpcParameters) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java index b1bf4338f..d296f28f9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFee.java @@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,10 +32,10 @@ import org.slf4j.LoggerFactory; public class MinerSetMinPriorityFee implements JsonRpcMethod { private static final Logger LOG = LoggerFactory.getLogger(MinerSetMinPriorityFee.class); - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public MinerSetMinPriorityFee(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public MinerSetMinPriorityFee(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -48,7 +48,7 @@ public class MinerSetMinPriorityFee implements JsonRpcMethod { try { final Wei minPriorityFeePerGas = Wei.fromHexString(requestContext.getRequiredParameter(0, String.class)); - miningParameters.setMinPriorityFeePerGas(minPriorityFeePerGas); + miningConfiguration.setMinPriorityFeePerGas(minPriorityFeePerGas); LOG.debug( "min priority fee per gas changed to {}", minPriorityFeePerGas.toHumanReadableString()); return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java index cdf4440bd..7be34f022 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.RpcModules; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.manager.EthPeers; @@ -67,7 +67,7 @@ public class JsonRpcMethodsFactory { final ProtocolContext protocolContext, final FilterManager filterManager, final TransactionPool transactionPool, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MiningCoordinator miningCoordinator, final ObservableMetricsSystem metricsSystem, final Set supportedCapabilities, @@ -139,7 +139,7 @@ public class JsonRpcMethodsFactory { webSocketConfiguration, metricsConfiguration, graphQLConfiguration), - new MinerJsonRpcMethods(miningParameters, miningCoordinator), + new MinerJsonRpcMethods(miningConfiguration, miningCoordinator), new PermJsonRpcMethods(accountsAllowlistController, nodeAllowlistController), new PrivJsonRpcMethods( blockchainQueries, diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java index c799c2330..14e74767e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/MinerJsonRpcMethods.java @@ -28,18 +28,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner.MinerSet import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner.MinerStart; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.miner.MinerStop; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import java.util.Map; public class MinerJsonRpcMethods extends ApiGroupJsonRpcMethods { private final MiningCoordinator miningCoordinator; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; public MinerJsonRpcMethods( - final MiningParameters miningParameters, final MiningCoordinator miningCoordinator) { - this.miningParameters = miningParameters; + final MiningConfiguration miningConfiguration, final MiningCoordinator miningCoordinator) { + this.miningConfiguration = miningConfiguration; this.miningCoordinator = miningCoordinator; } @@ -57,11 +57,11 @@ public class MinerJsonRpcMethods extends ApiGroupJsonRpcMethods { minerSetCoinbase, new MinerSetEtherbase(minerSetCoinbase), new MinerChangeTargetGasLimit(miningCoordinator), - new MinerGetMinPriorityFee(miningParameters), - new MinerSetMinPriorityFee(miningParameters), - new MinerGetMinGasPrice(miningParameters), - new MinerSetMinGasPrice(miningParameters), - new MinerGetExtraData(miningParameters), - new MinerSetExtraData(miningParameters)); + new MinerGetMinPriorityFee(miningConfiguration), + new MinerSetMinPriorityFee(miningConfiguration), + new MinerGetMinGasPrice(miningConfiguration), + new MinerSetMinGasPrice(miningConfiguration), + new MinerGetExtraData(miningConfiguration), + new MinerSetExtraData(miningConfiguration)); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java index c03bf124c..7e5a7c6fe 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.LogWithMetadata; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -77,20 +77,20 @@ public class BlockchainQueries { private final Optional transactionLogBloomCacher; private final Optional ethScheduler; private final ApiConfiguration apiConfig; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; public BlockchainQueries( final ProtocolSchedule protocolSchedule, final Blockchain blockchain, final WorldStateArchive worldStateArchive, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this( protocolSchedule, blockchain, worldStateArchive, Optional.empty(), Optional.empty(), - miningParameters); + miningConfiguration); } public BlockchainQueries( @@ -98,14 +98,14 @@ public class BlockchainQueries { final Blockchain blockchain, final WorldStateArchive worldStateArchive, final EthScheduler scheduler, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this( protocolSchedule, blockchain, worldStateArchive, Optional.empty(), Optional.ofNullable(scheduler), - miningParameters); + miningConfiguration); } public BlockchainQueries( @@ -114,7 +114,7 @@ public class BlockchainQueries { final WorldStateArchive worldStateArchive, final Optional cachePath, final Optional scheduler, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this( protocolSchedule, blockchain, @@ -122,7 +122,7 @@ public class BlockchainQueries { cachePath, scheduler, ImmutableApiConfiguration.builder().build(), - miningParameters); + miningConfiguration); } public BlockchainQueries( @@ -132,7 +132,7 @@ public class BlockchainQueries { final Optional cachePath, final Optional scheduler, final ApiConfiguration apiConfig, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { this.protocolSchedule = protocolSchedule; this.blockchain = blockchain; this.worldStateArchive = worldStateArchive; @@ -144,7 +144,7 @@ public class BlockchainQueries { new TransactionLogBloomCacher(blockchain, cachePath.get(), scheduler.get())) : Optional.empty(); this.apiConfig = apiConfig; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; } public Blockchain getBlockchain() { @@ -1034,7 +1034,7 @@ public class BlockchainQueries { private Wei gasPriceLowerBound( final BlockHeader chainHeadHeader, final FeeMarket nextBlockFeeMarket) { - final var minGasPrice = miningParameters.getMinTransactionGasPrice(); + final var minGasPrice = miningConfiguration.getMinTransactionGasPrice(); if (nextBlockFeeMarket.implementsBaseFee()) { return UInt256s.max( @@ -1070,9 +1070,9 @@ public class BlockchainQueries { .toArray(Wei[]::new); return gasCollection.length == 0 - ? miningParameters.getMinPriorityFeePerGas() + ? miningConfiguration.getMinPriorityFeePerGas() : UInt256s.max( - miningParameters.getMinPriorityFeePerGas(), + miningConfiguration.getMinPriorityFeePerGas(), gasCollection[ Math.min( gasCollection.length - 1, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java index 5a1c23d40..2b55b42ba 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java @@ -27,7 +27,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.DefaultSyncStatus; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -119,7 +119,7 @@ public abstract class AbstractEthGraphQLHttpServiceTest { Optional.empty(), Optional.empty(), ImmutableApiConfiguration.builder().build(), - MiningParameters.newDefault().setMinTransactionGasPrice(Wei.ZERO)); + MiningConfiguration.newDefault().setMinTransactionGasPrice(Wei.ZERO)); final Set supportedCapabilities = new HashSet<>(); supportedCapabilities.add(EthProtocol.ETH62); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java index d504e3bb0..db896a948 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguratio import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Transaction; @@ -137,7 +137,7 @@ public abstract class AbstractJsonRpcHttpServiceTest { final Synchronizer synchronizerMock = mock(Synchronizer.class); final P2PNetwork peerDiscoveryMock = mock(P2PNetwork.class); final TransactionPool transactionPoolMock = mock(TransactionPool.class); - final MiningParameters miningParameters = mock(MiningParameters.class); + final MiningConfiguration miningConfiguration = mock(MiningConfiguration.class); final PoWMiningCoordinator miningCoordinatorMock = mock(PoWMiningCoordinator.class); when(transactionPoolMock.addTransactionViaApi(any(Transaction.class))) .thenReturn(ValidationResult.valid()); @@ -151,7 +151,7 @@ public abstract class AbstractJsonRpcHttpServiceTest { blockchainSetupUtil.getProtocolSchedule(), blockchainSetupUtil.getBlockchain(), blockchainSetupUtil.getWorldArchive(), - miningParameters); + miningConfiguration); final FilterIdGenerator filterIdGenerator = mock(FilterIdGenerator.class); final FilterRepository filterRepository = new FilterRepository(); when(filterIdGenerator.nextId()).thenReturn("0x1"); @@ -183,7 +183,7 @@ public abstract class AbstractJsonRpcHttpServiceTest { protocolContext, filterManager, transactionPoolMock, - miningParameters, + miningConfiguration, miningCoordinatorMock, new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java index 022aa2442..9113e15a1 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguratio import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -113,14 +113,14 @@ public class JsonRpcHttpServiceHostAllowlistTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java index f9dba0bc2..aacf11579 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java @@ -37,7 +37,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguratio import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -144,14 +144,14 @@ public class JsonRpcHttpServiceLoginTest { synchronizer, MainnetProtocolSchedule.fromConfig( genesisConfigOptions, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java index 63ae1b8bf..ae66f2ac7 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Synchronizer; @@ -217,7 +217,7 @@ public class JsonRpcHttpServiceRpcApisTest { mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, @@ -328,7 +328,7 @@ public class JsonRpcHttpServiceRpcApisTest { mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java index 5a439fa19..ec4f6c6e2 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.ChainHead; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -122,14 +122,14 @@ public class JsonRpcHttpServiceTestBase { MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java index 28474d3c5..fa336169b 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java @@ -37,7 +37,7 @@ import org.hyperledger.besu.ethereum.api.tls.SelfSignedP12Certificate; import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -127,14 +127,14 @@ public class JsonRpcHttpServiceTlsClientAuthTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java index 15df60230..b675430c4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.api.tls.SelfSignedP12Certificate; import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -115,14 +115,14 @@ class JsonRpcHttpServiceTlsMisconfigurationTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java index 6f7ce4e1d..de5683ad5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.api.tls.SelfSignedP12Certificate; import org.hyperledger.besu.ethereum.api.tls.TlsConfiguration; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -116,14 +116,14 @@ public class JsonRpcHttpServiceTlsTest { synchronizer, MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java index 8c7cba99c..c55f9b465 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java @@ -39,7 +39,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; @@ -77,13 +77,13 @@ public class EthGasPriceTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private Blockchain blockchain; private EthGasPrice method; - private MiningParameters miningParameters; + private MiningConfiguration miningConfiguration; @BeforeEach public void setUp() { ApiConfiguration apiConfig = createDefaultApiConfiguration(); - miningParameters = - MiningParameters.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE); + miningConfiguration = + MiningConfiguration.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE); method = createEthGasPriceMethod(apiConfig); } @@ -96,7 +96,7 @@ public class EthGasPriceTest { public void shouldReturnMinValueWhenNoTransactionsExist() { final JsonRpcRequestContext request = requestWithParams(); final String expectedWei = "0x4d2"; // minGasPrice > nextBlockBaseFee - miningParameters.setMinTransactionGasPrice(Wei.fromHexString(expectedWei)); + miningConfiguration.setMinTransactionGasPrice(Wei.fromHexString(expectedWei)); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei); @@ -117,7 +117,7 @@ public class EthGasPriceTest { final JsonRpcRequestContext request = requestWithParams(); final String expectedWei = DEFAULT_BASE_FEE.toShortHexString(); // nextBlockBaseFee > minGasPrice - miningParameters.setMinTransactionGasPrice(Wei.fromHexString(expectedWei)); + miningConfiguration.setMinTransactionGasPrice(Wei.fromHexString(expectedWei)); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei); @@ -234,7 +234,7 @@ public class EthGasPriceTest { @MethodSource("ethGasPriceAtGenesis") public void ethGasPriceAtGenesis( final Wei minGasPrice, final Optional maybeGenesisBaseFee, final Wei expectedGasPrice) { - miningParameters.setMinTransactionGasPrice(minGasPrice); + miningConfiguration.setMinTransactionGasPrice(minGasPrice); if (maybeGenesisBaseFee.isPresent()) { mockBaseFeeMarket(); @@ -267,7 +267,7 @@ public class EthGasPriceTest { final Long lowerBoundCoefficient, final Long upperBoundCoefficient, final long expectedGasPrice) { - miningParameters.setMinTransactionGasPrice(Wei.of(100)); + miningConfiguration.setMinTransactionGasPrice(Wei.of(100)); mockBaseFeeMarket(); @@ -423,7 +423,7 @@ public class EthGasPriceTest { Optional.empty(), Optional.empty(), apiConfig, - miningParameters), + miningConfiguration), apiConfig); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java index 254d0fbe9..fd92b55ba 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockByNumberTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -93,7 +93,7 @@ public class EthGetBlockByNumberTest { blockchainQueries = spy( new BlockchainQueries( - protocolSchedule, blockchain, worldStateArchive, MiningParameters.newDefault())); + protocolSchedule, blockchain, worldStateArchive, MiningConfiguration.newDefault())); method = new EthGetBlockByNumber(blockchainQueries, blockResult, synchronizer); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java index 545b43a6e..f25407c86 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetBlockReceiptsTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -86,7 +86,7 @@ public class EthGetBlockReceiptsTest { blockchainQueries = spy( new BlockchainQueries( - protocolSchedule, blockchain, worldStateArchive, MiningParameters.newDefault())); + protocolSchedule, blockchain, worldStateArchive, MiningConfiguration.newDefault())); protocolSchedule = mock(ProtocolSchedule.class); method = new EthGetBlockReceipts(blockchainQueries, protocolSchedule); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java index 06a4b9d0e..a346cd827 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProofTest.java @@ -39,7 +39,7 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.ChainHead; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.proof.WorldStateProof; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; @@ -89,7 +89,7 @@ class EthGetProofTest { blockchainQueries = spy( new BlockchainQueries( - protocolSchedule, blockchain, archive, MiningParameters.newDefault())); + protocolSchedule, blockchain, archive, MiningConfiguration.newDefault())); when(blockchainQueries.getBlockchain()).thenReturn(blockchain); when(blockchainQueries.headBlockNumber()).thenReturn(14L); when(blockchain.getChainHead()).thenReturn(chainHead); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java index 884cc504d..608577f47 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java @@ -42,7 +42,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.PoWHasher; @@ -195,7 +195,7 @@ public class EthGetTransactionReceiptTest { protocolSchedule, blockchain, mock(WorldStateArchive.class), - MiningParameters.newDefault())); + MiningConfiguration.newDefault())); private final EthGetTransactionReceipt ethGetTransactionReceipt = new EthGetTransactionReceipt(blockchainQueries, protocolSchedule); private final String receiptString = diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java index d29a10a11..05b5f8cb0 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthMaxPriorityFeePerGasTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.feemarket.CancunFeeMarket; @@ -67,12 +67,12 @@ public class EthMaxPriorityFeePerGasTest { private EthMaxPriorityFeePerGas method; @Mock private ProtocolSchedule protocolSchedule; @Mock private Blockchain blockchain; - private MiningParameters miningParameters; + private MiningConfiguration miningConfiguration; @BeforeEach public void setUp() { - miningParameters = - MiningParameters.newDefault().setMinPriorityFeePerGas(DEFAULT_MIN_PRIORITY_FEE_PER_GAS); + miningConfiguration = + MiningConfiguration.newDefault().setMinPriorityFeePerGas(DEFAULT_MIN_PRIORITY_FEE_PER_GAS); method = createEthMaxPriorityFeePerGasMethod(); } @@ -85,7 +85,7 @@ public class EthMaxPriorityFeePerGasTest { public void whenNoTransactionsExistReturnMinPriorityFeePerGasPrice() { final JsonRpcRequestContext request = requestWithParams(); final Wei expectedWei = Wei.ONE; - miningParameters.setMinPriorityFeePerGas(expectedWei); + miningConfiguration.setMinPriorityFeePerGas(expectedWei); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei.toShortHexString()); @@ -111,7 +111,7 @@ public class EthMaxPriorityFeePerGasTest { public void returnMinPriorityFeePerGasWhenMedianValueIsLower() { final JsonRpcRequestContext request = requestWithParams(); final Wei expectedWei = Wei.of(100_000); - miningParameters.setMinPriorityFeePerGas(expectedWei); + miningConfiguration.setMinPriorityFeePerGas(expectedWei); mockBlockchain(100, 1); @@ -128,7 +128,7 @@ public class EthMaxPriorityFeePerGasTest { public void atGenesisReturnMinPriorityFeePerGas() { final JsonRpcRequestContext request = requestWithParams(); final Wei expectedWei = Wei.ONE; - miningParameters.setMinPriorityFeePerGas(expectedWei); + miningConfiguration.setMinPriorityFeePerGas(expectedWei); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), expectedWei.toShortHexString()); @@ -235,6 +235,6 @@ public class EthMaxPriorityFeePerGasTest { Optional.empty(), Optional.empty(), ImmutableApiConfiguration.builder().build(), - miningParameters)); + miningConfiguration)); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java index ebaf817a4..882a07111 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetExtraDataTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.Test; @@ -30,8 +30,8 @@ public class MinerGetExtraDataTest { @Test public void shouldReturnDefaultExtraData() { - final MiningParameters miningParameters = ImmutableMiningParameters.newDefault(); - final MinerGetExtraData method = new MinerGetExtraData(miningParameters); + final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault(); + final MinerGetExtraData method = new MinerGetExtraData(miningConfiguration); final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {})); @@ -43,12 +43,12 @@ public class MinerGetExtraDataTest { @Test public void shouldReturnSetAtRuntimeExtraData() { - final MiningParameters miningParameters = ImmutableMiningParameters.newDefault(); - final MinerGetExtraData method = new MinerGetExtraData(miningParameters); + final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault(); + final MinerGetExtraData method = new MinerGetExtraData(miningConfiguration); final var extraData = "0x123456"; final Bytes extraDataAtRuntime = Bytes.fromHexString(extraData); - miningParameters.setExtraData(extraDataAtRuntime); + miningConfiguration.setExtraData(extraDataAtRuntime); final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {})); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java index f73229f0e..8e036d822 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinGasPriceTest.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.junit.jupiter.api.Test; @@ -31,15 +31,16 @@ public class MinerGetMinGasPriceTest { @Test public void shouldReturnDefaultMinGasPrice() { - final MiningParameters miningParameters = ImmutableMiningParameters.newDefault(); - final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningParameters); + final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault(); + final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningConfiguration); final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {})); final JsonRpcResponse expected = new JsonRpcSuccessResponse( request.getRequest().getId(), - Quantity.create(MiningParameters.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE)); + Quantity.create( + MiningConfiguration.MutableInitValues.DEFAULT_MIN_TRANSACTION_GAS_PRICE)); final JsonRpcResponse actual = method.response(request); assertThat(actual).usingRecursiveComparison().isEqualTo(expected); @@ -47,12 +48,12 @@ public class MinerGetMinGasPriceTest { @Test public void shouldReturnSetAtRuntimeMinGasPrice() { - final MiningParameters miningParameters = ImmutableMiningParameters.newDefault(); - final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningParameters); + final MiningConfiguration miningConfiguration = ImmutableMiningConfiguration.newDefault(); + final MinerGetMinGasPrice method = new MinerGetMinGasPrice(miningConfiguration); final Wei minGasPriceAtRuntime = Wei.of(2000); - miningParameters.setMinTransactionGasPrice(minGasPriceAtRuntime); + miningConfiguration.setMinTransactionGasPrice(minGasPriceAtRuntime); final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {})); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java index 78fb85b94..07e3e5842 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerGetMinPriorityFeeTest.java @@ -23,18 +23,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MinerGetMinPriorityFeeTest { - MiningParameters miningParameters = mock(MiningParameters.class); + MiningConfiguration miningConfiguration = mock(MiningConfiguration.class); private MinerGetMinPriorityFee method; @BeforeEach public void setUp() { - method = new MinerGetMinPriorityFee(miningParameters); + method = new MinerGetMinPriorityFee(miningConfiguration); } @Test @@ -44,7 +44,8 @@ public class MinerGetMinPriorityFeeTest { final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", method.getName(), new Object[] {})); - when(miningParameters.getMinPriorityFeePerGas()).thenReturn(Wei.fromHexString(minPriorityFee)); + when(miningConfiguration.getMinPriorityFeePerGas()) + .thenReturn(Wei.fromHexString(minPriorityFee)); final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), minPriorityFee); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java index b3c7b45d0..e19796408 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetExtraDataTest.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import java.nio.charset.StandardCharsets; @@ -32,12 +32,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MinerSetExtraDataTest { - MiningParameters miningParameters = MiningParameters.newDefault(); + MiningConfiguration miningConfiguration = MiningConfiguration.newDefault(); private MinerSetExtraData method; @BeforeEach public void setUp() { - method = new MinerSetExtraData(miningParameters); + method = new MinerSetExtraData(miningConfiguration); } @Test @@ -49,7 +49,7 @@ public class MinerSetExtraDataTest { final JsonRpcResponse actual = method.response(request); assertThat(actual).usingRecursiveComparison().isEqualTo(expected); - final var currExtraData = miningParameters.getExtraData(); + final var currExtraData = miningConfiguration.getExtraData(); assertThat(new String(currExtraData.toArray(), StandardCharsets.UTF_8)).isEqualTo(newExtraData); } @@ -67,7 +67,7 @@ public class MinerSetExtraDataTest { final JsonRpcResponse actual = method.response(request); assertThat(actual).usingRecursiveComparison().isEqualTo(expected); - final var currExtraData = miningParameters.getExtraData(); + final var currExtraData = miningConfiguration.getExtraData(); assertThat(new String(currExtraData.toArray(), StandardCharsets.UTF_8)) .isEqualTo( new String( diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java index fb56b5730..860e1967d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinGasPriceTest.java @@ -24,18 +24,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MinerSetMinGasPriceTest { - MiningParameters miningParameters = MiningParameters.newDefault(); + MiningConfiguration miningConfiguration = MiningConfiguration.newDefault(); private MinerSetMinGasPrice method; @BeforeEach public void setUp() { - method = new MinerSetMinGasPrice(miningParameters); + method = new MinerSetMinGasPrice(miningConfiguration); } @Test @@ -64,7 +64,7 @@ public class MinerSetMinGasPriceTest { final JsonRpcResponse actual = method.response(request); assertThat(actual).usingRecursiveComparison().isEqualTo(expected); - assertThat(miningParameters.getMinTransactionGasPrice()) + assertThat(miningConfiguration.getMinTransactionGasPrice()) .isEqualTo(Wei.fromHexString(newMinGasPrice)); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java index 7e564ac42..fb75788d4 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/miner/MinerSetMinPriorityFeeTest.java @@ -24,18 +24,18 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorR import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MinerSetMinPriorityFeeTest { - MiningParameters miningParameters = MiningParameters.newDefault(); + MiningConfiguration miningConfiguration = MiningConfiguration.newDefault(); private MinerSetMinPriorityFee method; @BeforeEach public void setUp() { - method = new MinerSetMinPriorityFee(miningParameters); + method = new MinerSetMinPriorityFee(miningConfiguration); } @Test @@ -80,7 +80,7 @@ public class MinerSetMinPriorityFeeTest { final JsonRpcResponse expected = new JsonRpcSuccessResponse(request.getRequest().getId(), true); final JsonRpcResponse actual = method.response(request); assertThat(actual).usingRecursiveComparison().isEqualTo(expected); - assertThat(miningParameters.getMinPriorityFeePerGas()) + assertThat(miningConfiguration.getMinPriorityFeePerGas()) .isEqualTo(Wei.fromHexString(newMinPriorityFee)); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java index 47a16135f..53785012d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java @@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.Subscrip import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.blockcreation.PoWMiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -180,14 +180,14 @@ public class WebSocketServiceLoginTest { synchronizer, MainnetProtocolSchedule.fromConfig( genesisConfigOptions, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()), mock(ProtocolContext.class), mock(FilterManager.class), mock(TransactionPool.class), - mock(MiningParameters.class), + mock(MiningConfiguration.class), mock(PoWMiningCoordinator.class), new NoOpMetricsSystem(), supportedCapabilities, diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java index 8cb33fa71..aa69a239c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/blockheaders/NewBlockHeadersSubscriptionServiceTest.java @@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -85,7 +85,7 @@ public class NewBlockHeadersSubscriptionServiceTest { protocolSchedule, blockchain, createInMemoryWorldStateArchive(), - MiningParameters.newDefault())); + MiningConfiguration.newDefault())); @BeforeEach public void before() { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java index 4b9631732..7b3d50b2d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -136,7 +136,7 @@ public class BlockchainQueriesLogCacheTest { worldStateArchive, Optional.of(cacheDir), Optional.of(scheduler), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } /** diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java index a49b290e4..a0213a41a 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.LogWithMetadata; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -599,7 +599,7 @@ public class BlockchainQueriesTest { blockchain, worldStateArchive, scheduler, - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } } diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index ad9489daf..51cde269e 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Request; @@ -84,7 +84,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { private final MiningBeneficiaryCalculator miningBeneficiaryCalculator; private final ExtraDataCalculator extraDataCalculator; private final TransactionPool transactionPool; - protected final MiningParameters miningParameters; + protected final MiningConfiguration miningConfiguration; protected final ProtocolContext protocolContext; protected final ProtocolSchedule protocolSchedule; protected final BlockHeaderFunctions blockHeaderFunctions; @@ -92,14 +92,14 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { private final AtomicBoolean isCancelled = new AtomicBoolean(false); protected AbstractBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, final EthScheduler ethScheduler) { - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.miningBeneficiaryCalculator = miningBeneficiaryCalculator; this.extraDataCalculator = extraDataCalculator; this.transactionPool = transactionPool; @@ -219,7 +219,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { throwIfStopped(); final PluginTransactionSelector pluginTransactionSelector = - miningParameters.getTransactionSelectionService().createPluginTransactionSelector(); + miningConfiguration.getTransactionSelectionService().createPluginTransactionSelector(); final BlockAwareOperationTracer operationTracer = pluginTransactionSelector.getOperationTracer(); @@ -377,7 +377,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { final BlockTransactionSelector selector = new BlockTransactionSelector( - miningParameters, + miningConfiguration, transactionProcessor, protocolContext.getBlockchain(), disposableWorldState, @@ -433,7 +433,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { .getGasLimitCalculator() .nextGasLimit( parentHeader.getGasLimit(), - miningParameters.getTargetGasLimit().orElse(parentHeader.getGasLimit()), + miningConfiguration.getTargetGasLimit().orElse(parentHeader.getGasLimit()), newBlockNumber); final DifficultyCalculator difficultyCalculator = protocolSpec.getDifficultyCalculator(); @@ -457,7 +457,7 @@ public abstract class AbstractBlockCreator implements AsyncBlockCreator { final Bytes32 parentBeaconBlockRoot = maybeParentBeaconBlockRoot.orElse(null); return BlockHeaderBuilder.create() .parentHash(parentHeader.getHash()) - .coinbase(miningParameters.getCoinbase().orElseThrow()) + .coinbase(miningConfiguration.getCoinbase().orElseThrow()) .difficulty(Difficulty.of(difficulty)) .number(newBlockNumber) .gasLimit(gasLimit) diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java index af71938d1..4d2b1274c 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractMinerExecutor.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; import org.hyperledger.besu.ethereum.chain.PoWObserver; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.AbstractGasLimitSpecification; @@ -47,7 +47,7 @@ public abstract class AbstractMinerExecutor getCoinbase(); diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java index 6eb492722..8b5624f84 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/NoopMiningCoordinator.java @@ -18,7 +18,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import java.util.List; @@ -26,10 +26,10 @@ import java.util.Optional; public class NoopMiningCoordinator implements MiningCoordinator { - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; - public NoopMiningCoordinator(final MiningParameters miningParameters) { - this.miningParameters = miningParameters; + public NoopMiningCoordinator(final MiningConfiguration miningConfiguration) { + this.miningConfiguration = miningConfiguration; } @Override @@ -58,17 +58,17 @@ public class NoopMiningCoordinator implements MiningCoordinator { @Override public Wei getMinTransactionGasPrice() { - return miningParameters.getMinTransactionGasPrice(); + return miningConfiguration.getMinTransactionGasPrice(); } @Override public Wei getMinPriorityFeePerGas() { - return miningParameters.getMinPriorityFeePerGas(); + return miningConfiguration.getMinPriorityFeePerGas(); } @Override public Optional
getCoinbase() { - return miningParameters.getCoinbase(); + return miningConfiguration.getCoinbase(); } @Override diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java index d0042a5ad..173330568 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreator.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.blockcreation; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; @@ -39,7 +39,7 @@ public class PoWBlockCreator extends AbstractBlockCreator { private final PoWSolver nonceSolver; public PoWBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, final ProtocolContext protocolContext, @@ -47,8 +47,8 @@ public class PoWBlockCreator extends AbstractBlockCreator { final PoWSolver nonceSolver, final EthScheduler ethScheduler) { super( - miningParameters, - __ -> miningParameters.getCoinbase().orElseThrow(), + miningConfiguration, + __ -> miningConfiguration.getCoinbase().orElseThrow(), extraDataCalculator, transactionPool, protocolContext, diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java index b14eb1934..f17b7989d 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutor.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; import org.hyperledger.besu.ethereum.chain.PoWObserver; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.EpochCalculator; @@ -40,7 +40,7 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { final ProtocolContext protocolContext, final ProtocolSchedule protocolSchedule, final TransactionPool transactionPool, - final MiningParameters miningParams, + final MiningConfiguration miningParams, final AbstractBlockScheduler blockScheduler, final EpochCalculator epochCalculator, final EthScheduler ethScheduler) { @@ -62,7 +62,7 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { final Subscribers observers, final Subscribers ethHashObservers, final BlockHeader parentHeader) { - if (miningParameters.getCoinbase().isEmpty()) { + if (miningConfiguration.getCoinbase().isEmpty()) { throw new CoinbaseNotSetException("Unable to start mining without a coinbase."); } return super.startAsyncMining(observers, ethHashObservers, parentHeader); @@ -79,7 +79,7 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { protocolSchedule.getForNextBlockHeader(parentHeader, 0); final PoWSolver solver = new PoWSolver( - miningParameters, + miningConfiguration, nextBlockProtocolSpec.getPoWHasher().get(), stratumMiningEnabled, ethHashObservers, @@ -87,8 +87,8 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { final Function blockCreator = (header) -> new PoWBlockCreator( - miningParameters, - parent -> miningParameters.getExtraData(), + miningConfiguration, + parent -> miningConfiguration.getExtraData(), transactionPool, protocolContext, protocolSchedule, @@ -103,7 +103,7 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { if (coinbase == null) { throw new IllegalArgumentException("Coinbase cannot be unset."); } else { - miningParameters.setCoinbase(Address.wrap(coinbase.copy())); + miningConfiguration.setCoinbase(Address.wrap(coinbase.copy())); } } @@ -113,7 +113,7 @@ public class PoWMinerExecutor extends AbstractMinerExecutor { @Override public Optional
getCoinbase() { - return miningParameters.getCoinbase(); + return miningConfiguration.getCoinbase(); } public EpochCalculator getEpochCalculator() { diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java index f8bf6d50c..99da62ca0 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockSelectionContext.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.blockcreation.txselection; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.blockhash.BlockHashProcessor; @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.evm.gascalculator.GasCalculator; public record BlockSelectionContext( - MiningParameters miningParameters, + MiningConfiguration miningConfiguration, GasCalculator gasCalculator, GasLimitCalculator gasLimitCalculator, BlockHashProcessor blockHashProcessor, diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java index 5370d2ec4..a9b57a697 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPrio import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.PriceTransactionSelector; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.ProcessingResultTransactionSelector; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; @@ -108,7 +108,7 @@ public class BlockTransactionSelector { private volatile TransactionEvaluationContext currTxEvaluationContext; public BlockTransactionSelector( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MainnetTransactionProcessor transactionProcessor, final Blockchain blockchain, final MutableWorldState worldState, @@ -132,7 +132,7 @@ public class BlockTransactionSelector { this.ethScheduler = ethScheduler; this.blockSelectionContext = new BlockSelectionContext( - miningParameters, + miningConfiguration, gasCalculator, gasLimitCalculator, blockHashProcessor, @@ -146,7 +146,7 @@ public class BlockTransactionSelector { this.operationTracer = new InterruptibleOperationTracer(pluginTransactionSelector.getOperationTracer()); blockWorldStateUpdater = worldState.updater(); - blockTxsSelectionMaxTime = miningParameters.getBlockTxsSelectionMaxTime(); + blockTxsSelectionMaxTime = miningConfiguration.getBlockTxsSelectionMaxTime(); } private List createTransactionSelectors( @@ -315,7 +315,7 @@ public class BlockTransactionSelector { pendingTransaction, Stopwatch.createStarted(), transactionGasPriceInBlock, - blockSelectionContext.miningParameters().getMinTransactionGasPrice()); + blockSelectionContext.miningConfiguration().getMinTransactionGasPrice()); } /** diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java index 2877c4ce1..0da2b1386 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/BlockSizeTransactionSelector.java @@ -112,13 +112,13 @@ public class BlockSizeTransactionSelector extends AbstractTransactionSelector { LOG.trace( "Min block occupancy ratio {}, gas used {}, available {}, remaining {}, used/available {}", - context.miningParameters().getMinBlockOccupancyRatio(), + context.miningConfiguration().getMinBlockOccupancyRatio(), gasUsed, gasAvailable, gasRemaining, occupancyRatio); - return occupancyRatio >= context.miningParameters().getMinBlockOccupancyRatio(); + return occupancyRatio >= context.miningConfiguration().getMinBlockOccupancyRatio(); } /** diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java index 5783c7e50..c6dae8a14 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/MinPriorityFeePerGasTransactionSelector.java @@ -69,7 +69,7 @@ public class MinPriorityFeePerGasTransactionSelector extends AbstractTransaction pendingTransaction .getTransaction() .getEffectivePriorityFeePerGas(context.pendingBlockHeader().getBaseFee()); - return priorityFeePerGas.lessThan(context.miningParameters().getMinPriorityFeePerGas()); + return priorityFeePerGas.lessThan(context.miningConfiguration().getMinPriorityFeePerGas()); } /** diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java index 707b1c486..d3c3047f6 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/txselection/selectors/PriceTransactionSelector.java @@ -76,7 +76,7 @@ public class PriceTransactionSelector extends AbstractTransactionSelector { if (!pendingTransaction.hasPriority()) { if (context - .miningParameters() + .miningConfiguration() .getMinTransactionGasPrice() .compareTo(evaluationContext.getTransactionGasPrice()) > 0) { @@ -86,7 +86,7 @@ public class PriceTransactionSelector extends AbstractTransactionSelector { .addArgument(pendingTransaction::toTraceLog) .addArgument(evaluationContext.getTransactionGasPrice()::toHumanReadableString) .addArgument( - context.miningParameters().getMinTransactionGasPrice()::toHumanReadableString) + context.miningConfiguration().getMinTransactionGasPrice()::toHumanReadableString) .log(); return true; } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index d30349e3d..b70c48ad0 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -47,9 +47,9 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; @@ -304,12 +304,12 @@ abstract class AbstractBlockCreatorTest { .protocolSchedule( new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), protocolSpecAdapters, PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -342,8 +342,8 @@ abstract class AbstractBlockCreatorTest { new BlobCache()); transactionPool.setEnabled(); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder() + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .extraData(Bytes.fromHexString("deadbeef")) @@ -355,7 +355,7 @@ abstract class AbstractBlockCreatorTest { return new CreateOn( new TestBlockCreator( - miningParameters, + miningConfiguration, __ -> Address.ZERO, __ -> Bytes.fromHexString("deadbeef"), transactionPool, @@ -368,7 +368,7 @@ abstract class AbstractBlockCreatorTest { static class TestBlockCreator extends AbstractBlockCreator { protected TestBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, @@ -376,7 +376,7 @@ abstract class AbstractBlockCreatorTest { final ProtocolSchedule protocolSchedule, final EthScheduler ethScheduler) { super( - miningParameters, + miningConfiguration, miningBeneficiaryCalculator, extraDataCalculator, transactionPool, diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java index 6eb03ece9..2787189ec 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockTransactionSelectorTest.java @@ -18,7 +18,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.awaitility.Awaitility.await; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.EXECUTION_INTERRUPTED; import static org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason.NONCE_TOO_LOW; import static org.hyperledger.besu.plugin.data.TransactionSelectionResult.BLOCK_SELECTION_TIMEOUT; @@ -55,10 +55,10 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; @@ -138,7 +138,7 @@ public abstract class AbstractBlockTransactionSelectorTest { protected MutableWorldState worldState; protected ProtocolSchedule protocolSchedule; protected TransactionSelectionService transactionSelectionService; - protected MiningParameters defaultTestMiningParameters; + protected MiningConfiguration defaultTestMiningConfiguration; @Mock protected EthScheduler ethScheduler; @@ -155,7 +155,7 @@ public abstract class AbstractBlockTransactionSelectorTest { genesisConfigFile = getGenesisConfigFile(); protocolSchedule = createProtocolSchedule(); transactionSelectionService = new TransactionSelectionServiceImpl(); - defaultTestMiningParameters = + defaultTestMiningConfiguration = createMiningParameters( transactionSelectionService, Wei.ZERO, @@ -234,7 +234,7 @@ public abstract class AbstractBlockTransactionSelectorTest { FixedDifficultyProtocolSchedule.create( GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -248,7 +248,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, mainnetTransactionProcessor, blockHeader, miningBeneficiary, @@ -269,7 +269,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -296,7 +296,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -336,7 +336,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -377,7 +377,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -412,7 +412,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -568,7 +568,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -643,7 +643,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -757,7 +757,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, createBlock(300_000), AddressHelpers.ofValue(1), @@ -793,7 +793,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -824,12 +824,12 @@ public abstract class AbstractBlockTransactionSelectorTest { final Address miningBeneficiary = AddressHelpers.ofValue(1); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build(); + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build(); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -841,7 +841,7 @@ public abstract class AbstractBlockTransactionSelectorTest { ensureTransactionIsValid(transaction, 0, 5); // raise the minGasPrice at runtime from 1 wei to 10 wei - miningParameters.setMinTransactionGasPrice(Wei.of(10)); + miningConfiguration.setMinTransactionGasPrice(Wei.of(10)); final TransactionSelectionResults results = selector.buildTransactionListForBlock(); @@ -857,15 +857,15 @@ public abstract class AbstractBlockTransactionSelectorTest { @Test public void decreaseOfMinGasPriceAtRuntimeIncludeTxThatWasPreviouslyNotSelected() { final Transaction transaction = createTransaction(0, Wei.of(7L), 100_000); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build(); + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build(); final ProcessableBlockHeader blockHeader = createBlock(500_000); final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector1 = createBlockSelectorAndSetupTxPool( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -876,7 +876,7 @@ public abstract class AbstractBlockTransactionSelectorTest { ensureTransactionIsValid(transaction, 0, 5); // raise the minGasPrice at runtime from 1 wei to 10 wei - miningParameters.setMinTransactionGasPrice(Wei.of(10)); + miningConfiguration.setMinTransactionGasPrice(Wei.of(10)); final TransactionSelectionResults results1 = selector1.buildTransactionListForBlock(); @@ -889,11 +889,11 @@ public abstract class AbstractBlockTransactionSelectorTest { .containsOnly(transaction); // decrease the minGasPrice at runtime from 10 wei to 5 wei - miningParameters.setMinTransactionGasPrice(Wei.of(5)); + miningConfiguration.setMinTransactionGasPrice(Wei.of(5)); final BlockTransactionSelector selector2 = createBlockSelector( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -910,9 +910,9 @@ public abstract class AbstractBlockTransactionSelectorTest { @Test public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() { ProcessableBlockHeader blockHeader = createBlock(5_000_000, Wei.ONE); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build(); - miningParameters.setMinPriorityFeePerGas(Wei.of(7)); + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build(); + miningConfiguration.setMinPriorityFeePerGas(Wei.of(7)); final Transaction txSelected = createTransaction(1, Wei.of(8), 100_000); ensureTransactionIsValid(txSelected); // transaction txNotSelected should not be selected @@ -921,7 +921,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, AddressHelpers.ofValue(1), @@ -1259,7 +1259,7 @@ public abstract class AbstractBlockTransactionSelectorTest { } protected BlockTransactionSelector createBlockSelectorAndSetupTxPool( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MainnetTransactionProcessor transactionProcessor, final ProcessableBlockHeader blockHeader, final Address miningBeneficiary, @@ -1269,7 +1269,7 @@ public abstract class AbstractBlockTransactionSelectorTest { transactionPool = createTransactionPool(); return createBlockSelector( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -1278,7 +1278,7 @@ public abstract class AbstractBlockTransactionSelectorTest { } protected BlockTransactionSelector createBlockSelector( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MainnetTransactionProcessor transactionProcessor, final ProcessableBlockHeader blockHeader, final Address miningBeneficiary, @@ -1287,7 +1287,7 @@ public abstract class AbstractBlockTransactionSelectorTest { final BlockTransactionSelector selector = new BlockTransactionSelector( - miningParameters, + miningConfiguration, transactionProcessor, blockchain, worldState, @@ -1423,12 +1423,12 @@ public abstract class AbstractBlockTransactionSelectorTest { return new BlockHeaderTestFixture().number(number).buildHeader(); } - protected MiningParameters createMiningParameters( + protected MiningConfiguration createMiningParameters( final TransactionSelectionService transactionSelectionService, final Wei minGasPrice, final double minBlockOccupancyRatio, final PositiveNumber txsSelectionMaxTime) { - return ImmutableMiningParameters.builder() + return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .minTransactionGasPrice(minGasPrice) @@ -1439,13 +1439,13 @@ public abstract class AbstractBlockTransactionSelectorTest { .build(); } - protected MiningParameters createMiningParameters( + protected MiningConfiguration createMiningParameters( final TransactionSelectionService transactionSelectionService, final Wei minGasPrice, final double minBlockOccupancyRatio, final int genesisBlockPeriodSeconds, final PositiveNumber minBlockTimePercentage) { - return ImmutableMiningParameters.builder() + return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .minTransactionGasPrice(minGasPrice) diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java index 940d076bb..327d4bd37 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LegacyFeeMarketBlockTransactionSelectorTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -42,6 +42,7 @@ import org.hyperledger.besu.testutil.TestClock; import org.hyperledger.besu.util.number.Fraction; import java.time.ZoneId; +import java.util.Optional; import java.util.function.Function; public class LegacyFeeMarketBlockTransactionSelectorTest @@ -56,12 +57,12 @@ public class LegacyFeeMarketBlockTransactionSelectorTest protected ProtocolSchedule createProtocolSchedule() { return new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - CHAIN_ID, + Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java index 68d9a71de..62eaf713c 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/LondonFeeMarketBlockTransactionSelectorTest.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.blockcreation; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.hyperledger.besu.ethereum.core.MiningParameters.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME; import static org.mockito.Mockito.mock; import org.hyperledger.besu.config.GenesisConfigFile; @@ -26,8 +26,8 @@ import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockTransactionS import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.AddressHelpers; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; @@ -51,6 +51,7 @@ import org.hyperledger.besu.util.number.Fraction; import java.time.ZoneId; import java.util.List; +import java.util.Optional; import java.util.function.Function; import org.junit.jupiter.api.Test; @@ -67,12 +68,12 @@ public class LondonFeeMarketBlockTransactionSelectorTest protected ProtocolSchedule createProtocolSchedule() { return new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - CHAIN_ID, + Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -221,7 +222,7 @@ public class LondonFeeMarketBlockTransactionSelectorTest final Address miningBeneficiary = AddressHelpers.ofValue(1); final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - defaultTestMiningParameters, + defaultTestMiningConfiguration, transactionProcessor, blockHeader, miningBeneficiary, @@ -241,9 +242,9 @@ public class LondonFeeMarketBlockTransactionSelectorTest @Override public void shouldNotSelectTransactionsWithPriorityFeeLessThanConfig() { ProcessableBlockHeader blockHeader = createBlock(5_000_000, Wei.ONE); - final MiningParameters miningParameters = - ImmutableMiningParameters.builder().from(defaultTestMiningParameters).build(); - miningParameters.setMinPriorityFeePerGas(Wei.of(7)); + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder().from(defaultTestMiningConfiguration).build(); + miningConfiguration.setMinPriorityFeePerGas(Wei.of(7)); final Transaction txSelected1 = createEIP1559Transaction(1, Wei.of(8), Wei.of(8), 100_000); ensureTransactionIsValid(txSelected1); @@ -262,7 +263,7 @@ public class LondonFeeMarketBlockTransactionSelectorTest final BlockTransactionSelector selector = createBlockSelectorAndSetupTxPool( - miningParameters, + miningConfiguration, transactionProcessor, blockHeader, AddressHelpers.ofValue(1), diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java index 6f81f4df2..29cea9d08 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/MinPriorityFeePerGasTransactionSelectorTest.java @@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionCon import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector; import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; @@ -46,11 +46,11 @@ public class MinPriorityFeePerGasTransactionSelectorTest { @BeforeEach public void initialize() { - MiningParameters miningParameters = - MiningParameters.newDefault().setMinPriorityFeePerGas(Wei.of(minPriorityFeeParameter)); + MiningConfiguration miningConfiguration = + MiningConfiguration.newDefault().setMinPriorityFeePerGas(Wei.of(minPriorityFeeParameter)); BlockSelectionContext context = new BlockSelectionContext( - miningParameters, null, null, null, pendingBlockHeader, null, null, null, null); + miningConfiguration, null, null, null, pendingBlockHeader, null, null, null, null); transactionSelector = new MinPriorityFeePerGasTransactionSelector(context); } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java index 509efd7b1..e8b9baa0a 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java @@ -31,9 +31,9 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; @@ -62,6 +62,7 @@ import org.hyperledger.besu.util.Subscribers; import java.io.IOException; import java.math.BigInteger; import java.util.Collections; +import java.util.Optional; import java.util.function.Function; import com.google.common.collect.Lists; @@ -86,19 +87,19 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { void createMainnetBlock1() throws IOException { final var genesisConfigFile = GenesisConfigFile.mainnet(); - final MiningParameters miningParameters = createMiningParameters(BLOCK_1_NONCE); + final MiningConfiguration miningConfiguration = createMiningParameters(BLOCK_1_NONCE); final ExecutionContextTestFixture executionContextTestFixture = ExecutionContextTestFixture.builder(genesisConfigFile) .protocolSchedule( new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create(0, Function.identity()), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -107,7 +108,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWSolver solver = new PoWSolver( - miningParameters, + miningConfiguration, PoWHasher.ETHASH_LIGHT, false, Subscribers.none(), @@ -117,7 +118,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWBlockCreator blockCreator = new PoWBlockCreator( - miningParameters, + miningConfiguration, parent -> BLOCK_1_EXTRA_DATA, transactionPool, executionContextTestFixture.getProtocolContext(), @@ -145,14 +146,14 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final var genesisConfigFile = GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); - final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE); + final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); final ExecutionContextTestFixture executionContextTestFixture = ExecutionContextTestFixture.builder(genesisConfigFile) .protocolSchedule( new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> @@ -162,7 +163,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -171,7 +172,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWSolver solver = new PoWSolver( - miningParameters, + miningConfiguration, PoWHasher.ETHASH_LIGHT, false, Subscribers.none(), @@ -181,7 +182,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWBlockCreator blockCreator = new PoWBlockCreator( - miningParameters, + miningConfiguration, parent -> BLOCK_1_EXTRA_DATA, transactionPool, executionContextTestFixture.getProtocolContext(), @@ -203,12 +204,12 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final var genesisConfigFile = GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); - final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE); + final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> @@ -218,7 +219,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -230,7 +231,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWSolver solver = new PoWSolver( - miningParameters, + miningConfiguration, PoWHasher.ETHASH_LIGHT, false, Subscribers.none(), @@ -240,7 +241,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWBlockCreator blockCreator = new PoWBlockCreator( - miningParameters, + miningConfiguration, parent -> BLOCK_1_EXTRA_DATA, transactionPool, executionContextTestFixture.getProtocolContext(), @@ -280,12 +281,12 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final var genesisConfigFile = GenesisConfigFile.fromResource("/block-creation-fixed-difficulty-genesis.json"); - final MiningParameters miningParameters = createMiningParameters(FIXED_DIFFICULTY_NONCE); + final MiningConfiguration miningConfiguration = createMiningParameters(FIXED_DIFFICULTY_NONCE); ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create( 0, specBuilder -> @@ -295,7 +296,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -307,7 +308,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWSolver solver = new PoWSolver( - miningParameters, + miningConfiguration, PoWHasher.ETHASH_LIGHT, false, Subscribers.none(), @@ -317,7 +318,7 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { final PoWBlockCreator blockCreator = new PoWBlockCreator( - miningParameters, + miningConfiguration, parent -> BLOCK_1_EXTRA_DATA, transactionPool, executionContextTestFixture.getProtocolContext(), @@ -381,8 +382,8 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest { return transactionPool; } - private MiningParameters createMiningParameters(final long nonce) { - return ImmutableMiningParameters.builder() + private MiningConfiguration createMiningParameters(final long nonce) { + return ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .nonceGenerator(Lists.newArrayList(nonce)) diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java index 8c1e217d7..14e6b5437 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMinerExecutorTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -51,7 +51,7 @@ public class PoWMinerExecutorTest { @Test public void startingMiningWithoutCoinbaseThrowsException() { - final MiningParameters miningParameters = MiningParameters.newDefault(); + final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault(); final TransactionPool transactionPool = createTransactionPool(); @@ -60,7 +60,7 @@ public class PoWMinerExecutorTest { null, null, transactionPool, - miningParameters, + miningConfiguration, new DefaultBlockScheduler(1L, 10, TestClock.fixed()), new EpochCalculator.DefaultEpochCalculator(), ethScheduler); @@ -72,7 +72,7 @@ public class PoWMinerExecutorTest { @Test public void settingCoinbaseToNullThrowsException() { - final MiningParameters miningParameters = MiningParameters.newDefault(); + final MiningConfiguration miningConfiguration = MiningConfiguration.newDefault(); final TransactionPool transactionPool = createTransactionPool(); @@ -81,7 +81,7 @@ public class PoWMinerExecutorTest { null, null, transactionPool, - miningParameters, + miningConfiguration, new DefaultBlockScheduler(1, 10, TestClock.fixed()), new EpochCalculator.DefaultEpochCalculator(), ethScheduler); diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java index 6efd63fba..6dd272473 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWMiningCoordinatorTest.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.blockcreation; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; -import static org.hyperledger.besu.ethereum.core.MiningParameters.Unstable.DEFAULT_REMOTE_SEALERS_TTL; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_LIMIT; +import static org.hyperledger.besu.ethereum.core.MiningConfiguration.Unstable.DEFAULT_REMOTE_SEALERS_TTL; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index 11e020c0e..d40406a3a 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -108,6 +108,8 @@ dependencies { testSupportImplementation 'org.junit.jupiter:junit-jupiter' testSupportImplementation 'org.assertj:assertj-core' testSupportImplementation 'org.mockito:mockito-core' + testSupportImplementation 'com.google.dagger:dagger' + testSupportAnnotationProcessor 'com.google.dagger:dagger-compiler' jmhImplementation project(path: ':config', configuration: 'testSupportArtifacts') jmhImplementation project(':crypto:algorithms') diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java new file mode 100644 index 000000000..98575272c --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolScheduleModule.java @@ -0,0 +1,100 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.components; + +import org.hyperledger.besu.config.GenesisConfigOptions; +import org.hyperledger.besu.ethereum.chain.BadBlockManager; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; +import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; +import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters; +import org.hyperledger.besu.evm.internal.EvmConfiguration; +import org.hyperledger.besu.plugin.services.MetricsSystem; + +import java.math.BigInteger; +import java.util.Optional; +import javax.inject.Singleton; + +import dagger.Module; +import dagger.Provides; + +/** Provides the protocol schedule for the network. */ +@Module +public class ProtocolScheduleModule { + + /** Default constructor. */ + public ProtocolScheduleModule() {} + + /** + * Provides the protocol schedule builder. + * + * @param config the genesis config options + * @param protocolSpecAdapters the protocol spec adapters + * @param privacyParameters the privacy parameters + * @param isRevertReasonEnabled whether revert reason is enabled + * @param evmConfiguration the EVM configuration + * @param badBlockManager the bad block manager + * @param isParallelTxProcessingEnabled whether parallel tx processing is enabled + * @param metricsSystem the metrics system + * @param miningConfiguration the mining parameters + * @return the protocol schedule builder + */ + @Singleton + @Provides + public ProtocolScheduleBuilder provideProtocolScheduleBuilder( + final GenesisConfigOptions config, + final ProtocolSpecAdapters protocolSpecAdapters, + final PrivacyParameters privacyParameters, + final boolean isRevertReasonEnabled, + final EvmConfiguration evmConfiguration, + final BadBlockManager badBlockManager, + final boolean isParallelTxProcessingEnabled, + final MetricsSystem metricsSystem, + final MiningConfiguration miningConfiguration) { + + ProtocolScheduleBuilder builder = + new ProtocolScheduleBuilder( + config, + config.getChainId(), + protocolSpecAdapters, + privacyParameters, + isRevertReasonEnabled, + evmConfiguration, + miningConfiguration, + badBlockManager, + isParallelTxProcessingEnabled, + metricsSystem); + + return builder; + } + + /** + * Provides the protocol schedule. + * + * @param builder the protocol schedule builder + * @param config the genesis config options + * @return the protocol schedule + */ + @Provides + public ProtocolSchedule createProtocolSchedule( + final ProtocolScheduleBuilder builder, final GenesisConfigOptions config) { + final Optional chainId = config.getChainId().or(() -> builder.getDefaultChainId()); + DefaultProtocolSchedule protocolSchedule = new DefaultProtocolSchedule(chainId); + builder.initSchedule(protocolSchedule, chainId); + return protocolSchedule; + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java new file mode 100644 index 000000000..fe9b0f3fa --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/components/ProtocolSpecModule.java @@ -0,0 +1,51 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.components; + +import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs; +import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder; +import org.hyperledger.besu.evm.internal.EvmConfiguration; +import org.hyperledger.besu.plugin.services.MetricsSystem; + +import javax.inject.Named; + +import dagger.Module; +import dagger.Provides; + +/** Provides protocol specs for network forks. */ +@Module +public class ProtocolSpecModule { + + /** Default constructor. */ + public ProtocolSpecModule() {} + + /** + * Provides the protocol spec for the frontier network fork. + * + * @param evmConfiguration the EVM configuration + * @param isParalleltxEnabled whether parallel tx processing is enabled + * @param metricsSystem the metrics system + * @return the protocol spec for the frontier network fork + */ + @Provides + @Named("frontier") + public ProtocolSpecBuilder frontierProtocolSpec( + final EvmConfiguration evmConfiguration, + final boolean isParalleltxEnabled, + final MetricsSystem metricsSystem) { + return MainnetProtocolSpecs.frontierDefinition( + evmConfiguration, isParalleltxEnabled, metricsSystem); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java index 1921b3568..fb39d164b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParameters.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningConfiguration.java @@ -34,27 +34,29 @@ import org.immutables.value.Value; @Value.Immutable @Value.Enclosing -public abstract class MiningParameters { +public abstract class MiningConfiguration { public static final PositiveNumber DEFAULT_NON_POA_BLOCK_TXS_SELECTION_MAX_TIME = PositiveNumber.fromInt((int) Duration.ofSeconds(5).toMillis()); public static final PositiveNumber DEFAULT_POA_BLOCK_TXS_SELECTION_MAX_TIME = PositiveNumber.fromInt(75); - public static final MiningParameters MINING_DISABLED = - ImmutableMiningParameters.builder() + public static final MiningConfiguration MINING_DISABLED = + ImmutableMiningConfiguration.builder() .mutableInitValues( - ImmutableMiningParameters.MutableInitValues.builder().isMiningEnabled(false).build()) + ImmutableMiningConfiguration.MutableInitValues.builder() + .isMiningEnabled(false) + .build()) .build(); @VisibleForTesting - public static final MiningParameters newDefault() { - return ImmutableMiningParameters.builder().build(); + public static final MiningConfiguration newDefault() { + return ImmutableMiningConfiguration.builder().build(); } public boolean isMiningEnabled() { return getMutableRuntimeValues().miningEnabled; } - public MiningParameters setMiningEnabled(final boolean miningEnabled) { + public MiningConfiguration setMiningEnabled(final boolean miningEnabled) { getMutableRuntimeValues().miningEnabled = miningEnabled; return this; } @@ -63,7 +65,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().extraData; } - public MiningParameters setExtraData(final Bytes extraData) { + public MiningConfiguration setExtraData(final Bytes extraData) { getMutableRuntimeValues().extraData = extraData; return this; } @@ -72,7 +74,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().minTransactionGasPrice; } - public MiningParameters setMinTransactionGasPrice(final Wei minTransactionGasPrice) { + public MiningConfiguration setMinTransactionGasPrice(final Wei minTransactionGasPrice) { getMutableRuntimeValues().minTransactionGasPrice = minTransactionGasPrice; return this; } @@ -81,7 +83,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().minPriorityFeePerGas; } - public MiningParameters setMinPriorityFeePerGas(final Wei minPriorityFeePerGas) { + public MiningConfiguration setMinPriorityFeePerGas(final Wei minPriorityFeePerGas) { getMutableRuntimeValues().minPriorityFeePerGas = minPriorityFeePerGas; return this; } @@ -90,7 +92,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().coinbase; } - public MiningParameters setCoinbase(final Address coinbase) { + public MiningConfiguration setCoinbase(final Address coinbase) { getMutableRuntimeValues().coinbase = Optional.of(coinbase); return this; } @@ -99,7 +101,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().targetGasLimit; } - public MiningParameters setTargetGasLimit(final long targetGasLimit) { + public MiningConfiguration setTargetGasLimit(final long targetGasLimit) { getMutableRuntimeValues().targetGasLimit = OptionalLong.of(targetGasLimit); return this; } @@ -108,7 +110,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().minBlockOccupancyRatio; } - public MiningParameters setMinBlockOccupancyRatio(final double minBlockOccupancyRatio) { + public MiningConfiguration setMinBlockOccupancyRatio(final double minBlockOccupancyRatio) { getMutableRuntimeValues().minBlockOccupancyRatio = minBlockOccupancyRatio; return this; } @@ -117,7 +119,7 @@ public abstract class MiningParameters { return getMutableRuntimeValues().nonceGenerator; } - public MiningParameters setNonceGenerator(final Iterable nonceGenerator) { + public MiningConfiguration setNonceGenerator(final Iterable nonceGenerator) { getMutableRuntimeValues().nonceGenerator = Optional.of(nonceGenerator); return this; } @@ -126,12 +128,12 @@ public abstract class MiningParameters { return getMutableRuntimeValues().blockPeriodSeconds; } - public MiningParameters setBlockPeriodSeconds(final int blockPeriodSeconds) { + public MiningConfiguration setBlockPeriodSeconds(final int blockPeriodSeconds) { getMutableRuntimeValues().blockPeriodSeconds = OptionalInt.of(blockPeriodSeconds); return this; } - public MiningParameters setEmptyBlockPeriodSeconds(final int emptyBlockPeriodSeconds) { + public MiningConfiguration setEmptyBlockPeriodSeconds(final int emptyBlockPeriodSeconds) { getMutableRuntimeValues().emptyBlockPeriodSeconds = OptionalInt.of(emptyBlockPeriodSeconds); return this; } @@ -207,7 +209,7 @@ public abstract class MiningParameters { Wei DEFAULT_MIN_PRIORITY_FEE_PER_GAS = Wei.ZERO; double DEFAULT_MIN_BLOCK_OCCUPANCY_RATIO = 0.8; - MutableInitValues DEFAULT = ImmutableMiningParameters.MutableInitValues.builder().build(); + MutableInitValues DEFAULT = ImmutableMiningConfiguration.MutableInitValues.builder().build(); @Value.Default default boolean isMiningEnabled() { @@ -335,7 +337,7 @@ public abstract class MiningParameters { long DEFAULT_POS_BLOCK_CREATION_MAX_TIME = Duration.ofSeconds(12).toMillis(); long DEFAULT_POS_BLOCK_CREATION_REPETITION_MIN_DURATION = Duration.ofMillis(500).toMillis(); - MiningParameters.Unstable DEFAULT = ImmutableMiningParameters.Unstable.builder().build(); + MiningConfiguration.Unstable DEFAULT = ImmutableMiningConfiguration.Unstable.builder().build(); @Value.Default default int getRemoteSealersLimit() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java index 3b3e3a28d..8be0b621a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MiningParametersMetrics.java @@ -22,18 +22,18 @@ public class MiningParametersMetrics { public static final String MIN_PRIORITY_FEE_GAUGE = "min_priority_fee"; public MiningParametersMetrics( - final MetricsSystem metricsSystem, final MiningParameters miningParameters) { + final MetricsSystem metricsSystem, final MiningConfiguration miningConfiguration) { metricsSystem.createGauge( BesuMetricCategory.ETHEREUM, MIN_GAS_PRICE_GAUGE, "Gauge to measure the runtime value of min-gas-price", - () -> miningParameters.getMinTransactionGasPrice().toBigInteger().doubleValue()); + () -> miningConfiguration.getMinTransactionGasPrice().toBigInteger().doubleValue()); metricsSystem.createGauge( BesuMetricCategory.ETHEREUM, MIN_PRIORITY_FEE_GAUGE, "Gauge to measure the runtime value of min-priority-fee", - () -> miningParameters.getMinPriorityFeePerGas().toBigInteger().doubleValue()); + () -> miningConfiguration.getMinPriorityFeePerGas().toBigInteger().doubleValue()); } } diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java similarity index 60% rename from ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java index bb4fa31a5..bb613b4e1 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethConfiguration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/CoinbaseModule.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * Copyright contributors to Hyperledger Besu. * * 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 @@ -12,19 +12,20 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.retesteth; +package org.hyperledger.besu.ethereum.core.components; -import java.nio.file.Path; +import org.hyperledger.besu.datatypes.Address; -public class RetestethConfiguration { +import javax.inject.Named; - private final Path dataPath; +import dagger.Module; +import dagger.Provides; - public RetestethConfiguration(final Path dataPath) { - this.dataPath = dataPath; - } - - Path getDataPath() { - return dataPath; +@Module +public class CoinbaseModule { + @Provides + @Named("emptyCoinbase") + Address provideEmptyCoinbase() { + return Address.fromHexString(String.format("%020x", 1)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java new file mode 100644 index 000000000..84de2cef5 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/EthereumCoreComponent.java @@ -0,0 +1,32 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.core.components; + +import org.hyperledger.besu.ethereum.components.ProtocolScheduleModule; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; + +import javax.inject.Singleton; + +import dagger.Subcomponent; + +@Singleton +@Subcomponent( + modules = { + MiningParametersModule.class, + ProtocolScheduleModule.class, + }) +public interface EthereumCoreComponent { + MiningConfiguration getMiningParameters(); +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java new file mode 100644 index 000000000..7a36e4d81 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/components/MiningParametersModule.java @@ -0,0 +1,64 @@ +/* + * Copyright contributors to Hyperledger Besu. + * + * 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.core.components; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; + +import javax.inject.Named; + +import dagger.Module; +import dagger.Provides; + +@Module +public class MiningParametersModule { + + @Provides + @Named("defaultMiningParameters") + protected MiningConfiguration createImmutableMiningParams() { + return ImmutableMiningConfiguration.builder().build(); + } + + @Provides + @Named("noMining") + protected MiningConfiguration createNoMining() { + return ImmutableMiningConfiguration.builder() + .mutableInitValues( + ImmutableMiningConfiguration.MutableInitValues.builder().isMiningEnabled(false).build()) + .build(); + } + + @Provides + @Named("zeroGas") + MiningConfiguration createZeroGasMining(final @Named("emptyCoinbase") Address coinbase) { + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() + .mutableInitValues( + ImmutableMiningConfiguration.MutableInitValues.builder() + .isMiningEnabled(true) + .minTransactionGasPrice(Wei.ZERO) + .coinbase(coinbase) + .build()) + .build(); + return miningConfiguration; + } + + @Provides + MiningConfiguration provideMiningParameters() { + throw new IllegalStateException("unimplemented"); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java index b86b2b0de..09ca09ff6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.difficulty.fixed; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; @@ -24,7 +24,12 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.plugin.services.MetricsSystem; -/** A ProtocolSchedule which behaves similarly to MainNet, but with a much reduced difficulty. */ +import java.util.Optional; + +/** + * A ProtocolSchedule which behaves similarly to pre-merge MainNet, but with a much reduced + * difficulty. + */ public class FixedDifficultyProtocolSchedule { public static ProtocolSchedule create( @@ -32,12 +37,13 @@ public class FixedDifficultyProtocolSchedule { final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return new ProtocolScheduleBuilder( config, + Optional.empty(), ProtocolSpecAdapters.create( 0, builder -> @@ -45,7 +51,7 @@ public class FixedDifficultyProtocolSchedule { privacyParameters, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem) @@ -56,7 +62,7 @@ public class FixedDifficultyProtocolSchedule { final GenesisConfigOptions config, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -65,7 +71,7 @@ public class FixedDifficultyProtocolSchedule { PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -74,7 +80,7 @@ public class FixedDifficultyProtocolSchedule { public static ProtocolSchedule create( final GenesisConfigOptions config, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -83,7 +89,7 @@ public class FixedDifficultyProtocolSchedule { PrivacyParameters.DEFAULT, false, evmConfiguration, - miningParameters, + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LineaProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LineaProtocolSpecs.java index daa5e4eeb..2c4b42e90 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LineaProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LineaProtocolSpecs.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.evm.MainnetEVMs; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -31,7 +31,7 @@ public class LineaProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -40,7 +40,7 @@ public class LineaProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) // some Linea evm opcodes behave differently. diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java index 88b6a5ae1..9528e2dfb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; @@ -24,6 +24,7 @@ import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.plugin.services.MetricsSystem; import java.math.BigInteger; +import java.util.Optional; import java.util.function.Function; /** Provides {@link ProtocolSpec} lookups for mainnet hard forks. */ @@ -39,7 +40,7 @@ public class MainnetProtocolSchedule { * @param privacyParameters the parameters set for private transactions * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param evmConfiguration how to configure the EVMs jumpdest cache - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled * @param metricsSystem A metricSystem instance to expose metrics in the underlying calls @@ -47,32 +48,32 @@ public class MainnetProtocolSchedule { */ public static ProtocolSchedule fromConfig( final GenesisConfigOptions config, - final PrivacyParameters privacyParameters, - final boolean isRevertReasonEnabled, - final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final Optional privacyParameters, + final Optional isRevertReasonEnabled, + final Optional evmConfiguration, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) { return FixedDifficultyProtocolSchedule.create( config, - privacyParameters, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, + privacyParameters.orElse(PrivacyParameters.DEFAULT), + isRevertReasonEnabled.orElse(false), + evmConfiguration.orElse(EvmConfiguration.DEFAULT), + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); } return new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), - privacyParameters, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, + privacyParameters.orElse(PrivacyParameters.DEFAULT), + isRevertReasonEnabled.orElse(false), + evmConfiguration.orElse(EvmConfiguration.DEFAULT), + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem) @@ -86,7 +87,7 @@ public class MainnetProtocolSchedule { * starting points * @param isRevertReasonEnabled whether storing the revert reason is for failed transactions * @param evmConfiguration how to configure the EVMs jumpdest cache - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return A configured mainnet protocol schedule @@ -95,16 +96,16 @@ public class MainnetProtocolSchedule { final GenesisConfigOptions config, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return fromConfig( config, - PrivacyParameters.DEFAULT, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, + Optional.empty(), + Optional.of(isRevertReasonEnabled), + Optional.of(evmConfiguration), + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -116,7 +117,7 @@ public class MainnetProtocolSchedule { * @param config {@link GenesisConfigOptions} containing the config options for the milestone * starting points * @param evmConfiguration size of - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return A configured mainnet protocol schedule @@ -124,16 +125,16 @@ public class MainnetProtocolSchedule { public static ProtocolSchedule fromConfig( final GenesisConfigOptions config, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return fromConfig( config, - PrivacyParameters.DEFAULT, - false, - evmConfiguration, - miningParameters, + Optional.empty(), + Optional.empty(), + Optional.of(evmConfiguration), + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); @@ -144,23 +145,23 @@ public class MainnetProtocolSchedule { * * @param config {@link GenesisConfigOptions} containing the config options for the milestone * starting points - * @param miningParameters the mining parameters + * @param miningConfiguration the mining parameters * @param badBlockManager the cache to use to keep invalid blocks * @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled. * @return A configured mainnet protocol schedule */ public static ProtocolSchedule fromConfig( final GenesisConfigOptions config, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return fromConfig( config, - PrivacyParameters.DEFAULT, - false, - EvmConfiguration.DEFAULT, - miningParameters, + Optional.empty(), + Optional.empty(), + Optional.empty(), + miningConfiguration, badBlockManager, isParallelTxProcessingEnabled, metricsSystem); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java index e6a89d2d6..ba13e585c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.config.GenesisConfigOptions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.plugin.services.MetricsSystem; @@ -29,7 +29,7 @@ public class MainnetProtocolSpecFactory { private final boolean isRevertReasonEnabled; private final OptionalLong ecip1017EraRounds; private final EvmConfiguration evmConfiguration; - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; private final boolean isParallelTxProcessingEnabled; private final MetricsSystem metricsSystem; @@ -38,14 +38,14 @@ public class MainnetProtocolSpecFactory { final boolean isRevertReasonEnabled, final OptionalLong ecip1017EraRounds, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { this.chainId = chainId; this.isRevertReasonEnabled = isRevertReasonEnabled; this.ecip1017EraRounds = ecip1017EraRounds; this.evmConfiguration = evmConfiguration; - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled; this.metricsSystem = metricsSystem; } @@ -140,7 +140,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -152,7 +152,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -164,7 +164,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -175,7 +175,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -186,7 +186,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -197,7 +197,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -208,7 +208,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -219,7 +219,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -230,7 +230,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -252,7 +252,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -274,7 +274,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } @@ -378,7 +378,7 @@ public class MainnetProtocolSpecFactory { isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index 23908664f..87396bff3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.MainnetBlockValidator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -447,7 +447,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { final long londonForkBlockNumber = @@ -458,7 +458,7 @@ public abstract class MainnetProtocolSpecs { } else if (genesisConfigOptions.isFixedBaseFee()) { londonFeeMarket = FeeMarket.fixedBaseFee( - londonForkBlockNumber, miningParameters.getMinTransactionGasPrice()); + londonForkBlockNumber, miningConfiguration.getMinTransactionGasPrice()); } else { londonFeeMarket = FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); @@ -533,7 +533,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return londonDefinition( @@ -541,7 +541,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) .difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER) @@ -553,7 +553,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return arrowGlacierDefinition( @@ -561,7 +561,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) .difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER) @@ -573,7 +573,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -582,7 +582,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) .evmBuilder( @@ -601,7 +601,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return parisDefinition( @@ -609,7 +609,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) // gas calculator has new code to support EIP-3860 limit and meter initcode @@ -660,7 +660,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L); @@ -670,7 +670,7 @@ public abstract class MainnetProtocolSpecs { } else if (genesisConfigOptions.isFixedBaseFee()) { cancunFeeMarket = FeeMarket.fixedBaseFee( - londonForkBlockNumber, miningParameters.getMinTransactionGasPrice()); + londonForkBlockNumber, miningConfiguration.getMinTransactionGasPrice()); } else { cancunFeeMarket = FeeMarket.cancun(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas()); @@ -681,7 +681,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) .feeMarket(cancunFeeMarket) @@ -741,7 +741,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -751,7 +751,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("CancunEOF"); @@ -762,7 +762,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -774,7 +774,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) // EIP-3074 AUTH and AUTCALL gas @@ -820,7 +820,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -830,7 +830,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("Osaka"); @@ -863,7 +863,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { return osakaDefinition( @@ -871,7 +871,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) // Use Future EIP configured EVM @@ -898,7 +898,7 @@ public abstract class MainnetProtocolSpecs { final boolean enableRevertReason, final GenesisConfigOptions genesisConfigOptions, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -907,7 +907,7 @@ public abstract class MainnetProtocolSpecs { enableRevertReason, genesisConfigOptions, evmConfiguration, - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem) .evmBuilder( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java index 316149047..aafc61e71 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PoWSolver.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.ethereum.chain.PoWObserver; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.util.Subscribers; import java.util.Optional; @@ -34,7 +34,7 @@ public class PoWSolver { private static final Logger LOG = LoggerFactory.getLogger(PoWSolver.class); - private final MiningParameters miningParameters; + private final MiningConfiguration miningConfiguration; public static class PoWSolverJob { @@ -86,12 +86,12 @@ public class PoWSolver { private final ExpiringMap currentJobs = new ExpiringMap<>(); public PoWSolver( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final PoWHasher poWHasher, final Boolean stratumMiningEnabled, final Subscribers ethHashObservers, final EpochCalculator epochCalculator) { - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; this.poWHasher = poWHasher; this.stratumMiningEnabled = stratumMiningEnabled; this.ethHashObservers = ethHashObservers; @@ -105,7 +105,7 @@ public class PoWSolver { currentJobs.put( job.getInputs().getPrePowHash(), job, - System.currentTimeMillis() + miningParameters.getUnstable().getPowJobTimeToLive()); + System.currentTimeMillis() + miningConfiguration.getUnstable().getPowJobTimeToLive()); if (stratumMiningEnabled) { LOG.debug( "solving with stratum miner for {} observers", ethHashObservers.getSubscriberCount()); @@ -121,7 +121,7 @@ public class PoWSolver { final Stopwatch operationTimer = Stopwatch.createStarted(); final PoWSolverJob job = currentJob.get(); long hashesExecuted = 0; - for (final Long n : miningParameters.getNonceGenerator().get()) { + for (final Long n : miningConfiguration.getNonceGenerator().get()) { if (job.isDone()) { return; @@ -181,7 +181,7 @@ public class PoWSolver { solution.getPowHash(), ommerCandidate.getInputs().getBlockNumber(), distanceToHead); - if (distanceToHead <= miningParameters.getUnstable().getMaxOmmerDepth()) { + if (distanceToHead <= miningConfiguration.getUnstable().getMaxOmmerDepth()) { jobToTestWith = ommerCandidate; } else { LOG.debug("Discarded ommer solution as too far from head {}", distanceToHead); @@ -211,6 +211,6 @@ public class PoWSolver { } public Iterable getNonceGenerator() { - return miningParameters.getNonceGenerator().get(); + return miningConfiguration.getNonceGenerator().get(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java index 86ee7d784..eb2323c4e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java @@ -18,7 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.HardforkId; import org.hyperledger.besu.datatypes.HardforkId.MainnetHardforkId; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -48,66 +48,19 @@ public class ProtocolScheduleBuilder { private final PrivacyParameters privacyParameters; private final boolean isRevertReasonEnabled; private final EvmConfiguration evmConfiguration; - private final MiningParameters miningParameters; private final BadBlockManager badBlockManager; private final boolean isParallelTxProcessingEnabled; private final MetricsSystem metricsSystem; + private final MiningConfiguration miningConfiguration; public ProtocolScheduleBuilder( - final GenesisConfigOptions config, - final BigInteger defaultChainId, - final ProtocolSpecAdapters protocolSpecAdapters, - final PrivacyParameters privacyParameters, - final boolean isRevertReasonEnabled, - final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, - final BadBlockManager badBlockManager, - final boolean isParallelTxProcessingEnabled, - final MetricsSystem metricsSystem) { - this( - config, - Optional.of(defaultChainId), - protocolSpecAdapters, - privacyParameters, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, - badBlockManager, - isParallelTxProcessingEnabled, - metricsSystem); - } - - public ProtocolScheduleBuilder( - final GenesisConfigOptions config, - final ProtocolSpecAdapters protocolSpecAdapters, - final PrivacyParameters privacyParameters, - final boolean isRevertReasonEnabled, - final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, - final BadBlockManager badBlockManager, - final boolean isParallelTxProcessingEnabled, - final MetricsSystem metricsSystem) { - this( - config, - Optional.empty(), - protocolSpecAdapters, - privacyParameters, - isRevertReasonEnabled, - evmConfiguration, - miningParameters, - badBlockManager, - isParallelTxProcessingEnabled, - metricsSystem); - } - - private ProtocolScheduleBuilder( final GenesisConfigOptions config, final Optional defaultChainId, final ProtocolSpecAdapters protocolSpecAdapters, final PrivacyParameters privacyParameters, final boolean isRevertReasonEnabled, final EvmConfiguration evmConfiguration, - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final BadBlockManager badBlockManager, final boolean isParallelTxProcessingEnabled, final MetricsSystem metricsSystem) { @@ -117,10 +70,10 @@ public class ProtocolScheduleBuilder { this.isRevertReasonEnabled = isRevertReasonEnabled; this.evmConfiguration = evmConfiguration; this.defaultChainId = defaultChainId; - this.miningParameters = miningParameters; this.badBlockManager = badBlockManager; this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled; this.metricsSystem = metricsSystem; + this.miningConfiguration = miningConfiguration; } public ProtocolSchedule createProtocolSchedule() { @@ -130,7 +83,7 @@ public class ProtocolScheduleBuilder { return protocolSchedule; } - private void initSchedule( + public void initSchedule( final ProtocolSchedule protocolSchedule, final Optional chainId) { final MainnetProtocolSpecFactory specFactory = @@ -140,7 +93,7 @@ public class ProtocolScheduleBuilder { config.getEcip1017EraRounds(), evmConfiguration.overrides( config.getContractSizeLimit(), OptionalInt.empty(), config.getEvmStackSize()), - miningParameters, + miningConfiguration, isParallelTxProcessingEnabled, metricsSystem); @@ -593,4 +546,8 @@ public class ProtocolScheduleBuilder { TIMESTAMP } } + + public Optional getDefaultChainId() { + return defaultChainId; + } } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java index 7be6ad12c..57f115858 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java @@ -152,7 +152,7 @@ public class BlockchainSetupUtil { return MainnetProtocolSchedule.fromConfig( genesisConfigFile.getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.newDefault(), + MiningConfiguration.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java index 511b94d3a..b2b979e28 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java @@ -152,12 +152,12 @@ public class ExecutionContextTestFixture { protocolSchedule = new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(42), + Optional.of(BigInteger.valueOf(42)), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java index e94c6b49f..db1114e83 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java @@ -22,10 +22,10 @@ import org.hyperledger.besu.config.JsonGenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.io.IOException; +import java.util.Optional; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; @@ -36,10 +36,10 @@ public class ProtocolScheduleFixture { public static final ProtocolSchedule MAINNET = MainnetProtocolSchedule.fromConfig( getMainnetConfigOptions(), - PrivacyParameters.DEFAULT, - false, - EvmConfiguration.DEFAULT, - MiningParameters.newDefault(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + MiningConfiguration.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java index 7969ab682..02bb41feb 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -36,7 +36,7 @@ public class FixedProtocolScheduleTest { FixedDifficultyProtocolSchedule.create( GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java index 2d5dd2cee..92818e31e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DefaultProtocolScheduleTest.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -56,12 +56,12 @@ public class DefaultProtocolScheduleTest { builder = new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), ProtocolSpecAdapters.create(FIRST_TIMESTAMP_FORK, modifier), privacyParameters, isRevertReasonEnabled, evmConfiguration, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java index c63a9b5cc..9ce20cb62 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java @@ -18,7 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -73,7 +73,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig("{}").getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -90,7 +90,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -124,7 +124,7 @@ public class MainnetProtocolScheduleTest { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java index 91553afed..1f0b78282 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PoWSolverTest.java @@ -21,9 +21,9 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.util.Subscribers; import java.util.Arrays; @@ -530,12 +530,12 @@ public class PoWSolverTest { powThread1.interrupt(); } - private MiningParameters createMiningParameters( + private MiningConfiguration createMiningParameters( final List nonceToTry, final int powJobTimeToLive, final int maxOmmerDepth) { - return ImmutableMiningParameters.builder() + return ImmutableMiningConfiguration.builder() .mutableInitValues(MutableInitValues.builder().nonceGenerator(nonceToTry).build()) .unstable( - ImmutableMiningParameters.Unstable.builder() + ImmutableMiningConfiguration.Unstable.builder() .maxOmmerDepth(maxOmmerDepth) .powJobTimeToLive(powJobTimeToLive) .build()) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java index ad261abf4..8046d7e83 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java @@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MilestoneStreamingProtocolSchedule; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -62,12 +62,12 @@ class ProtocolScheduleBuilderTest { builder = new ProtocolScheduleBuilder( configOptions, - CHAIN_ID, + Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -257,12 +257,12 @@ class ProtocolScheduleBuilderTest { final ProtocolScheduleBuilder builder = new ProtocolScheduleBuilder( configOptions, - CHAIN_ID, + Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(blockNumber, modifier), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java index dd9257441..999d33a5c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/trie/diffbased/bonsai/AbstractIsolationTests.java @@ -39,9 +39,9 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration; +import org.hyperledger.besu.ethereum.core.ImmutableMiningConfiguration.MutableInitValues; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; @@ -104,7 +104,7 @@ public abstract class AbstractIsolationTests { protected final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -138,7 +138,7 @@ public abstract class AbstractIsolationTests { txPoolMetrics, transactionReplacementTester, new BlobCache(), - MiningParameters.newDefault()), + MiningConfiguration.newDefault()), ethScheduler); protected final List accounts = @@ -229,7 +229,7 @@ public abstract class AbstractIsolationTests { @Override public Wei getMinGasPrice() { - return MiningParameters.newDefault().getMinTransactionGasPrice(); + return MiningConfiguration.newDefault().getMinTransactionGasPrice(); } @Override @@ -254,7 +254,7 @@ public abstract class AbstractIsolationTests { static class TestBlockCreator extends AbstractBlockCreator { private TestBlockCreator( - final MiningParameters miningParameters, + final MiningConfiguration miningConfiguration, final MiningBeneficiaryCalculator miningBeneficiaryCalculator, final ExtraDataCalculator extraDataCalculator, final TransactionPool transactionPool, @@ -262,7 +262,7 @@ public abstract class AbstractIsolationTests { final ProtocolSchedule protocolSchedule, final EthScheduler ethScheduler) { super( - miningParameters, + miningConfiguration, miningBeneficiaryCalculator, extraDataCalculator, transactionPool, @@ -277,8 +277,8 @@ public abstract class AbstractIsolationTests { final TransactionPool transactionPool, final EthScheduler ethScheduler) { - final MiningParameters miningParameters = - ImmutableMiningParameters.builder() + final MiningConfiguration miningConfiguration = + ImmutableMiningConfiguration.builder() .mutableInitValues( MutableInitValues.builder() .extraData(Bytes.fromHexString("deadbeef")) @@ -290,7 +290,7 @@ public abstract class AbstractIsolationTests { .build(); return new TestBlockCreator( - miningParameters, + miningConfiguration, __ -> Address.ZERO, __ -> Bytes.fromHexString("deadbeef"), transactionPool, diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java index 79b1298d2..9f1332363 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactory.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.eth.transactions; import static org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration.Implementation.LAYERED; import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.messages.EthPV62; @@ -56,7 +56,7 @@ public class TransactionPoolFactory { final SyncState syncState, final TransactionPoolConfiguration transactionPoolConfiguration, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { final TransactionPoolMetrics metrics = new TransactionPoolMetrics(metricsSystem); @@ -80,7 +80,7 @@ public class TransactionPoolFactory { transactionsMessageSender, newPooledTransactionHashesMessageSender, blobCache, - miningParameters); + miningConfiguration); } static TransactionPool createTransactionPool( @@ -95,7 +95,7 @@ public class TransactionPoolFactory { final TransactionsMessageSender transactionsMessageSender, final NewPooledTransactionHashesMessageSender newPooledTransactionHashesMessageSender, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { final TransactionPool transactionPool = new TransactionPool( @@ -108,7 +108,7 @@ public class TransactionPoolFactory { metrics, transactionPoolConfiguration, blobCache, - miningParameters), + miningConfiguration), protocolSchedule, protocolContext, new TransactionBroadcaster( @@ -241,7 +241,7 @@ public class TransactionPoolFactory { final TransactionPoolMetrics metrics, final TransactionPoolConfiguration transactionPoolConfiguration, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { boolean isFeeMarketImplementBaseFee = protocolSchedule.anyMatch( @@ -256,7 +256,7 @@ public class TransactionPoolFactory { transactionPoolConfiguration, isFeeMarketImplementBaseFee, blobCache, - miningParameters); + miningConfiguration); } else { return createPendingTransactionSorter( protocolContext, @@ -296,7 +296,7 @@ public class TransactionPoolFactory { final TransactionPoolConfiguration transactionPoolConfiguration, final boolean isFeeMarketImplementBaseFee, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { final TransactionPoolReplacementHandler transactionReplacementHandler = new TransactionPoolReplacementHandler( @@ -345,7 +345,7 @@ public class TransactionPoolFactory { transactionReplacementTester, feeMarket, blobCache, - miningParameters); + miningConfiguration); } else { pendingTransactionsSorter = new GasPricePrioritizedTransactions( @@ -355,7 +355,7 @@ public class TransactionPoolFactory { metrics, transactionReplacementTester, blobCache, - miningParameters); + miningConfiguration); } return new LayeredPendingTransactions( diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactions.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactions.java index fce565a80..06db1b1ed 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactions.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactions.java @@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.eth.transactions.layered; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.TransactionType; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; @@ -42,7 +42,7 @@ import java.util.stream.Collectors; */ public abstract class AbstractPrioritizedTransactions extends AbstractSequentialTransactionsLayer { protected final TreeSet orderByFee; - protected final MiningParameters miningParameters; + protected final MiningConfiguration miningConfiguration; public AbstractPrioritizedTransactions( final TransactionPoolConfiguration poolConfig, @@ -52,7 +52,7 @@ public abstract class AbstractPrioritizedTransactions extends AbstractSequential final BiFunction transactionReplacementTester, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { super( poolConfig, ethScheduler, @@ -61,7 +61,7 @@ public abstract class AbstractPrioritizedTransactions extends AbstractSequential metrics, blobCache); this.orderByFee = new TreeSet<>(this::compareByFee); - this.miningParameters = miningParameters; + this.miningConfiguration = miningConfiguration; } @Override diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactions.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactions.java index df9b1537a..b168babe6 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactions.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactions.java @@ -19,7 +19,7 @@ import static org.hyperledger.besu.ethereum.eth.transactions.layered.LayeredRemo import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; @@ -51,7 +51,7 @@ public class BaseFeePrioritizedTransactions extends AbstractPrioritizedTransacti transactionReplacementTester, final FeeMarket feeMarket, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { super( poolConfig, ethScheduler, @@ -59,7 +59,7 @@ public class BaseFeePrioritizedTransactions extends AbstractPrioritizedTransacti metrics, transactionReplacementTester, blobCache, - miningParameters); + miningConfiguration); this.nextBlockBaseFee = Optional.of(calculateNextBlockBaseFee(feeMarket, chainHeadHeaderSupplier.get())); } @@ -174,15 +174,15 @@ public class BaseFeePrioritizedTransactions extends AbstractPrioritizedTransacti if (pendingTransaction .getTransaction() .getEffectiveGasPrice(nextBlockBaseFee) - .lessThan(miningParameters.getMinTransactionGasPrice())) { + .lessThan(miningConfiguration.getMinTransactionGasPrice())) { return false; } // check if enough priority fee is paid - if (!miningParameters.getMinPriorityFeePerGas().equals(Wei.ZERO)) { + if (!miningConfiguration.getMinPriorityFeePerGas().equals(Wei.ZERO)) { final Wei priorityFeePerGas = pendingTransaction.getTransaction().getEffectivePriorityFeePerGas(nextBlockBaseFee); - if (priorityFeePerGas.lessThan(miningParameters.getMinPriorityFeePerGas())) { + if (priorityFeePerGas.lessThan(miningConfiguration.getMinPriorityFeePerGas())) { return false; } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactions.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactions.java index 504a453fa..205c02f54 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactions.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactions.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.eth.transactions.layered; import static java.util.Comparator.comparing; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; @@ -43,7 +43,7 @@ public class GasPricePrioritizedTransactions extends AbstractPrioritizedTransact final BiFunction transactionReplacementTester, final BlobCache blobCache, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { super( poolConfig, ethScheduler, @@ -51,7 +51,7 @@ public class GasPricePrioritizedTransactions extends AbstractPrioritizedTransact metrics, transactionReplacementTester, blobCache, - miningParameters); + miningConfiguration); } @Override @@ -74,7 +74,7 @@ public class GasPricePrioritizedTransactions extends AbstractPrioritizedTransact || pendingTransaction .getTransaction() .getGasPrice() - .map(miningParameters.getMinTransactionGasPrice()::lessThan) + .map(miningConfiguration.getMinTransactionGasPrice()::lessThan) .orElse(false); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java index 3a3331b56..b7c346af6 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthProtocolManagerTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -1123,7 +1123,7 @@ public final class EthProtocolManagerTest { new SyncState(blockchain, ethManager.ethContext().getEthPeers()), TransactionPoolConfiguration.DEFAULT, new BlobCache(), - MiningParameters.newDefault()) + MiningConfiguration.newDefault()) .setEnabled(); // Send just a transaction message. diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java index 6dbea259c..b1691d0af 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/AbstractMessageTaskTest.java @@ -26,7 +26,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.manager.EthContext; @@ -144,7 +144,7 @@ public abstract class AbstractMessageTaskTest { syncState, TransactionPoolConfiguration.DEFAULT, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); transactionPool.setEnabled(); ethProtocolManager = diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java index b11afeb4c..2bb1394a1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; @@ -60,7 +60,7 @@ public final class BlockBodiesMessageTest { GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java index 72f089a53..9173a7af4 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.eth.messages; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; @@ -67,7 +67,7 @@ public final class BlockHeadersMessageTest { GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java index 5f7baaff4..f97fe91c6 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.eth.manager.ChainState; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -58,7 +58,7 @@ public class ChainHeadTrackerTest { GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java index cfc9f9dc1..4cd4d1c67 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContextTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -95,7 +95,7 @@ public class BackwardSyncContextTest { private ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions(), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java index 6dc69ea27..696856c07 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncStepTest.java @@ -29,7 +29,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -72,7 +72,7 @@ public class BackwardSyncStepTest { private final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions(), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java index a5d2cf610..34479bf11 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/ForwardSyncStepTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -75,7 +75,7 @@ public class ForwardSyncStepTest { private final ProtocolSchedule protocolSchedule = MainnetProtocolSchedule.fromConfig( new StubGenesisConfigOptions(), - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java index c3ca24a4e..e3e8046ba 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/AbstractTransactionPoolTestBase.java @@ -49,7 +49,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -178,12 +178,12 @@ public abstract class AbstractTransactionPoolTestBase { final ProtocolSchedule protocolSchedule = new ProtocolScheduleBuilder( genesisConfigFile.getConfigOptions(), - BigInteger.valueOf(1), + Optional.of(BigInteger.valueOf(1)), ProtocolSpecAdapters.create(0, Function.identity()), new PrivacyParameters(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java index c679183b0..0081dc7d9 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java @@ -34,7 +34,7 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -122,7 +122,7 @@ public class TestNode implements Closeable { GenesisConfigFile.fromResource("/dev.json").getConfigOptions(), false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -181,7 +181,7 @@ public class TestNode implements Closeable { syncState, TransactionPoolConfiguration.DEFAULT, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); final EthProtocolManager ethProtocolManager = new EthProtocolManager( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java index 5742637c3..612a1de9d 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolFactoryTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; @@ -373,12 +373,12 @@ public class TransactionPoolFactoryTest { schedule = new ProtocolScheduleBuilder( config, - DEFAULT_CHAIN_ID, + Optional.of(DEFAULT_CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) @@ -413,7 +413,7 @@ public class TransactionPoolFactoryTest { transactionsMessageSender, newPooledTransactionHashesMessageSender, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } private TransactionPool createAndEnableTransactionPool( diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactionsTestBase.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactionsTestBase.java index 6a0005eec..69db32701 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactionsTestBase.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/AbstractPrioritizedTransactionsTestBase.java @@ -22,7 +22,7 @@ import static org.hyperledger.besu.ethereum.eth.transactions.layered.AddReason.N import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; @@ -47,8 +47,8 @@ public abstract class AbstractPrioritizedTransactionsTestBase extends BaseTransa new EnumMap<>(Map.of(TransactionType.BLOB, 2)); protected final TransactionPoolMetrics txPoolMetrics = new TransactionPoolMetrics(metricsSystem); protected final EvictCollectorLayer evictCollector = new EvictCollectorLayer(txPoolMetrics); - protected final MiningParameters miningParameters = - MiningParameters.newDefault() + protected final MiningConfiguration miningConfiguration = + MiningConfiguration.newDefault() .setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE) .setMinPriorityFeePerGas(DEFAULT_MIN_PRIORITY_FEE); protected AbstractPrioritizedTransactions transactions = @@ -58,16 +58,17 @@ public abstract class AbstractPrioritizedTransactionsTestBase extends BaseTransa .maxPrioritizedTransactionsByType(MAX_TRANSACTIONS_BY_TYPE) .maxFutureBySender(MAX_TRANSACTIONS) .build(), - miningParameters); + miningConfiguration); private AbstractPrioritizedTransactions getSorter( - final TransactionPoolConfiguration poolConfig, final MiningParameters miningParameters) { + final TransactionPoolConfiguration poolConfig, + final MiningConfiguration miningConfiguration) { return getSorter( poolConfig, evictCollector, txPoolMetrics, (pt1, pt2) -> transactionReplacementTester(poolConfig, pt1, pt2), - miningParameters); + miningConfiguration); } abstract AbstractPrioritizedTransactions getSorter( @@ -76,7 +77,7 @@ public abstract class AbstractPrioritizedTransactionsTestBase extends BaseTransa final TransactionPoolMetrics txPoolMetrics, final BiFunction transactionReplacementTester, - final MiningParameters miningParameters); + final MiningConfiguration miningConfiguration); abstract BlockHeader mockBlockHeader(); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactionsTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactionsTest.java index b9a675287..8d01bd739 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactionsTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/BaseFeePrioritizedTransactionsTest.java @@ -26,7 +26,7 @@ import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -60,7 +60,7 @@ public class BaseFeePrioritizedTransactionsTest extends AbstractPrioritizedTrans final TransactionPoolMetrics txPoolMetrics, final BiFunction transactionReplacementTester, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return new BaseFeePrioritizedTransactions( poolConfig, @@ -71,7 +71,7 @@ public class BaseFeePrioritizedTransactionsTest extends AbstractPrioritizedTrans transactionReplacementTester, EIP1559_FEE_MARKET, new BlobCache(), - miningParameters); + miningConfiguration); } @Override @@ -164,7 +164,7 @@ public class BaseFeePrioritizedTransactionsTest extends AbstractPrioritizedTrans @Test public void txBelowCurrentMineableMinPriorityFeeIsNotPrioritized() { - miningParameters.setMinPriorityFeePerGas(Wei.of(5)); + miningConfiguration.setMinPriorityFeePerGas(Wei.of(5)); final PendingTransaction lowPriorityFeeTx = createRemotePendingTransaction( createTransaction(0, DEFAULT_MIN_GAS_PRICE.subtract(1), KEYS1)); @@ -175,7 +175,7 @@ public class BaseFeePrioritizedTransactionsTest extends AbstractPrioritizedTrans @Test public void txWithPriorityBelowCurrentMineableMinPriorityFeeIsPrioritized() { - miningParameters.setMinPriorityFeePerGas(Wei.of(5)); + miningConfiguration.setMinPriorityFeePerGas(Wei.of(5)); final PendingTransaction lowGasPriceTx = createRemotePendingTransaction( createTransaction(0, DEFAULT_MIN_GAS_PRICE.subtract(1), KEYS1), true); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactionsTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactionsTest.java index 66dcd3c72..a300ec23b 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactionsTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/GasPricePrioritizedTransactionsTest.java @@ -20,7 +20,7 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -44,7 +44,7 @@ public class GasPricePrioritizedTransactionsTest extends AbstractPrioritizedTran final TransactionPoolMetrics txPoolMetrics, final BiFunction transactionReplacementTester, - final MiningParameters miningParameters) { + final MiningConfiguration miningConfiguration) { return new GasPricePrioritizedTransactions( poolConfig, @@ -53,7 +53,7 @@ public class GasPricePrioritizedTransactionsTest extends AbstractPrioritizedTran txPoolMetrics, transactionReplacementTester, new BlobCache(), - miningParameters); + miningConfiguration); } @Override diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactionsTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactionsTest.java index 5f6126326..28814790a 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactionsTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactionsTest.java @@ -42,7 +42,7 @@ import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; @@ -158,7 +158,7 @@ public class LayeredPendingTransactionsTest extends BaseTransactionPoolTest { transactionReplacementTester, FeeMarket.london(0L), new BlobCache(), - MiningParameters.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE)); + MiningConfiguration.newDefault().setMinTransactionGasPrice(DEFAULT_MIN_GAS_PRICE)); return new CreatedLayers( prioritizedTransactions, readyTransactions, sparseTransactions, evictCollector); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolBaseFeeTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolBaseFeeTest.java index b3a840e70..c485ea787 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolBaseFeeTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolBaseFeeTest.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -49,7 +49,7 @@ public class LayeredTransactionPoolBaseFeeTest extends AbstractLayeredTransactio transactionReplacementTester, FeeMarket.london(0L), new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } @Override diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolGasPriceTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolGasPriceTest.java index 0c6f5f0bd..305bd9959 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolGasPriceTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredTransactionPoolGasPriceTest.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -46,7 +46,7 @@ public class LayeredTransactionPoolGasPriceTest extends AbstractLayeredTransacti txPoolMetrics, transactionReplacementTester, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } @Override diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayersTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayersTest.java index 0decabaaa..ee900e3dc 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayersTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayersTest.java @@ -36,7 +36,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -1404,7 +1404,7 @@ public class LayersTest extends BaseTransactionPoolTest { (pt1, pt2) -> transactionReplacementTester(poolConfig, pt1, pt2), FeeMarket.london(0L), new BlobCache(), - MiningParameters.newDefault().setMinTransactionGasPrice(MIN_GAS_PRICE)); + MiningConfiguration.newDefault().setMinTransactionGasPrice(MIN_GAS_PRICE)); this.pending = new LayeredPendingTransactions(poolConfig, this.prio, ethScheduler); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java index 847f5f2b9..760591a87 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java @@ -25,7 +25,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; @@ -232,7 +232,7 @@ public class ReplayTest { txReplacementTester, baseFeeMarket, new BlobCache(), - MiningParameters.newDefault()); + MiningConfiguration.newDefault()); } // ToDo: commented since not always working, needs fix diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java index 8dc8a74c1..1addf8032 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.crypto.SignatureAlgorithmType; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; @@ -81,7 +81,7 @@ class MainnetGenesisFileModule extends GenesisFileModule { return MainnetProtocolSchedule.fromConfig( configOptions, evmConfiguration, - MiningParameters.newDefault(), + MiningConfiguration.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()); @@ -187,12 +187,12 @@ class MainnetGenesisFileModule extends GenesisFileModule { return () -> new ProtocolScheduleBuilder( options, - options.getChainId().orElse(BigInteger.ONE), + options.getChainId(), ProtocolSpecAdapters.create(0, Function.identity()), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/ethereum/referencetests/build.gradle b/ethereum/referencetests/build.gradle index 48f556a5b..5fbab994c 100644 --- a/ethereum/referencetests/build.gradle +++ b/ethereum/referencetests/build.gradle @@ -191,6 +191,8 @@ dependencies { implementation 'io.tmio:tuweni-rlp' implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.google.guava:guava' + implementation 'com.google.dagger:dagger' + annotationProcessor 'com.google.dagger:dagger-compiler' referenceTestImplementation project(path: ':config') referenceTestImplementation project(path: ':datatypes') diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java index 976c8e70d..153f56d63 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder; @@ -34,6 +34,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.function.Function; import java.util.stream.Collectors; @@ -151,12 +152,12 @@ public class ReferenceTestProtocolSchedules { private static ProtocolSchedule createSchedule(final GenesisConfigOptions options) { return new ProtocolScheduleBuilder( options, - CHAIN_ID, + Optional.of(CHAIN_ID), ProtocolSpecAdapters.create(0, Function.identity()), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT, - MiningParameters.MINING_DISABLED, + MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java index cfb56d1eb..3333f02e5 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java @@ -18,7 +18,6 @@ package org.hyperledger.besu.ethereum.mainnet; import static org.assertj.core.api.Assertions.assertThat; -import org.checkerframework.checker.units.qual.N; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.config.JsonUtil; import org.hyperledger.besu.config.StubGenesisConfigOptions; @@ -28,13 +27,12 @@ import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.MiningParameters; +import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; @@ -61,64 +59,64 @@ public class DifficultyCalculatorTests { MainnetProtocolSchedule.fromConfig( GenesisConfigFile.mainnet() .withOverrides(postMergeOverrides).getConfigOptions(), - EvmConfiguration.DEFAULT, MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem())), + EvmConfiguration.DEFAULT, MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem())), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().grayGlacierBlock(15050000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierForkBlock.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff1.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfArrowGlacier/difficultyArrowGlacierTimeDiff2.json", MainnetProtocolSchedule.fromConfig( - new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + new StubGenesisConfigOptions().arrowGlacierBlock(13773000), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfByzantium/difficultyByzantium.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().byzantiumBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfConstantinople/difficultyConstantinople.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384_random.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfEIP2384/difficultyEIP2384_random_to20M.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().muirGlacierBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfFrontier/difficultyFrontier.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions(), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) ), Arguments.of( "/DifficultyTests/dfHomestead/difficultyHomestead.json", - MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), MiningParameters.newDefault(), new BadBlockManager(), false, new NoOpMetricsSystem()) + MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().homesteadBlock(0), MiningConfiguration.MINING_DISABLED, new BadBlockManager(), false, new NoOpMetricsSystem()) )); } diff --git a/ethereum/retesteth/build.gradle b/ethereum/retesteth/build.gradle deleted file mode 100644 index 484953a39..000000000 --- a/ethereum/retesteth/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2019 ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -apply plugin: 'java-library' - -jar { - archiveBaseName = 'besu-retesteth' - manifest { - attributes( - 'Specification-Title': archiveBaseName, - 'Specification-Version': project.version, - 'Implementation-Title': archiveBaseName, - 'Implementation-Version': calculateVersion(), - 'Commit-Hash': getGitCommitDetails(40).hash - ) - } -} - -dependencies { - api 'org.slf4j:slf4j-api' - - implementation project(':config') - implementation project(':datatypes') - implementation project(':ethereum:api') - implementation project(':ethereum:api') - implementation project(':ethereum:blockcreation') - implementation project(':ethereum:core') - implementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') - implementation project(':ethereum:eth') - implementation project(':ethereum:p2p') - implementation project(':ethereum:rlp') - implementation project(':evm') - implementation project(':metrics:core') - implementation project(':nat') - implementation project(':services:kvstore') - implementation project(':util') - - implementation 'com.google.guava:guava' - implementation 'io.vertx:vertx-core' - implementation 'io.vertx:vertx-web' - implementation 'com.fasterxml.jackson.core:jackson-databind' - implementation 'io.tmio:tuweni-bytes' - implementation 'io.tmio:tuweni-units' - - testImplementation 'org.assertj:assertj-core' - testImplementation 'org.junit.jupiter:junit-jupiter' - testImplementation 'org.mockito:mockito-core' -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java deleted file mode 100644 index db1ac943f..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/NoRewardProtocolScheduleWrapper.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth; - -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.BlockValidator; -import org.hyperledger.besu.ethereum.MainnetBlockValidator; -import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.BlockImporter; -import org.hyperledger.besu.ethereum.core.PermissionTransactionFilter; -import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.mainnet.BlockProcessor; -import org.hyperledger.besu.ethereum.mainnet.MainnetBlockImporter; -import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; -import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec; -import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; - -import java.math.BigInteger; -import java.util.Optional; -import java.util.function.Predicate; - -public class NoRewardProtocolScheduleWrapper implements ProtocolSchedule { - - private final ProtocolSchedule delegate; - private final BadBlockManager badBlockManager; - - NoRewardProtocolScheduleWrapper( - final ProtocolSchedule delegate, final BadBlockManager badBlockManager) { - this.delegate = delegate; - this.badBlockManager = badBlockManager; - } - - @Override - public ProtocolSpec getByBlockHeader(final ProcessableBlockHeader blockHeader) { - final ProtocolSpec original = delegate.getByBlockHeader(blockHeader); - final BlockProcessor noRewardBlockProcessor = - new MainnetBlockProcessor( - original.getTransactionProcessor(), - original.getTransactionReceiptFactory(), - Wei.ZERO, - original.getMiningBeneficiaryCalculator(), - original.isSkipZeroBlockRewards(), - delegate); - final BlockValidator noRewardBlockValidator = - new MainnetBlockValidator( - original.getBlockHeaderValidator(), - original.getBlockBodyValidator(), - noRewardBlockProcessor, - badBlockManager); - final BlockImporter noRewardBlockImporter = new MainnetBlockImporter(noRewardBlockValidator); - return new ProtocolSpec( - original.getName(), - original.getEvm(), - original.getTransactionValidatorFactory(), - original.getTransactionProcessor(), - original.getPrivateTransactionProcessor(), - original.getBlockHeaderValidator(), - original.getOmmerHeaderValidator(), - original.getBlockBodyValidator(), - noRewardBlockProcessor, - noRewardBlockImporter, - noRewardBlockValidator, - original.getBlockHeaderFunctions(), - original.getTransactionReceiptFactory(), - original.getDifficultyCalculator(), - Wei.ZERO, // block reward - original.getMiningBeneficiaryCalculator(), - original.getPrecompileContractRegistry(), - original.isSkipZeroBlockRewards(), - original.getGasCalculator(), - original.getGasLimitCalculator(), - original.getFeeMarket(), - Optional.empty(), - original.getWithdrawalsValidator(), - original.getWithdrawalsProcessor(), - original.getRequestsValidator(), - original.getRequestProcessorCoordinator(), - original.getBlockHashProcessor(), - original.isPoS(), - original.isReplayProtectionSupported()); - } - - @Override - public boolean anyMatch(final Predicate predicate) { - return delegate.anyMatch(predicate); - } - - @Override - public boolean isOnMilestoneBoundary(final BlockHeader blockHeader) { - return delegate.isOnMilestoneBoundary(blockHeader); - } - - @Override - public Optional getChainId() { - return delegate.getChainId(); - } - - @Override - public void putBlockNumberMilestone(final long blockNumber, final ProtocolSpec protocolSpec) { - delegate.putBlockNumberMilestone(blockNumber, protocolSpec); - } - - @Override - public void putTimestampMilestone(final long timestamp, final ProtocolSpec protocolSpec) { - delegate.putTimestampMilestone(timestamp, protocolSpec); - } - - @Override - public Optional hardforkFor( - final Predicate predicate) { - return delegate.hardforkFor(predicate); - } - - @Override - public String listMilestones() { - return delegate.listMilestones(); - } - - @Override - public void setPermissionTransactionFilter( - final PermissionTransactionFilter permissionTransactionFilter) { - delegate.setPermissionTransactionFilter(permissionTransactionFilter); - } - - @Override - public void setPublicWorldStateArchiveForPrivacyBlockProcessor( - final WorldStateArchive publicWorldStateArchive) { - delegate.setPublicWorldStateArchiveForPrivacyBlockProcessor(publicWorldStateArchive); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethClock.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethClock.java deleted file mode 100644 index fdd22f42b..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethClock.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth; - -import java.time.Clock; -import java.time.Instant; -import java.time.ZoneId; -import java.util.Optional; - -public class RetestethClock extends Clock { - - private Optional fixedInstant; - private final Clock delegateClock; - - RetestethClock() { - this(Clock.systemUTC()); - } - - private RetestethClock(final Clock delegateClock) { - fixedInstant = Optional.empty(); - this.delegateClock = delegateClock; - } - - @Override - public ZoneId getZone() { - return delegateClock.getZone(); - } - - @Override - public Clock withZone(final ZoneId zone) { - final RetestethClock zonedClock = new RetestethClock(delegateClock.withZone(zone)); - zonedClock.fixedInstant = fixedInstant; - return zonedClock; - } - - @Override - public Instant instant() { - return fixedInstant.orElseGet(delegateClock::instant); - } - - public void resetTime(final long time) { - fixedInstant = Optional.of(Instant.ofEpochSecond(time)); - } - - public void advanceSeconds(final long seconds) { - fixedInstant = Optional.of(Instant.ofEpochSecond(instant().getEpochSecond() + seconds)); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java deleted file mode 100644 index 32d4e0bab..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth; - -import static org.hyperledger.besu.config.JsonUtil.normalizeKeys; - -import org.hyperledger.besu.config.JsonGenesisConfigOptions; -import org.hyperledger.besu.config.JsonUtil; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockReplay; -import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; -import org.hyperledger.besu.ethereum.chain.GenesisState; -import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.chain.VariablesStorage; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.MutableInitValues; -import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters.Unstable; -import org.hyperledger.besu.ethereum.core.MiningParameters; -import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; -import org.hyperledger.besu.ethereum.eth.manager.EthContext; -import org.hyperledger.besu.ethereum.eth.manager.EthMessages; -import org.hyperledger.besu.ethereum.eth.manager.EthPeers; -import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; -import org.hyperledger.besu.ethereum.eth.sync.SyncMode; -import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; -import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; -import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; -import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; -import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; -import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory; -import org.hyperledger.besu.ethereum.forkid.ForkIdManager; -import org.hyperledger.besu.ethereum.mainnet.EpochCalculator; -import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; -import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.PoWHasher; -import org.hyperledger.besu.ethereum.mainnet.PoWSolution; -import org.hyperledger.besu.ethereum.mainnet.PoWSolver; -import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage; -import org.hyperledger.besu.ethereum.storage.keyvalue.VariablesKeyValueStorage; -import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; -import org.hyperledger.besu.ethereum.trie.forest.ForestWorldStateArchive; -import org.hyperledger.besu.ethereum.trie.forest.storage.ForestWorldStateKeyValueStorage; -import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; -import org.hyperledger.besu.ethereum.worldstate.WorldStateStorageCoordinator; -import org.hyperledger.besu.evm.internal.EvmConfiguration; -import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; -import org.hyperledger.besu.plugin.services.MetricsSystem; -import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; -import org.hyperledger.besu.util.Subscribers; -import org.hyperledger.besu.util.number.Fraction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.locks.ReentrantLock; -import java.util.function.Supplier; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; -import org.apache.tuweni.units.bigints.UInt256; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RetestethContext { - - private static final Logger LOG = LoggerFactory.getLogger(RetestethContext.class); - private static final PoWHasher NO_WORK_HASHER = - (final long nonce, final long number, EpochCalculator epochCalc, final Bytes headerHash) -> - new PoWSolution(nonce, Hash.ZERO, UInt256.ZERO, Hash.ZERO); - public static final int MAX_PEERS = 25; - - private final ReentrantLock contextLock = new ReentrantLock(); - private final BadBlockManager badBlockManager = new BadBlockManager(); - private Address coinbase; - private Bytes extraData; - private MutableBlockchain blockchain; - private ProtocolContext protocolContext; - private BlockchainQueries blockchainQueries; - private ProtocolSchedule protocolSchedule; - private BlockHeaderFunctions blockHeaderFunctions; - private HeaderValidationMode headerValidationMode; - private BlockReplay blockReplay; - private RetestethClock retestethClock; - private MiningParameters miningParameters; - private TransactionPool transactionPool; - private EthScheduler ethScheduler; - private PoWSolver poWSolver; - - private Optional terminalTotalDifficulty; - private Optional mixHash; - - public boolean resetContext( - final String genesisConfigString, final String sealEngine, final Optional clockTime) { - contextLock.lock(); - try { - tearDownContext(); - return buildContext(genesisConfigString, sealEngine, clockTime); - } catch (final Exception e) { - LOG.error("Error shutting down existing runner", e); - return false; - } finally { - contextLock.unlock(); - } - } - - private void tearDownContext() { - try { - if (ethScheduler != null) { - ethScheduler.stop(); - ethScheduler.awaitStop(); - } - } catch (final InterruptedException e) { - throw new RuntimeException(e); - } - } - - private boolean buildContext( - final String genesisConfigString, final String sealEngine, final Optional clockTime) { - final ObjectNode genesisConfig = - normalizeKeys(JsonUtil.objectNodeFromString(genesisConfigString)); - - retestethClock = new RetestethClock(); - clockTime.ifPresent(retestethClock::resetTime); - final MetricsSystem metricsSystem = new NoOpMetricsSystem(); - - terminalTotalDifficulty = - Optional.ofNullable(genesisConfig.get("params")) - .map(n -> n.get("terminaltotaldifficulty")) - .map(JsonNode::asText) - .map(Bytes::fromHexString); - - final JsonGenesisConfigOptions jsonGenesisConfigOptions = - JsonGenesisConfigOptions.fromJsonObject( - JsonUtil.getObjectNode(genesisConfig, "config").get()); - protocolSchedule = - MainnetProtocolSchedule.fromConfig( - jsonGenesisConfigOptions, - EvmConfiguration.DEFAULT, - miningParameters, - badBlockManager, - false, - new NoOpMetricsSystem()); - if ("NoReward".equalsIgnoreCase(sealEngine)) { - protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule, badBlockManager); - } - blockHeaderFunctions = ScheduleBasedBlockHeaderFunctions.create(protocolSchedule); - - final GenesisState genesisState = GenesisState.fromJson(genesisConfigString, protocolSchedule); - coinbase = genesisState.getBlock().getHeader().getCoinbase(); - extraData = genesisState.getBlock().getHeader().getExtraData(); - mixHash = Optional.ofNullable(genesisState.getBlock().getHeader().getMixHashOrPrevRandao()); - - final WorldStateArchive worldStateArchive = - new ForestWorldStateArchive( - new WorldStateStorageCoordinator( - new ForestWorldStateKeyValueStorage(new InMemoryKeyValueStorage())), - new WorldStatePreimageKeyValueStorage(new InMemoryKeyValueStorage()), - EvmConfiguration.DEFAULT); - final MutableWorldState worldState = worldStateArchive.getMutable(); - genesisState.writeStateTo(worldState); - - blockchain = createInMemoryBlockchain(genesisState.getBlock()); - protocolContext = new ProtocolContext(blockchain, worldStateArchive, null, badBlockManager); - - blockchainQueries = - new BlockchainQueries( - protocolSchedule, blockchain, worldStateArchive, ethScheduler, miningParameters); - - final String sealengine = JsonUtil.getString(genesisConfig, "sealengine", ""); - headerValidationMode = - "NoProof".equals(sealengine) || "NoReward".equals(sealEngine) - ? HeaderValidationMode.LIGHT - : HeaderValidationMode.FULL; - - miningParameters = - ImmutableMiningParameters.builder() - .mutableInitValues( - MutableInitValues.builder() - .coinbase(coinbase) - .extraData(extraData) - .targetGasLimit(blockchain.getChainHeadHeader().getGasLimit()) - .minBlockOccupancyRatio(0.0) - .minTransactionGasPrice(Wei.ZERO) - .build()) - .unstable(Unstable.builder().powJobTimeToLive(1000).maxOmmerDepth(8).build()) - .build(); - miningParameters.setMinTransactionGasPrice(Wei.ZERO); - poWSolver = - ("NoProof".equals(sealengine) || "NoReward".equals(sealEngine)) - ? new PoWSolver( - miningParameters, - NO_WORK_HASHER, - false, - Subscribers.none(), - new EpochCalculator.DefaultEpochCalculator()) - : new PoWSolver( - miningParameters, - PoWHasher.ETHASH_LIGHT, - false, - Subscribers.none(), - new EpochCalculator.DefaultEpochCalculator()); - - blockReplay = - new BlockReplay(protocolSchedule, protocolContext, blockchainQueries.getBlockchain()); - - final Bytes localNodeKey = Bytes.wrap(new byte[64]); - - // mining support - - final Supplier currentProtocolSpecSupplier = - () -> protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()); - final EthPeers ethPeers = - new EthPeers( - "reteseth", - currentProtocolSpecSupplier, - retestethClock, - metricsSystem, - EthProtocolConfiguration.DEFAULT_MAX_MESSAGE_SIZE, - Collections.emptyList(), - localNodeKey, - MAX_PEERS, - MAX_PEERS, - false, - SyncMode.FAST, - new ForkIdManager(blockchain, List.of(), List.of(), false)); - final SyncState syncState = new SyncState(blockchain, ethPeers); - - ethScheduler = new EthScheduler(1, 1, 1, 1, metricsSystem); - final EthContext ethContext = new EthContext(ethPeers, new EthMessages(), ethScheduler); - - final TransactionPoolConfiguration transactionPoolConfiguration = - ImmutableTransactionPoolConfiguration.builder() - .txPoolLimitByAccountPercentage(Fraction.fromFloat(0.004f)) - .build(); - - transactionPool = - TransactionPoolFactory.createTransactionPool( - protocolSchedule, - protocolContext, - ethContext, - retestethClock, - metricsSystem, - syncState, - transactionPoolConfiguration, - new BlobCache(), - MiningParameters.newDefault()); - - if (LOG.isTraceEnabled()) { - LOG.trace("Genesis Block {} ", genesisState.getBlock()); - } - - return true; - } - - private static MutableBlockchain createInMemoryBlockchain(final Block genesisBlock) { - return createInMemoryBlockchain(genesisBlock, new MainnetBlockHeaderFunctions()); - } - - private static MutableBlockchain createInMemoryBlockchain( - final Block genesisBlock, final BlockHeaderFunctions blockHeaderFunctions) { - final InMemoryKeyValueStorage keyValueStorage = new InMemoryKeyValueStorage(); - final VariablesStorage variablesStorage = - new VariablesKeyValueStorage(new InMemoryKeyValueStorage()); - return DefaultBlockchain.createMutable( - genesisBlock, - new KeyValueStoragePrefixedKeyBlockchainStorage( - keyValueStorage, variablesStorage, blockHeaderFunctions, false), - new NoOpMetricsSystem(), - 100); - } - - public ProtocolSchedule getProtocolSchedule() { - return protocolSchedule; - } - - public BlockHeaderFunctions getBlockHeaderFunctions() { - return blockHeaderFunctions; - } - - public ProtocolContext getProtocolContext() { - return protocolContext; - } - - public EthScheduler getEthScheduler() { - return ethScheduler; - } - - public void setEthScheduler(final EthScheduler ethScheduler) { - this.ethScheduler = ethScheduler; - } - - public long getBlockHeight() { - return blockchain.getChainHeadBlockNumber(); - } - - public ProtocolSpec getProtocolSpec(final BlockHeader blockHeader) { - return getProtocolSchedule().getByBlockHeader(blockHeader); - } - - public BlockHeader getBlockHeader(final long blockNumber) { - return blockchain.getBlockHeader(blockNumber).get(); - } - - public BlockchainQueries getBlockchainQueries() { - return blockchainQueries; - } - - public HeaderValidationMode getHeaderValidationMode() { - return headerValidationMode; - } - - BlockReplay getBlockReplay() { - return blockReplay; - } - - public TransactionPool getTransactionPool() { - return transactionPool; - } - - public MiningParameters getMiningParameters() { - return miningParameters; - } - - public MutableBlockchain getBlockchain() { - return blockchain; - } - - public RetestethClock getRetestethClock() { - return retestethClock; - } - - public Optional getTerminalTotalDifficulty() { - return terminalTotalDifficulty; - } - - public Optional getMixHash() { - return mixHash; - } - - public PoWSolver getEthHashSolver() { - return poWSolver; - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java deleted file mode 100644 index 877c59768..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth; - -import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration; -import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService; -import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService; -import org.hyperledger.besu.ethereum.api.jsonrpc.health.LivenessCheck; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugAccountRange; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugStorageRangeAt; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthBlockNumber; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetBalance; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetBlockByHash; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetBlockByNumber; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetCode; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthGetTransactionCount; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthSendRawTransaction; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.Web3ClientVersion; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory; -import org.hyperledger.besu.ethereum.core.DummySynchronizer; -import org.hyperledger.besu.ethereum.core.Synchronizer; -import org.hyperledger.besu.ethereum.retesteth.methods.TestGetLogHash; -import org.hyperledger.besu.ethereum.retesteth.methods.TestImportRawBlock; -import org.hyperledger.besu.ethereum.retesteth.methods.TestMineBlocks; -import org.hyperledger.besu.ethereum.retesteth.methods.TestModifyTimestamp; -import org.hyperledger.besu.ethereum.retesteth.methods.TestRewindToBlock; -import org.hyperledger.besu.ethereum.retesteth.methods.TestSetChainParams; -import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; -import org.hyperledger.besu.nat.NatService; - -import java.util.Arrays; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import io.vertx.core.Vertx; - -public class RetestethService { - - private final JsonRpcHttpService jsonRpcHttpService; - private final Vertx vertx; - - private final RetestethContext retestethContext; - - public RetestethService( - final String clientVersion, - final RetestethConfiguration retestethConfiguration, - final JsonRpcConfiguration jsonRpcConfiguration) { - vertx = Vertx.vertx(); - retestethContext = new RetestethContext(); - - final BlockResultFactory blockResult = new BlockResultFactory(); - final NatService natService = new NatService(Optional.empty()); - - // Synchronizer needed by RPC methods. Didn't wanna mock it, since this isn't the test module. - Synchronizer sync = new DummySynchronizer(); - - final Map jsonRpcMethods = - mapOf( - new Web3ClientVersion(clientVersion), - new TestSetChainParams(retestethContext), - new TestImportRawBlock(retestethContext), - new EthBlockNumber(retestethContext::getBlockchainQueries, true), - new EthGetBlockByNumber( - retestethContext::getBlockchainQueries, blockResult, sync, true), - new DebugAccountRange(retestethContext::getBlockchainQueries), - new EthGetBalance(retestethContext::getBlockchainQueries), - new EthGetBlockByHash(retestethContext::getBlockchainQueries, blockResult, true), - new EthGetCode(retestethContext::getBlockchainQueries), - new EthGetTransactionCount( - retestethContext::getBlockchainQueries, retestethContext::getTransactionPool), - new DebugStorageRangeAt( - retestethContext::getBlockchainQueries, retestethContext::getBlockReplay, true), - new TestModifyTimestamp(retestethContext), - new EthSendRawTransaction(retestethContext::getTransactionPool, true), - new TestMineBlocks(retestethContext), - new TestGetLogHash(retestethContext), - new TestRewindToBlock(retestethContext)); - - jsonRpcHttpService = - new JsonRpcHttpService( - vertx, - retestethConfiguration.getDataPath(), - jsonRpcConfiguration, - new NoOpMetricsSystem(), - natService, - jsonRpcMethods, - new HealthService(new LivenessCheck()), - HealthService.ALWAYS_HEALTHY); - } - - public void start() { - jsonRpcHttpService.start(); - } - - public void close() { - stop(); - } - - public void stop() { - jsonRpcHttpService.stop(); - vertx.close(); - } - - private static Map mapOf(final JsonRpcMethod... rpcMethods) { - return Arrays.stream(rpcMethods) - .collect(Collectors.toMap(JsonRpcMethod::getName, rpcMethod -> rpcMethod)); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java deleted file mode 100644 index 398d72d66..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.api.query.TransactionReceiptWithMetadata; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.evm.log.Log; - -import java.util.Optional; - -public class TestGetLogHash implements JsonRpcMethod { - private final RetestethContext context; - - public TestGetLogHash(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return "test_getLogHash"; - } - - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - final Hash txHash; - try { - txHash = requestContext.getRequiredParameter(0, Hash.class); - } catch (JsonRpcParameterException e) { - throw new InvalidJsonRpcParameters( - "Invalid transaction hash parameter (index 0)", - RpcErrorType.INVALID_TRANSACTION_HASH_PARAMS, - e); - } - - final Optional receipt = - context - .getBlockchainQueries() - .transactionReceiptByTransactionHash(txHash, context.getProtocolSchedule()); - return new JsonRpcSuccessResponse( - requestContext.getRequest().getId(), - receipt.map(this::calculateLogHash).orElse(Hash.EMPTY_LIST_HASH).toString()); - } - - private Hash calculateLogHash( - final TransactionReceiptWithMetadata transactionReceiptWithMetadata) { - return Hash.hash( - RLP.encode( - out -> - out.writeList( - transactionReceiptWithMetadata.getReceipt().getLogsList(), Log::writeTo))); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java deleted file mode 100644 index 580b107a8..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlock.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockImporter; -import org.hyperledger.besu.ethereum.mainnet.BlockImportResult; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; -import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.rlp.RLPException; - -import java.util.Collections; - -import org.apache.tuweni.bytes.Bytes; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestImportRawBlock implements JsonRpcMethod { - private static final Logger LOG = LoggerFactory.getLogger(TestImportRawBlock.class); - - public static final String METHOD_NAME = "test_importRawBlock"; - - private final RetestethContext context; - - public TestImportRawBlock(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return METHOD_NAME; - } - - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - final String input; - try { - input = requestContext.getRequiredParameter(0, String.class); - } catch (JsonRpcParameterException e) { - throw new InvalidJsonRpcParameters( - "Invalid block parameter (index 0)", RpcErrorType.INVALID_BLOCK_PARAMS, e); - } - final ProtocolContext protocolContext = this.context.getProtocolContext(); - - final Block block; - try { - block = - Block.readFrom(RLP.input(Bytes.fromHexString(input)), context.getBlockHeaderFunctions()); - } catch (final RLPException | IllegalArgumentException e) { - LOG.debug("Failed to parse block RLP", e); - return new JsonRpcErrorResponse( - requestContext.getRequest().getId(), RpcErrorType.BLOCK_RLP_IMPORT_ERROR); - } - - // retesteth expects test_rawImportBlock to not only import the block, but append it to head - if (context.getBlockchain().contains(block.getHash())) { - // if we already have the block but it is not head, append it: - context - .getBlockchain() - .appendBlock( - block, - context - .getBlockchain() - .getTxReceipts(block.getHash()) - .orElse(Collections.emptyList())); - } else { - // otherwise attempt to import the block - final BlockImporter blockImporter = - context.getProtocolSpec(block.getHeader()).getBlockImporter(); - final BlockImportResult result = - blockImporter.importBlock( - protocolContext, - block, - context.getHeaderValidationMode(), - context.getHeaderValidationMode()); - if (!result.isImported()) { - LOG.debug("Failed to import block."); - return new JsonRpcErrorResponse( - requestContext.getRequest().getId(), RpcErrorType.BLOCK_IMPORT_ERROR); - } - } - // return success on append or import - return new JsonRpcSuccessResponse( - requestContext.getRequest().getId(), block.getHash().toString()); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestMineBlocks.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestMineBlocks.java deleted file mode 100644 index 00a27bb7a..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestMineBlocks.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.blockcreation.PoWBlockCreator; -import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.BlockImporter; -import org.hyperledger.besu.ethereum.core.MiningParameters; -import org.hyperledger.besu.ethereum.mainnet.BlockImportResult; -import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; -import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.retesteth.RetestethClock; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; - -public class TestMineBlocks implements JsonRpcMethod { - private final RetestethContext context; - - public TestMineBlocks(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return "test_mineBlocks"; - } - - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - long blocksToMine = 0; - try { - blocksToMine = requestContext.getRequiredParameter(0, Long.class); - } catch (JsonRpcParameterException e) { - throw new InvalidJsonRpcParameters( - "Invalid blocks to mine (index 0)", RpcErrorType.INVALID_BLOCK_COUNT_PARAMS, e); - } - while (blocksToMine-- > 0) { - if (!mineNewBlock()) { - return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), false); - } - } - - return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true); - } - - private boolean mineNewBlock() { - final RetestethClock retesethClock = context.getRetestethClock(); - final ProtocolSchedule protocolSchedule = context.getProtocolSchedule(); - final ProtocolContext protocolContext = context.getProtocolContext(); - final MutableBlockchain blockchain = context.getBlockchain(); - final HeaderValidationMode headerValidationMode = context.getHeaderValidationMode(); - final MiningParameters miningParameters = context.getMiningParameters(); - final PoWBlockCreator blockCreator = - new PoWBlockCreator( - miningParameters, - header -> miningParameters.getExtraData(), - context.getTransactionPool(), - protocolContext, - protocolSchedule, - context.getEthHashSolver(), - context.getEthScheduler()); - final Block block = - blockCreator - .createBlock(retesethClock.instant().getEpochSecond(), blockchain.getChainHeadHeader()) - .getBlock(); - - // advance clock so next mine won't hit the same timestamp - retesethClock.advanceSeconds(1); - - final BlockImporter blockImporter = - protocolSchedule.getByBlockHeader(blockchain.getChainHeadHeader()).getBlockImporter(); - final BlockImportResult result = - blockImporter.importBlock( - protocolContext, block, headerValidationMode, headerValidationMode); - return result.isImported(); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestModifyTimestamp.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestModifyTimestamp.java deleted file mode 100644 index 717cf41b4..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestModifyTimestamp.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; - -public class TestModifyTimestamp implements JsonRpcMethod { - - private final RetestethContext context; - - public TestModifyTimestamp(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return "test_modifyTimestamp"; - } - - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - final long epochSeconds; - try { - epochSeconds = requestContext.getRequiredParameter(0, Long.class); - } catch (JsonRpcParameterException e) { - throw new InvalidJsonRpcParameters( - "Invalid timestamp parameter (index 0)", RpcErrorType.INVALID_TIMESTAMP_PARAMS, e); - } - context.getRetestethClock().resetTime(epochSeconds); - return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), true); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestRewindToBlock.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestRewindToBlock.java deleted file mode 100644 index d9b847af4..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestRewindToBlock.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcParameters; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonRpcParameter.JsonRpcParameterException; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; - -public class TestRewindToBlock implements JsonRpcMethod { - private final RetestethContext context; - - public static final String METHOD_NAME = "test_rewindToBlock"; - - public TestRewindToBlock(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return METHOD_NAME; - } - - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - final long blockNumber; - try { - blockNumber = requestContext.getRequiredParameter(0, Long.TYPE); - } catch (JsonRpcParameterException e) { - throw new InvalidJsonRpcParameters( - "Invalid block number parameter (index 0)", RpcErrorType.INVALID_BLOCK_NUMBER_PARAMS, e); - } - - return new JsonRpcSuccessResponse( - requestContext.getRequest().getId(), context.getBlockchain().rewindToBlock(blockNumber)); - } -} diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java deleted file mode 100644 index 1446fd939..000000000 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParams.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; - -import java.util.Iterator; -import java.util.Map; -import java.util.Optional; - -import io.vertx.core.json.JsonObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestSetChainParams implements JsonRpcMethod { - - private static final Logger LOG = LoggerFactory.getLogger(TestSetChainParams.class); - - public static final String METHOD_NAME = "test_setChainParams"; - private final RetestethContext context; - - public TestSetChainParams(final RetestethContext context) { - this.context = context; - } - - @Override - public String getName() { - return METHOD_NAME; - } - - @SuppressWarnings("unchecked") - @Override - public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { - - try { - final JsonObject chainParamsAsJson = - new JsonObject((Map) requestContext.getRequest().getParams()[0]); - final String chainParamsAsString = chainParamsAsJson.encodePrettily(); - LOG.trace("ChainParams {}", chainParamsAsString); - final String genesisFileAsString = modifyGenesisFile(chainParamsAsString); - LOG.trace("Genesis {}", genesisFileAsString); - final boolean result = - context.resetContext( - genesisFileAsString, - chainParamsAsJson.getString("sealEngine", "NoProof"), - Optional.empty()); - - return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result); - } catch (final Exception e) { - LOG.error("Unhandled error", e); - return new JsonRpcErrorResponse( - requestContext.getRequest().getId(), RpcErrorType.INVALID_PARAMS); - } - } - - private static void maybeMove( - final JsonObject src, final String srcName, final JsonObject dest, final String destName) { - if (src.containsKey(srcName)) { - dest.put(destName, src.getValue(srcName)); - src.remove(srcName); - } - } - - private static void maybeMoveToNumber( - final JsonObject src, final String srcName, final JsonObject dest, final String destName) { - if (src.containsKey(srcName)) { - dest.put(destName, Long.decode(src.getString(srcName))); - src.remove(srcName); - } - } - - private static void maybeMoveToNumber( - final JsonObject src, - final String srcName, - final JsonObject dest, - final String destName, - final long defaultValue) { - if (src.containsKey(srcName)) { - dest.put(destName, Long.decode(src.getString(srcName))); - src.remove(srcName); - } else { - dest.put(destName, defaultValue); - } - } - - private static String modifyGenesisFile(final String initialGenesis) { - final JsonObject chainParamsJson = new JsonObject(initialGenesis); - final JsonObject config = new JsonObject(); - chainParamsJson.put("config", config); - final JsonObject params = chainParamsJson.getJsonObject("params"); - final JsonObject genesis = chainParamsJson.getJsonObject("genesis"); - - // Whether sealEngine is NoProof, Ethash, or NoReward the genesis file is the same - final JsonObject ethash = new JsonObject(); - config.put("ethash", ethash); - - maybeMoveToNumber(params, "homesteadForkBlock", config, "homesteadBlock"); - maybeMoveToNumber(params, "daoHardforkBlock", config, "daoForkBlock"); - maybeMoveToNumber(params, "EIP150ForkBlock", config, "eip150Block"); - maybeMoveToNumber(params, "EIP158ForkBlock", config, "eip158Block"); - maybeMoveToNumber(params, "byzantiumForkBlock", config, "byzantiumBlock"); - maybeMoveToNumber(params, "constantinopleForkBlock", config, "constantinopleBlock"); - maybeMoveToNumber(params, "constantinopleFixForkBlock", config, "petersburgBlock"); - maybeMoveToNumber(params, "istanbulForkBlock", config, "istanbulBlock"); - maybeMoveToNumber(params, "muirGlacierForkBlock", config, "muirGlacierBlock"); - maybeMoveToNumber(params, "berlinForkBlock", config, "berlinBlock"); - maybeMoveToNumber(params, "londonForkBlock", config, "londonBlock"); - maybeMoveToNumber(params, "arrowGlacierForkBlock", config, "arrowGlacierBlock"); - maybeMoveToNumber(params, "grayGlacierForkBlock", config, "grayGlacierBlock"); - maybeMoveToNumber(params, "mergeNetSplitForkBlock", config, "mergeNetSplitBlock"); - maybeMoveToNumber(params, "shanghaiForkTime", config, "shanghaiTime"); - maybeMoveToNumber(params, "cancunForkTime", config, "cancunTime"); - maybeMoveToNumber(params, "pragueForkTime", config, "pragueTime"); - maybeMoveToNumber(params, "futureEipsForkTime", config, "futureEipsTime"); - maybeMoveToNumber(params, "experimentalEipsForkTime", config, "experimentalEipsTime"); - maybeMoveToNumber(params, "chainID", config, "chainId", 1); - - maybeMove(genesis, "author", chainParamsJson, "coinbase"); - maybeMove(genesis, "difficulty", chainParamsJson, "difficulty"); - maybeMove(genesis, "extraData", chainParamsJson, "extraData"); - maybeMove(genesis, "gasLimit", chainParamsJson, "gasLimit"); - maybeMove(genesis, "mixHash", chainParamsJson, "mixHash"); - maybeMove(genesis, "nonce", chainParamsJson, "nonce"); - maybeMove(genesis, "timestamp", chainParamsJson, "timestamp"); - maybeMove(chainParamsJson, "accounts", chainParamsJson, "alloc"); - maybeMove(genesis, "baseFeePerGas", chainParamsJson, "baseFeePerGas"); - - // strip out precompiles with zero balance - final JsonObject alloc = chainParamsJson.getJsonObject("alloc"); - final Iterator fieldNamesIter = alloc.fieldNames().iterator(); - while (fieldNamesIter.hasNext()) { - final String address = fieldNamesIter.next(); - final JsonObject account = alloc.getJsonObject(address); - if (account.containsKey("precompiled") && !account.containsKey("balance")) { - fieldNamesIter.remove(); - } - } - - return chainParamsJson.encodePrettily(); - } -} diff --git a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java b/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java deleted file mode 100644 index b156f2294..000000000 --- a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestImportRawBlockTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; -import org.hyperledger.besu.plugin.services.rpc.RpcResponseType; - -import java.io.IOException; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import io.vertx.core.json.JsonObject; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class TestImportRawBlockTest { - private TestImportRawBlock test_importRawBlock; - private TestRewindToBlock test_rewindToBlock; - private RetestethContext context; - - @BeforeEach - public void setupClass() throws IOException { - context = new RetestethContext(); - test_importRawBlock = new TestImportRawBlock(context); - test_rewindToBlock = new TestRewindToBlock(context); - final TestSetChainParams test_setChainParams = new TestSetChainParams(context); - final String chainParamsJsonString = - Resources.toString( - TestSetChainParamsTest.class.getResource("multimpleBalanceInstructionChainParams.json"), - Charsets.UTF_8); - final JsonObject chainParamsJson = new JsonObject(chainParamsJsonString); - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestSetChainParams.METHOD_NAME, new Object[] {chainParamsJson.getMap()})); - - assertThat(test_setChainParams.response(request)) - .isEqualTo(new JsonRpcSuccessResponse(null, true)); - } - - @Test - public void testMissingParent() { - final String rawBlockRLPString = - "0xf9045df901f9a0e38bef3dadb98e856ea82c7e9813b76a6ec8d9cf60694dd65d800a1669c1a1fda03770bba814f8cc5534ab5e40bdb3fe51866b537805c5577888091766e621fc13948888f1f195afa192cfee860698584c030f4c9db1a019ce64082807650d3d01ac60cd16a583e9472dcc0ccb8f39dd867e317cf025dda09735e49acaddb4d8338ed33df8dd006449b20b85e89e47224ac8ec8f7ea26071a0056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200000483301fd28252088454c99c2142a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f862f86003018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0a7b7f2fa93025fc1e6aa18c1aa07c32a456439754e196cb74f2f7d12cf3e840da02078cf840fb25fc3d858b2a85b622f21be0588b5c5d81d433427f6470e06a4a7f901faf901f7a0f88512d9e022357594866c44ecaa2fc9cb48f34d1987e401109400761aeb898da01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794bcde5374fce5edbc8e2a8697c15331677e6ebf0ba0fe87abb0d3ab38d4eb64405de03db5245b0d40c4b85d8a1b5028ada8643de2dba056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000002833007cf808454c9945142a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"; - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); - - final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); - assertThat(((JsonRpcErrorResponse) response).getErrorType()) - .isEqualTo(RpcErrorType.BLOCK_IMPORT_ERROR); - } - - @Test - public void testBadBlock() { - final String rawBlockRLPString = "0xf9045df901f9a08"; - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); - - final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(RpcResponseType.ERROR); - assertThat(((JsonRpcErrorResponse) response).getErrorType()) - .isEqualTo(RpcErrorType.BLOCK_RLP_IMPORT_ERROR); - } - - @Test - public void testGoodBlock() { - final String rawBlockRLPString = - "0xf90262f901faa0e38bef3dadb98e856ea82c7e9813b76a6ec8d9cf60694dd65d800a1669c1a1fda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a06e6be3f633fe0399cb17a9d8238b988a39bd9ab3e0ac0820f4df705a1ee37536a06fb77a9ddaa64a8e161b643d05533a4093f2be900ad06279b1b56b3bcee3b979a04b33fa3c9c50b7b9a4500f5c0b1e71ab43362abc81c2cf31fd2b54acf7d750d8b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefba83016b66845db7320980a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f862f860800a830249f094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0d42a045ac77a6d4676dd5fbc5104ed7471b6cef2465cfefaa52919b340f942a9a06e4d319aea79e45cde79d337e6edf849ceac505cab65dd41a572cab132d4dccac0"; - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); - - final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); - } - - @Test - public void testReimportExistingBlock() { - final String rawBlockRLPString = - "0xf90262f901faa0e38bef3dadb98e856ea82c7e9813b76a6ec8d9cf60694dd65d800a1669c1a1fda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a06e6be3f633fe0399cb17a9d8238b988a39bd9ab3e0ac0820f4df705a1ee37536a06fb77a9ddaa64a8e161b643d05533a4093f2be900ad06279b1b56b3bcee3b979a04b33fa3c9c50b7b9a4500f5c0b1e71ab43362abc81c2cf31fd2b54acf7d750d8b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefba83016b66845db7320980a00000000000000000000000000000000000000000000000000000000000000000880000000000000000f862f860800a830249f094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0d42a045ac77a6d4676dd5fbc5104ed7471b6cef2465cfefaa52919b340f942a9a06e4d319aea79e45cde79d337e6edf849ceac505cab65dd41a572cab132d4dccac0"; - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestImportRawBlock.METHOD_NAME, new Object[] {rawBlockRLPString})); - - final JsonRpcRequestContext requestRewind = - new JsonRpcRequestContext( - new JsonRpcRequest("2.0", TestRewindToBlock.METHOD_NAME, new Object[] {0L})); - - final var response = test_importRawBlock.response(request); - assertThat(response.getType()).isEqualTo(RpcResponseType.SUCCESS); - final var rewindResponse = test_rewindToBlock.response(requestRewind); - assertThat(rewindResponse.getType()).isEqualTo(RpcResponseType.SUCCESS); - final var reimportResponse = test_importRawBlock.response(request); - assertThat(reimportResponse.getType()).isEqualTo(RpcResponseType.SUCCESS); - - assertThat(context.getBlockchain().getChainHead().getHeight()).isEqualTo(1L); - } -} diff --git a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParamsTest.java b/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParamsTest.java deleted file mode 100644 index f376fa0c2..000000000 --- a/ethereum/retesteth/src/test/java/org/hyperledger/besu/ethereum/retesteth/methods/TestSetChainParamsTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.ethereum.retesteth.methods; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.retesteth.RetestethContext; - -import java.io.IOException; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import io.vertx.core.json.JsonObject; -import org.apache.tuweni.units.bigints.UInt256; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -public class TestSetChainParamsTest { - - private static RetestethContext context; - private static TestSetChainParams test_setChainParams; - - @BeforeAll - public static void setupClass() { - context = new RetestethContext(); - test_setChainParams = new TestSetChainParams(context); - } - - @Test - public void testValidateGenesisImport() throws IOException { - final String chainParamsJsonString = - Resources.toString( - TestSetChainParamsTest.class.getResource("multimpleBalanceInstructionChainParams.json"), - Charsets.UTF_8); - final JsonObject chainParamsJson = new JsonObject(chainParamsJsonString); - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestSetChainParams.METHOD_NAME, new Object[] {chainParamsJson.getMap()})); - - assertThat(test_setChainParams.response(request)) - .isEqualTo(new JsonRpcSuccessResponse(null, true)); - - final BlockHeader blockHeader = context.getBlockHeader(0); - - assertThat(blockHeader.getLogsBloom().toString()) - .isEqualTo( - "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - assertThat(blockHeader.getCoinbase().toString()) - .isEqualTo("0x8888f1f195afa192cfee860698584c030f4c9db1"); - assertThat(blockHeader.getDifficulty()).isEqualTo(UInt256.fromHexString("0x20000")); - assertThat(blockHeader.getExtraData().toHexString()).isEqualTo("0x42"); - assertThat(blockHeader.getGasLimit()).isEqualTo(3141592); - assertThat(blockHeader.getGasUsed()).isEqualTo(0); - assertThat(blockHeader.getMixHash().toString()) - .isEqualTo("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); - assertThat(blockHeader.getNonce()).isEqualTo(0x0102030405060708L); - assertThat(blockHeader.getNumber()).isEqualTo(0); - assertThat(blockHeader.getParentHash().toString()) - .isEqualTo("0x0000000000000000000000000000000000000000000000000000000000000000"); - assertThat(blockHeader.getReceiptsRoot().toString()) - .isEqualTo("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); - assertThat(blockHeader.getStateRoot().toString()) - .isEqualTo("0xf403922bfd555a9223f68fc755564004e20d78bb42aae647e867e3b23c48beba"); - assertThat(blockHeader.getTimestamp()).isEqualTo(0x54c98c81); - assertThat(blockHeader.getTransactionsRoot().toString()) - .isEqualTo("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); - assertThat(blockHeader.getOmmersHash().toString()) - .isEqualTo("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"); - } - - @Test - public void testValidate1559GenesisImport() throws IOException { - final String chainParamsJsonString = - Resources.toString( - TestSetChainParamsTest.class.getResource("1559ChainParams.json"), Charsets.UTF_8); - final JsonObject chainParamsJson = new JsonObject(chainParamsJsonString); - - final JsonRpcRequestContext request = - new JsonRpcRequestContext( - new JsonRpcRequest( - "2.0", TestSetChainParams.METHOD_NAME, new Object[] {chainParamsJson.getMap()})); - - assertThat(test_setChainParams.response(request)) - .isEqualTo(new JsonRpcSuccessResponse(null, true)); - - final BlockHeader blockHeader = context.getBlockHeader(0); - assertThat(blockHeader.getDifficulty()).isEqualTo(UInt256.fromHexString("0x20000")); - assertThat(blockHeader.getGasLimit()).isEqualTo(1234L); - assertThat(blockHeader.getBaseFee()).hasValue(Wei.of(12345L)); - assertThat(blockHeader.getExtraData().toHexString()).isEqualTo("0x00"); - assertThat(blockHeader.getTimestamp()).isEqualTo(0l); - assertThat(blockHeader.getNonce()).isEqualTo(0L); - assertThat(blockHeader.getMixHash().toHexString()) - .isEqualTo("0x0000000000000000000000000000000000000000000000000000000000000000"); - } -} diff --git a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json b/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json deleted file mode 100644 index 95535e269..000000000 --- a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/1559ChainParams.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "genesis" : { - "author" : "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "difficulty" : "0x020000", - "gasLimit" : "0x04d2", - "baseFeePerGas" : "0x3039", - "extraData" : "0x00", - "timestamp" : "0x00", - "nonce" : "0x0000000000000000", - "mixHash" : "0x0000000000000000000000000000000000000000000000000000000000000000" - }, - "params": { - "EIP150ForkBlock": "0x00", - "EIP158ForkBlock": "0x00", - "byzantiumForkBlock": "0x00", - "homesteadForkBlock": "0x00", - "londonForkBlock": "0x00" - }, - "sealEngine": "NoProof", - "accounts": {} -} \ No newline at end of file diff --git a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/multimpleBalanceInstructionChainParams.json b/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/multimpleBalanceInstructionChainParams.json deleted file mode 100644 index 0cb0cfc96..000000000 --- a/ethereum/retesteth/src/test/resources/org/hyperledger/besu/ethereum/retesteth/methods/multimpleBalanceInstructionChainParams.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "accounts": { - "0x0000000000000000000000000000000000000001": { - "precompiled": { - "linear": { - "base": 3000, - "word": 0 - }, - "name": "ecrecover" - } - }, - "0x0000000000000000000000000000000000000002": { - "precompiled": { - "linear": { - "base": 60, - "word": 12 - }, - "name": "sha256" - } - }, - "0x0000000000000000000000000000000000000003": { - "precompiled": { - "linear": { - "base": 600, - "word": 120 - }, - "name": "sha256" - } - }, - "0x0000000000000000000000000000000000000004": { - "precompiled": { - "linear": { - "base": 15, - "word": 3 - }, - "name": "identity" - } - }, - "0x0000000000000000000000000000000000000005": { - "precompiled": { - "name": "modexp" - } - }, - "0x0000000000000000000000000000000000000006": { - "precompiled": { - "linear": { - "base": 500, - "word": 0 - }, - "name": "alt_bn128_G1_add" - } - }, - "0x0000000000000000000000000000000000000007": { - "precompiled": { - "linear": { - "base": 40000, - "word": 0 - }, - "name": "alt_bn128_G1_mul" - } - }, - "0x0000000000000000000000000000000000000008": { - "precompiled": { - "name": "alt_bn128_pairing_product" - } - }, - "0x095e7baea6a6c7c4c2dfeb977efac326af552d87": { - "balance": "0x0186a0", - "code": "0x73a94f5374fce5edbc8e2a8697c15331677e6ebf0b31600055738888f1f195afa192cfee860698584c030f4c9db13160015573a94f5374fce5edbc8e2a8697c15331677e6ebf0b31600255738888f1f195afa192cfee860698584c030f4c9db13160035573095e7baea6a6c7c4c2dfeb977efac326af552d8731600555", - "nonce": "0x00", - "storage": {} - }, - "0x195e7baea6a6c7c4c2dfeb977efac326af552d87": { - "balance": "0x0186a0", - "code": "0x73a94f5374fce5edbc8e2a8697c15331677e6ebf0b31600055738888f1f195afa192cfee860698584c030f4c9db13160015573a94f5374fce5edbc8e2a8697c15331677e6ebf0b31600255738888f1f195afa192cfee860698584c030f4c9db13160035573095e7baea6a6c7c4c2dfeb977efac326af552d873160045573195e7baea6a6c7c4c2dfeb977efac326af552d8731600555", - "nonce": "0x00", - "storage": {} - }, - "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": { - "balance": "0x1748721582", - "code": "0x", - "nonce": "0x00", - "storage": {} - } - }, - "genesis": { - "author": "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty": "0x020000", - "extraData": "0x42", - "gasLimit": "0x2fefd8", - "mixHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce": "0x0102030405060708", - "timestamp": "0x54c98c81" - }, - "params": { - "EIP150ForkBlock": "0x00", - "EIP158ForkBlock": "0x00", - "byzantiumForkBlock": "0x00", - "homesteadForkBlock": "0x00" - }, - "sealEngine": "NoProof" -} \ No newline at end of file