Jumpdest constructor inj (#2821)

Implements caching of JUMP destinations for a contract, fixes #2607 

Signed-off-by: Justin Florentine <justin.florentine@consensys.net>

Co-authored-by: taccatisid <88524035+taccatisid@users.noreply.github.com>
Co-authored-by: Sally MacFarlane <sally.macfarlane@consensys.net>
Co-authored-by: Danno Ferrin <danno.ferrin@gmail.com>
pull/2846/head
Justin Florentine 3 years ago committed by GitHub
parent 77ac89a4bf
commit db3a55997b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 2
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/ThreadBesuNodeRunner.java
  3. 7
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  4. 56
      besu/src/main/java/org/hyperledger/besu/cli/options/unstable/EvmOptions.java
  5. 9
      besu/src/main/java/org/hyperledger/besu/controller/BesuControllerBuilder.java
  6. 3
      besu/src/main/java/org/hyperledger/besu/controller/CliqueBesuControllerBuilder.java
  7. 3
      besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
  8. 3
      besu/src/main/java/org/hyperledger/besu/controller/IbftLegacyBesuControllerBuilder.java
  9. 3
      besu/src/main/java/org/hyperledger/besu/controller/MainnetBesuControllerBuilder.java
  10. 3
      besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
  11. 4
      besu/src/test/java/org/hyperledger/besu/ForkIdsTest.java
  12. 2
      besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java
  13. 2
      besu/src/test/java/org/hyperledger/besu/PrivacyTest.java
  14. 4
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  15. 2
      besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
  16. 2
      besu/src/test/java/org/hyperledger/besu/chainimport/JsonBlockImporterTest.java
  17. 5
      besu/src/test/java/org/hyperledger/besu/chainimport/RlpBlockImporterTest.java
  18. 1
      besu/src/test/java/org/hyperledger/besu/cli/CommandTestAbstract.java
  19. 2
      besu/src/test/java/org/hyperledger/besu/controller/BesuControllerBuilderTest.java
  20. 3
      besu/src/test/resources/everything_config.toml
  21. 13
      consensus/clique/src/main/java/org/hyperledger/besu/consensus/clique/CliqueProtocolSchedule.java
  22. 21
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueProtocolScheduleTest.java
  23. 6
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueBlockCreatorTest.java
  24. 10
      consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/blockcreation/CliqueMinerExecutorTest.java
  25. 7
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolSchedule.java
  26. 7
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleTest.java
  27. 4
      consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
  28. 12
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolSchedule.java
  29. 4
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
  30. 13
      consensus/ibftlegacy/src/main/java/org/hyperledger/besu/consensus/ibftlegacy/IbftProtocolSchedule.java
  31. 4
      consensus/ibftlegacy/src/test/java/org/hyperledger/besu/consensus/ibftlegacy/blockcreation/BftBlockCreatorTest.java
  32. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  33. 12
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolSchedule.java
  34. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpServiceTestBase.java
  35. 4
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java
  36. 13
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/PoWBlockCreatorTest.java
  37. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedDifficultyProtocolSchedule.java
  38. 76
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java
  39. 32
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSchedule.java
  40. 97
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecFactory.java
  41. 88
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  42. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  43. 24
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilder.java
  44. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java
  45. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java
  46. 4
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockchainSetupUtil.java
  47. 4
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ExecutionContextTestFixture.java
  48. 3
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/MessageFrameTestFixture.java
  49. 3
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/ProtocolScheduleFixture.java
  50. 3
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TestCodeExecutor.java
  51. 7
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/difficulty/fixed/FixedProtocolScheduleTest.java
  52. 28
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java
  53. 19
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolScheduleTest.java
  54. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ProtocolScheduleBuilderTest.java
  55. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EVMTest.java
  56. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/VMReferenceTest.java
  57. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ConstantinopleSStoreOperationGasCostTest.java
  58. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/Create2OperationTest.java
  59. 65
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperationTest.java
  60. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/LondonSStoreOperationGasCostTest.java
  61. 1
      ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/manyJumps.hex
  62. 5
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java
  63. 5
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockHeadersMessageTest.java
  64. 3
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTrackerTest.java
  65. 3
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TestNode.java
  66. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/CliqueGenesisFileModule.java
  67. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java
  68. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/IBFTGenesisFileModule.java
  69. 3
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/MainnetGenesisFileModule.java
  70. 3
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestCode.java
  71. 4
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestProtocolSchedules.java
  72. 4
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethContext.java
  73. 1
      evm/build.gradle
  74. 96
      evm/src/main/java/org/hyperledger/besu/evm/Code.java
  75. 40
      evm/src/main/java/org/hyperledger/besu/evm/EVM.java
  76. 88
      evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java
  77. 50
      evm/src/main/java/org/hyperledger/besu/evm/fluent/EVMExecutor.java
  78. 27
      evm/src/main/java/org/hyperledger/besu/evm/internal/CodeScale.java
  79. 33
      evm/src/main/java/org/hyperledger/besu/evm/internal/EvmConfiguration.java
  80. 62
      evm/src/main/java/org/hyperledger/besu/evm/internal/JumpDestCache.java
  81. 6
      evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCallOperation.java
  82. 3
      evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java
  83. 2
      evm/src/main/java/org/hyperledger/besu/evm/operation/JumpOperation.java
  84. 2
      evm/src/main/java/org/hyperledger/besu/evm/operation/JumpiOperation.java
  85. 42
      evm/src/test/java/org/hyperledger/besu/evm/internal/JumpDestCacheTest.java
  86. 2
      evm/src/test/java/org/hyperledger/besu/evm/precompile/Benchmarks.java
  87. 6
      evm/src/test/java/org/hyperledger/besu/evm/toy/EvmToyCommand.java
  88. 2
      gradle/versions.gradle

@ -5,8 +5,10 @@
- The EVM has been factored out into a standalone module, suitable for inclusion as a library. [#2790](https://github.com/hyperledger/besu/pull/2790)
- Low level performance improvements changes to cut worst-case EVM performance in half. [#2796](https://github.com/hyperledger/besu/pull/2796)
- Migrate `ExceptionalHaltReason` from an enum to an interface to allow downstream users of the EVM to add new exceptional halt reasons. [#2810](https://github.com/hyperledger/besu/pull/2810)
- reduces need for JUMPDEST analysis via caching [#2607](https://github.com/hyperledger/besu/pull/2821)
- Add support for custom private key file for public-key export and public-key export-address commands [#2801](https://github.com/hyperledger/besu/pull/2801)
### Bug Fixes
- Allow BESU_CONFIG_FILE environment to specify TOML file [#2455](https://github.com/hyperledger/besu/issues/2455)
- Fix bug with private contracts not able to call public contracts that call public contracts [#2816](https://github.com/hyperledger/besu/pull/2816)

@ -34,6 +34,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.MetricsSystemFactory;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.data.EnodeURL;
@ -168,6 +169,7 @@ public class ThreadBesuNodeRunner implements BesuNodeRunner {
node.getPkiKeyStoreConfiguration()
.map(
(pkiConfig) -> new PkiBlockCreationConfigurationProvider().load(pkiConfig)))
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final RunnerBuilder runnerBuilder = new RunnerBuilder();

@ -54,6 +54,7 @@ import org.hyperledger.besu.cli.options.stable.P2PTLSConfigOptions;
import org.hyperledger.besu.cli.options.unstable.DataStorageOptions;
import org.hyperledger.besu.cli.options.unstable.DnsOptions;
import org.hyperledger.besu.cli.options.unstable.EthProtocolOptions;
import org.hyperledger.besu.cli.options.unstable.EvmOptions;
import org.hyperledger.besu.cli.options.unstable.LauncherOptions;
import org.hyperledger.besu.cli.options.unstable.MetricsCLIOptions;
import org.hyperledger.besu.cli.options.unstable.MiningOptions;
@ -266,6 +267,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final RPCOptions unstableRPCOptions = RPCOptions.create();
final LauncherOptions unstableLauncherOptions = LauncherOptions.create();
private final PrivacyPluginOptions unstablePrivacyPluginOptions = PrivacyPluginOptions.create();
private final EvmOptions unstableEvmOptions = EvmOptions.create();
// stable CLI options
private final EthstatsOptions ethstatsOptions = EthstatsOptions.create();
@ -293,6 +295,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
private final Set<Integer> allocatedPorts = new HashSet<>();
private final PkiBlockCreationConfigurationProvider pkiBlockCreationConfigProvider;
private GenesisConfigOptions genesisConfigOptions;
// CLI options defined by user at runtime.
// Options parsing is done with CLI library Picocli https://picocli.info/
@ -400,8 +403,6 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
"Allow for incoming connections to be prioritized randomly. This will prevent (typically small, stable) networks from forming impenetrable peer cliques. (default: ${DEFAULT-VALUE})")
private final Boolean randomPeerPriority = false;
private GenesisConfigOptions genesisConfigOptions;
@Option(
names = {"--banned-node-ids", "--banned-node-id"},
paramLabel = MANDATORY_NODE_ID_FORMAT_HELP,
@ -1292,6 +1293,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.put("Native Library", unstableNativeLibraryOptions)
.put("Data Storage Options", unstableDataStorageOptions)
.put("Launcher", unstableLauncherOptions)
.put("EVM Options", unstableEvmOptions)
.build();
UnstableOptionsSubCommand.createUnstableOptions(commandLine, unstableOptions);
@ -1732,6 +1734,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
.orElse(GasLimitCalculator.constant()))
.requiredBlocks(requiredBlocks)
.reorgLoggingThreshold(reorgLoggingThreshold)
.evmConfiguration(unstableEvmOptions.toDomainObject())
.dataStorageConfiguration(unstableDataStorageOptions.toDomainObject());
}

@ -0,0 +1,56 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.cli.options.unstable;
import org.hyperledger.besu.cli.options.CLIOptions;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.Arrays;
import java.util.List;
import picocli.CommandLine;
public class EvmOptions implements CLIOptions<EvmConfiguration> {
public static final String JUMPDEST_CACHE_WEIGHT = "--Xevm-jumpdest-cache-weight-kb";
public static EvmOptions create() {
return new EvmOptions();
}
@SuppressWarnings({"FieldCanBeFinal", "FieldMayBeFinal"})
@CommandLine.Option(
names = {JUMPDEST_CACHE_WEIGHT},
description =
"size in kilobytes to allow the cache "
+ "of valid jump destinations to grow to before evicting the least recently used entry",
fallbackValue = "32000",
defaultValue = "32000",
hidden = true,
arity = "1")
private Long jumpDestCacheWeightKilobytes =
32_000L; // 10k contracts, (25k max contract size / 8 bit) + 32byte hash
@Override
public EvmConfiguration toDomainObject() {
return new EvmConfiguration(jumpDestCacheWeightKilobytes);
}
@Override
public List<String> getCLIOptions() {
return Arrays.asList(JUMPDEST_CACHE_WEIGHT);
}
}

@ -64,6 +64,7 @@ import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.plugin.services.permissioning.NodeMessagePermissioningProvider;
@ -109,6 +110,7 @@ public abstract class BesuControllerBuilder {
DataStorageConfiguration.DEFAULT_CONFIG;
private List<NodeMessagePermissioningProvider> messagePermissioningProviders =
Collections.emptyList();
protected EvmConfiguration evmConfiguration;
public BesuControllerBuilder storageProvider(final StorageProvider storageProvider) {
this.storageProvider = storageProvider;
@ -227,6 +229,11 @@ public abstract class BesuControllerBuilder {
return this;
}
public BesuControllerBuilder evmConfiguration(final EvmConfiguration evmConfiguration) {
this.evmConfiguration = evmConfiguration;
return this;
}
public BesuController build() {
checkNotNull(genesisConfig, "Missing genesis config");
checkNotNull(syncConfig, "Missing sync config");
@ -241,7 +248,7 @@ public abstract class BesuControllerBuilder {
checkNotNull(nodeKey, "Missing node key");
checkNotNull(storageProvider, "Must supply a storage provider");
checkNotNull(gasLimitCalculator, "Missing gas limit calculator");
checkNotNull(evmConfiguration, "Missing evm config");
prepForBuild();
final ProtocolSchedule protocolSchedule = createProtocolSchedule();

@ -109,7 +109,8 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
genesisConfig.getConfigOptions(genesisConfigOverrides),
nodeKey,
privacyParameters,
isRevertReasonEnabled);
isRevertReasonEnabled,
evmConfiguration);
}
@Override

@ -233,7 +233,8 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isRevertReasonEnabled,
bftExtraDataCodec().get());
bftExtraDataCodec().get(),
evmConfiguration);
}
@Override

@ -76,7 +76,8 @@ public class IbftLegacyBesuControllerBuilder extends BesuControllerBuilder {
return IbftProtocolSchedule.create(
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isRevertReasonEnabled);
isRevertReasonEnabled,
evmConfiguration);
}
@Override

@ -92,7 +92,8 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
return MainnetProtocolSchedule.fromConfig(
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isRevertReasonEnabled);
isRevertReasonEnabled,
evmConfiguration);
}
@Override

@ -258,7 +258,8 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
genesisConfig.getConfigOptions(genesisConfigOverrides),
privacyParameters,
isRevertReasonEnabled,
bftExtraDataCodec().get());
bftExtraDataCodec().get(),
evmConfiguration);
}
@Override

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.eth.manager.ForkIdManager;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.MutableProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.Collection;
import java.util.List;
@ -156,7 +157,8 @@ public class ForkIdsTest {
final GenesisConfigFile genesisConfigFile =
GenesisConfigFile.fromConfig(EthNetworkConfig.jsonConfig(chainName));
final GenesisConfigOptions configOptions = genesisConfigFile.getConfigOptions();
final ProtocolSchedule schedule = MainnetProtocolSchedule.fromConfig(configOptions);
final ProtocolSchedule schedule =
MainnetProtocolSchedule.fromConfig(configOptions, EvmConfiguration.DEFAULT);
final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, schedule);
final Blockchain mockBlockchain = mock(Blockchain.class);

