Skip to content

Commit

Permalink
Move calldata limit validation in the Linea plugin (hyperledger#23)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored Nov 9, 2023
1 parent 3ecd3f7 commit 40d8617
Show file tree
Hide file tree
Showing 39 changed files with 47 additions and 911 deletions.
21 changes: 6 additions & 15 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.linea.LineaParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.FlexiblePrivacyPrecompiledContract;
import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration;
Expand Down Expand Up @@ -793,8 +792,6 @@ public Runner build() {

Optional<JsonRpcHttpService> jsonRpcHttpService = Optional.empty();

final LineaParameters lineaParameters = besuController.getLineaParameters();

if (jsonRpcConfiguration.isEnabled()) {
final Map<String, JsonRpcMethod> nonEngineMethods =
jsonRpcMethods(
Expand Down Expand Up @@ -822,8 +819,7 @@ public Runner build() {
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
rpcEndpointServiceImpl,
lineaParameters);
rpcEndpointServiceImpl);

jsonRpcHttpService =
Optional.of(
Expand Down Expand Up @@ -867,8 +863,7 @@ public Runner build() {
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
rpcEndpointServiceImpl,
lineaParameters);
rpcEndpointServiceImpl);

final Optional<AuthenticationService> authToUse =
engineJsonRpcConfiguration.get().isAuthenticationEnabled()
Expand Down Expand Up @@ -961,8 +956,7 @@ public Runner build() {
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
rpcEndpointServiceImpl,
lineaParameters);
rpcEndpointServiceImpl);

createLogsSubscriptionService(
context.getBlockchain(),
Expand Down Expand Up @@ -1045,8 +1039,7 @@ public Runner build() {
natService,
besuPluginContext.getNamedPlugins(),
dataDir,
rpcEndpointServiceImpl,
lineaParameters);
rpcEndpointServiceImpl);

jsonRpcIpcService =
Optional.of(
Expand Down Expand Up @@ -1213,8 +1206,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
final NatService natService,
final Map<String, BesuPlugin> namedPlugins,
final Path dataDir,
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final LineaParameters lineaParameters) {
final RpcEndpointServiceImpl rpcEndpointServiceImpl) {
// sync vertx for engine consensus API, to process requests in FIFO order;
final Vertx consensusEngineServer = Vertx.vertx(new VertxOptions().setWorkerPoolSize(1));

Expand Down Expand Up @@ -1248,8 +1240,7 @@ private Map<String, JsonRpcMethod> jsonRpcMethods(
besuController.getProtocolManager().ethContext().getEthPeers(),
consensusEngineServer,
rpcMaxLogsRange,
enodeDnsConfiguration,
lineaParameters);
enodeDnsConfiguration);
methods.putAll(besuController.getAdditionalJsonRpcMethods(jsonRpcApis));

final var pluginMethods =
Expand Down
6 changes: 1 addition & 5 deletions besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.cli.options.unstable.EvmOptions;
import org.hyperledger.besu.cli.options.unstable.IpcOptions;
import org.hyperledger.besu.cli.options.unstable.LineaOptions;
import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions;
import org.hyperledger.besu.cli.options.unstable.NatOptions;
import org.hyperledger.besu.cli.options.unstable.NativeLibraryOptions;
Expand Down Expand Up @@ -302,7 +301,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final NodePrivateKeyFileOption nodePrivateKeyFileOption =
NodePrivateKeyFileOption.create();
private final LoggingLevelOption loggingLevelOption = LoggingLevelOption.create();
private final LineaOptions unstableLineaOptions = LineaOptions.create();

@CommandLine.ArgGroup(validate = false, heading = "@|bold Tx Pool Common Options|@%n")
final org.hyperledger.besu.cli.options.stable.TransactionPoolOptions
Expand Down Expand Up @@ -1533,7 +1531,6 @@ private void handleUnstableOptions() {
.put("EVM Options", unstableEvmOptions)
.put("IPC Options", unstableIpcOptions)
.put("Chain Data Pruning Options", unstableChainPruningOptions)
.put("Linea Options", unstableLineaOptions)
.build();

UnstableOptionsSubCommand.createUnstableOptions(commandLine, unstableOptions);
Expand Down Expand Up @@ -2169,8 +2166,7 @@ public BesuControllerBuilder getControllerBuilder() {
.maxRemotelyInitiatedPeers(maxRemoteInitiatedPeers)
.randomPeerPriority(p2PDiscoveryOptionGroup.randomPeerPriority)
.chainPruningConfiguration(unstableChainPruningOptions.toDomainObject())
.cacheLastBlocks(numberOfblocksToCache)
.lineaParameters(unstableLineaOptions.toDomainObject());
.cacheLastBlocks(numberOfblocksToCache);
}

@NotNull
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.state.SyncState;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.linea.LineaParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.p2p.config.SubProtocolConfiguration;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
Expand Down Expand Up @@ -78,7 +77,6 @@ public class BesuController implements java.io.Closeable {
private final SyncState syncState;
private final EthPeers ethPeers;
private final StorageProvider storageProvider;
private final LineaParameters lineaParameters;

/**
* Instantiates a new Besu controller.
Expand Down Expand Up @@ -116,8 +114,7 @@ public class BesuController implements java.io.Closeable {
final List<Closeable> closeables,
final PluginServiceFactory additionalPluginServices,
final EthPeers ethPeers,
final StorageProvider storageProvider,
final LineaParameters lineaParameters) {
final StorageProvider storageProvider) {
this.protocolSchedule = protocolSchedule;
this.protocolContext = protocolContext;
this.ethProtocolManager = ethProtocolManager;
Expand All @@ -135,7 +132,6 @@ public class BesuController implements java.io.Closeable {
this.additionalPluginServices = additionalPluginServices;
this.ethPeers = ethPeers;
this.storageProvider = storageProvider;
this.lineaParameters = lineaParameters;
}

/**
Expand Down Expand Up @@ -297,15 +293,6 @@ public PluginServiceFactory getAdditionalPluginServices() {
return additionalPluginServices;
}

/**
* Gets linea-specific parameters
*
* @return configured LineaParameters
*/
public LineaParameters getLineaParameters() {
return lineaParameters;
}

/** The type Builder. */
public static class Builder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolFactory;
import org.hyperledger.besu.ethereum.linea.LineaParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
Expand Down Expand Up @@ -142,8 +141,6 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
protected ObservableMetricsSystem metricsSystem;
/** The Privacy parameters. */
protected PrivacyParameters privacyParameters;
/** The Linea parameters. */
protected LineaParameters lineaParameters = LineaParameters.DEFAULT;
/** The Pki block creation configuration. */
protected Optional<PkiBlockCreationConfiguration> pkiBlockCreationConfiguration =
Optional.empty();
Expand Down Expand Up @@ -589,7 +586,6 @@ public BesuController build() {
checkNotNull(gasLimitCalculator, "Missing gas limit calculator");
checkNotNull(evmConfiguration, "Missing evm config");
checkNotNull(networkingConfiguration, "Missing network configuration");
checkNotNull(lineaParameters, "Missing Linea parameters");
prepForBuild();

final ProtocolSchedule protocolSchedule = createProtocolSchedule();
Expand Down Expand Up @@ -805,8 +801,7 @@ public BesuController build() {
closeables,
additionalPluginServices,
ethPeers,
storageProvider,
lineaParameters);
storageProvider);
}

/**
Expand Down Expand Up @@ -1153,15 +1148,4 @@ protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protoc
*/
protected abstract PluginServiceFactory createAdditionalPluginServices(
final Blockchain blockchain, final ProtocolContext protocolContext);

/**
* Setter for LineaParameters .
*
* @param lineaParameters linea params to add to controller builder.
* @return the controller builder.
*/
public BesuControllerBuilder lineaParameters(final LineaParameters lineaParameters) {
this.lineaParameters = lineaParameters;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ protected PluginServiceFactory createAdditionalPluginServices(
@Override
protected ProtocolSchedule createProtocolSchedule() {
return MainnetProtocolSchedule.fromConfig(
configOptionsSupplier.get(),
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
lineaParameters);
configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled, evmConfiguration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected MiningCoordinator createTransitionMiningCoordinator(
@Override
protected ProtocolSchedule createProtocolSchedule() {
return MergeProtocolSchedule.create(
configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled, lineaParameters);
configOptionsSupplier.get(), privacyParameters, isRevertReasonEnabled);
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions besu/src/test/java/org/hyperledger/besu/LineaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.hyperledger.besu.ethereum.eth.sync.SyncMode;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.linea.LineaParameters;
import org.hyperledger.besu.ethereum.p2p.config.NetworkingConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
Expand Down Expand Up @@ -82,7 +81,6 @@ private BesuController setUpController(final String genesisFile) {
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkConfiguration(NetworkingConfiguration.create())
.lineaParameters(LineaParameters.DEFAULT)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ public void initMocks() throws Exception {
when(mockControllerBuilder.transactionSelectorFactory(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.pluginTransactionValidatorFactory(any()))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.lineaParameters(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.besuComponent(any(BesuComponent.class)))
.thenReturn(mockControllerBuilder);
when(mockControllerBuilder.cacheLastBlocks(any())).thenReturn(mockControllerBuilder);
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/linea_goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"lineaBlock": 0,
"londonBlock": 0,
"clique":{
"blockperiodseconds":12,
"epochlength":30000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.linea.LineaParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
Expand Down Expand Up @@ -47,8 +46,7 @@ public class MergeProtocolSchedule {
*/
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(
config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, LineaParameters.DEFAULT);
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
}

/**
Expand All @@ -57,14 +55,12 @@ public static ProtocolSchedule create(
* @param config the config
* @param privacyParameters the privacy parameters
* @param isRevertReasonEnabled the is revert reason enabled
* @param lineaParameters parameters for linea
* @return the protocol schedule
*/
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final LineaParameters lineaParameters) {
final boolean isRevertReasonEnabled) {

Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications =
new HashMap<>();
Expand All @@ -81,8 +77,7 @@ public static ProtocolSchedule create(
new ProtocolSpecAdapters(postMergeModifications),
privacyParameters,
isRevertReasonEnabled,
EvmConfiguration.DEFAULT,
lineaParameters)
EvmConfiguration.DEFAULT)
.createProtocolSchedule();
}

Expand Down
Loading

0 comments on commit 40d8617

Please sign in to comment.