Refactor: Move rpcGasCap and rpcMaxLogsRange to apiConfiguration (#6195)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/6199/head
Gabriel-Trintinalia 1 year ago committed by GitHub
parent 6dea9a0f3d
commit 31a57e01e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java
  2. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  3. 8
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfiguration.java
  4. 9
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeConfigurationBuilder.java
  5. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java
  6. 1
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/PrivacyNode.java
  7. 35
      besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
  8. 4
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  9. 2
      besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
  10. 13
      besu/src/test/java/org/hyperledger/besu/RunnerBuilderTest.java
  11. 3
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  12. 18
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java
  13. 5
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  14. 2
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  15. 4
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcTestMethodsFactory.java
  16. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/ApiConfiguration.java
  17. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java
  18. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java
  19. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetLogs.java
  20. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/DebugJsonRpcMethods.java
  21. 19
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/EthJsonRpcMethods.java
  22. 13
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/JsonRpcMethodsFactory.java
  23. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/TraceJsonRpcMethods.java
  24. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/graphql/AbstractEthGraphQLHttpServiceTest.java
  25. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/AbstractJsonRpcHttpServiceTest.java
  26. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceHostAllowlistTest.java
  27. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceLoginTest.java
  28. 7
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceRpcApisTest.java
  29. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
  30. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsClientAuthTest.java
  31. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsMisconfigurationTest.java
  32. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTlsTest.java
  33. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetLogsTest.java
  34. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/WebSocketServiceLoginTest.java
  35. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  36. 5
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java
  37. 3
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/NodeSmartContractPermissioningControllerTest.java
  38. 3
      ethereum/permissioning/src/test/java/org/hyperledger/besu/ethereum/permissioning/TransactionSmartContractPermissioningControllerTest.java

@ -22,6 +22,7 @@ import org.hyperledger.besu.config.MergeConfigOptions;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.KeyPairUtil;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
@ -107,6 +108,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private final JsonRpcIpcConfiguration jsonRpcIpcConfiguration;
private final MetricsConfiguration metricsConfiguration;
private Optional<PermissioningConfiguration> permissioningConfiguration;
private final ApiConfiguration apiConfiguration;
private final GenesisConfigurationProvider genesisConfigProvider;
private final boolean devMode;
private final NetworkName network;
@ -139,6 +141,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
final JsonRpcIpcConfiguration jsonRpcIpcConfiguration,
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final ApiConfiguration apiConfiguration,
final Optional<String> keyfilePath,
final boolean devMode,
final NetworkName network,
@ -187,6 +190,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.jsonRpcIpcConfiguration = jsonRpcIpcConfiguration;
this.metricsConfiguration = metricsConfiguration;
this.permissioningConfiguration = permissioningConfiguration;
this.apiConfiguration = apiConfiguration;
this.genesisConfigProvider = genesisConfigProvider;
this.devMode = devMode;
this.network = network;
@ -806,4 +810,8 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public Map<String, String> getEnvironment() {
return environment;
}
public ApiConfiguration getApiConfiguration() {
return apiConfiguration;
}
}

@ -225,6 +225,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
final RunnerBuilder runnerBuilder = new RunnerBuilder();
runnerBuilder.permissioningConfiguration(node.getPermissioningConfiguration());
runnerBuilder.apiConfiguration(node.getApiConfiguration());
runnerBuilder
.vertx(Vertx.vertx())