@ -55,6 +55,7 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap;
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.log.LogsBloomFilter;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.data.Restriction;
@ -187,6 +188,7 @@ public class PrivacyReorgTest {
.privacyParameters(privacyParameters)
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
}

@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.privacy.storage.PrivacyStorageProvider;
import org.hyperledger.besu.ethereum.privacy.storage.keyvalue.PrivacyKeyValueStorageProviderBuilder;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.precompile.PrecompiledContract;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBKeyValuePrivacyStorageFactory;
@ -115,6 +116,7 @@ public class PrivacyTest {
.privacyParameters(privacyParameters)
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
}

@ -49,6 +49,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStorageProviderBuilder;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
@ -170,6 +171,7 @@ public final class RunnerTest {
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.storageProvider(createKeyValueStorageProvider(dataDirAhead, dbAhead))
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build()) {
setupState(blockCount, controller.getProtocolSchedule(), controller.getProtocolContext());
}
@ -190,6 +192,7 @@ public final class RunnerTest {
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.storageProvider(createKeyValueStorageProvider(dataDirAhead, dbAhead))
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final String listenHost = InetAddress.getLoopbackAddress().getHostAddress();
final JsonRpcConfiguration aheadJsonRpcConfiguration = jsonRpcConfiguration();
@ -257,6 +260,7 @@ public final class RunnerTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final EnodeURL enode = runnerAhead.getLocalEnode().get();
final EthNetworkConfig behindEthNetworkConfiguration =

@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.util.RawBlockIterator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.BlockTestUtil;
import org.hyperledger.besu.testutil.TestClock;
@ -92,6 +93,7 @@ public final class RlpBlockExporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
}

@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -426,6 +427,7 @@ public abstract class JsonBlockImporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
}
}

