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 3baa6ee027..091c1534d3 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 @@ -458,7 +458,8 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { final BesuControllerBuilder builder, final MetricsSystem metricsSystem, final KeyValueStorageProvider storageProvider, - final MiningConfiguration miningConfiguration) { + final MiningConfiguration miningConfiguration, + final ApiConfiguration apiConfiguration) { builder .synchronizerConfiguration(synchronizerConfiguration) @@ -473,6 +474,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner { .maxRemotelyInitiatedPeers(15) .miningParameters(miningConfiguration) .randomPeerPriority(false) + .apiConfiguration(apiConfiguration) .besuComponent(null); return builder.build(); } diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index bfaf8011b0..9a9eb64fc8 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -672,12 +672,7 @@ public class RunnerBuilder { final Synchronizer synchronizer = besuController.getSynchronizer(); - final TransactionSimulator transactionSimulator = - new TransactionSimulator( - context.getBlockchain(), - context.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap()); + final TransactionSimulator transactionSimulator = besuController.getTransactionSimulator(); final Bytes localNodeId = nodeKey.getPublicKey().getEncodedBytes(); final Optional nodePermissioningController = @@ -840,7 +835,8 @@ public class RunnerBuilder { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); jsonRpcHttpService = Optional.of( @@ -885,7 +881,8 @@ public class RunnerBuilder { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); final Optional authToUse = engineJsonRpcConfiguration.get().isAuthenticationEnabled() @@ -932,7 +929,7 @@ public class RunnerBuilder { graphQlContextMap.putIfAbsent(GraphQLContextType.SYNCHRONIZER, synchronizer); graphQlContextMap.putIfAbsent( GraphQLContextType.CHAIN_ID, protocolSchedule.getChainId().map(UInt256::valueOf)); - graphQlContextMap.putIfAbsent(GraphQLContextType.GAS_CAP, apiConfiguration.getGasCap()); + graphQlContextMap.putIfAbsent(GraphQLContextType.TRANSACTION_SIMULATOR, transactionSimulator); final GraphQL graphQL; try { graphQL = GraphQLProvider.buildGraphQL(fetchers); @@ -980,7 +977,8 @@ public class RunnerBuilder { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); createLogsSubscriptionService( context.getBlockchain(), subscriptionManager, privacyParameters, blockchainQueries); @@ -1060,7 +1058,8 @@ public class RunnerBuilder { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); jsonRpcIpcService = Optional.of( @@ -1099,7 +1098,8 @@ public class RunnerBuilder { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); } else { inProcessRpcMethods = Map.of(); } @@ -1261,7 +1261,8 @@ public class RunnerBuilder { final NatService natService, final Map namedPlugins, final Path dataDir, - final RpcEndpointServiceImpl rpcEndpointServiceImpl) { + final RpcEndpointServiceImpl rpcEndpointServiceImpl, + final TransactionSimulator transactionSimulator) { // sync vertx for engine consensus API, to process requests in FIFO order; final Vertx consensusEngineServer = Vertx.vertx(new VertxOptions().setWorkerPoolSize(1)); @@ -1298,7 +1299,8 @@ public class RunnerBuilder { besuController.getProtocolManager().ethContext().getEthPeers(), consensusEngineServer, apiConfiguration, - enodeDnsConfiguration); + enodeDnsConfiguration, + transactionSimulator); methods.putAll(besuController.getAdditionalJsonRpcMethods(jsonRpcApis)); final var pluginMethods = 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 a686a00d98..b5bfa9182f 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -134,7 +134,6 @@ import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder; -import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.DiffBasedSubStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguration; @@ -339,6 +338,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable { Suppliers.memoize(this::readGenesisConfigOptions); private final Supplier miningParametersSupplier = Suppliers.memoize(this::getMiningParameters); + private final Supplier apiConfigurationSupplier = + Suppliers.memoize(this::getApiConfiguration); private RocksDBPlugin rocksDBPlugin; @@ -712,7 +713,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { private WebSocketConfiguration webSocketConfiguration; private JsonRpcIpcConfiguration jsonRpcIpcConfiguration; private InProcessRpcConfiguration inProcessRpcConfiguration; - private ApiConfiguration apiConfiguration; private MetricsConfiguration metricsConfiguration; private Optional permissioningConfiguration; private DataStorageConfiguration dataStorageConfiguration; @@ -1237,7 +1237,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { webSocketConfiguration, jsonRpcIpcConfiguration, inProcessRpcConfiguration, - apiConfiguration, + apiConfigurationSupplier.get(), metricsConfiguration, permissioningConfiguration, staticNodes, @@ -1249,11 +1249,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { besuController.getProtocolContext().getBlockchain(), besuController.getProtocolSchedule()); transactionSimulationServiceImpl.init( besuController.getProtocolContext().getBlockchain(), - new TransactionSimulator( - besuController.getProtocolContext().getBlockchain(), - besuController.getProtocolContext().getWorldStateArchive(), - besuController.getProtocolSchedule(), - apiConfiguration.getGasCap())); + besuController.getTransactionSimulator()); rpcEndpointServiceImpl.init(runner.getInProcessRpcMethods()); besuPluginContext.addService( @@ -1447,7 +1443,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { validateTransactionPoolOptions(); validateDataStorageOptions(); validateGraphQlOptions(); - validateApiOptions(); validateConsensusSyncCompatibilityOptions(); validatePluginOptions(); } @@ -1705,7 +1700,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable { unstableIpcOptions.getIpcPath(), unstableIpcOptions.getRpcIpcApis()); inProcessRpcConfiguration = inProcessRpcOptions.toDomainObject(); - apiConfiguration = apiConfigurationOptions.apiConfiguration(); dataStorageConfiguration = getDataStorageConfiguration(); // hostsWhitelist is a hidden option. If it is specified, add the list to hostAllowlist if (!hostsWhitelist.isEmpty()) { @@ -1823,6 +1817,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable { .chainPruningConfiguration(unstableChainPruningOptions.toDomainObject()) .cacheLastBlocks(numberOfblocksToCache) .genesisStateHashCacheEnabled(genesisStateHashCacheEnabled) + .apiConfiguration(apiConfigurationSupplier.get()) .besuComponent(besuComponent); if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) { final DiffBasedSubStorageConfiguration subStorageConfiguration = @@ -2148,6 +2143,11 @@ public class BesuCommand implements DefaultCommandValues, Runnable { return miningParameters; } + private ApiConfiguration getApiConfiguration() { + validateApiOptions(); + return apiConfigurationOptions.apiConfiguration(); + } + /** * Get the data storage configuration * 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 238e5c3c1c..25a306d3a2 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuController.java @@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration; import org.hyperledger.besu.ethereum.storage.StorageProvider; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import java.io.Closeable; @@ -66,7 +67,6 @@ public class BesuController implements java.io.Closeable { private final NodeKey nodeKey; private final Synchronizer synchronizer; private final JsonRpcMethods additionalJsonRpcMethodsFactory; - private final TransactionPool transactionPool; private final MiningCoordinator miningCoordinator; private final PrivacyParameters privacyParameters; @@ -77,6 +77,7 @@ public class BesuController implements java.io.Closeable { private final EthPeers ethPeers; private final StorageProvider storageProvider; private final DataStorageConfiguration dataStorageConfiguration; + private final TransactionSimulator transactionSimulator; /** * Instantiates a new Besu controller. @@ -99,6 +100,7 @@ public class BesuController implements java.io.Closeable { * @param ethPeers the eth peers * @param storageProvider the storage provider * @param dataStorageConfiguration the data storage configuration + * @param transactionSimulator the transaction simulator */ BesuController( final ProtocolSchedule protocolSchedule, @@ -118,7 +120,8 @@ public class BesuController implements java.io.Closeable { final PluginServiceFactory additionalPluginServices, final EthPeers ethPeers, final StorageProvider storageProvider, - final DataStorageConfiguration dataStorageConfiguration) { + final DataStorageConfiguration dataStorageConfiguration, + final TransactionSimulator transactionSimulator) { this.protocolSchedule = protocolSchedule; this.protocolContext = protocolContext; this.ethProtocolManager = ethProtocolManager; @@ -137,6 +140,7 @@ public class BesuController implements java.io.Closeable { this.ethPeers = ethPeers; this.storageProvider = storageProvider; this.dataStorageConfiguration = dataStorageConfiguration; + this.transactionSimulator = transactionSimulator; } /** @@ -307,6 +311,15 @@ public class BesuController implements java.io.Closeable { return dataStorageConfiguration; } + /** + * Gets the transaction simulator + * + * @return the transaction simulator + */ + public TransactionSimulator getTransactionSimulator() { + return transactionSimulator; + } + /** The type Builder. */ public static class Builder { /** Instantiates a new Builder. */ 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 96de7a2af0..fdce6a08e4 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.ConsensusContext; import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator; import org.hyperledger.besu.ethereum.chain.BadBlockManager; @@ -84,6 +85,7 @@ import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration; import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.BonsaiWorldStateProvider; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.cache.BonsaiCachedMerkleTrieLoader; import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.storage.BonsaiWorldStateKeyValueStorage; @@ -211,6 +213,12 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides /** whether parallel transaction processing is enabled or not */ protected boolean isParallelTxProcessingEnabled; + /** The API configuration */ + protected ApiConfiguration apiConfiguration; + + /** The transaction simulator */ + protected TransactionSimulator transactionSimulator; + /** Instantiates a new Besu controller builder. */ protected BesuControllerBuilder() {} @@ -272,6 +280,17 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides return this; } + /** + * API configuration besu controller builder. + * + * @param apiConfiguration the API config + * @return the besu controller builder + */ + public BesuControllerBuilder apiConfiguration(final ApiConfiguration apiConfiguration) { + this.apiConfiguration = apiConfiguration; + return this; + } + /** * Eth protocol configuration besu controller builder. * @@ -556,6 +575,7 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides checkNotNull(gasLimitCalculator, "Missing gas limit calculator"); checkNotNull(evmConfiguration, "Missing evm config"); checkNotNull(networkingConfiguration, "Missing network configuration"); + checkNotNull(apiConfiguration, "Missing API configuration"); checkNotNull(dataStorageConfiguration, "Missing data storage configuration"); checkNotNull(besuComponent, "Must supply a BesuComponent"); prepForBuild(); @@ -604,6 +624,10 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides genesisState.writeStateTo(worldStateArchive.getMutable()); } + transactionSimulator = + new TransactionSimulator( + blockchain, worldStateArchive, protocolSchedule, apiConfiguration.getGasCap()); + final var consensusContext = createConsensusContext(blockchain, worldStateArchive, protocolSchedule); @@ -795,7 +819,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides additionalPluginServices, ethPeers, storageProvider, - dataStorageConfiguration); + dataStorageConfiguration, + transactionSimulator); } private GenesisState getGenesisState( 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 b6f579ea68..e8c08d8a47 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java @@ -79,7 +79,6 @@ import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration; -import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.plugin.services.BesuEvents; import org.hyperledger.besu.util.Subscribers; @@ -399,8 +398,6 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder { BlockValidatorProvider.forkingValidatorProvider( blockchain, epochManager, bftBlockInterface().get(), validatorOverrides); - final TransactionSimulator transactionSimulator = - new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, 0L); transactionValidatorProvider = new TransactionValidatorProvider( blockchain, new ValidatorContractController(transactionSimulator), qbftForksSchedule); diff --git a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java index ff205e8751..bad87162fd 100644 --- a/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/FlexGroupPrivacyTest.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.enclave.EnclaveFactory; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; @@ -162,6 +163,7 @@ class FlexGroupPrivacyTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(context) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); } } diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java index a79b664458..beff4b8586 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java @@ -41,6 +41,7 @@ import org.hyperledger.besu.enclave.EnclaveFactory; import org.hyperledger.besu.enclave.types.ReceiveResponse; import org.hyperledger.besu.ethereum.GasLimitCalculator; import org.hyperledger.besu.ethereum.ProtocolContext; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.chain.DefaultBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; @@ -558,6 +559,7 @@ public class PrivacyReorgTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(context) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); return retval; } diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java index 305d786b8b..3e905d9441 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; @@ -137,6 +138,7 @@ class PrivacyTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(context) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); } } diff --git a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java index 4239cbdc34..cf995c25e0 100644 --- a/besu/src/test/java/org/hyperledger/besu/RunnerTest.java +++ b/besu/src/test/java/org/hyperledger/besu/RunnerTest.java @@ -510,6 +510,7 @@ public final class RunnerTest { .besuComponent(mock(BesuComponent.class)) .maxPeers(25) .maxRemotelyInitiatedPeers(15) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); } } 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 e76c06fe2d..a0e596a000 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.components.BesuComponent; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; @@ -105,6 +106,7 @@ public final class RlpBlockExporterTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); } 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 2b534660ed..383ef1a3a1 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java @@ -28,6 +28,7 @@ import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; @@ -475,6 +476,7 @@ public abstract class JsonBlockImporterTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(DaggerJsonBlockImporterTest_JsonBlockImportComponent.builder().build()) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); } 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 9f405d4cb3..2f707edc6f 100644 --- a/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java +++ b/besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.config.MergeConfiguration; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.PrivacyParameters; @@ -80,6 +81,7 @@ public final class RlpBlockImporterTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); final RlpBlockImporter.ImportResult result = rlpBlockImporter.importBlockchain(source, targetController, false); @@ -114,6 +116,7 @@ public final class RlpBlockImporterTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); assertThatThrownBy( @@ -145,6 +148,7 @@ public final class RlpBlockImporterTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); final RlpBlockImporter.ImportResult result = diff --git a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java index 7239659398..78f782d5e5 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java @@ -296,6 +296,7 @@ public abstract class CommandTestAbstract { when(mockControllerBuilder.cacheLastBlocks(any())).thenReturn(mockControllerBuilder); when(mockControllerBuilder.genesisStateHashCacheEnabled(any())) .thenReturn(mockControllerBuilder); + when(mockControllerBuilder.apiConfiguration(any())).thenReturn(mockControllerBuilder); when(mockControllerBuilder.build()).thenReturn(mockController); lenient().when(mockController.getProtocolManager()).thenReturn(mockEthProtocolManager); diff --git a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java index e17fb04acf..2636408749 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/AbstractBftBesuControllerBuilderTest.java @@ -29,6 +29,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -158,7 +159,8 @@ public abstract class AbstractBftBesuControllerBuilderTest { .gasLimitCalculator(gasLimitCalculator) .evmConfiguration(EvmConfiguration.DEFAULT) .besuComponent(mock(BesuComponent.class)) - .networkConfiguration(NetworkingConfiguration.create()); + .networkConfiguration(NetworkingConfiguration.create()) + .apiConfiguration(ImmutableApiConfiguration.builder().build()); } protected abstract void setupBftGenesisConfigFile() throws JsonProcessingException; diff --git a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java index 32924e29f9..f05ea666a0 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilderTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -191,7 +192,8 @@ public class CliqueBesuControllerBuilderTest { .gasLimitCalculator(gasLimitCalculator) .evmConfiguration(EvmConfiguration.DEFAULT) .besuComponent(mock(BesuComponent.class)) - .networkConfiguration(NetworkingConfiguration.create()); + .networkConfiguration(NetworkingConfiguration.create()) + .apiConfiguration(ImmutableApiConfiguration.builder().build()); } @Test diff --git a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java index 47971b6442..7c4a370beb 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java @@ -33,6 +33,7 @@ import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.GasLimitCalculator; +import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; @@ -191,7 +192,8 @@ public class MergeBesuControllerBuilderTest { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) - .networkId(networkId); + .networkId(networkId) + .apiConfiguration(ImmutableApiConfiguration.builder().build()); } @Test diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java index 2a65b1e7cb..f9918036ec 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java @@ -45,6 +45,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; import org.hyperledger.besu.metrics.ObservableMetricsSystem; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; @@ -77,6 +78,7 @@ public class JsonRpcTestMethodsFactory { private final BlockchainQueries blockchainQueries; private final Synchronizer synchronizer; private final ProtocolSchedule protocolSchedule; + private final TransactionSimulator transactionSimulator; public JsonRpcTestMethodsFactory(final BlockchainImporter importer) { this.importer = importer; @@ -98,6 +100,9 @@ public class JsonRpcTestMethodsFactory { this.blockchainQueries = new BlockchainQueries( protocolSchedule, blockchain, stateArchive, MiningConfiguration.newDefault()); + + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public JsonRpcTestMethodsFactory( @@ -117,6 +122,8 @@ public class JsonRpcTestMethodsFactory { stateArchive, MiningConfiguration.newDefault()); this.synchronizer = mock(Synchronizer.class); + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public JsonRpcTestMethodsFactory( @@ -137,6 +144,8 @@ public class JsonRpcTestMethodsFactory { blockchain, stateArchive, MiningConfiguration.newDefault()); + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public BlockchainQueries getBlockchainQueries() { @@ -219,6 +228,7 @@ public class JsonRpcTestMethodsFactory { ethPeers, Vertx.vertx(new VertxOptions().setWorkerPoolSize(1)), ImmutableApiConfiguration.builder().build(), - Optional.empty()); + Optional.empty(), + transactionSimulator); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLContextType.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLContextType.java index c12f7578c6..f689f191e6 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLContextType.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLContextType.java @@ -41,6 +41,6 @@ public enum GraphQLContextType { /** Represents chain ID context. */ CHAIN_ID, - /** Represents gas cap context. */ - GAS_CAP + /** Represents the transaction simulator. */ + TRANSACTION_SIMULATOR } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java index 6d5b696353..945727fda2 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java @@ -332,10 +332,8 @@ public class BlockAdapterBase extends AdapterBase { final ProtocolSchedule protocolSchedule = environment.getGraphQlContext().get(GraphQLContextType.PROTOCOL_SCHEDULE); final long bn = header.getNumber(); - final long gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP); final TransactionSimulator transactionSimulator = - new TransactionSimulator( - query.getBlockchain(), query.getWorldStateArchive(), protocolSchedule, gasCap); + environment.getGraphQlContext().get(GraphQLContextType.TRANSACTION_SIMULATOR); long gasParam = -1; Wei gasPriceParam = null; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java index 49f6bc890f..9ec80fbedd 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java @@ -145,10 +145,8 @@ public class PendingStateAdapter extends AdapterBase { final BlockchainQueries query = getBlockchainQueries(environment); final ProtocolSchedule protocolSchedule = environment.getGraphQlContext().get(GraphQLContextType.PROTOCOL_SCHEDULE); - final long gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP); final TransactionSimulator transactionSimulator = - new TransactionSimulator( - query.getBlockchain(), query.getWorldStateArchive(), protocolSchedule, gasCap); + environment.getGraphQlContext().get(GraphQLContextType.TRANSACTION_SIMULATOR); long gasParam = -1; Wei gasPriceParam = null; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java index 90ae97c5c4..9ca0bb6c1a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java @@ -15,7 +15,6 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods; import org.hyperledger.besu.ethereum.ProtocolContext; -import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.DebugReplayBlock; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.DebugAccountAt; @@ -64,7 +63,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods { private final TransactionPool transactionPool; private final Synchronizer synchronizer; private final Path dataDir; - private final ApiConfiguration apiConfiguration; + private final TransactionSimulator transactionSimulator; DebugJsonRpcMethods( final BlockchainQueries blockchainQueries, @@ -74,7 +73,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods { final TransactionPool transactionPool, final Synchronizer synchronizer, final Path dataDir, - final ApiConfiguration apiConfiguration) { + final TransactionSimulator transactionSimulator) { this.blockchainQueries = blockchainQueries; this.protocolContext = protocolContext; this.protocolSchedule = protocolSchedule; @@ -82,7 +81,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods { this.transactionPool = transactionPool; this.synchronizer = synchronizer; this.dataDir = dataDir; - this.apiConfiguration = apiConfiguration; + this.transactionSimulator = transactionSimulator; } @Override @@ -120,13 +119,6 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods { new DebugGetRawBlock(blockchainQueries), new DebugGetRawReceipts(blockchainQueries), new DebugGetRawTransaction(blockchainQueries), - new DebugTraceCall( - blockchainQueries, - protocolSchedule, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap()))); + new DebugTraceCall(blockchainQueries, protocolSchedule, transactionSimulator)); } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java index de5662692f..0ddcb56496 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java @@ -89,6 +89,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods { private final MiningCoordinator miningCoordinator; private final Set supportedCapabilities; private final ApiConfiguration apiConfiguration; + private final TransactionSimulator transactionSimulator; public EthJsonRpcMethods( final BlockchainQueries blockchainQueries, @@ -98,7 +99,8 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods { final TransactionPool transactionPool, final MiningCoordinator miningCoordinator, final Set supportedCapabilities, - final ApiConfiguration apiConfiguration) { + final ApiConfiguration apiConfiguration, + final TransactionSimulator transactionSimulator) { this.blockchainQueries = blockchainQueries; this.synchronizer = synchronizer; this.protocolSchedule = protocolSchedule; @@ -107,6 +109,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods { this.miningCoordinator = miningCoordinator; this.supportedCapabilities = supportedCapabilities; this.apiConfiguration = apiConfiguration; + this.transactionSimulator = transactionSimulator; } @Override @@ -125,13 +128,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods { new EthGetBlockReceipts(blockchainQueries, protocolSchedule), new EthGetBlockTransactionCountByNumber(blockchainQueries), new EthGetBlockTransactionCountByHash(blockchainQueries), - new EthCall( - blockchainQueries, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap())), + new EthCall(blockchainQueries, transactionSimulator), new EthFeeHistory(protocolSchedule, blockchainQueries, miningCoordinator, apiConfiguration), new EthGetCode(blockchainQueries), new EthGetLogs(blockchainQueries, apiConfiguration.getMaxLogsRange()), @@ -155,20 +152,8 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods { new EthGetStorageAt(blockchainQueries), new EthSendRawTransaction(transactionPool), new EthSendTransaction(), - new EthEstimateGas( - blockchainQueries, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap())), - new EthCreateAccessList( - blockchainQueries, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap())), + new EthEstimateGas(blockchainQueries, transactionSimulator), + new EthCreateAccessList(blockchainQueries, transactionSimulator), new EthMining(miningCoordinator), new EthCoinbase(miningCoordinator), new EthProtocolVersion(supportedCapabilities), 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 2e68576fca..476da3ee30 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 @@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.ObservableMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -85,7 +86,8 @@ public class JsonRpcMethodsFactory { final EthPeers ethPeers, final Vertx consensusEngineServer, final ApiConfiguration apiConfiguration, - final Optional enodeDnsConfiguration) { + final Optional enodeDnsConfiguration, + final TransactionSimulator transactionSimulator) { final Map enabled = new HashMap<>(); if (!rpcApis.isEmpty()) { final JsonRpcMethod modules = new RpcModules(rpcApis); @@ -111,7 +113,7 @@ public class JsonRpcMethodsFactory { transactionPool, synchronizer, dataDir, - apiConfiguration), + transactionSimulator), new EeaJsonRpcMethods( blockchainQueries, protocolSchedule, transactionPool, privacyParameters), new ExecutionEngineJsonRpcMethods( @@ -131,7 +133,8 @@ public class JsonRpcMethodsFactory { transactionPool, miningCoordinator, supportedCapabilities, - apiConfiguration), + apiConfiguration, + transactionSimulator), new NetJsonRpcMethods( p2pNetwork, networkId, @@ -155,6 +158,7 @@ public class JsonRpcMethodsFactory { protocolSchedule, protocolContext, apiConfiguration, + transactionSimulator, metricsSystem), new TxPoolJsonRpcMethods(transactionPool), new PluginsJsonRpcMethods(namedPlugins)); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java index 4638e90a62..0a2c090e5a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java @@ -41,6 +41,7 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods { private final ProtocolSchedule protocolSchedule; private final ApiConfiguration apiConfiguration; private final ProtocolContext protocolContext; + private final TransactionSimulator transactionSimulator; private final MetricsSystem metricsSystem; TraceJsonRpcMethods( @@ -48,11 +49,13 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods { final ProtocolSchedule protocolSchedule, final ProtocolContext protocolContext, final ApiConfiguration apiConfiguration, + final TransactionSimulator transactionSimulator, final MetricsSystem metricsSystem) { this.blockchainQueries = blockchainQueries; this.protocolSchedule = protocolSchedule; this.protocolContext = protocolContext; this.apiConfiguration = apiConfiguration; + this.transactionSimulator = transactionSimulator; this.metricsSystem = metricsSystem; } @@ -76,29 +79,8 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods { new TraceTransaction( () -> new BlockTracer(blockReplay), protocolSchedule, blockchainQueries), new TraceBlock(protocolSchedule, blockchainQueries, metricsSystem), - new TraceCall( - blockchainQueries, - protocolSchedule, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap())), - new TraceCallMany( - blockchainQueries, - protocolSchedule, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap())), - new TraceRawTransaction( - protocolSchedule, - blockchainQueries, - new TransactionSimulator( - blockchainQueries.getBlockchain(), - blockchainQueries.getWorldStateArchive(), - protocolSchedule, - apiConfiguration.getGasCap()))); + new TraceCall(blockchainQueries, protocolSchedule, transactionSimulator), + new TraceCallMany(blockchainQueries, protocolSchedule, transactionSimulator), + new TraceRawTransaction(protocolSchedule, blockchainQueries, transactionSimulator)); } } 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 08cfc3d7bd..4aad65f43c 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 @@ -38,6 +38,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.plugin.data.SyncStatus; import org.hyperledger.besu.plugin.services.storage.DataStorageFormat; @@ -135,6 +136,13 @@ public abstract class AbstractEthGraphQLHttpServiceTest { final GraphQLDataFetchers dataFetchers = new GraphQLDataFetchers(supportedCapabilities); final GraphQL graphQL = GraphQLProvider.buildGraphQL(dataFetchers); + final var transactionSimulator = + new TransactionSimulator( + blockchain, + blockchainSetupUtil.getWorldArchive(), + blockchainSetupUtil.getProtocolSchedule(), + 0L); + service = new GraphQLHttpService( vertx, @@ -152,8 +160,8 @@ public abstract class AbstractEthGraphQLHttpServiceTest { miningCoordinatorMock, GraphQLContextType.SYNCHRONIZER, synchronizerMock, - GraphQLContextType.GAS_CAP, - 0L), + GraphQLContextType.TRANSACTION_SIMULATOR, + transactionSimulator), mock(EthScheduler.class)); service.start().join(); 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 db896a9485..75f84e1333 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 @@ -46,6 +46,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -169,6 +170,13 @@ public abstract class AbstractJsonRpcHttpServiceTest { final NatService natService = new NatService(Optional.empty()); + final var transactionSimulator = + new TransactionSimulator( + blockchainSetupUtil.getBlockchain(), + blockchainSetupUtil.getWorldArchive(), + blockchainSetupUtil.getProtocolSchedule(), + 0L); + return new JsonRpcMethodsFactory() .methods( CLIENT_NODE_NAME, @@ -201,7 +209,8 @@ public abstract class AbstractJsonRpcHttpServiceTest { mock(EthPeers.class), syncVertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + transactionSimulator); } protected void startService() throws Exception { 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 9113e15a12..b3f650302a 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 @@ -41,6 +41,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -138,7 +139,8 @@ public class JsonRpcHttpServiceHostAllowlistTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); service = createJsonRpcHttpService(); service.start().join(); 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 aacf115796..72e947436d 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 @@ -46,6 +46,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -169,7 +170,8 @@ public class JsonRpcHttpServiceLoginTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); service = createJsonRpcHttpService(); jwtAuth = service.authenticationService.get().getJwtAuthProvider(); service.start().join(); 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 ae66f2ac76..4db5c019c3 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 @@ -51,6 +51,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -235,7 +236,8 @@ public class JsonRpcHttpServiceRpcApisTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, @@ -346,7 +348,8 @@ public class JsonRpcHttpServiceRpcApisTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, 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 ec4f6c6e2b..6f67cdeb3f 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 @@ -41,6 +41,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; @@ -147,7 +148,8 @@ public class JsonRpcHttpServiceTestBase { ethPeersMock, vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); disabledRpcMethods = new HashMap<>(); addedRpcMethods = new HashSet<>(); 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 fa336169b9..d1348e5327 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 @@ -48,6 +48,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -152,7 +153,8 @@ public class JsonRpcHttpServiceTlsClientAuthTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); System.setProperty("javax.net.ssl.trustStore", CLIENT_AS_CA_CERT.getKeyStoreFile().toString()); System.setProperty( 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 b675430c49..dfa519f746 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 @@ -47,6 +47,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -140,7 +141,8 @@ class JsonRpcHttpServiceTlsMisconfigurationTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); } @AfterEach 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 de5683ad5c..705ccdd994 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 @@ -47,6 +47,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController; import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -141,7 +142,8 @@ public class JsonRpcHttpServiceTlsTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); service = createJsonRpcHttpService(createJsonRpcConfig()); service.start().join(); baseUrl = service.url(); 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 53785012d0..e1a5b1a75f 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 @@ -54,6 +54,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; +import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatService; @@ -205,7 +206,8 @@ public class WebSocketServiceLoginTest { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty())); + Optional.empty(), + mock(TransactionSimulator.class))); websocketMethods.putAll(rpcMethods); webSocketMessageHandlerSpy =