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 9effaff4d44..0dafbf76fea 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 @@ -459,7 +459,8 @@ public BesuController provideBesuController( final BesuControllerBuilder builder, final MetricsSystem metricsSystem, final KeyValueStorageProvider storageProvider, - final MiningConfiguration miningConfiguration) { + final MiningConfiguration miningConfiguration, + final ApiConfiguration apiConfiguration) { builder .synchronizerConfiguration(synchronizerConfiguration) @@ -474,6 +475,7 @@ public BesuController provideBesuController( .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 0f398fae1eb..f26ace21f18 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -698,12 +698,7 @@ public Runner build() { 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 = @@ -867,7 +862,8 @@ public Runner build() { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); jsonRpcHttpService = Optional.of( @@ -912,7 +908,8 @@ public Runner build() { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); final Optional authToUse = engineJsonRpcConfiguration.get().isAuthenticationEnabled() @@ -959,7 +956,7 @@ public Runner build() { 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); @@ -1007,7 +1004,8 @@ public Runner build() { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); createLogsSubscriptionService( context.getBlockchain(), subscriptionManager, privacyParameters, blockchainQueries); @@ -1087,7 +1085,8 @@ public Runner build() { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); jsonRpcIpcService = Optional.of( @@ -1126,7 +1125,8 @@ public Runner build() { natService, besuPluginContext.getNamedPlugins(), dataDir, - rpcEndpointServiceImpl); + rpcEndpointServiceImpl, + transactionSimulator); } else { inProcessRpcMethods = Map.of(); } @@ -1288,7 +1288,8 @@ private Map jsonRpcMethods( 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)); @@ -1325,7 +1326,8 @@ private Map jsonRpcMethods( 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 e2c657dd18d..4f5f8fbc7ca 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -136,7 +136,6 @@ 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; @@ -342,6 +341,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; @@ -717,7 +718,6 @@ static class PrivacyOptionGroup { private WebSocketConfiguration webSocketConfiguration; private JsonRpcIpcConfiguration jsonRpcIpcConfiguration; private InProcessRpcConfiguration inProcessRpcConfiguration; - private ApiConfiguration apiConfiguration; private MetricsConfiguration metricsConfiguration; private Optional permissioningConfiguration; private Optional p2pTLSConfiguration; @@ -1244,7 +1244,7 @@ private Runner buildRunner() { webSocketConfiguration, jsonRpcIpcConfiguration, inProcessRpcConfiguration, - apiConfiguration, + apiConfigurationSupplier.get(), metricsConfiguration, permissioningConfiguration, staticNodes, @@ -1256,11 +1256,7 @@ private void startPlugins(final Runner runner) { 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( @@ -1454,7 +1450,6 @@ private void validateOptions() { validateTransactionPoolOptions(); validateDataStorageOptions(); validateGraphQlOptions(); - validateApiOptions(); validateConsensusSyncCompatibilityOptions(); validatePluginOptions(); p2pTLSConfigOptions.checkP2PTLSOptionsDependencies(logger, commandLine); @@ -1710,7 +1705,6 @@ private void configure() throws Exception { 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()) { @@ -1828,6 +1822,7 @@ public BesuControllerBuilder setupControllerBuilder() { .chainPruningConfiguration(unstableChainPruningOptions.toDomainObject()) .cacheLastBlocks(numberOfblocksToCache) .genesisStateHashCacheEnabled(genesisStateHashCacheEnabled) + .apiConfiguration(apiConfigurationSupplier.get()) .besuComponent(besuComponent); if (DataStorageFormat.BONSAI.equals(getDataStorageConfiguration().getDataStorageFormat())) { final DiffBasedSubStorageConfiguration subStorageConfiguration = @@ -2153,6 +2148,11 @@ private MiningConfiguration getMiningParameters() { 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 238e5c3c1c0..25a306d3a29 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.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 DataStorageConfiguration getDataStorageConfiguration() { 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 96de7a2af0c..fdce6a08e4a 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.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.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 BesuControllerBuilder synchronizerConfiguration( 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 BesuController build() { 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 BesuController build() { genesisState.writeStateTo(worldStateArchive.getMutable()); } + transactionSimulator = + new TransactionSimulator( + blockchain, worldStateArchive, protocolSchedule, apiConfiguration.getGasCap()); + final var consensusContext = createConsensusContext(blockchain, worldStateArchive, protocolSchedule); @@ -795,7 +819,8 @@ public BesuController build() { 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 b6f579ea68e..e8c08d8a473 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.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 @@ protected BftContext createConsensusContext( 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 ff205e87519..bad87162fd2 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.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 @@ BesuController provideBesuController( .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 a79b6644587..beff4b8586b 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.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 @@ BesuController provideBesuController( .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 305d786b8bd..3e905d94416 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.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 @@ BesuController provideBesuController( .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 4239cbdc344..cf995c25e07 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 @@ private BesuController getController( .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 e76c06fe2d4..a0e596a0005 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.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 @@ private static BesuController createController(final @TempDir Path dataDir) thro .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 2b534660ed2..383ef1a3a1a 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.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 @@ protected BesuController createController(final GenesisConfigFile genesisConfigF .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 9f405d4cb39..2f707edc6f4 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.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 void blockImport() throws IOException { .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 void blockImportRejectsBadPow() throws IOException { .evmConfiguration(EvmConfiguration.DEFAULT) .networkConfiguration(NetworkingConfiguration.create()) .besuComponent(mock(BesuComponent.class)) + .apiConfiguration(ImmutableApiConfiguration.builder().build()) .build(); assertThatThrownBy( @@ -145,6 +148,7 @@ public void blockImportCanSkipPow() throws IOException { .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 72396593985..78f782d5e55 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 void initMocks() throws Exception { 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 e17fb04acf0..26364087492 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.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 void setup() throws JsonProcessingException { .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 32924e29f92..f05ea666a0d 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.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 void setup() throws JsonProcessingException { .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 47971b6442e..7c4a370beb0 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.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 @@ MergeBesuControllerBuilder visitWithMockConfigs(final MergeBesuControllerBuilder .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 2a65b1e7cb0..f9918036ecb 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.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 JsonRpcTestMethodsFactory(final BlockchainImporter importer) { this.blockchainQueries = new BlockchainQueries( protocolSchedule, blockchain, stateArchive, MiningConfiguration.newDefault()); + + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public JsonRpcTestMethodsFactory( @@ -117,6 +122,8 @@ public JsonRpcTestMethodsFactory( stateArchive, MiningConfiguration.newDefault()); this.synchronizer = mock(Synchronizer.class); + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public JsonRpcTestMethodsFactory( @@ -137,6 +144,8 @@ public JsonRpcTestMethodsFactory( blockchain, stateArchive, MiningConfiguration.newDefault()); + this.transactionSimulator = + new TransactionSimulator(blockchain, stateArchive, protocolSchedule, 0L); } public BlockchainQueries getBlockchainQueries() { @@ -219,6 +228,7 @@ public Map methods() { 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 c12f7578c6c..f689f191e6c 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 6d5b696353a..945727fda24 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 @@ private Optional executeCall(final DataFetchingEnvironment environme 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 49f6bc890f9..9ec80fbedd0 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 Optional getCall(final DataFetchingEnvironment environment) { 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 90ae97c5c4f..9ca0bb6c1a4 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 @@ protected Map create() { 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 de5662692ff..0ddcb564963 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 EthJsonRpcMethods( 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 EthJsonRpcMethods( this.miningCoordinator = miningCoordinator; this.supportedCapabilities = supportedCapabilities; this.apiConfiguration = apiConfiguration; + this.transactionSimulator = transactionSimulator; } @Override @@ -125,13 +128,7 @@ protected Map create() { 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 @@ protected Map create() { 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 2e68576fca7..476da3ee304 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.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 Map methods( 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 Map methods( transactionPool, synchronizer, dataDir, - apiConfiguration), + transactionSimulator), new EeaJsonRpcMethods( blockchainQueries, protocolSchedule, transactionPool, privacyParameters), new ExecutionEngineJsonRpcMethods( @@ -131,7 +133,8 @@ public Map methods( transactionPool, miningCoordinator, supportedCapabilities, - apiConfiguration), + apiConfiguration, + transactionSimulator), new NetJsonRpcMethods( p2pNetwork, networkId, @@ -155,6 +158,7 @@ public Map methods( 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 4638e90a625..0a2c090e5a5 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 @@ protected Map create() { 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 08cfc3d7bd4..4aad65f43c8 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.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 void setupTest() throws Exception { 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 void setupTest() throws Exception { 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 db896a94856..75f84e1333f 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.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 @@ protected Map getRpcMethods( 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 @@ protected Map getRpcMethods( 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 9113e15a12d..b3f650302a9 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.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 void initServerAndClient() throws Exception { 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 aacf1157965..72e947436dd 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.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 static void initServerAndClient() throws Exception { 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 ae66f2ac760..4db5c019c3e 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.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 @@ private JsonRpcHttpService createJsonRpcHttpServiceWithRpcApis(final JsonRpcConf mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty()); + Optional.empty(), + mock(TransactionSimulator.class)); final JsonRpcHttpService jsonRpcHttpService = new JsonRpcHttpService( vertx, @@ -346,7 +348,8 @@ private JsonRpcHttpService createJsonRpcHttpService( 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 ec4f6c6e2b4..6f67cdeb3f9 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.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 static void initServerAndClient() throws Exception { 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 fa336169b9a..d1348e5327e 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.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 void initServer() throws Exception { 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 b675430c49e..dfa519f7464 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.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 @@ public void beforeEach() { 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 de5683ad5c0..705ccdd994c 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.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 void initServer() throws Exception { 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 53785012d09..e1a5b1a75fd 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.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 void before() throws URISyntaxException { mock(EthPeers.class), vertx, mock(ApiConfiguration.class), - Optional.empty())); + Optional.empty(), + mock(TransactionSimulator.class))); websocketMethods.putAll(rpcMethods); webSocketMessageHandlerSpy =