@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.BlockTestUtil;
import org.hyperledger.besu.testutil.TestClock;
@ -72,6 +73,7 @@ public final class RlpBlockImporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final RlpBlockImporter.ImportResult result =
rlpBlockImporter.importBlockchain(source, targetController, false);
@ -100,6 +102,7 @@ public final class RlpBlockImporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
assertThatThrownBy(
@ -128,6 +131,7 @@ public final class RlpBlockImporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final RlpBlockImporter.ImportResult result =
@ -168,6 +172,7 @@ public final class RlpBlockImporterTest {
.clock(TestClock.fixed())
.transactionPoolConfiguration(TransactionPoolConfiguration.DEFAULT)
.gasLimitCalculator(GasLimitCalculator.constant())
.evmConfiguration(EvmConfiguration.DEFAULT)
.build();
final RlpBlockImporter.ImportResult result =
rlpBlockImporter.importBlockchain(source, controller, false);

@ -220,6 +220,7 @@ public abstract class CommandTestAbstract {
when(mockControllerBuilder.requiredBlocks(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.reorgLoggingThreshold(anyLong())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.dataStorageConfiguration(any())).thenReturn(mockControllerBuilder);
when(mockControllerBuilder.evmConfiguration(any())).thenReturn(mockControllerBuilder);
// doReturn used because of generic BesuController
doReturn(mockController).when(mockControllerBuilder).build();

@ -43,6 +43,7 @@ import org.hyperledger.besu.ethereum.worldstate.ImmutableDataStorageConfiguratio
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration;
import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.ObservableMetricsSystem;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
@ -140,6 +141,7 @@ public class BesuControllerBuilderTest {
.transactionPoolConfiguration(poolConfiguration)
.nodeKey(nodeKey)
.storageProvider(storageProvider)
.evmConfiguration(EvmConfiguration.DEFAULT)
.networkId(networkId);
}

@ -187,3 +187,6 @@ Xp2p-tls-truststore-type="none"
Xp2p-tls-truststore-file="none.file"
Xp2p-tls-keystore-password-file="none"
Xp2p-tls-crl-file="none.file"
#contracts
Xevm-jumpdest-cache-weight-kb=32000

@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.Optional;
@ -45,7 +46,8 @@ public class CliqueProtocolSchedule {
final GenesisConfigOptions config,
final NodeKey nodeKey,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled) {
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
@ -71,15 +73,18 @@ public class CliqueProtocolSchedule {
privacyParameters.getGoQuorumPrivacyParameters().isPresent())),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final NodeKey nodeKey,
final boolean isRevertReasonEnabled) {
return create(config, nodeKey, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
return create(
config, nodeKey, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration);
}
private static ProtocolSpecBuilder applyCliqueSpecificModifications(

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.time.Instant;
@ -54,7 +55,7 @@ public class CliqueProtocolScheduleTest {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
final ProtocolSchedule protocolSchedule =
CliqueProtocolSchedule.create(config, NODE_KEY, false);
CliqueProtocolSchedule.create(config, NODE_KEY, false, EvmConfiguration.DEFAULT);
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockNumber(1);
final ProtocolSpec tangerineWhistleSpec = protocolSchedule.getByBlockNumber(2);
@ -69,7 +70,11 @@ public class CliqueProtocolScheduleTest {
@Test
public void parametersAlignWithMainnetWithAdjustments() {
final ProtocolSpec homestead =
CliqueProtocolSchedule.create(GenesisConfigFile.DEFAULT.getConfigOptions(), NODE_KEY, false)
CliqueProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(),
NODE_KEY,
false,
EvmConfiguration.DEFAULT)
.getByBlockNumber(0);
assertThat(homestead.getName()).isEqualTo("Frontier");
@ -84,7 +89,10 @@ public class CliqueProtocolScheduleTest {
when(cliqueOptions.getEpochLength()).thenReturn(0L);
when(genesisConfig.getCliqueConfigOptions()).thenReturn(cliqueOptions);
assertThatThrownBy(() -> CliqueProtocolSchedule.create(genesisConfig, NODE_KEY, false))
assertThatThrownBy(
() ->
CliqueProtocolSchedule.create(
genesisConfig, NODE_KEY, false, EvmConfiguration.DEFAULT))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero");
}
@ -95,7 +103,10 @@ public class CliqueProtocolScheduleTest {
when(cliqueOptions.getEpochLength()).thenReturn(-3000L);
when(genesisConfig.getCliqueConfigOptions()).thenReturn(cliqueOptions);
assertThatThrownBy(() -> CliqueProtocolSchedule.create(genesisConfig, NODE_KEY, false))
assertThatThrownBy(
() ->
CliqueProtocolSchedule.create(
genesisConfig, NODE_KEY, false, EvmConfiguration.DEFAULT))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Epoch length in config must be greater than zero");
}
@ -110,7 +121,7 @@ public class CliqueProtocolScheduleTest {
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
final ProtocolSchedule protocolSchedule =
CliqueProtocolSchedule.create(config, NODE_KEY, false);
CliqueProtocolSchedule.create(config, NODE_KEY, false, EvmConfiguration.DEFAULT);
BlockHeader emptyFrontierParent =
headerBuilder

@ -51,6 +51,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -86,7 +87,10 @@ public class CliqueBlockCreatorTest {
public void setup() {
protocolSchedule =
CliqueProtocolSchedule.create(
GenesisConfigFile.DEFAULT.getConfigOptions(), proposerNodeKey, false);
GenesisConfigFile.DEFAULT.getConfigOptions(),
proposerNodeKey,
false,
EvmConfiguration.DEFAULT);
final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
validatorList.add(otherAddress);

@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -90,7 +91,8 @@ public class CliqueMinerExecutorTest {
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
cliqueProtocolContext,
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerNodeKey, false),
CliqueProtocolSchedule.create(
GENESIS_CONFIG_OPTIONS, proposerNodeKey, false, EvmConfiguration.DEFAULT),
new GasPricePendingTransactionsSorter(
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
1,
@ -134,7 +136,8 @@ public class CliqueMinerExecutorTest {
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
cliqueProtocolContext,
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerNodeKey, false),
CliqueProtocolSchedule.create(
GENESIS_CONFIG_OPTIONS, proposerNodeKey, false, EvmConfiguration.DEFAULT),
new GasPricePendingTransactionsSorter(
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
1,
@ -178,7 +181,8 @@ public class CliqueMinerExecutorTest {
final CliqueMinerExecutor executor =
new CliqueMinerExecutor(
cliqueProtocolContext,
CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerNodeKey, false),
CliqueProtocolSchedule.create(
GENESIS_CONFIG_OPTIONS, proposerNodeKey, false, EvmConfiguration.DEFAULT),
new GasPricePendingTransactionsSorter(
TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS,
1,

@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.HashMap;
@ -46,7 +47,8 @@ public abstract class BaseBftProtocolSchedule {
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec) {
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
specMap.put(
@ -90,7 +92,8 @@ public abstract class BaseBftProtocolSchedule {
specAdapters,
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}

@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.MutableProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.List;
@ -192,6 +193,10 @@ public class BaseBftProtocolScheduleTest {
}
};
return bftProtocolSchedule.createProtocolSchedule(
genesisConfig, PrivacyParameters.DEFAULT, false, bftExtraDataCodec);
genesisConfig,
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,
EvmConfiguration.DEFAULT);
}
}

@ -74,6 +74,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfigurati
import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTransactionsSorter;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -293,7 +294,8 @@ public class TestContextBuilder {
genesisConfigOptions.byzantiumBlock(0);
final ProtocolSchedule protocolSchedule =
IbftProtocolSchedule.create(genesisConfigOptions, IBFT_EXTRA_DATA_ENCODER);
IbftProtocolSchedule.create(
genesisConfigOptions, IBFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT);
/////////////////////////////////////////////////////////////////////////////////////
// From here down is BASICALLY taken from IbftBesuController

@ -21,6 +21,7 @@ import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.function.Supplier;
@ -31,15 +32,18 @@ public class IbftProtocolSchedule extends BaseBftProtocolSchedule {
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec) {
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return new IbftProtocolSchedule()
.createProtocolSchedule(
config, privacyParameters, isRevertReasonEnabled, bftExtraDataCodec);
config, privacyParameters, isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration);
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final BftExtraDataCodec bftExtraDataCodec) {
return create(config, PrivacyParameters.DEFAULT, false, bftExtraDataCodec);
final GenesisConfigOptions config,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return create(config, PrivacyParameters.DEFAULT, false, bftExtraDataCodec, evmConfiguration);
}
@Override

@ -44,6 +44,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTran
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -103,7 +104,8 @@ public class BftBlockCreatorTest {
.getConfigOptions(),
PrivacyParameters.DEFAULT,
false,
bftExtraDataEncoder);
bftExtraDataEncoder,
EvmConfiguration.DEFAULT);
final ProtocolContext protContext =
new ProtocolContext(
blockchain,

@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
@ -38,7 +39,8 @@ public class IbftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled) {
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
final IbftLegacyConfigOptions ibftConfig = config.getIbftLegacyConfigOptions();
final long blockPeriod = ibftConfig.getBlockPeriodSeconds();
@ -52,13 +54,16 @@ public class IbftProtocolSchedule {
blockPeriod, builder, config.isQuorum(), ibftConfig.getCeil2Nby3Block())),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration);
}
private static ProtocolSpecBuilder applyIbftChanges(

@ -40,6 +40,7 @@ import org.hyperledger.besu.ethereum.eth.transactions.sorter.GasPricePendingTran
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -87,7 +88,8 @@ public class BftBlockCreatorTest {
IbftProtocolSchedule.create(
GenesisConfigFile.fromConfig("{\"config\": {\"spuriousDragonBlock\":0}}")
.getConfigOptions(),
false);
false,
EvmConfiguration.DEFAULT);
final ProtocolContext protContext =
new ProtocolContext(
blockchain,

@ -90,6 +90,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -396,7 +397,8 @@ public class TestContextBuilder {
genesisConfigOptions.transitions(new TestTransitions(qbftForks));
final ProtocolSchedule protocolSchedule =
QbftProtocolSchedule.create(genesisConfigOptions, BFT_EXTRA_DATA_ENCODER);
QbftProtocolSchedule.create(
genesisConfigOptions, BFT_EXTRA_DATA_ENCODER, EvmConfiguration.DEFAULT);
/////////////////////////////////////////////////////////////////////////////////////
// From here down is BASICALLY taken from IbftBesuController

@ -25,6 +25,7 @@ import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.util.function.Supplier;
@ -35,15 +36,18 @@ public class QbftProtocolSchedule extends BaseBftProtocolSchedule {
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec) {
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return new QbftProtocolSchedule()
.createProtocolSchedule(
config, privacyParameters, isRevertReasonEnabled, bftExtraDataCodec);
config, privacyParameters, isRevertReasonEnabled, bftExtraDataCodec, evmConfiguration);
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final BftExtraDataCodec bftExtraDataCodec) {
return create(config, PrivacyParameters.DEFAULT, false, bftExtraDataCodec);
final GenesisConfigOptions config,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return create(config, PrivacyParameters.DEFAULT, false, bftExtraDataCodec, evmConfiguration);
}
@Override

@ -38,6 +38,7 @@ import org.hyperledger.besu.ethereum.p2p.network.P2PNetwork;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability;
import org.hyperledger.besu.ethereum.permissioning.AccountLocalConfigPermissioningController;
import org.hyperledger.besu.ethereum.permissioning.NodeLocalConfigPermissioningController;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.nat.NatService;
@ -109,7 +110,8 @@ public class JsonRpcHttpServiceTestBase {
blockchainQueries,
synchronizer,
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID)),
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
EvmConfiguration.DEFAULT),
mock(FilterManager.class),
mock(TransactionPool.class),
mock(PoWMiningCoordinator.class),

@ -49,6 +49,7 @@ import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.worldstate.WorldState;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
@ -112,7 +113,8 @@ public class BlockTransactionSelectorTest {
@Test
public void emptyPendingTransactionsResultsInEmptyVettingResult() {
final ProtocolSchedule protocolSchedule =
FixedDifficultyProtocolSchedule.create(GenesisConfigFile.development().getConfigOptions());
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), EvmConfiguration.DEFAULT);
final MainnetTransactionProcessor mainnetTransactionProcessor =
protocolSchedule.getByBlockNumber(0).getTransactionProcessor();

@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.mainnet.PoWSolver;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.mainnet.ValidationTestUtils;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -76,7 +77,8 @@ public class PoWBlockCreatorTest {
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
genesisConfigOptions.isQuorum())
genesisConfigOptions.isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule())
.build();
@ -137,7 +139,8 @@ public class PoWBlockCreatorTest {
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
genesisConfigOptions.isQuorum())
genesisConfigOptions.isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule())
.build();
@ -193,7 +196,8 @@ public class PoWBlockCreatorTest {
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
genesisConfigOptions.isQuorum())
genesisConfigOptions.isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule())
.build();
@ -265,7 +269,8 @@ public class PoWBlockCreatorTest {
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
genesisConfigOptions.isQuorum())
genesisConfigOptions.isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule())
.build();

@ -19,6 +19,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
/** A ProtocolSchedule which behaves similarly to MainNet, but with a much reduced difficulty. */
public class FixedDifficultyProtocolSchedule {
@ -26,7 +27,8 @@ public class FixedDifficultyProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled) {
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
return new ProtocolScheduleBuilder(
config,
ProtocolSpecAdapters.create(
@ -35,16 +37,20 @@ public class FixedDifficultyProtocolSchedule {
builder.difficultyCalculator(FixedDifficultyCalculators.calculator(config))),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}
public static ProtocolSchedule create(
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
return create(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration);
}
public static ProtocolSchedule create(final GenesisConfigOptions config) {
return create(config, PrivacyParameters.DEFAULT, false);
public static ProtocolSchedule create(
final GenesisConfigOptions config, final EvmConfiguration evmConfiguration) {
return create(config, PrivacyParameters.DEFAULT, false, evmConfiguration);
}
}

@ -31,6 +31,7 @@ import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
import org.hyperledger.besu.evm.worldstate.WorldState;
@ -49,9 +50,10 @@ public class ClassicProtocolSpecs {
public static ProtocolSpecBuilder classicRecoveryInitDefinition(
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return MainnetProtocolSpecs.homesteadDefinition(
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.blockHeaderValidatorBuilder(
feeMarket -> MainnetBlockHeaderValidator.createClassicValidator())
.name("ClassicRecoveryInit");
@ -61,9 +63,10 @@ public class ClassicProtocolSpecs {
final Optional<BigInteger> chainId,
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return MainnetProtocolSpecs.homesteadDefinition(
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.gasCalculator(TangerineWhistleGasCalculator::new)
.transactionValidatorBuilder(
gasCalculator ->
@ -76,9 +79,14 @@ public class ClassicProtocolSpecs {
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return tangerineWhistleDefinition(
chainId, OptionalInt.empty(), configStackSizeLimit, quorumCompatibilityMode)
chainId,
OptionalInt.empty(),
configStackSizeLimit,
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(DieHardGasCalculator::new)
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_PAUSED)
.name("DieHard");
@ -89,9 +97,14 @@ public class ClassicProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return dieHardDefinition(
chainId, contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
chainId,
contractSizeLimit,
configStackSizeLimit,
quorumCompatibilityMode,
evmConfiguration)
.blockReward(MAX_BLOCK_REWARD)
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_DELAYED)
.blockProcessorBuilder(
@ -116,13 +129,15 @@ public class ClassicProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return gothamDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_REMOVED)
.transactionValidatorBuilder(
gasCalculator ->
@ -137,7 +152,8 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit =
configContractSizeLimit.orElse(MainnetProtocolSpecs.SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
@ -146,8 +162,10 @@ public class ClassicProtocolSpecs {
configContractSizeLimit,
configStackSizeLimit,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.evmBuilder(MainnetEVMs::byzantium)
.evmConfiguration(evmConfiguration)
.gasCalculator(SpuriousDragonGasCalculator::new)
.skipZeroBlockRewards(true)
.messageCallProcessorBuilder(MessageCallProcessor::new)
@ -188,14 +206,16 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return atlantisDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.evmBuilder(MainnetEVMs::constantinople)
.gasCalculator(PetersburgGasCalculator::new)
.evmBuilder(MainnetEVMs::constantinople)
@ -209,17 +229,21 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return aghartaDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(IstanbulGasCalculator::new)
.evmBuilder(
gasCalculator -> MainnetEVMs.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO)))
(gasCalculator, evmConfig) ->
MainnetEVMs.istanbul(
gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::istanbul)
.name("Phoenix");
}
@ -230,14 +254,16 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return phoenixDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.blockHeaderValidatorBuilder(
feeMarket ->
MainnetBlockHeaderValidator.createLegacyBlockHeaderValidator(
@ -275,14 +301,16 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return thanosDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.blockHeaderValidatorBuilder(
feeMarket ->
MainnetBlockHeaderValidator.createLegacyBlockHeaderValidator(
@ -303,14 +331,16 @@ public class ClassicProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return thanosDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(BerlinGasCalculator::new)
.transactionValidatorBuilder(
gasCalculator ->

@ -18,6 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators;
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.function.Function;
@ -34,15 +35,17 @@ public class MainnetProtocolSchedule {
* starting points
* @param privacyParameters the parameters set for private transactions
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled) {
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
return FixedDifficultyProtocolSchedule.create(
config, privacyParameters, isRevertReasonEnabled);
config, privacyParameters, isRevertReasonEnabled, evmConfiguration);
}
return new ProtocolScheduleBuilder(
config,
@ -50,7 +53,8 @@ public class MainnetProtocolSchedule {
ProtocolSpecAdapters.create(0, Function.identity()),
privacyParameters,
isRevertReasonEnabled,
config.isQuorum())
config.isQuorum(),
evmConfiguration)
.createProtocolSchedule();
}
@ -60,11 +64,27 @@ public class MainnetProtocolSchedule {
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
* @param isRevertReasonEnabled whether storing the revert reason is for failed transactions
* @param evmConfiguration how to configure the EVMs jumpdest cache
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config, final boolean isRevertReasonEnabled) {
return fromConfig(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled);
final GenesisConfigOptions config,
final boolean isRevertReasonEnabled,
final EvmConfiguration evmConfiguration) {
return fromConfig(config, PrivacyParameters.DEFAULT, isRevertReasonEnabled, evmConfiguration);
}
/**
* Create a Mainnet protocol schedule from a config object
*
* @param config {@link GenesisConfigOptions} containing the config options for the milestone
* starting points
* @param evmConfiguration size of
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(
final GenesisConfigOptions config, final EvmConfiguration evmConfiguration) {
return fromConfig(config, PrivacyParameters.DEFAULT, false, evmConfiguration);
}
/**
@ -75,6 +95,6 @@ public class MainnetProtocolSchedule {
* @return A configured mainnet protocol schedule
*/
public static ProtocolSchedule fromConfig(final GenesisConfigOptions config) {
return fromConfig(config, PrivacyParameters.DEFAULT, false);
return fromConfig(config, PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT);
}
}

@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.Optional;
@ -29,6 +30,7 @@ public class MainnetProtocolSpecFactory {
private final boolean isRevertReasonEnabled;
private final boolean quorumCompatibilityMode;
private final OptionalLong ecip1017EraRounds;
private final EvmConfiguration evmConfiguration;
public MainnetProtocolSpecFactory(
final Optional<BigInteger> chainId,
@ -36,73 +38,105 @@ public class MainnetProtocolSpecFactory {
final OptionalInt evmStackSize,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode,
final OptionalLong ecip1017EraRounds) {
final OptionalLong ecip1017EraRounds,
final EvmConfiguration evmConfiguration) {
this.chainId = chainId;
this.contractSizeLimit = contractSizeLimit;
this.evmStackSize = evmStackSize;
this.isRevertReasonEnabled = isRevertReasonEnabled;
this.quorumCompatibilityMode = quorumCompatibilityMode;
this.ecip1017EraRounds = ecip1017EraRounds;
this.evmConfiguration = evmConfiguration;
}
public ProtocolSpecBuilder frontierDefinition() {
return MainnetProtocolSpecs.frontierDefinition(
contractSizeLimit, evmStackSize, quorumCompatibilityMode);
contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder homesteadDefinition() {
return MainnetProtocolSpecs.homesteadDefinition(
contractSizeLimit, evmStackSize, quorumCompatibilityMode);
contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder daoRecoveryInitDefinition() {
return MainnetProtocolSpecs.daoRecoveryInitDefinition(
contractSizeLimit, evmStackSize, quorumCompatibilityMode);
contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder daoRecoveryTransitionDefinition() {
return MainnetProtocolSpecs.daoRecoveryTransitionDefinition(
contractSizeLimit, evmStackSize, quorumCompatibilityMode);
contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder tangerineWhistleDefinition() {
return MainnetProtocolSpecs.tangerineWhistleDefinition(
contractSizeLimit, evmStackSize, quorumCompatibilityMode);
contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder spuriousDragonDefinition() {
return MainnetProtocolSpecs.spuriousDragonDefinition(
chainId, contractSizeLimit, evmStackSize, quorumCompatibilityMode);
chainId, contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder byzantiumDefinition() {
return MainnetProtocolSpecs.byzantiumDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder constantinopleDefinition() {
return MainnetProtocolSpecs.constantinopleDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder petersburgDefinition() {
return MainnetProtocolSpecs.petersburgDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder istanbulDefinition() {
return MainnetProtocolSpecs.istanbulDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder muirGlacierDefinition() {
return MainnetProtocolSpecs.muirGlacierDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder berlinDefinition() {
return MainnetProtocolSpecs.berlinDefinition(
chainId, contractSizeLimit, evmStackSize, isRevertReasonEnabled, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder londonDefinition(final GenesisConfigOptions genesisConfigOptions) {
@ -112,7 +146,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
genesisConfigOptions,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
////////////////////////////////////////////////////////////////////////////////////////////////
@ -120,17 +155,27 @@ public class MainnetProtocolSpecFactory {
// Classic Protocol Specs
public ProtocolSpecBuilder dieHardDefinition() {
return ClassicProtocolSpecs.dieHardDefinition(
chainId, contractSizeLimit, evmStackSize, quorumCompatibilityMode);
chainId, contractSizeLimit, evmStackSize, quorumCompatibilityMode, evmConfiguration);
}
public ProtocolSpecBuilder gothamDefinition() {
return ClassicProtocolSpecs.gothamDefinition(
chainId, contractSizeLimit, evmStackSize, ecip1017EraRounds, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
ecip1017EraRounds,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder defuseDifficultyBombDefinition() {
return ClassicProtocolSpecs.defuseDifficultyBombDefinition(
chainId, contractSizeLimit, evmStackSize, ecip1017EraRounds, quorumCompatibilityMode);
chainId,
contractSizeLimit,
evmStackSize,
ecip1017EraRounds,
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder atlantisDefinition() {
@ -140,7 +185,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder aghartaDefinition() {
@ -150,7 +196,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder phoenixDefinition() {
@ -160,7 +207,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder thanosDefinition() {
@ -170,7 +218,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder magnetoDefinition() {
@ -180,7 +229,8 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
public ProtocolSpecBuilder ecip1049Definition() {
@ -190,6 +240,7 @@ public class MainnetProtocolSpecFactory {
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
}

@ -50,6 +50,7 @@ import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
import org.hyperledger.besu.evm.worldstate.WorldState;
@ -100,7 +101,8 @@ public abstract class MainnetProtocolSpecs {
public static ProtocolSpecBuilder frontierDefinition(
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean goQuorumMode) {
final boolean goQuorumMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(FRONTIER_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return new ProtocolSpecBuilder()
@ -162,6 +164,7 @@ public abstract class MainnetProtocolSpecs {
.blockImporterBuilder(MainnetBlockImporter::new)
.blockHeaderFunctions(new MainnetBlockHeaderFunctions())
.miningBeneficiaryCalculator(BlockHeader::getCoinbase)
.evmConfiguration(evmConfiguration)
.name("Frontier");
}
@ -205,10 +208,14 @@ public abstract class MainnetProtocolSpecs {
public static ProtocolSpecBuilder homesteadDefinition(
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit = configContractSizeLimit.orElse(FRONTIER_CONTRACT_SIZE_LIMIT);
return frontierDefinition(
configContractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
configContractSizeLimit,
configStackSizeLimit,
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(HomesteadGasCalculator::new)
.evmBuilder(MainnetEVMs::homestead)
.contractCreationProcessorBuilder(
@ -230,8 +237,10 @@ public abstract class MainnetProtocolSpecs {
public static ProtocolSpecBuilder daoRecoveryInitDefinition(
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
return homesteadDefinition(contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return homesteadDefinition(
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createDaoValidator())
.blockProcessorBuilder(
(transactionProcessor,
@ -254,9 +263,10 @@ public abstract class MainnetProtocolSpecs {
public static ProtocolSpecBuilder daoRecoveryTransitionDefinition(
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return daoRecoveryInitDefinition(
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.blockProcessorBuilder(MainnetBlockProcessor::new)
.name("DaoRecoveryTransition");
}
@ -264,8 +274,10 @@ public abstract class MainnetProtocolSpecs {
public static ProtocolSpecBuilder tangerineWhistleDefinition(
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
return homesteadDefinition(contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return homesteadDefinition(
contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.gasCalculator(TangerineWhistleGasCalculator::new)
.name("TangerineWhistle");
}
@ -274,13 +286,14 @@ public abstract class MainnetProtocolSpecs {
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return tangerineWhistleDefinition(
OptionalInt.empty(), configStackSizeLimit, quorumCompatibilityMode)
OptionalInt.empty(), configStackSizeLimit, quorumCompatibilityMode, evmConfiguration)
.gasCalculator(SpuriousDragonGasCalculator::new)
.skipZeroBlockRewards(true)
.messageCallProcessorBuilder(
@ -324,10 +337,15 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return spuriousDragonDefinition(
chainId, contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode)
chainId,
contractSizeLimit,
configStackSizeLimit,
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(ByzantiumGasCalculator::new)
.evmBuilder(MainnetEVMs::byzantium)
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium)
@ -360,13 +378,15 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return byzantiumDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.difficultyCalculator(MainnetDifficultyCalculators.CONSTANTINOPLE)
.gasCalculator(ConstantinopleGasCalculator::new)
.evmBuilder(MainnetEVMs::constantinople)
@ -379,13 +399,15 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return constantinopleDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(PetersburgGasCalculator::new)
.name("Petersburg");
}
@ -395,7 +417,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
return petersburgDefinition(
@ -403,10 +426,13 @@ public abstract class MainnetProtocolSpecs {
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(IstanbulGasCalculator::new)
.evmBuilder(
gasCalculator -> MainnetEVMs.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO)))
(gasCalculator, jdCacheConfig) ->
MainnetEVMs.istanbul(
gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::istanbul)
.contractCreationProcessorBuilder(
(gasCalculator, evm) ->
@ -425,13 +451,15 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return istanbulDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.difficultyCalculator(MainnetDifficultyCalculators.MUIR_GLACIER)
.name("MuirGlacier");
}
@ -441,13 +469,15 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt contractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
return muirGlacierDefinition(
chainId,
contractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(BerlinGasCalculator::new)
.transactionValidatorBuilder(
gasCalculator ->
@ -470,7 +500,8 @@ public abstract class MainnetProtocolSpecs {
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final GenesisConfigOptions genesisConfigOptions,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
final int contractSizeLimit =
configContractSizeLimit.orElse(SPURIOUS_DRAGON_CONTRACT_SIZE_LIMIT);
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
@ -482,7 +513,8 @@ public abstract class MainnetProtocolSpecs {
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
quorumCompatibilityMode)
quorumCompatibilityMode,
evmConfiguration)
.gasCalculator(LondonGasCalculator::new)
.gasLimitCalculator(
new LondonTargetingGasLimitCalculator(londonForkBlockNumber, londonFeeMarket))
@ -522,7 +554,9 @@ public abstract class MainnetProtocolSpecs {
1,
SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES))
.evmBuilder(
gasCalculator -> MainnetEVMs.london(gasCalculator, chainId.orElse(BigInteger.ZERO)))
(gasCalculator, jdCacheConfig) ->
MainnetEVMs.london(
gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
.feeMarket(londonFeeMarket)
.difficultyCalculator(MainnetDifficultyCalculators.LONDON)
.blockHeaderValidatorBuilder(

@ -20,6 +20,7 @@ import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSA
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
@ -371,7 +372,7 @@ public class MainnetTransactionProcessor {
.address(contractAddress)
.contract(contractAddress)
.inputData(Bytes.EMPTY)
.code(new Code(transaction.getPayload()))
.code(new Code(transaction.getPayload(), Hash.EMPTY))
.build();
} else {
@SuppressWarnings("OptionalGetWithoutIsPresent") // isContractCall tests isPresent
@ -383,7 +384,10 @@ public class MainnetTransactionProcessor {
.address(to)
.contract(to)
.inputData(transaction.getPayload())
.code(new Code(maybeContract.map(AccountState::getCode).orElse(Bytes.EMPTY)))
.code(
new Code(
maybeContract.map(AccountState::getCode).orElse(Bytes.EMPTY),
maybeContract.map(AccountState::getCodeHash).orElse(Hash.EMPTY)))
.build();
}

@ -18,6 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.Optional;
@ -68,6 +69,7 @@ public class ProtocolScheduleBuilder {
private final boolean isRevertReasonEnabled;
private final BadBlockManager badBlockManager = new BadBlockManager();
private final boolean quorumCompatibilityMode;
private final EvmConfiguration evmConfiguration;
public ProtocolScheduleBuilder(
final GenesisConfigOptions config,
@ -75,14 +77,16 @@ public class ProtocolScheduleBuilder {
final ProtocolSpecAdapters protocolSpecAdapters,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
this(
config,
Optional.of(defaultChainId),
protocolSpecAdapters,
privacyParameters,
isRevertReasonEnabled,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
private Optional<BuilderMapEntry> create(
@ -100,14 +104,16 @@ public class ProtocolScheduleBuilder {
final ProtocolSpecAdapters protocolSpecAdapters,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
this(
config,
Optional.empty(),
protocolSpecAdapters,
privacyParameters,
isRevertReasonEnabled,
quorumCompatibilityMode);
quorumCompatibilityMode,
evmConfiguration);
}
private ProtocolScheduleBuilder(
@ -116,13 +122,15 @@ public class ProtocolScheduleBuilder {
final ProtocolSpecAdapters protocolSpecAdapters,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final boolean quorumCompatibilityMode) {
final boolean quorumCompatibilityMode,
final EvmConfiguration evmConfiguration) {
this.config = config;
this.defaultChainId = defaultChainId;
this.protocolSpecAdapters = protocolSpecAdapters;
this.privacyParameters = privacyParameters;
this.isRevertReasonEnabled = isRevertReasonEnabled;
this.quorumCompatibilityMode = quorumCompatibilityMode;
this.evmConfiguration = evmConfiguration;
}
public ProtocolSchedule createProtocolSchedule() {
@ -137,7 +145,8 @@ public class ProtocolScheduleBuilder {
config.getEvmStackSize(),
isRevertReasonEnabled,
quorumCompatibilityMode,
config.getEcip1017EraRounds());
config.getEcip1017EraRounds(),
evmConfiguration);
validateForkOrdering();
@ -195,7 +204,8 @@ public class ProtocolScheduleBuilder {
ClassicProtocolSpecs.classicRecoveryInitDefinition(
config.getContractSizeLimit(),
config.getEvmStackSize(),
quorumCompatibilityMode));
quorumCompatibilityMode,
evmConfiguration));
protocolSchedule.putMilestone(classicBlockNumber + 1, originalProtocolSpec);
});

@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
import org.hyperledger.besu.evm.processor.AbstractMessageProcessor;
@ -51,7 +52,8 @@ public class ProtocolSpecBuilder {
private BlockHeaderFunctions blockHeaderFunctions;
private AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory;
private DifficultyCalculator difficultyCalculator;
private Function<GasCalculator, EVM> evmBuilder;
private EvmConfiguration evmConfiguration;
private BiFunction<GasCalculator, EvmConfiguration, EVM> evmBuilder;
private Function<GasCalculator, MainnetTransactionValidator> transactionValidatorBuilder;
private Function<FeeMarket, BlockHeaderValidator.Builder> blockHeaderValidatorBuilder;
private Function<FeeMarket, BlockHeaderValidator.Builder> ommerHeaderValidatorBuilder;
@ -110,7 +112,8 @@ public class ProtocolSpecBuilder {
return this;
}
public ProtocolSpecBuilder evmBuilder(final Function<GasCalculator, EVM> evmBuilder) {
public ProtocolSpecBuilder evmBuilder(
final BiFunction<GasCalculator, EvmConfiguration, EVM> evmBuilder) {
this.evmBuilder = evmBuilder;
return this;
}
@ -235,10 +238,16 @@ public class ProtocolSpecBuilder {
return this;
}
public ProtocolSpecBuilder evmConfiguration(final EvmConfiguration evmConfiguration) {
this.evmConfiguration = evmConfiguration;
return this;
}
public ProtocolSpec build(final ProtocolSchedule protocolSchedule) {
checkNotNull(gasCalculatorBuilder, "Missing gasCalculator");
checkNotNull(gasLimitCalculator, "Missing gasLimitCalculator");
checkNotNull(evmBuilder, "Missing operation registry");
checkNotNull(evmConfiguration, "Missing evm configuration");
checkNotNull(transactionValidatorBuilder, "Missing transaction validator");
checkNotNull(privateTransactionValidatorBuilder, "Missing private transaction validator");
checkNotNull(contractCreationProcessorBuilder, "Missing contract creation processor");
@ -263,7 +272,7 @@ public class ProtocolSpecBuilder {
checkNotNull(badBlockManager, "Missing bad blocks manager");
final GasCalculator gasCalculator = gasCalculatorBuilder.get();
final EVM evm = evmBuilder.apply(gasCalculator);
final EVM evm = evmBuilder.apply(gasCalculator, evmConfiguration);
final PrecompiledContractConfiguration precompiledContractConfiguration =
new PrecompiledContractConfiguration(gasCalculator, privacyParameters);
final MainnetTransactionValidator transactionValidator =

@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateU
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;
import org.hyperledger.besu.evm.account.EvmAccount;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.frame.MessageFrame;
@ -156,7 +157,7 @@ public class PrivateTransactionProcessor {
.address(privateContractAddress)
.contract(privateContractAddress)
.inputData(Bytes.EMPTY)
.code(new Code(transaction.getPayload()))
.code(new Code(transaction.getPayload(), Hash.EMPTY))
.build();
} else {
final Address to = transaction.getTo().get();
@ -167,7 +168,10 @@ public class PrivateTransactionProcessor {
.address(to)
.contract(to)
.inputData(transaction.getPayload())
.code(new Code(maybeContract.map(Account::getCode).orElse(Bytes.EMPTY)))
.code(
new Code(
maybeContract.map(AccountState::getCode).orElse(Bytes.EMPTY),
maybeContract.map(AccountState::getCodeHash).orElse(Hash.EMPTY)))
.build();
}

@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.util.RawBlockIterator;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.testutil.BlockTestUtil;
import org.hyperledger.besu.testutil.BlockTestUtil.ChainResources;
@ -134,7 +135,8 @@ public class BlockchainSetupUtil {
private static ProtocolSchedule mainnetProtocolScheduleProvider(
final GenesisConfigFile genesisConfigFile) {
return MainnetProtocolSchedule.fromConfig(genesisConfigFile.getConfigOptions());
return MainnetProtocolSchedule.fromConfig(
genesisConfigFile.getConfigOptions(), EvmConfiguration.DEFAULT);
}
private static ProtocolContext mainnetProtocolContextProvider(

@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueStoragePrefixedKeyBlockchainStorage;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
@ -120,7 +121,8 @@ public class ExecutionContextTestFixture {
ProtocolSpecAdapters.create(0, Function.identity()),
new PrivacyParameters(),
false,
genesisConfigFile.getConfigOptions().isQuorum())
genesisConfigFile.getConfigOptions().isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule();
}
if (keyValueStorage == null) {

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.hyperledger.besu.evm.frame.MessageFrame.DEFAULT_MAX_STACK_SIZE;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
@ -51,7 +52,7 @@ public class MessageFrameTestFixture {
private Wei gasPrice = Wei.ZERO;
private Wei value = Wei.ZERO;
private Bytes inputData = Bytes.EMPTY;
private Code code = new Code(Bytes.EMPTY);
private Code code = new Code(Bytes.EMPTY, Hash.EMPTY);
private final List<UInt256> stackItems = new ArrayList<>();
private Optional<BlockHeader> blockHeader = Optional.empty();
private int depth = 0;

@ -22,6 +22,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.JsonGenesisConfigOptions;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.io.IOException;
@ -33,7 +34,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class ProtocolScheduleFixture {
public static final ProtocolSchedule MAINNET =
MainnetProtocolSchedule.fromConfig(
getMainnetConfigOptions(), PrivacyParameters.DEFAULT, false);
getMainnetConfigOptions(), PrivacyParameters.DEFAULT, false, EvmConfiguration.DEFAULT);
private static GenesisConfigOptions getMainnetConfigOptions() {
// this method avoids reading all the alloc accounts when all we want is the "config" section

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.core;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
@ -84,7 +85,7 @@ public class TestCodeExecutor {
.inputData(transaction.getPayload())
.sender(SENDER_ADDRESS)
.value(transaction.getValue())
.code(new Code(Bytes.fromHexString(code)))
.code(new Code(Bytes.fromHexString(code), Hash.EMPTY))
.blockHeader(blockHeader)
.depth(0)
.build();

@ -20,6 +20,7 @@ import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.junit.Test;
@ -29,7 +30,8 @@ public class FixedProtocolScheduleTest {
public void reportedDifficultyForAllBlocksIsAFixedValue() {
final ProtocolSchedule schedule =
FixedDifficultyProtocolSchedule.create(GenesisConfigFile.development().getConfigOptions());
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), EvmConfiguration.DEFAULT);
final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();
@ -61,7 +63,8 @@ public class FixedProtocolScheduleTest {
public void reportedDifficultyForAllBlocksIsAFixedValueKeccak() {
final ProtocolSchedule schedule =
FixedDifficultyProtocolSchedule.create(GenesisConfigFile.ecip1049dev().getConfigOptions());
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.ecip1049dev().getConfigOptions(), EvmConfiguration.DEFAULT);
final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();

@ -25,6 +25,7 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.log.LogsBloomFilter;
import java.io.IOException;
@ -58,7 +59,8 @@ public class DifficultyCalculatorTests {
return List.of(
new Object[] {
"/BasicTests/difficultyMainNetwork.json",
MainnetProtocolSchedule.fromConfig(GenesisConfigFile.mainnet().getConfigOptions())
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.mainnet().getConfigOptions(), EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyRopsten.json",
@ -67,49 +69,57 @@ public class DifficultyCalculatorTests {
Resources.toString(
GenesisConfigFile.class.getResource("/ropsten.json"),
StandardCharsets.UTF_8))
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyFrontier.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\": {\"frontierBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyHomestead.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\": {\"homesteadBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyByzantium.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\": {\"byzantiumBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyConstantinople.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\": {\"constantinopleBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyEIP2384.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\":{\"muirGlacierBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyEIP2384_random.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\":{\"muirGlacierBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
},
new Object[] {
"/BasicTests/difficultyEIP2384_random_to20M.json",
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{\"config\":{\"muirGlacierBlock\":0}}")
.getConfigOptions())
.getConfigOptions(),
EvmConfiguration.DEFAULT)
});
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.nio.charset.StandardCharsets;
@ -52,7 +53,8 @@ public class MainnetProtocolScheduleTest {
@Test
public void shouldOnlyUseFrontierWhenEmptyJsonConfigIsUsed() {
final ProtocolSchedule sched =
MainnetProtocolSchedule.fromConfig(GenesisConfigFile.fromConfig("{}").getConfigOptions());
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig("{}").getConfigOptions(), EvmConfiguration.DEFAULT);
Assertions.assertThat(sched.getByBlockNumber(1L).getName()).isEqualTo("Frontier");
Assertions.assertThat(sched.getByBlockNumber(Long.MAX_VALUE).getName()).isEqualTo("Frontier");
}
@ -62,7 +64,8 @@ public class MainnetProtocolScheduleTest {
final String json =
"{\"config\": {\"homesteadBlock\": 2, \"daoForkBlock\": 3, \"eip150Block\": 14, \"eip158Block\": 15, \"byzantiumBlock\": 16, \"constantinopleBlock\": 18, \"petersburgBlock\": 19, \"chainId\":1234}}";
final ProtocolSchedule sched =
MainnetProtocolSchedule.fromConfig(GenesisConfigFile.fromConfig(json).getConfigOptions());
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions(), EvmConfiguration.DEFAULT);
Assertions.assertThat(sched.getByBlockNumber(1).getName()).isEqualTo("Frontier");
Assertions.assertThat(sched.getByBlockNumber(2).getName()).isEqualTo("Homestead");
Assertions.assertThat(sched.getByBlockNumber(3).getName()).isEqualTo("DaoRecoveryInit");
@ -85,7 +88,8 @@ public class MainnetProtocolScheduleTest {
.isThrownBy(
() ->
MainnetProtocolSchedule.fromConfig(
GenesisConfigFile.fromConfig(json).getConfigOptions()));
GenesisConfigFile.fromConfig(json).getConfigOptions(),
EvmConfiguration.DEFAULT));
}
@Test
@ -95,7 +99,8 @@ public class MainnetProtocolScheduleTest {
GenesisConfigFile.fromConfig(
Resources.toString(
this.getClass().getResource("/ropsten.json"), StandardCharsets.UTF_8))
.getConfigOptions());
.getConfigOptions(),
EvmConfiguration.DEFAULT);
Assertions.assertThat(sched.getByBlockNumber(0L).getName()).isEqualTo("TangerineWhistle");
Assertions.assertThat(sched.getByBlockNumber(1L).getName()).isEqualTo("TangerineWhistle");
Assertions.assertThat(sched.getByBlockNumber(10L).getName()).isEqualTo("SpuriousDragon");
@ -116,7 +121,8 @@ public class MainnetProtocolScheduleTest {
GenesisConfigFile.fromConfig(
Resources.toString(
this.getClass().getResource("/goerli.json"), StandardCharsets.UTF_8))
.getConfigOptions());
.getConfigOptions(),
EvmConfiguration.DEFAULT);
Assertions.assertThat(sched.getByBlockNumber(0L).getName()).isEqualTo("Petersburg");
Assertions.assertThat(sched.getByBlockNumber(1_561_651L).getName()).isEqualTo("Istanbul");
Assertions.assertThat(sched.getByBlockNumber(4_460_644L).getName()).isEqualTo("Berlin");
@ -131,7 +137,8 @@ public class MainnetProtocolScheduleTest {
GenesisConfigFile.fromConfig(
Resources.toString(
this.getClass().getResource("/rinkeby.json"), StandardCharsets.UTF_8))
.getConfigOptions());
.getConfigOptions(),
EvmConfiguration.DEFAULT);
Assertions.assertThat(sched.getByBlockNumber(0L).getName()).isEqualTo("Frontier");
Assertions.assertThat(sched.getByBlockNumber(1L).getName()).isEqualTo("Homestead");
Assertions.assertThat(sched.getByBlockNumber(2L).getName()).isEqualTo("TangerineWhistle");

@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.OptionalLong;
@ -55,7 +56,8 @@ public class ProtocolScheduleBuilderTest {
ProtocolSpecAdapters.create(2, modifier),
new PrivacyParameters(),
false,
false);
false,
EvmConfiguration.DEFAULT);
final MutableProtocolSchedule schedule =
(MutableProtocolSchedule) builder.createProtocolSchedule();
@ -83,7 +85,8 @@ public class ProtocolScheduleBuilderTest {
ProtocolSpecAdapters.create(2, modifier),
new PrivacyParameters(),
false,
false);
false,
EvmConfiguration.DEFAULT);
final MutableProtocolSchedule schedule =
(MutableProtocolSchedule) builder.createProtocolSchedule();
@ -111,7 +114,8 @@ public class ProtocolScheduleBuilderTest {
ProtocolSpecAdapters.create(5, modifier),
new PrivacyParameters(),
false,
false);
false,
EvmConfiguration.DEFAULT);
final MutableProtocolSchedule schedule =
(MutableProtocolSchedule) builder.createProtocolSchedule();

@ -18,10 +18,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyByte;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.operation.Operation;
import org.hyperledger.besu.evm.operation.OperationRegistry;
import org.hyperledger.besu.evm.operation.StopOperation;
@ -42,12 +44,13 @@ public class EVMTest {
@Before
public void setup() {
evm = new EVM(operationRegistry, gasCalculator);
evm = new EVM(operationRegistry, gasCalculator, EvmConfiguration.DEFAULT);
}
@Test
public void assertThatEndOfScriptNotExplicitlySetInCodeReturnsAVirtualOperation() {
final Code code = new Code(Bytes.fromHexString("0x60203560003555606035604035556000"));
final Bytes noEnd = Bytes.fromHexString("0x60203560003555606035604035556000");
final Code code = new Code(noEnd, Hash.hash(noEnd));
final Operation operation = evm.operationAtOffset(code, code.getSize());
assertThat(operation).isNotNull();
assertThat(operation.isVirtualOperation()).isTrue();
@ -55,7 +58,8 @@ public class EVMTest {
@Test
public void assertThatEndOfScriptExplicitlySetInCodeDoesNotReturnAVirtualOperation() {
final Code code = new Code(Bytes.fromHexString("0x6020356000355560603560403555600000"));
final Bytes ends = Bytes.fromHexString("0x6020356000355560603560403555600000");
final Code code = new Code(ends, Hash.hash(ends));
when(operationRegistry.get(anyByte())).thenReturn(new StopOperation(gasCalculator));
final Operation operation = evm.operationAtOffset(code, code.getSize() - 1);
assertThat(operation).isNotNull();

@ -30,6 +30,7 @@ import org.hyperledger.besu.ethereum.referencetests.VMReferenceTestCaseSpec;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.testutil.JsonTestParameters;
@ -98,7 +99,8 @@ public class VMReferenceTest extends AbstractRetryingTest {
final EnvironmentInformation execEnv = spec.getExec();
final ProtocolSpec protocolSpec =
MainnetProtocolSpecs.frontierDefinition(OptionalInt.empty(), OptionalInt.empty(), false)
MainnetProtocolSpecs.frontierDefinition(
OptionalInt.empty(), OptionalInt.empty(), false, EvmConfiguration.DEFAULT)
.privacyParameters(PrivacyParameters.DEFAULT)
.privateTransactionValidatorBuilder(() -> new PrivateTransactionValidator(CHAIN_ID))
.badBlocksManager(new BadBlockManager())

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.frame.MessageFrame.State;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.Before;
@ -36,7 +37,8 @@ import org.junit.runners.Parameterized.Parameters;
public class ConstantinopleSStoreOperationGasCostTest {
private static final ProtocolSchedule protocolSchedule =
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().constantinopleBlock(0));
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().constantinopleBlock(0), EvmConfiguration.DEFAULT);
@Parameters(name = "Code: {0}, Original: {1}")
public static Object[][] scenarios() {

@ -20,6 +20,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
@ -140,7 +141,7 @@ public class Create2OperationTest {
.sender(Address.fromHexString(sender))
.value(Wei.ZERO)
.apparentValue(Wei.ZERO)
.code(new Code(codeBytes))
.code(new Code(codeBytes, Hash.hash(codeBytes)))
.depth(1)
.completer(__ -> {})
.address(Address.fromHexString(sender))

@ -17,8 +17,11 @@ package org.hyperledger.besu.ethereum.vm.operations;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -31,6 +34,7 @@ import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.frame.ExceptionalHaltReason;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.operation.JumpDestOperation;
import org.hyperledger.besu.evm.operation.JumpOperation;
import org.hyperledger.besu.evm.operation.Operation.OperationResult;
@ -41,6 +45,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
public class JumpOperationTest {
@ -78,16 +83,17 @@ public class JumpOperationTest {
final OperationRegistry registry = new OperationRegistry();
registry.put(new JumpOperation(gasCalculator));
registry.put(new JumpDestOperation(gasCalculator));
evm = new EVM(registry, gasCalculator);
evm = new EVM(registry, gasCalculator, EvmConfiguration.DEFAULT);
}
@Test
public void shouldJumpWhenLocationIsJumpDest() {
final JumpOperation operation = new JumpOperation(gasCalculator);
final Bytes jumpBytes = Bytes.fromHexString("0x6003565b00");
final MessageFrame frame =
createMessageFrameBuilder(Gas.of(10_000))
.pushStackItem(UInt256.fromHexString("0x03"))
.code(new Code(Bytes.fromHexString("0x6003565b00")))
.code(new Code(jumpBytes, Hash.hash(jumpBytes)))
.build();
frame.setPC(CURRENT_PC);
@ -98,10 +104,11 @@ public class JumpOperationTest {
@Test
public void shouldJumpWhenLocationIsJumpDestAndAtEndOfCode() {
final JumpOperation operation = new JumpOperation(gasCalculator);
final Bytes jumpBytes = Bytes.fromHexString("0x6003565b");
final MessageFrame frame =
createMessageFrameBuilder(Gas.of(10_000))
.pushStackItem(UInt256.fromHexString("0x03"))
.code(new Code(Bytes.fromHexString("0x6003565b")))
.code(new Code(jumpBytes, Hash.hash(jumpBytes)))
.build();
frame.setPC(CURRENT_PC);
@ -112,41 +119,73 @@ public class JumpOperationTest {
@Test
public void shouldHaltWithInvalidJumDestinationWhenLocationIsOutsideOfCodeRange() {
final JumpOperation operation = new JumpOperation(gasCalculator);
final Bytes jumpBytes = Bytes.fromHexString("0x6801000000000000000c565b00");
final MessageFrame frameDestinationGreaterThanCodeSize =
createMessageFrameBuilder(Gas.of(100))
.pushStackItem(UInt256.fromHexString("0xFFFFFFFF"))
.code(new Code(Bytes.fromHexString("0x6801000000000000000c565b00")))
.code(new Code(jumpBytes, Hash.hash(jumpBytes)))
.build();
frameDestinationGreaterThanCodeSize.setPC(CURRENT_PC);
final OperationResult result = operation.execute(frameDestinationGreaterThanCodeSize, null);
final OperationResult result = operation.execute(frameDestinationGreaterThanCodeSize, evm);
assertThat(result.getHaltReason()).contains(ExceptionalHaltReason.INVALID_JUMP_DESTINATION);
Bytes badJump = Bytes.fromHexString("0x60045600");
final MessageFrame frameDestinationEqualsToCodeSize =
createMessageFrameBuilder(Gas.of(100))
.pushStackItem(UInt256.fromHexString("0x04"))
.code(new Code(Bytes.fromHexString("0x60045600")))
.code(new Code(badJump, Hash.hash(badJump)))
.build();
frameDestinationEqualsToCodeSize.setPC(CURRENT_PC);
final OperationResult result2 = operation.execute(frameDestinationEqualsToCodeSize, null);
final OperationResult result2 = operation.execute(frameDestinationEqualsToCodeSize, evm);
assertThat(result2.getHaltReason()).contains(ExceptionalHaltReason.INVALID_JUMP_DESTINATION);
}
@Test
public void longContractsValidate() {
final JumpOperation operation = new JumpOperation(gasCalculator);
final Bytes longCode =
Bytes.fromHexString(
"0x60006000351461001157600050610018565b6101016020525b60016000351461002a5760005061002f565b326020525b60026000351461004157600050610046565b336020525b6003600035146100585760005061005d565b306020525b60046000351461006f57600050610075565b60016020525b60005160005260006020351461008d576000506100b6565b5a600052602051315060165a60005103036000555a600052602051315060165a60005103036001555b6001602035146100c8576000506100f1565b5a6000526020513b5060165a60005103036000555a6000526020513b5060165a60005103036001555b6002602035146101035760005061012c565b5a6000526020513f5060165a60005103036000555a6000526020513f5060165a60005103036001555b60036020351461013e5760005061017a565b6106a5610100525a600052602060006101006020513c60205a60005103036000555a600052602060006101006020513c60205a60005103036001555b00");
final MessageFrame longContract =
createMessageFrameBuilder(Gas.of(100))
.pushStackItem(UInt256.fromHexString("0x12c"))
.code(
new Code(
Bytes.fromHexString(
"0x60006000351461001157600050610018565b6101016020525b60016000351461002a5760005061002f565b326020525b60026000351461004157600050610046565b336020525b6003600035146100585760005061005d565b306020525b60046000351461006f57600050610075565b60016020525b60005160005260006020351461008d576000506100b6565b5a600052602051315060165a60005103036000555a600052602051315060165a60005103036001555b6001602035146100c8576000506100f1565b5a6000526020513b5060165a60005103036000555a6000526020513b5060165a60005103036001555b6002602035146101035760005061012c565b5a6000526020513f5060165a60005103036000555a6000526020513f5060165a60005103036001555b60036020351461013e5760005061017a565b6106a5610100525a600052602060006101006020513c60205a60005103036000555a600052602060006101006020513c60205a60005103036001555b00")))
.code(new Code(longCode, Hash.hash(longCode)))
.build();
longContract.setPC(255);
final OperationResult result = operation.execute(longContract, null);
final OperationResult result = operation.execute(longContract, evm);
assertThat(result.getHaltReason()).isEmpty();
}
@Test
public void shouldReuseJumpDestMap() {
final JumpOperation operation = new JumpOperation(gasCalculator);
final Bytes jumpBytes = Bytes.fromHexString("0x6003565b00");
Code getsCached = spy(new Code(jumpBytes, Hash.hash(jumpBytes)));
MessageFrame frame =
createMessageFrameBuilder(Gas.of(10_000))
.pushStackItem(UInt256.fromHexString("0x03"))
.code(getsCached)
.build();
frame.setPC(CURRENT_PC);
OperationResult result = operation.execute(frame, evm);
assertThat(result.getHaltReason()).isEmpty();
Mockito.verify(getsCached, times(1)).calculateJumpDests();
// do it again to prove we don't recalc, and we hit the cache
frame =
createMessageFrameBuilder(Gas.of(10_000))
.pushStackItem(UInt256.fromHexString("0x03"))
.code(getsCached)
.build();
frame.setPC(CURRENT_PC);
result = operation.execute(frame, evm);
assertThat(result.getHaltReason()).isEmpty();
Mockito.verify(getsCached, times(1)).calculateJumpDests();
}
}

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.frame.MessageFrame.State;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.Before;
@ -77,7 +78,8 @@ public class LondonSStoreOperationGasCostTest {
@Before
public void setUp() {
protocolSchedule =
MainnetProtocolSchedule.fromConfig(new StubGenesisConfigOptions().londonBlock(0));
MainnetProtocolSchedule.fromConfig(
new StubGenesisConfigOptions().londonBlock(0), EvmConfiguration.DEFAULT);
codeExecutor = new TestCodeExecutor(protocolSchedule);
}

File diff suppressed because one or more lines are too long

@ -25,6 +25,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -68,7 +69,9 @@ public final class BlockBodiesMessageTest {
message
.bodies(
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), false))
GenesisConfigFile.development().getConfigOptions(),
false,
EvmConfiguration.DEFAULT))
.iterator();
for (int i = 0; i < 50; ++i) {
Assertions.assertThat(readBodies.next()).isEqualTo(bodies.get(i));

@ -23,6 +23,7 @@ import org.hyperledger.besu.ethereum.p2p.rlpx.wire.RawMessage;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -60,7 +61,9 @@ public final class BlockHeadersMessageTest {
final List<BlockHeader> readHeaders =
message.getHeaders(
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), false));
GenesisConfigFile.development().getConfigOptions(),
false,
EvmConfiguration.DEFAULT));
for (int i = 0; i < 50; ++i) {
Assertions.assertThat(readHeaders.get(i)).isEqualTo(headers.get(i));

@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer;
import org.hyperledger.besu.ethereum.eth.manager.RespondingEthPeer.Responder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import java.util.Arrays;
@ -51,7 +52,7 @@ public class ChainHeadTrackerTest {
private final ProtocolSchedule protocolSchedule =
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), false);
GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT);
private final TrailingPeerLimiter trailingPeerLimiter = mock(TrailingPeerLimiter.class);

@ -55,6 +55,7 @@ import org.hyperledger.besu.ethereum.p2p.peers.Peer;
import org.hyperledger.besu.ethereum.p2p.rlpx.connections.PeerConnection;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.messages.DisconnectMessage.DisconnectReason;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.testutil.TestClock;
@ -105,7 +106,7 @@ public class TestNode implements Closeable {
final GenesisConfigFile genesisConfigFile = GenesisConfigFile.development();
final ProtocolSchedule protocolSchedule =
FixedDifficultyProtocolSchedule.create(
GenesisConfigFile.development().getConfigOptions(), false);
GenesisConfigFile.development().getConfigOptions(), false, EvmConfiguration.DEFAULT);
final GenesisState genesisState = GenesisState.fromConfig(genesisConfigFile, protocolSchedule);
final BlockHeaderFunctions blockHeaderFunctions =

@ -23,6 +23,7 @@ import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import javax.inject.Named;
@ -41,7 +42,8 @@ class CliqueGenesisFileModule extends GenesisFileModule {
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
// dagger can handle this magic one day
return CliqueProtocolSchedule.create(configOptions, nodeKey, revertReasonEnabled);
return CliqueProtocolSchedule.create(
configOptions, nodeKey, revertReasonEnabled, EvmConfiguration.DEFAULT);
}
@Override

@ -241,7 +241,7 @@ public class EvmToolCommand implements Runnable {
.inputData(callData)
.value(ethValue)
.apparentValue(ethValue)
.code(new Code(codeHexString))
.code(new Code(codeHexString, Hash.hash(codeHexString)))
.blockValues(blockHeader)
.depth(0)
.completer(c -> {})

@ -21,6 +21,7 @@ import org.hyperledger.besu.consensus.ibft.IbftExtraDataCodec;
import org.hyperledger.besu.consensus.ibft.IbftProtocolSchedule;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import javax.inject.Named;
@ -35,7 +36,8 @@ class IBFTGenesisFileModule extends GenesisFileModule {
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
return IbftProtocolSchedule.create(configOptions, bftExtraDataEncoder);
return IbftProtocolSchedule.create(
configOptions, bftExtraDataEncoder, EvmConfiguration.DEFAULT);
}
@Override

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import javax.inject.Named;
@ -33,7 +34,7 @@ class MainnetGenesisFileModule extends GenesisFileModule {
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
return MainnetProtocolSchedule.fromConfig(configOptions);
return MainnetProtocolSchedule.fromConfig(configOptions, EvmConfiguration.DEFAULT);
}
@Override

@ -15,6 +15,7 @@
*/
package org.hyperledger.besu.ethereum.referencetests;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.Code;
import com.fasterxml.jackson.annotation.JsonCreator;
@ -32,6 +33,6 @@ public class ReferenceTestCode extends Code {
*/
@JsonCreator
public ReferenceTestCode(final String bytes) {
super(Bytes.fromHexString(bytes));
super(Bytes.fromHexString(bytes), Hash.hash(Bytes.fromHexString(bytes)));
}
}

@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import java.math.BigInteger;
import java.util.Arrays;
@ -85,7 +86,8 @@ public class ReferenceTestProtocolSchedules {
ProtocolSpecAdapters.create(0, Function.identity()),
PrivacyParameters.DEFAULT,
false,
options.isQuorum())
options.isQuorum(),
EvmConfiguration.DEFAULT)
.createProtocolSchedule();
}

@ -57,6 +57,7 @@ import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage;
import org.hyperledger.besu.ethereum.worldstate.DefaultWorldStateArchive;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
@ -131,7 +132,8 @@ public class RetestethContext {
final JsonGenesisConfigOptions jsonGenesisConfigOptions =
JsonGenesisConfigOptions.fromJsonObject(
JsonUtil.getObjectNode(genesisConfig, "config").get());
protocolSchedule = MainnetProtocolSchedule.fromConfig(jsonGenesisConfigOptions);
protocolSchedule =
MainnetProtocolSchedule.fromConfig(jsonGenesisConfigOptions, EvmConfiguration.DEFAULT);
if ("NoReward".equalsIgnoreCase(sealEngine)) {
protocolSchedule = new NoRewardProtocolScheduleWrapper(protocolSchedule);
}

@ -40,6 +40,7 @@ dependencies {
implementation 'org.apache.logging.log4j:log4j-api'
implementation 'org.hyperledger.besu:bls12-381'
implementation 'net.java.dev.jna:jna'
implementation 'com.github.ben-manes.caffeine:caffeine'
testImplementation 'info.picocli:picocli'
testImplementation 'junit:junit'

@ -14,13 +14,12 @@
*/
package org.hyperledger.besu.evm;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.operation.JumpDestOperation;
import org.hyperledger.besu.evm.operation.PushOperation;
import com.google.common.base.MoreObjects;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
/** Represents EVM code associated with an account. */
public class Code {
@ -28,21 +27,34 @@ public class Code {
/** The bytes representing the code. */
private final Bytes bytes;
/** The hash of the code, needed for accessing metadata about the bytecode */
private final Hash codeHash;
/** Used to cache valid jump destinations. */
// private BitSet validJumpDestinations;
long[] validJumpDestinations;
/** Syntactic sugar for an empty contract */
public static Code EMPTY = new Code(Bytes.EMPTY, Hash.EMPTY);
/**
* Public constructor.
*
* @param bytes The byte representation of the code.
* @param codeHash the Hash of the bytes in the code.
*/
public Code(final Bytes bytes) {
public Code(final Bytes bytes, final Hash codeHash) {
this.bytes = bytes;
this.codeHash = codeHash;
}
public Code(final Bytes bytecode, final Hash codeHash, final long[] validJumpDestinations) {
this.bytes = bytecode;
this.validJumpDestinations = validJumpDestinations;
this.codeHash = codeHash;
}
public Code() {
this(Bytes.EMPTY);
this(Bytes.EMPTY, Hash.EMPTY);
}
/**
@ -75,51 +87,33 @@ public class Code {
return bytes.size();
}
/**
* Determine whether a specified destination is a valid jump target.
*
* @param evm the EVM executing this code
* @param frame The current message frame
* @param destination The destination we're checking for validity.
* @return Whether or not this location is a valid jump destination.
*/
public boolean isValidJumpDestination(
final EVM evm, final MessageFrame frame, final UInt256 destination) {
if (!destination.fitsInt()) return false;
final int jumpDestination = destination.intValue();
if (jumpDestination >= getSize()) return false;
if (validJumpDestinations == null) {
// Calculate valid jump destinations
int size = getSize();
validJumpDestinations = new long[(size >> 6) + 1];
byte[] rawCode = getBytes().toArrayUnsafe();
int length = rawCode.length;
for (int i = 0; i < length; ) {
long thisEntry = 0L;
int entryPos = i >> 6;
int max = Math.min(64, length - (entryPos << 6));
int j = i & 0x3F;
for (; j < max; i++, j++) {
byte operationNum = rawCode[i];
if (operationNum == JumpDestOperation.OPCODE) {
thisEntry |= 1L << j;
} else if (operationNum > PushOperation.PUSH_BASE) {
// not needed - && operationNum <= PushOperation.PUSH_MAX
// Java quirk, all bytes are signed, and PUSH32 is 127, which is Byte.MAX_VALUE
// so we don't need to check the upper bound as it will never be violated
int multiByteDataLen = operationNum - PushOperation.PUSH_BASE;
j += multiByteDataLen;
i += multiByteDataLen;
}
public long[] calculateJumpDests() {
int size = getSize();
long[] bitmap = new long[(size >> 6) + 1];
byte[] rawCode = getBytes().toArrayUnsafe();
int length = rawCode.length;
for (int i = 0; i < length; ) {
long thisEntry = 0L;
int entryPos = i >> 6;
int max = Math.min(64, length - (entryPos << 6));
int j = i & 0x3F;
for (; j < max; i++, j++) {
byte operationNum = rawCode[i];
if (operationNum == JumpDestOperation.OPCODE) {
thisEntry |= 1L << j;
} else if (operationNum > PushOperation.PUSH_BASE) {
// not needed - && operationNum <= PushOperation.PUSH_MAX
// Java quirk, all bytes are signed, and PUSH32 is 127, which is Byte.MAX_VALUE
// so we don't need to check the upper bound as it will never be violated
int multiByteDataLen = operationNum - PushOperation.PUSH_BASE;
j += multiByteDataLen;
i += multiByteDataLen;
}
validJumpDestinations[entryPos] = thisEntry;
}
bitmap[entryPos] = thisEntry;
}
long targetLong = validJumpDestinations[jumpDestination >> 6];
long targetBit = 1L << (jumpDestination & 0x3F);
return (targetLong & targetBit) != 0L;
this.validJumpDestinations = bitmap;
return bitmap;
}
public Bytes getBytes() {
@ -130,4 +124,12 @@ public class Code {
public String toString() {
return MoreObjects.toStringHelper(this).add("bytes", bytes).toString();
}
public Hash getCodeHash() {
return codeHash;
}
public long[] getValidJumpDestinations() {
return validJumpDestinations;
}
}

@ -16,12 +16,15 @@ package org.hyperledger.besu.evm;
import static org.apache.logging.log4j.LogManager.getLogger;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.frame.ExceptionalHaltReason;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.frame.MessageFrame.State;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.internal.FixedStack.OverflowException;
import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException;
import org.hyperledger.besu.evm.internal.JumpDestCache;
import org.hyperledger.besu.evm.operation.InvalidOperation;
import org.hyperledger.besu.evm.operation.Operation;
import org.hyperledger.besu.evm.operation.Operation.OperationResult;
@ -36,6 +39,7 @@ import java.util.function.BiConsumer;
import com.google.common.annotations.VisibleForTesting;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
public class EVM {
private static final Logger LOG = getLogger();
@ -50,11 +54,16 @@ public class EVM {
private final OperationRegistry operations;
private final GasCalculator gasCalculator;
private final Operation endOfScriptStop;
private final JumpDestCache jumpDestCache;
public EVM(final OperationRegistry operations, final GasCalculator gasCalculator) {
public EVM(
final OperationRegistry operations,
final GasCalculator gasCalculator,
final EvmConfiguration evmConfiguration) {
this.operations = operations;
this.gasCalculator = gasCalculator;
this.endOfScriptStop = new VirtualOperation(new StopOperation(gasCalculator));
this.jumpDestCache = new JumpDestCache(evmConfiguration);
}
public GasCalculator getGasCalculator() {
@ -150,4 +159,33 @@ public class EVM {
return operation;
}
}
/**
* Determine whether a specified destination is a valid jump target.
*
* @param destination The destination we're checking for validity.
* @param code The code within which we are looking for the destination.
* @return Whether or not this location is a valid jump destination.
*/
public boolean isValidJumpDestination(final UInt256 destination, final Code code) {
if (!destination.fitsInt()) return false;
final int jumpDestination = destination.intValue();
if (jumpDestination >= code.getSize()) return false;
long[] validJumpDestinations = code.getValidJumpDestinations();
if (validJumpDestinations == null || validJumpDestinations.length == 0) {
validJumpDestinations = jumpDestCache.getIfPresent(code.getCodeHash());
if (validJumpDestinations == null) {
validJumpDestinations = code.calculateJumpDests();
if (code.getCodeHash() != null && !code.getCodeHash().equals(Hash.EMPTY)) {
jumpDestCache.put(code.getCodeHash(), validJumpDestinations);
} else {
LOG.debug("not caching jumpdest for unhashed contract code");
}
}
}
long targetLong = validJumpDestinations[jumpDestination >> 6];
long targetBit = 1L << (jumpDestination & 0x3F);
return (targetLong & targetBit) != 0L;
}
}

@ -24,6 +24,7 @@ import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.operation.AddModOperation;
import org.hyperledger.besu.evm.operation.AddOperation;
import org.hyperledger.besu.evm.operation.AddressOperation;
@ -114,13 +115,13 @@ public abstract class MainnetEVMs {
public static final BigInteger DEV_NET_CHAIN_ID = BigInteger.valueOf(1337);
public static EVM frontier() {
return frontier(new FrontierGasCalculator());
public static EVM frontier(final EvmConfiguration evmConfiguration) {
return frontier(new FrontierGasCalculator(), evmConfiguration);
}
public static EVM frontier(final GasCalculator gasCalculator) {
return new EVM(frontierOperations(gasCalculator), gasCalculator);
public static EVM frontier(
final GasCalculator gasCalculator, final EvmConfiguration evmConfiguration) {
return new EVM(frontierOperations(gasCalculator), gasCalculator, evmConfiguration);
}
public static OperationRegistry frontierOperations(final GasCalculator gasCalculator) {
@ -214,12 +215,13 @@ public abstract class MainnetEVMs {
}
}
public static EVM homestead() {
return homestead(new FrontierGasCalculator());
public static EVM homestead(final EvmConfiguration evmConfiguration) {
return homestead(new FrontierGasCalculator(), evmConfiguration);
}
public static EVM homestead(final GasCalculator gasCalculator) {
return new EVM(homesteadOperations(gasCalculator), gasCalculator);
public static EVM homestead(
final GasCalculator gasCalculator, final EvmConfiguration evmConfiguration) {
return new EVM(homesteadOperations(gasCalculator), gasCalculator, evmConfiguration);
}
public static OperationRegistry homesteadOperations(final GasCalculator gasCalculator) {
@ -234,20 +236,21 @@ public abstract class MainnetEVMs {
registry.put(new DelegateCallOperation(gasCalculator));
}
public static EVM spuriousDragon() {
return homestead(new SpuriousDragonGasCalculator());
public static EVM spuriousDragon(final EvmConfiguration evmConfiguration) {
return homestead(new SpuriousDragonGasCalculator(), evmConfiguration);
}
public static EVM tangerineWhistle() {
return homestead(new TangerineWhistleGasCalculator());
public static EVM tangerineWhistle(final EvmConfiguration evmConfiguration) {
return homestead(new TangerineWhistleGasCalculator(), evmConfiguration);
}
public static EVM byzantium() {
return byzantium(new ByzantiumGasCalculator());
public static EVM byzantium(final EvmConfiguration evmConfiguration) {
return byzantium(new ByzantiumGasCalculator(), evmConfiguration);
}
public static EVM byzantium(final GasCalculator gasCalculator) {
return new EVM(byzantiumOperations(gasCalculator), gasCalculator);
public static EVM byzantium(
final GasCalculator gasCalculator, final EvmConfiguration evmConfiguration) {
return new EVM(byzantiumOperations(gasCalculator), gasCalculator, evmConfiguration);
}
public static OperationRegistry byzantiumOperations(final GasCalculator gasCalculator) {
@ -265,12 +268,13 @@ public abstract class MainnetEVMs {
registry.put(new StaticCallOperation(gasCalculator));
}
public static EVM constantinople() {
return constantinople(new ConstantinopleGasCalculator());
public static EVM constantinople(final EvmConfiguration evmConfiguration) {
return constantinople(new ConstantinopleGasCalculator(), evmConfiguration);
}
public static EVM constantinople(final GasCalculator gasCalculator) {
return new EVM(constantinopleOperations(gasCalculator), gasCalculator);
public static EVM constantinople(
final GasCalculator gasCalculator, final EvmConfiguration evmConfiguration) {
return new EVM(constantinopleOperations(gasCalculator), gasCalculator, evmConfiguration);
}
public static OperationRegistry constantinopleOperations(final GasCalculator gasCalculator) {
@ -289,20 +293,23 @@ public abstract class MainnetEVMs {
registry.put(new ExtCodeHashOperation(gasCalculator));
}
public static EVM petersburg() {
return constantinople(new PetersburgGasCalculator());
public static EVM petersburg(final EvmConfiguration evmConfiguration) {
return constantinople(new PetersburgGasCalculator(), evmConfiguration);
}
public static EVM istanbul() {
return istanbul(DEV_NET_CHAIN_ID);
public static EVM istanbul(final EvmConfiguration evmConfiguration) {
return istanbul(DEV_NET_CHAIN_ID, evmConfiguration);
}
public static EVM istanbul(final BigInteger chainId) {
return istanbul(new IstanbulGasCalculator(), chainId);
public static EVM istanbul(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return istanbul(new IstanbulGasCalculator(), chainId, evmConfiguration);
}
public static EVM istanbul(final GasCalculator gasCalculator, final BigInteger chainId) {
return new EVM(istanbulOperations(gasCalculator, chainId), gasCalculator);
public static EVM istanbul(
final GasCalculator gasCalculator,
final BigInteger chainId,
final EvmConfiguration evmConfiguration) {
return new EVM(istanbulOperations(gasCalculator, chainId), gasCalculator, evmConfiguration);
}
public static OperationRegistry istanbulOperations(
@ -323,24 +330,27 @@ public abstract class MainnetEVMs {
registry.put(new SStoreOperation(gasCalculator, SStoreOperation.EIP_1706_MINIMUM));
}
public static EVM berlin() {
return berlin(DEV_NET_CHAIN_ID);
public static EVM berlin(final EvmConfiguration evmConfiguration) {
return berlin(DEV_NET_CHAIN_ID, evmConfiguration);
}
public static EVM berlin(final BigInteger chainId) {
return istanbul(new BerlinGasCalculator(), chainId);
public static EVM berlin(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return istanbul(new BerlinGasCalculator(), chainId, evmConfiguration);
}
public static EVM london() {
return london(DEV_NET_CHAIN_ID);
public static EVM london(final EvmConfiguration evmConfiguration) {
return london(DEV_NET_CHAIN_ID, evmConfiguration);
}
public static EVM london(final BigInteger chainId) {
return london(new LondonGasCalculator(), chainId);
public static EVM london(final BigInteger chainId, final EvmConfiguration evmConfiguration) {
return london(new LondonGasCalculator(), chainId, evmConfiguration);
}
public static EVM london(final GasCalculator gasCalculator, final BigInteger chainId) {
return new EVM(londonOperations(gasCalculator, chainId), gasCalculator);
public static EVM london(
final GasCalculator gasCalculator,
final BigInteger chainId,
final EvmConfiguration evmConfiguration) {
return new EVM(londonOperations(gasCalculator, chainId), gasCalculator, evmConfiguration);
}
public static OperationRegistry londonOperations(

@ -15,6 +15,7 @@
package org.hyperledger.besu.evm.fluent;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
@ -25,6 +26,7 @@ import org.hyperledger.besu.evm.contractvalidation.MaxCodeSizeRule;
import org.hyperledger.besu.evm.contractvalidation.PrefixCodeRule;
import org.hyperledger.besu.evm.frame.BlockValues;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
@ -56,7 +58,7 @@ public class EVMExecutor {
private Wei gasPriceGWei = Wei.ZERO;
private Bytes callData = Bytes.EMPTY;
private Wei ethValue = Wei.ZERO;
private Code code = new Code(Bytes.EMPTY);
private Code code = new Code(Bytes.EMPTY, Hash.EMPTY);
private BlockValues blockValues = new SimpleBlockValues();
private OperationTracer tracer = OperationTracer.NO_TRACING;
private boolean requireDeposit = true;
@ -75,9 +77,9 @@ public class EVMExecutor {
return executor;
}
public static EVMExecutor frontier() {
public static EVMExecutor frontier(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.frontier();
executor.evm = MainnetEVMs.frontier(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of();
@ -86,9 +88,9 @@ public class EVMExecutor {
return executor;
}
public static EVMExecutor homestead() {
public static EVMExecutor homestead(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.homestead();
executor.evm = MainnetEVMs.homestead(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of();
@ -96,72 +98,72 @@ public class EVMExecutor {
return executor;
}
public static EVMExecutor spuriousDragon() {
public static EVMExecutor spuriousDragon(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.spuriousDragon();
executor.evm = MainnetEVMs.spuriousDragon(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor tangerineWhistle() {
public static EVMExecutor tangerineWhistle(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.tangerineWhistle();
executor.evm = MainnetEVMs.tangerineWhistle(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.frontier(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor byzantium() {
public static EVMExecutor byzantium(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.byzantium();
executor.evm = MainnetEVMs.byzantium(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.byzantium(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor constantinople() {
public static EVMExecutor constantinople(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.constantinople();
executor.evm = MainnetEVMs.constantinople(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.byzantium(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor petersburg() {
public static EVMExecutor petersburg(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.petersburg();
executor.evm = MainnetEVMs.petersburg(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.byzantium(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor istanbul() {
public static EVMExecutor istanbul(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.istanbul();
executor.evm = MainnetEVMs.istanbul(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.istanbul(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor berlin() {
public static EVMExecutor berlin(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.berlin();
executor.evm = MainnetEVMs.berlin(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.istanbul(executor.evm.getGasCalculator());
executor.contractValidationRules = List.of(MaxCodeSizeRule.of(0x6000));
return executor;
}
public static EVMExecutor london() {
public static EVMExecutor london(final EvmConfiguration evmConfiguration) {
EVMExecutor executor = new EVMExecutor();
executor.evm = MainnetEVMs.istanbul();
executor.evm = MainnetEVMs.istanbul(evmConfiguration);
executor.precompileContractRegistry =
MainnetPrecompiledContracts.istanbul(executor.evm.getGasCalculator());
return executor;
@ -196,7 +198,7 @@ public class EVMExecutor {
public Bytes execute(
final Bytes codeBytes, final Bytes inputData, final Wei value, final Address receiver) {
this.code = new Code(codeBytes);
this.code = new Code(codeBytes, Hash.EMPTY);
this.callData = inputData;
this.ethValue = value;
this.receiver = receiver;
@ -299,8 +301,8 @@ public class EVMExecutor {
return this;
}
public EVMExecutor code(final Bytes codeBytes) {
this.code = new Code(codeBytes);
public EVMExecutor code(final Bytes codeBytes, final Hash hash) {
this.code = new Code(codeBytes, hash);
return this;
}

@ -0,0 +1,27 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.evm.internal;
import org.hyperledger.besu.datatypes.Hash;
import com.github.benmanes.caffeine.cache.Weigher;
class CodeScale implements Weigher<Hash, long[]> {
@Override
public int weigh(final Hash key, final long[] value) {
return (value.length * 8) + key.size();
}
}

@ -0,0 +1,33 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.evm.internal;
public class EvmConfiguration {
public static final EvmConfiguration DEFAULT = new EvmConfiguration(32_000L);
private final long jumpDestCacheWeightKB;
public EvmConfiguration(final long jumpDestCacheWeightKB) {
this.jumpDestCacheWeightKB = jumpDestCacheWeightKB;
}
public long getJumpDestCacheWeightBytes() {
return jumpDestCacheWeightKB * 1024L;
}
public long getJumpDestCacheWeightKB() {
return jumpDestCacheWeightKB;
}
}

@ -0,0 +1,62 @@
/*
* Copyright contributors to Hyperledger Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.evm.internal;
import org.hyperledger.besu.datatypes.Hash;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
public class JumpDestCache {
private final Cache<Hash, long[]> cache;
private final long weightLimit;
public JumpDestCache(final EvmConfiguration config) {
this(config.getJumpDestCacheWeightBytes());
}
private JumpDestCache(final long maxWeightBytes) {
this.weightLimit = maxWeightBytes;
this.cache =
Caffeine.newBuilder().maximumWeight(maxWeightBytes).weigher(new CodeScale()).build();
}
public void invalidate(final Hash key) {
this.cache.invalidate(key);
}
public void cleanUp() {
this.cache.cleanUp();
}
public long[] getIfPresent(final Hash codeHash) {
return cache.getIfPresent(codeHash);
}
public void put(final Hash key, final long[] value) {
cache.put(key, value);
}
public long size() {
cache.cleanUp();
return cache.estimatedSize();
}
public long getWeightLimit() {
return weightLimit;
}
}

@ -15,6 +15,7 @@
package org.hyperledger.besu.evm.operation;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
@ -206,7 +207,10 @@ public abstract class AbstractCallOperation extends AbstractOperation {
.sender(sender(frame))
.value(value(frame))
.apparentValue(apparentValue(frame))
.code(new Code(contract != null ? contract.getCode() : Bytes.EMPTY))
.code(
new Code(
contract != null ? contract.getCode() : Bytes.EMPTY,
contract != null ? contract.getCodeHash() : Hash.EMPTY))
.blockValues(frame.getBlockValues())
.depth(frame.getMessageStackDepth() + 1)
.isStatic(isStatic(frame))

@ -17,6 +17,7 @@ package org.hyperledger.besu.evm.operation;
import static org.hyperledger.besu.evm.internal.Words.clampedToLong;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
@ -136,7 +137,7 @@ public abstract class AbstractCreateOperation extends AbstractOperation {
.sender(frame.getRecipientAddress())
.value(value)
.apparentValue(value)
.code(new Code(inputData))
.code(new Code(inputData, Hash.EMPTY))
.blockValues(frame.getBlockValues())
.depth(frame.getMessageStackDepth() + 1)
.completer(child -> complete(frame, child))

@ -40,7 +40,7 @@ public class JumpOperation extends AbstractFixedCostOperation {
final MessageFrame frame, final EVM evm) {
final UInt256 jumpDestination = UInt256.fromBytes(frame.popStackItem());
final Code code = frame.getCode();
if (!code.isValidJumpDestination(evm, frame, jumpDestination)) {
if (!evm.isValidJumpDestination(jumpDestination, code)) {
return invalidJumpResponse;
} else {
frame.setPC(jumpDestination.intValue());

@ -47,7 +47,7 @@ public class JumpiOperation extends AbstractFixedCostOperation {
frame.setPC(frame.getPC() + 1);
} else {
final Code code = frame.getCode();
if (!code.isValidJumpDestination(evm, frame, jumpDestination)) {
if (!evm.isValidJumpDestination(jumpDestination, code)) {
return invalidJumpResponse;
}
frame.setPC(jumpDestination.intValue());

@ -0,0 +1,42 @@
/*
* Copyright Hyperledger Besu Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.evm.internal;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.operation.JumpDestOperation;
import org.apache.tuweni.bytes.Bytes;
import org.junit.Test;
public class JumpDestCacheTest {
private final String op = Bytes.of(JumpDestOperation.OPCODE).toUnprefixedHexString();
@Test
public void testScale() {
Bytes contractBytes =
Bytes.fromHexString("0xDEAD" + op + "BEEF" + op + "B0B0" + op + "C0DE" + op + "FACE");
// 3rd bit, 6th bit, 9th bit, 12th bit
long[] jumpDests = {4 + 32 + 256 + 2048};
CodeScale scale = new CodeScale();
Code contractCode = new Code(contractBytes, Hash.hash(contractBytes), jumpDests);
int weight = scale.weigh(contractCode.getCodeHash(), contractCode.getValidJumpDestinations());
assertThat(weight).isEqualTo(contractCode.getCodeHash().size() + jumpDests.length * 8);
}
}

@ -66,7 +66,7 @@ public class Benchmarks {
.sender(Address.ZERO)
.value(Wei.ZERO)
.apparentValue(Wei.ZERO)
.code(new Code(Bytes.EMPTY))
.code(new Code(Bytes.EMPTY, org.hyperledger.besu.datatypes.Hash.EMPTY))
.depth(1)
.completer(__ -> {})
.address(Address.ZERO)

@ -16,12 +16,14 @@
package org.hyperledger.besu.evm.toy;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.Code;
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.Gas;
import org.hyperledger.besu.evm.MainnetEVMs;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
import org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts;
import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry;
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
@ -141,7 +143,7 @@ public class EvmToyCommand implements Runnable {
worldUpdater.getOrCreate(receiver).getMutable().setCode(codeBytes);
int repeat = this.repeat;
final EVM evm = MainnetEVMs.berlin();
final EVM evm = MainnetEVMs.berlin(EvmConfiguration.DEFAULT);
final PrecompileContractRegistry precompileContractRegistry = new PrecompileContractRegistry();
MainnetPrecompiledContracts.populateForIstanbul(
precompileContractRegistry, evm.getGasCalculator());
@ -170,7 +172,7 @@ public class EvmToyCommand implements Runnable {
.inputData(callData)
.value(ethValue)
.apparentValue(ethValue)
.code(new Code(codeBytes))
.code(new Code(codeBytes, Hash.hash(codeBytes)))
.blockValues(new ToyBlockValues())
.depth(0)
.completer(c -> {})

@ -34,7 +34,7 @@ dependencyManagement {
}
dependency 'com.google.guava:guava:30.1.1-jre'
dependency 'com.github.ben-manes.caffeine:caffeine:3.0.4'
dependency 'com.graphql-java:graphql-java:16.2'
dependency 'com.splunk.logging:splunk-library-javalogging:1.9.0'

Loading…
Cancel
Save