@ -16,6 +16,7 @@ package org.hyperledger.besu.tests.acceptance.dsl.node.configuration;
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
@ -44,6 +45,7 @@ public class BesuNodeConfiguration {
private final JsonRpcIpcConfiguration jsonRpcIpcConfiguration;
private final MetricsConfiguration metricsConfiguration;
private final Optional<PermissioningConfiguration> permissioningConfiguration;
private final ApiConfiguration apiConfiguration;
private final Optional<String> keyFilePath;
private final boolean devMode;
private final GenesisConfigurationProvider genesisConfigProvider;
@ -78,6 +80,7 @@ public class BesuNodeConfiguration {
final JsonRpcIpcConfiguration jsonRpcIpcConfiguration,
final MetricsConfiguration metricsConfiguration,
final Optional<PermissioningConfiguration> permissioningConfiguration,
final ApiConfiguration apiConfiguration,
final Optional<String> keyFilePath,
final boolean devMode,
final NetworkName network,
@ -109,6 +112,7 @@ public class BesuNodeConfiguration {
this.jsonRpcIpcConfiguration = jsonRpcIpcConfiguration;
this.metricsConfiguration = metricsConfiguration;
this.permissioningConfiguration = permissioningConfiguration;
this.apiConfiguration = apiConfiguration;
this.keyFilePath = keyFilePath;
this.dataPath = dataPath;
this.devMode = devMode;
@ -167,6 +171,10 @@ public class BesuNodeConfiguration {
return permissioningConfiguration;
}
public ApiConfiguration getApiConfiguration() {
return apiConfiguration;
}
public Optional<String> getKeyFilePath() {
return keyFilePath;
}

@ -22,6 +22,8 @@ import static org.hyperledger.besu.pki.keystore.KeyStoreWrapper.KEYSTORE_TYPE_PK
import org.hyperledger.besu.cli.config.NetworkName;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.authentication.JwtAlgorithm;
@ -68,6 +70,7 @@ public class BesuNodeConfigurationBuilder {
private JsonRpcIpcConfiguration jsonRpcIpcConfiguration = new JsonRpcIpcConfiguration();
private MetricsConfiguration metricsConfiguration = MetricsConfiguration.builder().build();
private Optional<PermissioningConfiguration> permissioningConfiguration = Optional.empty();
private ApiConfiguration apiConfiguration = ImmutableApiConfiguration.builder().build();
private String keyFilePath = null;
private boolean devMode = true;
private GenesisConfigurationProvider genesisConfigProvider = ignore -> Optional.empty();
@ -490,6 +493,11 @@ public class BesuNodeConfigurationBuilder {
return this;
}
public BesuNodeConfigurationBuilder apiConfiguration(final ApiConfiguration apiConfiguration) {
this.apiConfiguration = apiConfiguration;
return this;
}
public BesuNodeConfiguration build() {
return new BesuNodeConfiguration(
name,
@ -501,6 +509,7 @@ public class BesuNodeConfigurationBuilder {
jsonRpcIpcConfiguration,
metricsConfiguration,
permissioningConfiguration,
apiConfiguration,
Optional.ofNullable(keyFilePath),
devMode,
network,

@ -69,6 +69,7 @@ public class BesuNodeFactory {
config.getJsonRpcIpcConfiguration(),
config.getMetricsConfiguration(),
config.getPermissioningConfiguration(),
config.getApiConfiguration(),
config.getKeyFilePath(),
config.isDevMode(),
config.getNetwork(),

@ -106,6 +106,7 @@ public class PrivacyNode implements AutoCloseable {
besuConfig.getJsonRpcIpcConfiguration(),
besuConfig.getMetricsConfiguration(),
besuConfig.getPermissioningConfiguration(),
besuConfig.getApiConfiguration(),
besuConfig.getKeyFilePath(),
besuConfig.isDevMode(),
besuConfig.getNetwork(),

@ -191,8 +191,6 @@ public class RunnerBuilder {
private RpcEndpointServiceImpl rpcEndpointServiceImpl;
private JsonRpcIpcConfiguration jsonRpcIpcConfiguration;
private boolean legacyForkIdEnabled;
private Optional<Long> rpcMaxLogsRange;
private Optional<Long> rpcGasCap;
private Optional<EnodeDnsConfiguration> enodeDnsConfiguration;
/**
@ -576,27 +574,6 @@ public class RunnerBuilder {
return this;
}
/**
* Add Rpc max logs range.
*
* @param rpcMaxLogsRange the rpc max logs range
* @return the runner builder
*/
public RunnerBuilder rpcMaxLogsRange(final Long rpcMaxLogsRange) {
this.rpcMaxLogsRange = rpcMaxLogsRange > 0 ? Optional.of(rpcMaxLogsRange) : Optional.empty();
return this;
}
/**
* Add Rpc gasLimit cap .
*
* @param rpcGasCap the rpc gas limit cap for transaction simulation methods
* @return the runner builder
*/
public RunnerBuilder rpcGasCap(final Long rpcGasCap) {
this.rpcGasCap = rpcGasCap > 0 ? Optional.of(rpcGasCap) : Optional.empty();
return this;
}
/**
* Add enode DNS configuration
*
@ -672,7 +649,10 @@ public class RunnerBuilder {
final TransactionSimulator transactionSimulator =
new TransactionSimulator(
context.getBlockchain(), context.getWorldStateArchive(), protocolSchedule, rpcGasCap);
context.getBlockchain(),
context.getWorldStateArchive(),
protocolSchedule,
apiConfiguration.getGasCap());
final Bytes localNodeId = nodeKey.getPublicKey().getEncodedBytes();
final Optional<NodePermissioningController> nodePermissioningController =
@ -921,7 +901,7 @@ public class RunnerBuilder {
graphQlContextMap.putIfAbsent(GraphQLContextType.SYNCHRONIZER, synchronizer);
graphQlContextMap.putIfAbsent(
GraphQLContextType.CHAIN_ID, protocolSchedule.getChainId().map(UInt256::valueOf));
graphQlContextMap.putIfAbsent(GraphQLContextType.GAS_CAP, rpcGasCap);
graphQlContextMap.putIfAbsent(GraphQLContextType.GAS_CAP, apiConfiguration.getGasCap());
final GraphQL graphQL;
try {
graphQL = GraphQLProvider.buildGraphQL(fetchers);
@ -1251,9 +1231,8 @@ public class RunnerBuilder {
dataDir,
besuController.getProtocolManager().ethContext().getEthPeers(),
consensusEngineServer,
rpcMaxLogsRange,
enodeDnsConfiguration,
rpcGasCap);
apiConfiguration,
enodeDnsConfiguration);
methods.putAll(besuController.getAdditionalJsonRpcMethods(jsonRpcApis));
final var pluginMethods =

@ -2491,6 +2491,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.gasPriceMinSupplier(
getMiningParameters().getMinTransactionGasPrice().getAsBigInteger()::longValueExact)
.gasPriceMax(apiGasPriceMax)
.maxLogsRange(rpcMaxLogsRange)
.gasCap(rpcGasCap)
.build();
}
@ -2953,8 +2955,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.ethstatsOptions(ethstatsOptions)
.storageProvider(keyValueStorageProvider(keyValueStorageName))
.rpcEndpointService(rpcEndpointServiceImpl)
.rpcMaxLogsRange(rpcMaxLogsRange)
.rpcGasCap(rpcGasCap)
.enodeDnsConfiguration(getEnodeDnsConfiguration())
.build();

@ -367,7 +367,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
blockchain, epochManager, bftBlockInterface().get(), validatorOverrides);
final TransactionSimulator transactionSimulator =
new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, Optional.empty());
new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, 0L);
transactionValidatorProvider =
new TransactionValidatorProvider(
blockchain, new ValidatorContractController(transactionSimulator), qbftForksSchedule);

@ -36,6 +36,7 @@ import org.hyperledger.besu.cryptoservices.KeyPairSecurityModule;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
@ -167,7 +168,7 @@ public final class RunnerBuilderTest {
.dataDir(dataDir.getRoot())
.storageProvider(mock(KeyValueStorageProvider.class, RETURNS_DEEP_STUBS))
.rpcEndpointService(new RpcEndpointServiceImpl())
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
runner.startEthereumMainLoop();
@ -212,7 +213,7 @@ public final class RunnerBuilderTest {
.dataDir(dataDir.getRoot())
.storageProvider(storageProvider)
.rpcEndpointService(new RpcEndpointServiceImpl())
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
runner.startEthereumMainLoop();
@ -272,7 +273,7 @@ public final class RunnerBuilderTest {
.storageProvider(mock(KeyValueStorageProvider.class, RETURNS_DEEP_STUBS))
.rpcEndpointService(new RpcEndpointServiceImpl())
.besuPluginContext(mock(BesuPluginContextImpl.class))
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
assertThat(runner.getJsonRpcPort()).isPresent();
@ -315,7 +316,7 @@ public final class RunnerBuilderTest {
.storageProvider(mock(KeyValueStorageProvider.class, RETURNS_DEEP_STUBS))
.rpcEndpointService(new RpcEndpointServiceImpl())
.besuPluginContext(mock(BesuPluginContextImpl.class))
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
assertThat(runner.getEngineJsonRpcPort()).isPresent();
@ -357,7 +358,7 @@ public final class RunnerBuilderTest {
.storageProvider(mock(KeyValueStorageProvider.class, RETURNS_DEEP_STUBS))
.rpcEndpointService(new RpcEndpointServiceImpl())
.besuPluginContext(mock(BesuPluginContextImpl.class))
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
assertThat(runner.getEngineJsonRpcPort()).isPresent();
@ -401,7 +402,7 @@ public final class RunnerBuilderTest {
.rpcEndpointService(new RpcEndpointServiceImpl())
.besuPluginContext(mock(BesuPluginContextImpl.class))
.networkingConfiguration(NetworkingConfiguration.create())
.rpcGasCap(50_000_000L)
.apiConfiguration(ImmutableApiConfiguration.builder().build())
.build();
assertThat(runner.getJsonRpcPort()).isPresent();

@ -33,6 +33,7 @@ import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.ethereum.GasLimitCalculator;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.ipc.JsonRpcIpcConfiguration;
@ -193,7 +194,7 @@ public final class RunnerTest {
.staticNodes(emptySet())
.storageProvider(new InMemoryKeyValueStorageProvider())
.rpcEndpointService(new RpcEndpointServiceImpl())
.rpcGasCap(50_000_000L);
.apiConfiguration(ImmutableApiConfiguration.builder().build());
Runner runnerBehind = null;
final Runner runnerAhead =

@ -63,6 +63,8 @@ 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.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
@ -149,6 +151,8 @@ public class BesuCommandTest extends CommandTestAbstract {
private static final GraphQLConfiguration DEFAULT_GRAPH_QL_CONFIGURATION;
private static final WebSocketConfiguration DEFAULT_WEB_SOCKET_CONFIGURATION;
private static final MetricsConfiguration DEFAULT_METRICS_CONFIGURATION;
private static final ApiConfiguration DEFAULT_API_CONFIGURATION;
private static final int GENESIS_CONFIG_TEST_CHAINID = 3141592;
private static final JsonObject GENESIS_VALID_JSON =
(new JsonObject())
@ -191,6 +195,7 @@ public class BesuCommandTest extends CommandTestAbstract {
DEFAULT_GRAPH_QL_CONFIGURATION = GraphQLConfiguration.createDefault();
DEFAULT_WEB_SOCKET_CONFIGURATION = WebSocketConfiguration.createDefault();
DEFAULT_METRICS_CONFIGURATION = MetricsConfiguration.builder().build();
DEFAULT_API_CONFIGURATION = ImmutableApiConfiguration.builder().build();
}
@Before
@ -258,7 +263,7 @@ public class BesuCommandTest extends CommandTestAbstract {
verify(mockRunnerBuilder).metricsConfiguration(eq(DEFAULT_METRICS_CONFIGURATION));
verify(mockRunnerBuilder).ethNetworkConfig(ethNetworkArg.capture());
verify(mockRunnerBuilder).autoLogBloomCaching(eq(true));
verify(mockRunnerBuilder).rpcMaxLogsRange(eq(5000L));
verify(mockRunnerBuilder).apiConfiguration(DEFAULT_API_CONFIGURATION);
verify(mockRunnerBuilder).build();
verify(mockControllerBuilderFactory)
@ -1575,13 +1580,15 @@ public class BesuCommandTest extends CommandTestAbstract {
@Test
public void rpcMaxLogsRangeOptionMustBeUsed() {
final long rpcMaxLogsRange = 150L;
parseCommand("--rpc-max-logs-range", Long.toString(rpcMaxLogsRange));
verify(mockRunnerBuilder).rpcMaxLogsRange(longArgumentCaptor.capture());
verify(mockRunnerBuilder).apiConfiguration(apiConfigurationCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(longArgumentCaptor.getValue()).isEqualTo(rpcMaxLogsRange);
assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(ImmutableApiConfiguration.builder().maxLogsRange((rpcMaxLogsRange)).build());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
@ -1592,10 +1599,11 @@ public class BesuCommandTest extends CommandTestAbstract {
final long rpcGasCap = 150L;
parseCommand("--rpc-gas-cap", Long.toString(rpcGasCap));
verify(mockRunnerBuilder).rpcGasCap(longArgumentCaptor.capture());
verify(mockRunnerBuilder).apiConfiguration(apiConfigurationCaptor.capture());
verify(mockRunnerBuilder).build();
assertThat(longArgumentCaptor.getValue()).isEqualTo(rpcGasCap);
assertThat(apiConfigurationCaptor.getValue())
.isEqualTo(ImmutableApiConfiguration.builder().gasCap((rpcGasCap)).build());
assertThat(commandOutput.toString(UTF_8)).isEmpty();
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();

@ -51,6 +51,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithm;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.cryptoservices.NodeKey;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.WebSocketConfiguration;
@ -213,6 +214,7 @@ public abstract class CommandTestAbstract {
permissioningConfigurationArgumentCaptor;
@Captor protected ArgumentCaptor<TransactionPoolConfiguration> transactionPoolConfigCaptor;
@Captor protected ArgumentCaptor<ApiConfiguration> apiConfigurationCaptor;
@Captor protected ArgumentCaptor<EthstatsOptions> ethstatsOptionsArgumentCaptor;
@ -312,9 +314,8 @@ public abstract class CommandTestAbstract {
when(mockRunnerBuilder.storageProvider(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.rpcEndpointService(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.legacyForkId(anyBoolean())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.rpcMaxLogsRange(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.apiConfiguration(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.enodeDnsConfiguration(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.rpcGasCap(any())).thenReturn(mockRunnerBuilder);
when(mockRunnerBuilder.build()).thenReturn(mockRunner);
final SignatureAlgorithm signatureAlgorithm = SignatureAlgorithmFactory.getInstance();

@ -414,7 +414,7 @@ public class TestContextBuilder {
final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks);
final TransactionSimulator transactionSimulator =
new TransactionSimulator(blockChain, worldStateArchive, protocolSchedule, Optional.empty());
new TransactionSimulator(blockChain, worldStateArchive, protocolSchedule, 0L);
final BlockValidatorProvider blockValidatorProvider =
BlockValidatorProvider.forkingValidatorProvider(

@ -20,6 +20,7 @@ import static org.mockito.Mockito.mock;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ImmutableApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManagerBuilder;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -187,8 +188,7 @@ public class JsonRpcTestMethodsFactory {
dataDir,
ethPeers,
Vertx.vertx(new VertxOptions().setWorkerPoolSize(1)),
Optional.empty(),
Optional.empty(),
ImmutableApiConfiguration.builder().build(),
Optional.empty());
}
}

@ -35,6 +35,7 @@ public abstract class ApiConfiguration {
}
@Value.Default
@Value.Auxiliary
public LongSupplier getGasPriceMinSupplier() {
return () -> 1_000_000_000L; // 1 GWei
}
@ -48,4 +49,14 @@ public abstract class ApiConfiguration {
public double getGasPriceFraction() {
return getGasPricePercentile() / 100.0;
}
@Value.Default
public Long getMaxLogsRange() {
return 5000L;
}
@Value.Default
public Long getGasCap() {
return 0L;
}
}

@ -209,7 +209,7 @@ public class BlockAdapterBase extends AdapterBase {
final ProtocolSchedule protocolSchedule =
environment.getGraphQlContext().get(GraphQLContextType.PROTOCOL_SCHEDULE);
final long bn = header.getNumber();
final Optional<Long> gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP);
final long gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP);
final TransactionSimulator transactionSimulator =
new TransactionSimulator(
query.getBlockchain(), query.getWorldStateArchive(), protocolSchedule, gasCap);

@ -92,7 +92,7 @@ public class PendingStateAdapter extends AdapterBase {
final BlockchainQueries query = getBlockchainQueries(environment);
final ProtocolSchedule protocolSchedule =
environment.getGraphQlContext().get(GraphQLContextType.PROTOCOL_SCHEDULE);
final Optional<Long> gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP);
final long gasCap = environment.getGraphQlContext().get(GraphQLContextType.GAS_CAP);
final TransactionSimulator transactionSimulator =
new TransactionSimulator(
query.getBlockchain(), query.getWorldStateArchive(), protocolSchedule, gasCap);

@ -27,7 +27,6 @@ import org.hyperledger.besu.ethereum.core.LogWithMetadata;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
@ -38,9 +37,9 @@ public class EthGetLogs implements JsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(EthGetLogs.class);
private final BlockchainQueries blockchain;
private final Optional<Long> maxLogRange;
private final long maxLogRange;
public EthGetLogs(final BlockchainQueries blockchain, final Optional<Long> maxLogRange) {
public EthGetLogs(final BlockchainQueries blockchain, final long maxLogRange) {
this.blockchain = blockchain;
this.maxLogRange = maxLogRange;
}
@ -86,8 +85,7 @@ public class EthGetLogs implements JsonRpcMethod {
.getBlockNumber(blockchain)
.orElseThrow(
() -> new Exception("toBlock not found: " + filter.getToBlock()));
if (maxLogRange.isPresent()
&& (toBlockNumber - fromBlockNumber) > maxLogRange.get()) {
if (maxLogRange > 0 && (toBlockNumber - fromBlockNumber) > maxLogRange) {
throw new IllegalArgumentException(
"Requested range exceeds maximum range limit");
}

@ -15,6 +15,7 @@
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;
@ -51,7 +52,6 @@ import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
@ -64,8 +64,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final TransactionPool transactionPool;
private final Synchronizer synchronizer;
private final Path dataDir;
private final Optional<Long> gasCap;
private final ApiConfiguration apiConfiguration;
DebugJsonRpcMethods(
final BlockchainQueries blockchainQueries,
@ -75,7 +74,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
final TransactionPool transactionPool,
final Synchronizer synchronizer,
final Path dataDir,
final Optional<Long> gasCap) {
final ApiConfiguration apiConfiguration) {
this.blockchainQueries = blockchainQueries;
this.protocolContext = protocolContext;
this.protocolSchedule = protocolSchedule;
@ -83,7 +82,7 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.transactionPool = transactionPool;
this.synchronizer = synchronizer;
this.dataDir = dataDir;
this.gasCap = gasCap;
this.apiConfiguration = apiConfiguration;
}
@Override
@ -128,6 +127,6 @@ public class DebugJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)));
apiConfiguration.getGasCap())));
}
}

@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.methods;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthAccounts;
@ -72,7 +73,6 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
@ -86,8 +86,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final TransactionPool transactionPool;
private final MiningCoordinator miningCoordinator;
private final Set<Capability> supportedCapabilities;
private final Optional<Long> maxLogRange;
private final Optional<Long> gasCap;
private final ApiConfiguration apiConfiguration;
public EthJsonRpcMethods(
final BlockchainQueries blockchainQueries,
@ -97,8 +96,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
final TransactionPool transactionPool,
final MiningCoordinator miningCoordinator,
final Set<Capability> supportedCapabilities,
final Optional<Long> maxLogRange,
final Optional<Long> gasCap) {
final ApiConfiguration apiConfiguration) {
this.blockchainQueries = blockchainQueries;
this.synchronizer = synchronizer;
this.protocolSchedule = protocolSchedule;
@ -106,8 +104,7 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
this.transactionPool = transactionPool;
this.miningCoordinator = miningCoordinator;
this.supportedCapabilities = supportedCapabilities;
this.maxLogRange = maxLogRange;
this.gasCap = gasCap;
this.apiConfiguration = apiConfiguration;
}
@Override
@ -132,10 +129,10 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)),
apiConfiguration.getGasCap())),
new EthFeeHistory(protocolSchedule, blockchainQueries.getBlockchain()),
new EthGetCode(blockchainQueries),
new EthGetLogs(blockchainQueries, maxLogRange),
new EthGetLogs(blockchainQueries, apiConfiguration.getMaxLogsRange()),
new EthGetProof(blockchainQueries),
new EthGetUncleCountByBlockHash(blockchainQueries),
new EthGetUncleCountByBlockNumber(blockchainQueries),
@ -162,14 +159,14 @@ public class EthJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)),
apiConfiguration.getGasCap())),
new EthCreateAccessList(
blockchainQueries,
new TransactionSimulator(
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)),
apiConfiguration.getGasCap())),
new EthMining(miningCoordinator),
new EthCoinbase(miningCoordinator),
new EthProtocolVersion(supportedCapabilities),

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -79,9 +80,8 @@ public class JsonRpcMethodsFactory {
final Path dataDir,
final EthPeers ethPeers,
final Vertx consensusEngineServer,
final Optional<Long> maxLogRange,
final Optional<EnodeDnsConfiguration> enodeDnsConfiguration,
final Optional<Long> gasCap) {
final ApiConfiguration apiConfiguration,
final Optional<EnodeDnsConfiguration> enodeDnsConfiguration) {
final Map<String, JsonRpcMethod> enabled = new HashMap<>();
if (!rpcApis.isEmpty()) {
final JsonRpcMethod modules = new RpcModules(rpcApis);
@ -106,7 +106,7 @@ public class JsonRpcMethodsFactory {
transactionPool,
synchronizer,
dataDir,
gasCap),
apiConfiguration),
new EeaJsonRpcMethods(
blockchainQueries, protocolSchedule, transactionPool, privacyParameters),
new ExecutionEngineJsonRpcMethods(
@ -123,8 +123,7 @@ public class JsonRpcMethodsFactory {
transactionPool,
miningCoordinator,
supportedCapabilities,
maxLogRange,
gasCap),
apiConfiguration),
new NetJsonRpcMethods(
p2pNetwork,
networkId,
@ -142,7 +141,7 @@ public class JsonRpcMethodsFactory {
new PrivxJsonRpcMethods(
blockchainQueries, protocolSchedule, transactionPool, privacyParameters),
new Web3JsonRpcMethods(clientVersion),
new TraceJsonRpcMethods(blockchainQueries, protocolSchedule, gasCap),
new TraceJsonRpcMethods(blockchainQueries, protocolSchedule, apiConfiguration),
new TxPoolJsonRpcMethods(transactionPool),
new PluginsJsonRpcMethods(namedPlugins));

@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.methods;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcApis;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceBlock;
@ -31,22 +32,21 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import java.util.Map;
import java.util.Optional;
public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods {
private final BlockchainQueries blockchainQueries;
private final ProtocolSchedule protocolSchedule;
private final Optional<Long> gasCap;
private final ApiConfiguration apiConfiguration;
TraceJsonRpcMethods(
final BlockchainQueries blockchainQueries,
final ProtocolSchedule protocolSchedule,
final Optional<Long> gasCap) {
final ApiConfiguration apiConfiguration) {
this.blockchainQueries = blockchainQueries;
this.protocolSchedule = protocolSchedule;
this.gasCap = gasCap;
this.apiConfiguration = apiConfiguration;
}
@Override
@ -72,7 +72,7 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)),
apiConfiguration.getGasCap())),
new TraceCallMany(
blockchainQueries,
protocolSchedule,
@ -80,7 +80,7 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)),
apiConfiguration.getGasCap())),
new TraceRawTransaction(
protocolSchedule,
blockchainQueries,
@ -88,6 +88,6 @@ public class TraceJsonRpcMethods extends ApiGroupJsonRpcMethods {
blockchainQueries.getBlockchain(),
blockchainQueries.getWorldStateArchive(),
protocolSchedule,
gasCap)));
apiConfiguration.getGasCap())));
}
}

@ -145,7 +145,7 @@ public abstract class AbstractEthGraphQLHttpServiceTest {
GraphQLContextType.SYNCHRONIZER,
synchronizerMock,
GraphQLContextType.GAS_CAP,
Optional.empty()),
0L),
Mockito.mock(EthScheduler.class));
service.start().join();

@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterIdGenerator;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
@ -190,8 +191,7 @@ public abstract class AbstractJsonRpcHttpServiceTest {
folder,
mock(EthPeers.class),
syncVertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty());
}

@ -21,6 +21,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -127,8 +128,7 @@ public class JsonRpcHttpServiceHostAllowlistTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
service = createJsonRpcHttpService();
service.start().join();

@ -23,6 +23,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.EthAccounts;
@ -156,8 +157,7 @@ public class JsonRpcHttpServiceLoginTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
service = createJsonRpcHttpService();
jwtAuth = service.authenticationService.get().getJwtAuthProvider();

@ -24,6 +24,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -229,8 +230,7 @@ public class JsonRpcHttpServiceRpcApisTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
final JsonRpcHttpService jsonRpcHttpService =
new JsonRpcHttpService(
@ -340,8 +340,7 @@ public class JsonRpcHttpServiceRpcApisTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
final JsonRpcHttpService jsonRpcHttpService =
new JsonRpcHttpService(

@ -20,6 +20,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -135,8 +136,7 @@ public class JsonRpcHttpServiceTestBase {
folder,
ethPeersMock,
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
service = createJsonRpcHttpService(createLimitedJsonRpcConfig());
service.start().join();

@ -25,6 +25,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -140,8 +141,7 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
System.setProperty("javax.net.ssl.trustStore", CLIENT_AS_CA_CERT.getKeyStoreFile().toString());

@ -24,6 +24,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -129,8 +130,7 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
tempDir.getRoot(),
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
}

@ -24,6 +24,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.health.HealthService;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.filter.FilterManager;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
@ -130,8 +131,7 @@ public class JsonRpcHttpServiceTlsTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
service = createJsonRpcHttpService(createJsonRpcConfig());
service.start().join();

@ -53,7 +53,7 @@ public class EthGetLogsTest {
private EthGetLogs method;
@Mock BlockchainQueries blockchainQueries;
@Mock Optional<Long> maxLogRange;
long maxLogRange;
@BeforeEach
public void setUp() {
@ -276,10 +276,8 @@ public class EthGetLogsTest {
@Test
public void shouldFailIfParamsExceedMaxRange() {
final JsonRpcRequestContext request = buildRequest(0, 50);
when(maxLogRange.isPresent()).thenReturn(true);
when(maxLogRange.get()).thenReturn(20L);
maxLogRange = 20L;
method = new EthGetLogs(blockchainQueries, maxLogRange);
final JsonRpcResponse response = method.response(request);
assertThat(response).isInstanceOf(JsonRpcErrorResponse.class);
final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response;

@ -25,6 +25,7 @@ import static org.mockito.Mockito.spy;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.ApiConfiguration;
import org.hyperledger.besu.ethereum.api.handlers.TimeoutOptions;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcConfiguration;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcHttpService;
@ -191,8 +192,7 @@ public class WebSocketServiceLoginTest {
folder,
mock(EthPeers.class),
vertx,
Optional.empty(),
Optional.empty(),
mock(ApiConfiguration.class),
Optional.empty()));
websocketMethods.putAll(rpcMethods);

@ -79,13 +79,13 @@ public class TransactionSimulator {
private final Blockchain blockchain;
private final WorldStateArchive worldStateArchive;
private final ProtocolSchedule protocolSchedule;
private final Optional<Long> rpcGasCap;
private final long rpcGasCap;
public TransactionSimulator(
final Blockchain blockchain,
final WorldStateArchive worldStateArchive,
final ProtocolSchedule protocolSchedule,
final Optional<Long> rpcGasCap) {
final long rpcGasCap) {
this.blockchain = blockchain;
this.worldStateArchive = worldStateArchive;
this.protocolSchedule = protocolSchedule;
@ -217,8 +217,8 @@ public class TransactionSimulator {
callParams.getGasLimit() >= 0
? callParams.getGasLimit()
: blockHeaderToProcess.getGasLimit();
if (rpcGasCap.isPresent()) {
final long gasCap = rpcGasCap.get();
if (rpcGasCap > 0) {
final long gasCap = rpcGasCap;
if (gasCap < gasLimit) {
gasLimit = gasCap;
LOG.info("Capping gasLimit to " + gasCap);

@ -91,10 +91,9 @@ public class TransactionSimulatorTest {
@BeforeEach
public void setUp() {
this.transactionSimulator =
new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, Optional.empty());
new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, 0);
this.cappedTransactionSimulator =
new TransactionSimulator(
blockchain, worldStateArchive, protocolSchedule, Optional.of(GASCAP));
new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule, GASCAP);
}
@Test

@ -38,7 +38,6 @@ import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import java.io.IOException;
import java.util.Optional;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.io.Resources;
@ -71,7 +70,7 @@ public class NodeSmartContractPermissioningControllerTest {
genesisState.writeStateTo(worldArchive.getMutable());
final TransactionSimulator ts =
new TransactionSimulator(blockchain, worldArchive, protocolSchedule, Optional.empty());
new TransactionSimulator(blockchain, worldArchive, protocolSchedule, 0L);
final Address contractAddress = Address.fromHexString(contractAddressString);
when(metricsSystem.createCounter(

@ -41,7 +41,6 @@ import org.hyperledger.besu.plugin.services.metrics.Counter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Optional;
import com.google.common.io.Resources;
import org.apache.tuweni.bytes.Bytes;
@ -72,7 +71,7 @@ public class TransactionSmartContractPermissioningControllerTest {
genesisState.writeStateTo(worldArchive.getMutable());
final TransactionSimulator ts =
new TransactionSimulator(blockchain, worldArchive, protocolSchedule, Optional.empty());
new TransactionSimulator(blockchain, worldArchive, protocolSchedule, 0L);
final Address contractAddress = Address.fromHexString(contractAddressString);
when(metricsSystem.createCounter(

Loading…
Cancel
Save