Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,7 @@ private String generateConfigurationOverview() {
.setTxPoolImplementation(buildTransactionPoolConfiguration().getTxPoolImplementation())
.setWorldStateUpdateMode(unstableEvmOptions.toDomainObject().worldUpdaterMode())
.setEnabledOpcodeOptimizations(unstableEvmOptions.toDomainObject().enableOptimizedOpcodes())
.setEvmV2(unstableEvmOptions.toDomainObject().enableEvmV2())
.setPluginContext(this.besuPluginContext)
.setHistoryExpiryPruneEnabled(getDataStorageConfiguration().getHistoryExpiryPruneEnabled())
.setBlobDBSettings(rocksDBPlugin.getBlobDBSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ConfigurationOverviewBuilder {
private TransactionPoolConfiguration.Implementation txPoolImplementation;
private EvmConfiguration.WorldUpdaterMode worldStateUpdateMode;
private boolean enabledOpcodeOptimizations;
private boolean evmV2 = false;
private Map<String, String> environment;
private BesuPluginContextImpl besuPluginContext;
private boolean isHistoryExpiryPruneEnabled = false;
Expand Down Expand Up @@ -320,6 +321,17 @@ public ConfigurationOverviewBuilder setEnabledOpcodeOptimizations(
return this;
}

/**
* Sets whether the experimental EVM v2 (long[] stack) is enabled.
*
* @param evmV2 true if --Xevm-go-fast / --Xevm-v2 is enabled
* @return the builder
*/
public ConfigurationOverviewBuilder setEvmV2(final boolean evmV2) {
this.evmV2 = evmV2;
return this;
}

/**
* Sets the engine jwt file path.
*
Expand Down Expand Up @@ -513,7 +525,11 @@ public String build() {

lines.add("Using " + worldStateUpdateMode + " worldstate update mode");

lines.add("Opcode optimizations " + (enabledOpcodeOptimizations ? "enabled" : "disabled"));
if (evmV2) {
lines.add("Experimental EVM v2 (long[] stack) enabled");
} else {
lines.add("Opcode optimizations " + (enabledOpcodeOptimizations ? "enabled" : "disabled"));
}

if (isParallelTxProcessingEnabled) {
lines.add("Parallel transaction processing enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class EvmOptions implements CLIOptions<EvmConfiguration> {
/** The constant OPTIMIZED_OP_CODES. */
public static final String OPTIMIZED_OP_CODES = "--Xevm-optimized-opcodes";

/** The constant EVM_GO_FAST. */
public static final String EVM_GO_FAST = "--Xevm-go-fast";

/** Default constructor. */
EvmOptions() {}

Expand Down Expand Up @@ -72,10 +75,18 @@ public static EvmOptions create() {
arity = "1")
private boolean enableOptimizedOpcodes = true;

@CommandLine.Option(
names = {EVM_GO_FAST, "--Xevm-v2"},
description = "Enable experimental EVM v2 with long[] stack representation (default: false)",
fallbackValue = "false",
hidden = true,
arity = "1")
private boolean enableEvmV2 = false;

@Override
public EvmConfiguration toDomainObject() {
return new EvmConfiguration(
jumpDestCacheWeightKilobytes, worldstateUpdateMode, enableOptimizedOpcodes);
jumpDestCacheWeightKilobytes, worldstateUpdateMode, enableOptimizedOpcodes, enableEvmV2);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,13 @@ void execute(final InputStream input, final PrintWriter output, final String[] a
addForkHelp(commandLine.getSubcommands().get("t8n"));
addForkHelp(commandLine.getSubcommands().get("t8n-server"));

commandLine.setExecutionStrategy(new CommandLine.RunLast());
commandLine.setExecutionStrategy(
parseResult -> {
if (daggerOptions.isEvmV2Enabled()) {
out.println("EVM v2 (long[] stack) enabled");
}
return new CommandLine.RunLast().execute(parseResult);
});
commandLine.execute(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,29 @@ BlockParameter provideBlockParameter() {
arity = "1")
private boolean enableOptimizedOpcodes = true;

@CommandLine.Option(
names = {"--Xevm-go-fast", "--Xevm-v2"},
description = "Enable experimental EVM v2 with long[] stack representation (default: false)",
fallbackValue = "false",
defaultValue = "false",
hidden = true,
arity = "1")
private boolean enableEvmV2 = false;

@Provides
@Singleton
EvmConfiguration provideEvmConfiguration() {
return new EvmConfiguration(
jumpDestCacheWeightKilobytes, worldstateUpdateMode, enableOptimizedOpcodes);
jumpDestCacheWeightKilobytes, worldstateUpdateMode, enableOptimizedOpcodes, enableEvmV2);
}

/**
* Returns whether experimental EVM v2 is enabled. Used by the tool to emit a startup notice.
*
* @return true if EVM v2 is enabled
*/
public boolean isEvmV2Enabled() {
return enableEvmV2;
}

/** Default constructor for the EvmToolCommandOptionsModule class. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* @param jumpDestCacheWeightKB the jump destination cache weight in kb
* @param worldUpdaterMode the world updater mode
* @param enableOptimizedOpcodes enable optimized implementation of certain opcodes in the EVM
* @param enableEvmV2 enable experimental EVM v2 with long[] stack representation
* @param evmStackSize the maximum evm stack size
* @param maxCodeSizeOverride An optional override of the maximum code size set by the EVM fork
* @param maxInitcodeSizeOverride An optional override of the maximum initcode size set by the EVM
Expand All @@ -34,6 +35,7 @@ public record EvmConfiguration(
long jumpDestCacheWeightKB,
WorldUpdaterMode worldUpdaterMode,
boolean enableOptimizedOpcodes,
boolean enableEvmV2,
Integer evmStackSize,
Optional<Integer> maxCodeSizeOverride,
Optional<Integer> maxInitcodeSizeOverride) {
Expand All @@ -50,7 +52,7 @@ public enum WorldUpdaterMode {

/** The constant DEFAULT. */
public static final EvmConfiguration DEFAULT =
new EvmConfiguration(32_000L, WorldUpdaterMode.STACKED, true);
new EvmConfiguration(32_000L, WorldUpdaterMode.STACKED, true, false);

/**
* Create an EVM Configuration without any overrides
Expand All @@ -67,6 +69,30 @@ public EvmConfiguration(
jumpDestCacheWeightKilobytes,
worldstateUpdateMode,
enableOptimizedOpcodes,
false,
MessageFrame.DEFAULT_MAX_STACK_SIZE,
Optional.empty(),
Optional.empty());
}

/**
* Create an EVM Configuration without any overrides, with explicit EVM v2 flag
*
* @param jumpDestCacheWeightKilobytes the jump dest cache weight (in kibibytes)
* @param worldstateUpdateMode the world update mode
* @param enableOptimizedOpcodes enabled opcode optimizations
* @param enableEvmV2 enable experimental EVM v2 with long[] stack representation
*/
public EvmConfiguration(
final Long jumpDestCacheWeightKilobytes,
final WorldUpdaterMode worldstateUpdateMode,
final boolean enableOptimizedOpcodes,
final boolean enableEvmV2) {
this(
jumpDestCacheWeightKilobytes,
worldstateUpdateMode,
enableOptimizedOpcodes,
enableEvmV2,
MessageFrame.DEFAULT_MAX_STACK_SIZE,
Optional.empty(),
Optional.empty());
Expand Down Expand Up @@ -98,6 +124,7 @@ public EvmConfiguration overrides(
jumpDestCacheWeightKB,
worldUpdaterMode,
enableOptimizedOpcodes,
enableEvmV2,
newEvmStackSize.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE),
newMaxCodeSize.isPresent() ? Optional.of(newMaxCodeSize.getAsInt()) : Optional.empty(),
newMaxInitcodeSize.isPresent()
Expand Down
Loading