diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ee583acb3a..b6ca69d4242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 21.10.0-RC1 ### Additions and Improvements +* The EVM has been factored out into a standalone module, suitable for inclusion as a library. [#2790](https://github.com/hyperledger/besu/pull/2790) ### Bug Fixes diff --git a/acceptance-tests/dsl/build.gradle b/acceptance-tests/dsl/build.gradle index 2f68c16d704..04732c2c4bc 100644 --- a/acceptance-tests/dsl/build.gradle +++ b/acceptance-tests/dsl/build.gradle @@ -13,6 +13,7 @@ dependencies { implementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') implementation project(':ethereum:eth') implementation project(':ethereum:p2p') + implementation project(':evm') implementation project(':datatypes') implementation project(':ethereum:permissioning') implementation project(':ethereum:rlp') diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java index 787f5f88c70..f0b89f9c594 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/BlockUtils.java @@ -21,7 +21,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.apache.tuweni.bytes.Bytes; import org.web3j.protocol.core.methods.response.EthBlock.Block; diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java index 5fe49f486d3..03e461517fc 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/privacy/transaction/GetAllPrivateMarkerTransactionHashes.java @@ -14,7 +14,8 @@ */ package org.hyperledger.besu.tests.acceptance.dsl.privacy.transaction; -import org.hyperledger.besu.datatypes.Address; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; + import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests; import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction; @@ -41,9 +42,7 @@ public List execute(final NodeRequests node) { .getTransactions() .forEach( t -> { - if (((EthBlock.TransactionObject) t) - .getTo() - .equals(Address.DEFAULT_PRIVACY.toString())) { + if (((EthBlock.TransactionObject) t).getTo().equals(DEFAULT_PRIVACY.toString())) { toReturn.add(((EthBlock.TransactionObject) t).getHash()); } }); diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java index ac4ddb39d73..da511b9b76b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/transaction/privacy/PrivacyRequestFactory.java @@ -17,6 +17,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import org.hyperledger.besu.crypto.SecureRandomProvider; import org.hyperledger.besu.datatypes.Address; @@ -184,7 +185,7 @@ public String privxAddToPrivacyGroup( nonce, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(adder.getEnclaveKey()), privacyGroupId, @@ -217,7 +218,7 @@ public String privxRemoveFromPrivacyGroup( nonce, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(removerTenant), privacyGroupId, @@ -271,7 +272,7 @@ private String privxLockOrUnlockPrivacyGroup( nonce, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), callData, Base64String.wrap(locker.getEnclaveKey()), privacyGroupId, @@ -311,7 +312,7 @@ public PrivxCreatePrivacyGroupResponse privxCreatePrivacyGroup( BigInteger.ZERO, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(privateFrom), Base64String.wrap(privacyGroupId.toArrayUnsafe()), diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java index 05273a66aa2..4e78af91e00 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/privacy/multitenancy/MultiTenancyAcceptanceTest.java @@ -21,7 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; -import static org.hyperledger.besu.datatypes.Address.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithm; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTest.java index a5c67f704ff..56f77480441 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTest.java @@ -16,9 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.junit.runners.Parameterized.Parameters; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.tests.acceptance.dsl.condition.eth.EthConditions; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; import org.hyperledger.besu.tests.acceptance.dsl.transaction.miner.MinerTransactions; @@ -412,7 +412,7 @@ public void bobCanAddCharlieAfterBeingAddedByAlice() { new PrivateTransactionReceipt( null, alice.getAddress().toHexString(), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), "0x", Collections.emptyList(), null, diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTestBase.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTestBase.java index bff73faba44..e0868728f5a 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTestBase.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/OnChainPrivacyAcceptanceTestBase.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.tests.web3j.privacy; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyAcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode; @@ -95,7 +95,7 @@ protected String callGetParticipantsMethodAndReturnCommitmentHash( final String privacyGroupId, final PrivacyNode groupCreator, final String privateFrom) { return groupCreator.execute( privateContractTransactions.callOnChainPermissioningSmartContract( - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), GET_PARTICIPANTS_METHOD_SIGNATURE.toString(), groupCreator.getTransactionSigningKey(), privateFrom, @@ -128,7 +128,7 @@ protected PrivateTransactionReceipt buildExpectedAddMemberTransactionReceipt( return new PrivateTransactionReceipt( null, groupCreator.getAddress().toHexString(), - Address.ONCHAIN_PRIVACY_PROXY.toHexString(), + ONCHAIN_PRIVACY_PROXY.toHexString(), output.toString(), Collections.emptyList(), null, diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/PrivacyClusterAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/PrivacyClusterAcceptanceTest.java index 9130c2357a9..f884f1f63c3 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/PrivacyClusterAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/web3j/privacy/PrivacyClusterAcceptanceTest.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.tests.web3j.privacy; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.web3j.utils.Restriction.RESTRICTED; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveFactory; import org.hyperledger.besu.enclave.types.ReceiveResponse; @@ -205,7 +205,7 @@ public void aliceCanUsePrivDistributeTransaction() { BigInteger.ZERO, BigInteger.valueOf(1000), BigInteger.valueOf(65000), - Address.DEFAULT_PRIVACY.toString(), + DEFAULT_PRIVACY.toString(), transactionKey); final String signedPmt = diff --git a/besu/build.gradle b/besu/build.gradle index a45e70ce04d..df9d4db1eba 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -49,6 +49,7 @@ dependencies { implementation project(':ethereum:trie') implementation project(':ethereum:stratum') implementation project(':ethereum:ethstats') + implementation project(':evm') implementation project(':metrics:core') implementation project(':nat') implementation project(':plugin-api') diff --git a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java index 15603a9d4c1..0df11540033 100644 --- a/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java @@ -19,11 +19,11 @@ import static java.util.function.Predicate.isEqual; import static java.util.function.Predicate.not; import static org.hyperledger.besu.controller.BesuController.CACHE_PATH; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import org.hyperledger.besu.cli.config.EthNetworkConfig; import org.hyperledger.besu.controller.BesuController; import org.hyperledger.besu.crypto.NodeKey; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.ApiConfiguration; import org.hyperledger.besu.ethereum.api.graphql.GraphQLConfiguration; @@ -915,7 +915,7 @@ private void createPrivateTransactionObserver( .getProtocolSchedule() .getByBlockNumber(1) .getPrecompileContractRegistry() - .get(Address.ONCHAIN_PRIVACY); + .get(ONCHAIN_PRIVACY); onchainPrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver); } } diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java b/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java index cd595a564e0..9f1c2fce758 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/JsonBlockImporter.java @@ -26,8 +26,8 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.io.IOException; import java.util.ArrayList; diff --git a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java index 8a370597a4d..1ce886ed525 100644 --- a/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java +++ b/besu/src/main/java/org/hyperledger/besu/chainimport/internal/BlockData.java @@ -17,9 +17,9 @@ import org.hyperledger.besu.chainimport.internal.TransactionData.NonceProvider; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.HashMap; import java.util.List; diff --git a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java index 874299b1008..3d76e8b0b29 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java @@ -113,7 +113,6 @@ import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.mainnet.FrontierTargetingGasLimitCalculator; -import org.hyperledger.besu.ethereum.mainnet.precompiles.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.ethereum.p2p.config.DiscoveryConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeDnsConfiguration; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; @@ -134,6 +133,7 @@ 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.precompile.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl; import org.hyperledger.besu.metrics.MetricsProtocol; diff --git a/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java b/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java index 1dfdde09812..75dd638ee35 100644 --- a/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java +++ b/besu/src/main/java/org/hyperledger/besu/services/BesuEventsImpl.java @@ -20,12 +20,12 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.eth.sync.BlockBroadcaster; import org.hyperledger.besu.ethereum.eth.sync.state.SyncState; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; +import org.hyperledger.besu.evm.log.LogTopic; import org.hyperledger.besu.plugin.data.AddedBlockContext; import org.hyperledger.besu.plugin.data.Address; import org.hyperledger.besu.plugin.data.BlockHeader; diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java index 5c02c6f4dc1..ce1d5c6d92f 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyReorgTest.java @@ -15,6 +15,7 @@ package org.hyperledger.besu; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -26,7 +27,6 @@ import org.hyperledger.besu.crypto.NodeKeyUtils; import org.hyperledger.besu.crypto.SignatureAlgorithm; 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.enclave.Enclave; @@ -41,7 +41,6 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; @@ -56,6 +55,7 @@ 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.log.LogsBloomFilter; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.data.Restriction; import org.hyperledger.besu.plugin.data.TransactionType; @@ -461,7 +461,7 @@ private Transaction buildMarkerTransaction(final Bytes payload) { .gasPrice(Wei.of(1000)) .nonce(0) .payload(payload) - .to(Address.DEFAULT_PRIVACY) + .to(DEFAULT_PRIVACY) .value(Wei.ZERO) .signAndBuild(KEY_PAIR); } diff --git a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java index 7755f16527a..5615e32531e 100644 --- a/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java +++ b/besu/src/test/java/org/hyperledger/besu/PrivacyTest.java @@ -15,6 +15,8 @@ package org.hyperledger.besu; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import org.hyperledger.besu.config.GenesisConfigFile; import org.hyperledger.besu.controller.BesuController; @@ -28,10 +30,10 @@ 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.ethereum.mainnet.PrecompiledContract; 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.precompile.PrecompiledContract; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBKeyValuePrivacyStorageFactory; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBKeyValueStorageFactory; @@ -72,8 +74,7 @@ public void cleanUp() { public void defaultPrivacy() throws IOException, URISyntaxException { final BesuController besuController = setUpControllerWithPrivacyEnabled(false); - final PrecompiledContract precompiledContract = - getPrecompile(besuController, Address.DEFAULT_PRIVACY); + final PrecompiledContract precompiledContract = getPrecompile(besuController, DEFAULT_PRIVACY); assertThat(precompiledContract.getName()).isEqualTo("Privacy"); } @@ -83,7 +84,7 @@ public void onchainEnabledPrivacy() throws IOException, URISyntaxException { final BesuController besuController = setUpControllerWithPrivacyEnabled(true); final PrecompiledContract onchainPrecompiledContract = - getPrecompile(besuController, Address.ONCHAIN_PRIVACY); + getPrecompile(besuController, ONCHAIN_PRIVACY); assertThat(onchainPrecompiledContract.getName()).isEqualTo("OnChainPrivacy"); } diff --git a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java index 3e7008b7086..dab03d9974d 100644 --- a/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java +++ b/besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java @@ -64,13 +64,13 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.eth.sync.SyncMode; import org.hyperledger.besu.ethereum.eth.sync.SynchronizerConfiguration; -import org.hyperledger.besu.ethereum.mainnet.precompiles.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.ethereum.p2p.peers.EnodeURLImpl; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.SmartContractPermissioningConfiguration; import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration; +import org.hyperledger.besu.evm.precompile.AbstractAltBnPrecompiledContract; import org.hyperledger.besu.metrics.StandardMetricCategory; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.nat.NatMethod; diff --git a/consensus/clique/build.gradle b/consensus/clique/build.gradle index aef1b79a812..025e004a378 100644 --- a/consensus/clique/build.gradle +++ b/consensus/clique/build.gradle @@ -40,6 +40,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':services:kvstore') implementation project(':util') diff --git a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueBlockHashingTest.java b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueBlockHashingTest.java index c79889b4119..34b299024a5 100644 --- a/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueBlockHashingTest.java +++ b/consensus/clique/src/test/java/org/hyperledger/besu/consensus/clique/CliqueBlockHashingTest.java @@ -21,7 +21,7 @@ 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.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Arrays; import java.util.List; diff --git a/consensus/common/build.gradle b/consensus/common/build.gradle index f09fc46d4fe..0e7b4e279b3 100644 --- a/consensus/common/build.gradle +++ b/consensus/common/build.gradle @@ -39,6 +39,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':util') implementation 'com.fasterxml.jackson.core:jackson-databind' diff --git a/consensus/ibft/build.gradle b/consensus/ibft/build.gradle index 1792ece0138..cb81ff7aa99 100644 --- a/consensus/ibft/build.gradle +++ b/consensus/ibft/build.gradle @@ -38,6 +38,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':services:kvstore') implementation 'com.google.guava:guava' diff --git a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/BftBlockHashingTest.java b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/BftBlockHashingTest.java index 3514175dd5c..6a0cf9e2416 100644 --- a/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/BftBlockHashingTest.java +++ b/consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/BftBlockHashingTest.java @@ -31,9 +31,9 @@ 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.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Arrays; import java.util.List; diff --git a/consensus/ibftlegacy/build.gradle b/consensus/ibftlegacy/build.gradle index 0e7635d87a3..8e28cd9c7e4 100644 --- a/consensus/ibftlegacy/build.gradle +++ b/consensus/ibftlegacy/build.gradle @@ -24,6 +24,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':metrics:core') implementation project(':services:kvstore') diff --git a/consensus/ibftlegacy/src/test/java/org/hyperledger/besu/consensus/ibftlegacy/BftBlockHashingTest.java b/consensus/ibftlegacy/src/test/java/org/hyperledger/besu/consensus/ibftlegacy/BftBlockHashingTest.java index d056718cf09..1d97a0f71a4 100644 --- a/consensus/ibftlegacy/src/test/java/org/hyperledger/besu/consensus/ibftlegacy/BftBlockHashingTest.java +++ b/consensus/ibftlegacy/src/test/java/org/hyperledger/besu/consensus/ibftlegacy/BftBlockHashingTest.java @@ -21,7 +21,7 @@ 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.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Arrays; import java.util.List; diff --git a/consensus/qbft/build.gradle b/consensus/qbft/build.gradle index b92c1be2584..13c163ba549 100644 --- a/consensus/qbft/build.gradle +++ b/consensus/qbft/build.gradle @@ -66,6 +66,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':pki') implementation project(':services:kvstore') diff --git a/datatypes/build.gradle b/datatypes/build.gradle index 515d465bad3..74fa2a227e1 100644 --- a/datatypes/build.gradle +++ b/datatypes/build.gradle @@ -43,3 +43,16 @@ dependencies { } configurations { testArtifacts } + +publishing { + publications { + mavenJava(MavenPublication) { + groupId 'org.hyperledger.besu' + artifactId 'besu-datatypes' + pom { + name = 'Besu Datatypes' + description = 'Cross-module datatypes' + } + } + } +} diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Address.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Address.java index 99eb1bc10cd..b5ef69b4ff2 100644 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Address.java +++ b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Address.java @@ -51,17 +51,6 @@ public class Address extends DelegatingBytes implements org.hyperledger.besu.plu public static final Address BLS12_MAP_FP_TO_G1 = Address.precompiled(0x11); public static final Address BLS12_MAP_FP2_TO_G2 = Address.precompiled(0x12); - // Last address that can be generated for a pre-compiled contract - public static final Integer PRIVACY = Byte.MAX_VALUE - 1; - public static final Address DEFAULT_PRIVACY = Address.precompiled(PRIVACY); - public static final Address ONCHAIN_PRIVACY = Address.precompiled(PRIVACY - 1); - - // Onchain privacy management contracts (injected in private state) - public static final Address ONCHAIN_PRIVACY_PROXY = Address.precompiled(PRIVACY - 2); - public static final Address DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT = Address.precompiled(PRIVACY - 3); - - public static final Address PLUGIN_PRIVACY = Address.precompiled(PRIVACY - 4); - public static final Address ZERO = Address.fromHexString("0x0"); protected Address(final Bytes bytes) { diff --git a/ethereum/api/build.gradle b/ethereum/api/build.gradle index 5ddc2ad1419..b8547b08e61 100644 --- a/ethereum/api/build.gradle +++ b/ethereum/api/build.gradle @@ -43,6 +43,7 @@ dependencies { implementation project(':ethereum:permissioning') implementation project(':ethereum:rlp') implementation project(':ethereum:trie') + implementation project(':evm') implementation project(':metrics:core') implementation project(':nat') implementation project(':plugin-api') diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java index 7b145a4d92b..3cecd31b7ed 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcResponseUtils.java @@ -49,9 +49,9 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java index 9f43c2160e1..4e6a95c3de4 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.testutil.BlockTestUtil; import java.util.Map; diff --git a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java index cf5aaff110e..c9cee6ed194 100644 --- a/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java +++ b/ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.testutil.BlockTestUtil; import java.util.Map; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java index 4d8d9deb98c..f59f37105ff 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java @@ -32,13 +32,10 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.LogsQuery; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; @@ -46,6 +43,9 @@ import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.plugin.data.SyncStatus; import java.util.ArrayList; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java index 59f43ed2d1c..c6a4b0ffdb5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccountAdapter.java @@ -16,7 +16,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; +import org.hyperledger.besu.evm.account.Account; import java.util.Optional; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java index 6ce9696afae..c20a3f574c1 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java @@ -24,15 +24,15 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/LogAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/LogAdapter.java index b5aa285ed39..a638044ea49 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/LogAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/LogAdapter.java @@ -17,8 +17,8 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java index 01ae071a3f0..198453b2d73 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/PendingStateAdapter.java @@ -19,12 +19,12 @@ import org.hyperledger.besu.ethereum.api.graphql.GraphQLDataFetcherContext; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.transactions.sorter.AbstractPendingTransactionsSorter; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.List; import java.util.Map; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java index 2bc2369bb6b..40120e4a41e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java index f5e3ff17ca1..972ef324e98 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountAt.java @@ -29,9 +29,9 @@ import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; +import org.hyperledger.besu.evm.account.Account; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java index bcb858b8e23..28208459cee 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugAccountRange.java @@ -24,8 +24,8 @@ import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldState.StreamableAccount; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldState.StreamableAccount; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java index efb991f13be..76e62ae78bc 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAt.java @@ -26,10 +26,10 @@ import org.hyperledger.besu.ethereum.api.query.BlockWithMetadata; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.WorldState; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.Collections; import java.util.NavigableMap; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java index 6837a3a4664..b2373578f55 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCall.java @@ -38,7 +38,7 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.tracing.OperationTracer; public class EthCall extends AbstractBlockParameterOrBlockHashMethod { private final TransactionSimulator transactionSimulator; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java index 57d84bef6f2..014bdbb2263 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; -import org.hyperledger.besu.ethereum.vm.EstimateGasOperationTracer; +import org.hyperledger.besu.evm.tracing.EstimateGasOperationTracer; import java.util.Optional; import java.util.function.Function; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetCode.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetCode.java index 5b82e4527b1..c04ab32b3ee 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetCode.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetCode.java @@ -23,10 +23,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameterOrBlockHash; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; +import org.hyperledger.besu.evm.account.Account; import java.util.Optional; import java.util.function.Supplier; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java index 404c0e7b08b..d7e037c6620 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetProof.java @@ -25,8 +25,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.proof.GetProofResult; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.proof.WorldStateProof; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.Arrays; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameter.java index f47500fc281..c2d0dac1075 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameter.java @@ -19,7 +19,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.query.LogsQuery; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.List; import java.util.Objects; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java index 74b1581d475..1d5d9bad1d7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java @@ -16,10 +16,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.json.GasDeserializer; import org.hyperledger.besu.ethereum.core.json.HexStringDeserializer; import org.hyperledger.besu.ethereum.transaction.CallParameter; +import org.hyperledger.besu.evm.Gas; import java.util.Optional; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TopicsDeserializer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TopicsDeserializer.java index 3aec91040e3..7e4b5794f47 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TopicsDeserializer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/TopicsDeserializer.java @@ -16,7 +16,7 @@ import static java.util.Collections.singletonList; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.LogTopic; import java.io.IOException; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/PluginEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/PluginEeaSendRawTransaction.java index ff73bf4ae42..96017b5bc2e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/PluginEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/PluginEeaSendRawTransaction.java @@ -14,6 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; + import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.PrivacyIdProvider; import org.hyperledger.besu.ethereum.core.Transaction; @@ -23,7 +25,7 @@ import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.util.NonceProvider; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; import java.util.Optional; @@ -71,7 +73,7 @@ protected Transaction createPrivateMarkerTransaction( privateTransaction, privacyUserId, Optional.empty()); return createPrivateMarkerTransaction( - sender, Address.PLUGIN_PRIVACY, payloadFromPlugin, privateTransaction, privacyUserId); + sender, PLUGIN_PRIVACY, payloadFromPlugin, privateTransaction, privacyUserId); } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffChainEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffChainEeaSendRawTransaction.java index 97d5ad28a72..cabf7280bd4 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffChainEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOffChainEeaSendRawTransaction.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError.PRIVATE_FROM_DOES_NOT_MATCH_ENCLAVE_PUBLIC_KEY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.privacy.PrivacyGroupUtil.findOffchainPrivacyGroup; import org.hyperledger.besu.datatypes.Address; @@ -86,11 +87,7 @@ protected Transaction createPrivateMarkerTransaction( privateTransaction, privacyUserId, maybePrivacyGroup); return createPrivateMarkerTransaction( - sender, - Address.DEFAULT_PRIVACY, - privateTransactionLookupId, - privateTransaction, - privacyUserId); + sender, DEFAULT_PRIVACY, privateTransactionLookupId, privateTransaction, privacyUserId); } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnChainEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnChainEeaSendRawTransaction.java index a50d39a16bc..1cece250862 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnChainEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/RestrictedOnChainEeaSendRawTransaction.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.privacy.PrivacyGroupUtil.findOnchainPrivacyGroup; import org.hyperledger.besu.datatypes.Address; @@ -98,7 +99,7 @@ protected Transaction createPrivateMarkerTransaction( buildCompoundLookupId(privateTransactionLookupId, addPayloadPrivateTransactionLookupId); return createPrivateMarkerTransaction( - sender, Address.ONCHAIN_PRIVACY, pmtPayload, privateTransaction, privacyUserId); + sender, ONCHAIN_PRIVACY, pmtPayload, privateTransaction, privacyUserId); } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java index 2bb167faaff..7cf42212b70 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/BlockTracer.java @@ -15,14 +15,14 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater.StackedUpdater; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater.StackedUpdater; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.List; import java.util.Optional; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java index 3a2a7286e57..7b129016601 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracer.java @@ -19,18 +19,18 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TransactionTraceParams; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; -import org.hyperledger.besu.ethereum.vm.OperationTracer; -import org.hyperledger.besu.ethereum.vm.StandardJsonTracer; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.tracing.StandardJsonTracer; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.io.File; import java.io.FileNotFoundException; @@ -43,12 +43,16 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.base.Stopwatch; +import org.apache.tuweni.units.bigints.UInt256; /** Used to produce debug traces of transactions */ public class TransactionTracer { public static final String TRACE_PATH = "traces"; + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private final BlockReplay blockReplay; @@ -101,7 +105,8 @@ public List traceTransactionToFile( WorldUpdater stackedUpdater = worldState.updater().updater(); final List traces = new ArrayList<>(); for (int i = 0; i < body.getTransactions().size(); i++) { - ((AbstractWorldUpdater.StackedUpdater) stackedUpdater).markTransactionBoundary(); + ((AbstractWorldUpdater.StackedUpdater) stackedUpdater) + .markTransactionBoundary(); final Transaction transaction = body.getTransactions().get(i); if (selectedHash.isEmpty() || selectedHash.filter(isEqual(transaction.getHash())).isPresent()) { @@ -117,7 +122,7 @@ public List traceTransactionToFile( transactionProcessor, new StandardJsonTracer(out, showMemory)); out.println( - StandardJsonTracer.summaryTrace( + summaryTrace( transaction, timer.stop().elapsed(TimeUnit.NANOSECONDS), result)); traces.add(traceFile.getPath()); } catch (FileNotFoundException e) { @@ -173,4 +178,16 @@ private TransactionProcessingResult processTransaction( false, ImmutableTransactionValidationParams.builder().isAllowFutureNonce(true).build()); } + + public static String summaryTrace( + final Transaction transaction, final long timer, final TransactionProcessingResult result) { + final ObjectNode summaryLine = OBJECT_MAPPER.createObjectNode(); + summaryLine.put("output", result.getOutput().toUnprefixedHexString()); + summaryLine.put( + "gasUsed", + StandardJsonTracer.shortNumber( + UInt256.valueOf(transaction.getGasLimit() - result.getGasRemaining()))); + summaryLine.put("time", timer); + return summaryLine.toString(); + } } diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/DebugStorageRangeAtResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/DebugStorageRangeAtResult.java index b5cb16a0697..54d0abf8bc3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/DebugStorageRangeAtResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/DebugStorageRangeAtResult.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; +import org.hyperledger.besu.evm.account.AccountStorageEntry; import java.util.NavigableMap; import java.util.Objects; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/StructLog.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/StructLog.java index 0c561533273..010b41563d7 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/StructLog.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/StructLog.java @@ -14,8 +14,8 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; +import org.hyperledger.besu.evm.Gas; import java.util.Arrays; import java.util.Map; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java index bb03f3276ed..a3c845bcac0 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java @@ -16,9 +16,9 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java index f63c775a95f..3221995f422 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java @@ -16,9 +16,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptLogResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptLogResult.java index 8a6b67ef147..8dc2e2158aa 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptLogResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptLogResult.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptResult.java index 569345423c3..9c2920b9caf 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptResult.java @@ -17,9 +17,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.query.TransactionReceiptWithMetadata; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.evm.log.Log; import java.util.ArrayList; import java.util.List; @@ -78,7 +78,7 @@ protected TransactionReceiptResult(final TransactionReceiptWithMetadata receiptW this.logs = logReceipts( - receipt.getLogs(), + receipt.getLogsList(), receiptWithMetadata.getBlockNumber(), txn.getHash(), receiptWithMetadata.getBlockHash(), diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/privacy/PrivateTransactionReceiptResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/privacy/PrivateTransactionReceiptResult.java index 2da5df0c058..ab36e695e76 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/privacy/PrivateTransactionReceiptResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/privacy/PrivateTransactionReceiptResult.java @@ -17,8 +17,8 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionReceiptLogResult; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/diff/StateDiffGenerator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/diff/StateDiffGenerator.java index 50583f47b58..e8b975e11b8 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/diff/StateDiffGenerator.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/diff/StateDiffGenerator.java @@ -20,10 +20,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TracingUtils; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.UpdateTrackingAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java index d89335a4823..29e4b818ee9 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/Action.java @@ -18,8 +18,8 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; +import org.hyperledger.besu.evm.Gas; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java index f855a981f40..a67c901f075 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java @@ -21,12 +21,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.TracingUtils; import org.hyperledger.besu.ethereum.core.Block; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; import java.util.ArrayDeque; import java.util.ArrayList; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/vm/VmTraceGenerator.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/vm/VmTraceGenerator.java index 8978d2065a3..140a2e1a82a 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/vm/VmTraceGenerator.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/vm/VmTraceGenerator.java @@ -17,10 +17,10 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.tracing.Trace; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; import java.util.ArrayDeque; import java.util.Deque; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java index 59547528407..152635739f4 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/PrivacyApiGroupJsonRpcMethods.java @@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.privacy.RestrictedMultiTenancyPrivacyController; import org.hyperledger.besu.ethereum.privacy.markertransaction.FixedKeySigningPrivateMarkerTransactionFactory; import org.hyperledger.besu.ethereum.privacy.markertransaction.RandomSigningPrivateMarkerTransactionFactory; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; import java.math.BigInteger; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java index 0652dde4266..29a8f3a7593 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java @@ -26,17 +26,17 @@ import org.hyperledger.besu.ethereum.api.query.cache.TransactionLogBloomCacher; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.TransactionLocation; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.LogWithMetadata; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.io.EOFException; import java.io.IOException; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/LogsQuery.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/LogsQuery.java index 9b5890a88ef..79d5f0246c5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/LogsQuery.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/LogsQuery.java @@ -21,9 +21,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.TopicsDeserializer; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.ArrayList; import java.util.Arrays; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/LogsQueryTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/LogsQueryTest.java index ffc6ac194e1..041130ad4fc 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/LogsQueryTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/filter/LogsQueryTest.java @@ -20,9 +20,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.api.query.LogsQuery; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java index 94ee37d0c78..ed01d89ab08 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugStorageRangeAtTest.java @@ -32,13 +32,13 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.AccountStorageEntry; import java.util.ArrayList; import java.util.Collections; @@ -152,6 +152,7 @@ public void shouldRetrieveStorageRange_fullValues() { } private Object callAction(final InvocationOnMock invocation) { + //noinspection rawtypes return Optional.of( ((BlockReplay.TransactionAction) invocation.getArgument(2)) .performAction(transaction, blockHeader, blockchain, worldState, transactionProcessor)); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java index 110b152d75a..f119d3a8dbe 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByHashTest.java @@ -28,9 +28,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.BlockTracer; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; +import org.hyperledger.besu.evm.Gas; import java.util.Arrays; import java.util.Collection; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java index 7ac58f46311..b6fec5ef534 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockByNumberTest.java @@ -32,9 +32,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.DebugTraceTransactionResult; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; +import org.hyperledger.besu.evm.Gas; import java.util.Collection; import java.util.Optional; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java index dc5d4bb49de..d05c5507bdf 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceBlockTest.java @@ -34,10 +34,10 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; +import org.hyperledger.besu.evm.Gas; import java.util.Collection; import java.util.Collections; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java index 8560e30c618..73757688090 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugTraceTransactionTest.java @@ -32,11 +32,11 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; +import org.hyperledger.besu.evm.Gas; import java.util.Collections; import java.util.HashMap; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCallTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCallTest.java index bdf35723679..c17f91d59ae 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCallTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCallTest.java @@ -40,11 +40,11 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.ChainHead; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; +import org.hyperledger.besu.evm.Gas; import java.util.Optional; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java index f25eba4cd18..b4d6a4c295a 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java @@ -35,7 +35,6 @@ import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; @@ -44,8 +43,9 @@ import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Optional; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java index e7b226b3069..ed79714b4f9 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGasPriceTest.java @@ -35,8 +35,8 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.List; import java.util.Optional; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilterTest.java index d9da34f26ad..dd252ac9210 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilterTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthNewFilterTest.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.query.LogsQuery; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameterTest.java index 6a6d66cf1f0..ec8f465fb68 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameterTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/FilterParameterTest.java @@ -23,7 +23,7 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Arrays; import java.util.HashMap; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java index d4fcbafc397..f7d90510f59 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/BaseEeaSendRawTransaction.java @@ -14,6 +14,10 @@ */ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.eea; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; + import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; @@ -23,12 +27,12 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; -import org.hyperledger.besu.ethereum.mainnet.BerlinGasCalculator; import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.markertransaction.FixedKeySigningPrivateMarkerTransactionFactory; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.plugin.data.Restriction; import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory; @@ -68,7 +72,7 @@ public class BaseEeaSendRawTransaction { 0L, Wei.of(1), 21000L, - Optional.of(Address.ONCHAIN_PRIVACY), + Optional.of(ONCHAIN_PRIVACY), Wei.ZERO, SIGNATURE_ALGORITHM_SUPPLIER .get() @@ -87,7 +91,7 @@ public class BaseEeaSendRawTransaction { 0L, Wei.of(1), 21112L, - Optional.of(Address.PLUGIN_PRIVACY), + Optional.of(PLUGIN_PRIVACY), Wei.ZERO, SIGNATURE_ALGORITHM_SUPPLIER .get() @@ -106,7 +110,7 @@ public class BaseEeaSendRawTransaction { 0L, Wei.of(1), 21000L, - Optional.of(Address.DEFAULT_PRIVACY), + Optional.of(DEFAULT_PRIVACY), Wei.ZERO, SIGNATURE_ALGORITHM_SUPPLIER .get() diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java index b73682bfcd3..6016ec8725e 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java @@ -36,13 +36,13 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.Quantity; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; import org.hyperledger.besu.ethereum.privacy.RestrictedDefaultPrivacyController; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; +import org.hyperledger.besu.evm.Gas; import java.util.Optional; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetLogsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetLogsTest.java index 0ed0eb0c0e2..f3b90ae14d5 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetLogsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetLogsTest.java @@ -40,10 +40,10 @@ import org.hyperledger.besu.ethereum.api.query.LogsQuery; import org.hyperledger.besu.ethereum.api.query.PrivacyQueries; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java index 5a89d140cdf..88cf1e29f03 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivGetPrivacyPrecompileAddressTest.java @@ -15,6 +15,8 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.privacy.methods.priv; import static org.assertj.core.api.Assertions.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PRIVACY; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -33,7 +35,7 @@ public class PrivGetPrivacyPrecompileAddressTest { @Test public void verifyPrivacyPrecompileAddress() { - when(privacyParameters.getPrivacyAddress()).thenReturn(Address.DEFAULT_PRIVACY); + when(privacyParameters.getPrivacyAddress()).thenReturn(DEFAULT_PRIVACY); when(privacyParameters.isEnabled()).thenReturn(true); final PrivGetPrivacyPrecompileAddress privGetPrivacyPrecompileAddress = @@ -47,6 +49,6 @@ public void verifyPrivacyPrecompileAddress() { (JsonRpcSuccessResponse) privGetPrivacyPrecompileAddress.response(request); verify(privacyParameters).getPrivacyAddress(); - assertThat(response.getResult()).isEqualTo(Address.precompiled(Address.PRIVACY).toString()); + assertThat(response.getResult()).isEqualTo(Address.precompiled(PRIVACY).toString()); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivNewFilterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivNewFilterTest.java index f993e287d6f..494331098fc 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivNewFilterTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivNewFilterTest.java @@ -37,9 +37,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.query.LogsQuery; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.privacy.MultiTenancyValidationException; import org.hyperledger.besu.ethereum.privacy.PrivacyController; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java index bd1e63b8d61..02f94f8babb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/processor/TransactionTracerTest.java @@ -25,20 +25,20 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.ImmutableTransactionTraceParams; import org.hyperledger.besu.ethereum.chain.BadBlockManager; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.DebugOperationTracer; -import org.hyperledger.besu.ethereum.vm.StandardJsonTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.tracing.StandardJsonTracer; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.io.IOException; import java.nio.file.Files; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/logs/LogsSubscriptionServiceTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/logs/LogsSubscriptionServiceTest.java index a047cfbbbc7..80727e2f197 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/logs/LogsSubscriptionServiceTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/logs/LogsSubscriptionServiceTest.java @@ -36,11 +36,11 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockWithReceipts; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.ArrayList; import java.util.Arrays; @@ -91,7 +91,7 @@ public void singleMatchingLogEvent() { final int txIndex = 1; final int logIndex = 1; - final Log targetLog = receipts.get(txIndex).getLogs().get(logIndex); + final Log targetLog = receipts.get(txIndex).getLogsList().get(logIndex); final LogsSubscription subscription = createSubscription(targetLog.getLogger()); registerSubscriptions(subscription); @@ -116,7 +116,7 @@ public void singleMatchingLogEmittedThenRemovedInReorg() { final int txIndex = 1; final int logIndex = 1; - final Log targetLog = receipts.get(txIndex).getLogs().get(logIndex); + final Log targetLog = receipts.get(txIndex).getLogsList().get(logIndex); final LogsSubscription subscription = createSubscription(targetLog.getLogger()); registerSubscriptions(subscription); @@ -152,7 +152,7 @@ public void singleMatchingLogEmittedThenMovedInReorg() { final int txIndex = 1; final int logIndex = 1; - final Log targetLog = receipts.get(txIndex).getLogs().get(logIndex); + final Log targetLog = receipts.get(txIndex).getLogsList().get(logIndex); final LogsSubscription subscription = createSubscription(targetLog.getLogger()); registerSubscriptions(subscription); @@ -241,7 +241,7 @@ public void multipleSubscriptionsForSingleMatchingLog() { final int txIndex = 1; final int logIndex = 1; - final Log targetLog = receipts.get(txIndex).getLogs().get(logIndex); + final Log targetLog = receipts.get(txIndex).getLogsList().get(logIndex); final List subscriptions = Stream.generate(() -> createSubscription(targetLog.getLogger())) @@ -335,7 +335,7 @@ private void assertLogResultMatches( final int logIndex, final boolean isRemoved) { final Transaction expectedTransaction = block.getBody().getTransactions().get(txIndex); - final Log expectedLog = receipts.get(txIndex).getLogs().get(logIndex); + final Log expectedLog = receipts.get(txIndex).getLogsList().get(logIndex); assertThat(result.getLogIndex()).isEqualTo(Quantity.create(logIndex)); assertThat(result.getTransactionIndex()).isEqualTo(Quantity.create(txIndex)); @@ -380,7 +380,7 @@ private BlockWithReceipts generateBlock( final TransactionReceipt receipt = gen.receipt(logsSupplier.get()); receipts.add(receipt); - receipt.getLogs().forEach(logs::add); + receipt.getLogsList().forEach(logs::add); blockOptions.addTransaction(tx); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/request/SubscriptionRequestMapperTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/request/SubscriptionRequestMapperTest.java index 34ad4a72f8e..28e06213709 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/request/SubscriptionRequestMapperTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/subscription/request/SubscriptionRequestMapperTest.java @@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.BlockParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.FilterParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.websocket.methods.WebSocketRpcRequest; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.List; import java.util.stream.Stream; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java index 323d211943d..33b82e3a18c 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesLogCacheTest.java @@ -30,11 +30,11 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.io.IOException; import java.io.RandomAccessFile; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java index a6fda32d869..d1abacc0a04 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueriesTest.java @@ -25,7 +25,6 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; @@ -33,9 +32,10 @@ import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import java.util.ArrayList; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/GoQuorumPrivateTxBloomBlockchainQueriesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/GoQuorumPrivateTxBloomBlockchainQueriesTest.java index f7e4977090e..4770214e20f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/GoQuorumPrivateTxBloomBlockchainQueriesTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/GoQuorumPrivateTxBloomBlockchainQueriesTest.java @@ -29,11 +29,11 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/LogsQueryTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/LogsQueryTest.java index 0cd18c9ae00..19932e3da2f 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/LogsQueryTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/LogsQueryTest.java @@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/PrivacyQueriesTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/PrivacyQueriesTest.java index ef8a232ec4a..1da57461ea3 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/PrivacyQueriesTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/PrivacyQueriesTest.java @@ -27,13 +27,13 @@ import org.hyperledger.besu.ethereum.chain.TransactionLocation; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.PrivateTransactionReceiptTestFixture; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; import org.hyperledger.besu.ethereum.privacy.PrivateWorldStateReader; import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Collections; import java.util.List; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/GoQuorumPrivateTransactionLogBloomCacherTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/GoQuorumPrivateTransactionLogBloomCacherTest.java index b148403e10e..d84aeb9b22b 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/GoQuorumPrivateTransactionLogBloomCacherTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/GoQuorumPrivateTransactionLogBloomCacherTest.java @@ -33,11 +33,11 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.io.File; import java.io.IOException; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java index e9b7a1c94f6..32352886b35 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/query/cache/TransactionLogBloomCacherTest.java @@ -28,10 +28,10 @@ import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.io.File; import java.io.IOException; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java index 5d1d8156a91..942898b8128 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java @@ -20,11 +20,11 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; +import org.hyperledger.besu.evm.AccessListEntry; import java.math.BigInteger; import java.util.List; diff --git a/ethereum/blockcreation/build.gradle b/ethereum/blockcreation/build.gradle index 775e9f80c62..f3cb05a1056 100644 --- a/ethereum/blockcreation/build.gradle +++ b/ethereum/blockcreation/build.gradle @@ -18,6 +18,7 @@ dependencies { implementation project(':datatypes') implementation project(':ethereum:core') implementation project(':ethereum:eth') + implementation project(':evm') implementation project(':services:kvstore') implementation project(':util') diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java index 4b494829864..8116ebdd9eb 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreator.java @@ -24,12 +24,10 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.EvmAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.eth.transactions.sorter.AbstractPendingTransactionsSorter; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; @@ -40,6 +38,8 @@ import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.services.securitymodule.SecurityModuleException; import java.math.BigInteger; diff --git a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java index 8f6b187b487..946406d2964 100644 --- a/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java +++ b/ethereum/blockcreation/src/main/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelector.java @@ -17,12 +17,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.EvmAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.eth.transactions.sorter.AbstractPendingTransactionsSorter; import org.hyperledger.besu.ethereum.eth.transactions.sorter.AbstractPendingTransactionsSorter.TransactionSelectionResult; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; @@ -34,6 +32,8 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Collections; import java.util.List; diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java index 73cbe6947c5..521441f343c 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/BlockTransactionSelectorTest.java @@ -38,8 +38,6 @@ import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.sorter.BaseFeePendingTransactionsSorter; @@ -51,6 +49,8 @@ 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.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.data.TransactionType; import org.hyperledger.besu.plugin.services.MetricsSystem; diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index d105bd7af11..8c71bd9d7dc 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -46,6 +46,7 @@ dependencies { implementation project(':enclave') implementation project(':ethereum:rlp') implementation project(':ethereum:trie') + implementation project(':evm') implementation project(':metrics:core') implementation project(':plugin-api') implementation project(':services:kvstore') diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java index e5db129422a..3d1301ae79b 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractIntegrationTest.java @@ -17,6 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -26,14 +28,12 @@ import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveFactory; import org.hyperledger.besu.enclave.types.SendResponse; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; +import org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; @@ -44,9 +44,11 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.enclave.testutil.EnclaveKeyConfiguration; import org.hyperledger.enclave.testutil.OrionTestHarness; import org.hyperledger.enclave.testutil.OrionTestHarnessFactory; @@ -85,7 +87,6 @@ public class PrivacyPrecompiledContractIntegrationTest { private static Enclave enclave; private static MessageFrame messageFrame; - private static Blockchain blockchain; private static OrionTestHarness testHarness; private static WorldStateArchive worldStateArchive; @@ -99,7 +100,6 @@ private PrivateTransactionProcessor mockPrivateTxProcessor() { TransactionProcessingResult.successful( null, 0, 0, Bytes.fromHexString(DEFAULT_OUTPUT), null); when(mockPrivateTransactionProcessor.processTransaction( - nullable(Blockchain.class), nullable(WorldUpdater.class), nullable(WorldUpdater.class), nullable(ProcessableBlockHeader.class), @@ -129,22 +129,23 @@ public static void setUpOnce() throws Exception { final EnclaveFactory factory = new EnclaveFactory(vertx); enclave = factory.createVertxEnclave(testHarness.clientUrl()); messageFrame = mock(MessageFrame.class); - blockchain = mock(Blockchain.class); final BlockDataGenerator blockGenerator = new BlockDataGenerator(); final Block genesis = blockGenerator.genesisBlock(); final Block block = blockGenerator.block( new BlockDataGenerator.BlockOptions().setParentHash(genesis.getHeader().getHash())); - when(blockchain.getGenesisBlock()).thenReturn(genesis); - when(blockchain.getBlockByHash(block.getHash())).thenReturn(Optional.of(block)); - when(blockchain.getBlockByHash(genesis.getHash())).thenReturn(Optional.of(genesis)); - when(messageFrame.getBlockchain()).thenReturn(blockchain); - when(messageFrame.getBlockHeader()).thenReturn(block.getHeader()); + when(messageFrame.getBlockValues()).thenReturn(block.getHeader()); final PrivateMetadataUpdater privateMetadataUpdater = mock(PrivateMetadataUpdater.class); when(privateMetadataUpdater.getPrivateBlockMetadata(any())).thenReturn(null); when(privateMetadataUpdater.getPrivacyGroupHeadBlockMap()) .thenReturn(PrivacyGroupHeadBlockMap.empty()); - when(messageFrame.getPrivateMetadataUpdater()).thenReturn(privateMetadataUpdater); + when(messageFrame.getContextVariable( + eq(PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE), anyBoolean())) + .thenReturn(false); + when(messageFrame.getContextVariable(eq(PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER))) + .thenReturn(privateMetadataUpdater); + when(messageFrame.hasContextVariable(eq(PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER))) + .thenReturn(true); worldStateArchive = mock(WorldStateArchive.class); final MutableWorldState mutableWorldState = mock(MutableWorldState.class); diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java index bb14b2d1c29..1a844f2b1f4 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/EntriesFromIntegrationTest.java @@ -19,10 +19,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Map; import java.util.Random; diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java index a1d360cf7ea..77cb45b6012 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java @@ -21,14 +21,11 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; @@ -37,6 +34,9 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.List; diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java index 3db5a52c579..fcdb05ccea1 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/worldstate/PrunerIntegrationTest.java @@ -25,13 +25,13 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.worldstate.Pruner.PruningPhase; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import org.hyperledger.besu.testutil.MockExecutorService; diff --git a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperationBenchmark.java b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperationBenchmark.java index 51d0c994321..284529f0abc 100644 --- a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperationBenchmark.java +++ b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperationBenchmark.java @@ -14,11 +14,13 @@ */ package org.hyperledger.besu.ethereum.vm.operations; -import org.hyperledger.besu.ethereum.mainnet.PetersburgGasCalculator; +import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator; +import org.hyperledger.besu.evm.operation.BlockHashOperation; -import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; @@ -54,18 +56,21 @@ public void cleanUp() throws Exception { } @Benchmark - public Bytes32 executeOperation() { + public Bytes executeOperation() { frame.pushStackItem(UInt256.valueOf(blockNumber)); operation.execute(frame, null); return frame.popStackItem(); } @Benchmark - public Bytes32 executeOperationWithEmptyHashCache() { + public Bytes executeOperationWithEmptyHashCache() { final MessageFrame cleanFrame = operationBenchmarkHelper .createMessageFrameBuilder() - .blockHashLookup(new BlockHashLookup(frame.getBlockHeader(), frame.getBlockchain())) + .blockHashLookup( + new BlockHashLookup( + (ProcessableBlockHeader) frame.getBlockValues(), + operationBenchmarkHelper.getBlockchain())) .build(); cleanFrame.pushStackItem(UInt256.valueOf(blockNumber)); operation.execute(cleanFrame, null); diff --git a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java index 52817faa48d..f6bba6a165f 100644 --- a/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java +++ b/ethereum/core/src/jmh/java/org/hyperledger/besu/ethereum/vm/operations/OperationBenchmarkHelper.java @@ -16,6 +16,7 @@ import static java.util.Collections.emptyList; +import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; @@ -23,7 +24,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.rocksdb.RocksDBMetricsFactory; @@ -42,14 +43,17 @@ public class OperationBenchmarkHelper { private final Path storageDirectory; private final KeyValueStorage keyValueStorage; private final MessageFrame messageFrame; + private final Blockchain blockchain; private OperationBenchmarkHelper( final Path storageDirectory, final KeyValueStorage keyValueStorage, - final MessageFrame messageFrame) { + final MessageFrame messageFrame, + final Blockchain blockchain) { this.storageDirectory = storageDirectory; this.keyValueStorage = keyValueStorage; this.messageFrame = messageFrame; + this.blockchain = blockchain; } public static OperationBenchmarkHelper create() throws IOException { @@ -85,7 +89,12 @@ public static OperationBenchmarkHelper create() throws IOException { .difficulty(Difficulty.ONE) .buildHeader()) .build(); - return new OperationBenchmarkHelper(storageDirectory, keyValueStorage, messageFrame); + return new OperationBenchmarkHelper( + storageDirectory, keyValueStorage, messageFrame, blockchain); + } + + public Blockchain getBlockchain() { + return blockchain; } public MessageFrame createMessageFrame() { @@ -96,8 +105,7 @@ public MessageFrame.Builder createMessageFrameBuilder() { return MessageFrame.builder() .type(MessageFrame.Type.MESSAGE_CALL) .messageFrameStack(messageFrame.getMessageFrameStack()) - .blockchain(messageFrame.getBlockchain()) - .worldState(messageFrame.getWorldState()) + .worldUpdater(messageFrame.getWorldUpdater()) .initialGas(messageFrame.getRemainingGas()) .address(messageFrame.getContractAddress()) .originator(messageFrame.getOriginatorAddress()) @@ -108,13 +116,12 @@ public MessageFrame.Builder createMessageFrameBuilder() { .value(messageFrame.getValue()) .apparentValue(messageFrame.getApparentValue()) .code(messageFrame.getCode()) - .blockHeader(messageFrame.getBlockHeader()) + .blockValues(messageFrame.getBlockValues()) .depth(messageFrame.getMessageStackDepth()) .isStatic(messageFrame.isStatic()) .completer(messageFrame -> {}) .miningBeneficiary(messageFrame.getMiningBeneficiary()) - .maxStackSize(messageFrame.getMaxStackSize()) - .blockHashLookup(messageFrame.getBlockHashLookup()); + .maxStackSize(messageFrame.getMaxStackSize()); } public void cleanUp() throws IOException { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java index a8e88887fbe..7cf935c28fd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiAccount.java @@ -19,16 +19,16 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.ModificationNotAllowedException; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.core.UpdateTrackingAccount; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount; import java.util.HashMap; import java.util.Map; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java index 3d2cebf9781..f62d25a03ea 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.bonsai; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.BlockHeader; +import org.hyperledger.besu.plugin.data.BlockHeader; public class BonsaiInMemoryWorldState extends BonsaiPersistedWorldState { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java index a9f4f8ea674..63ca7d63408 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java @@ -19,12 +19,12 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.plugin.data.BlockHeader; import java.util.HashMap; import java.util.Map; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java index c4fbc7c7458..5f995f4ab11 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiPersistedWorldState.java @@ -22,13 +22,13 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.trie.StoredMerklePatriciaTrie; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.plugin.data.BlockHeader; import org.hyperledger.besu.plugin.services.exception.StorageException; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; @@ -91,8 +91,8 @@ public Optional getCode(@Nonnull final Address address) { } public void setArchiveStateUnSafe(final BlockHeader blockHeader) { - worldStateBlockHash = blockHeader.getHash(); - worldStateRootHash = blockHeader.getStateRoot(); + worldStateBlockHash = Hash.fromPlugin(blockHeader.getBlockHash()); + worldStateRootHash = Hash.fromPlugin(blockHeader.getStateRoot()); } public BonsaiWorldStateKeyValueStorage getWorldStateStorage() { @@ -263,7 +263,7 @@ public void persist(final BlockHeader blockHeader) { + " calculated " + worldStateRootHash.toHexString()); } - worldStateBlockHash = blockHeader.getHash(); + worldStateBlockHash = Hash.fromPlugin(blockHeader.getBlockHash()); stateUpdater .getTrieBranchStorageTransaction() .put(WORLD_BLOCK_HASH_KEY, worldStateBlockHash.toArrayUnsafe()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java index c1feb3d7de0..d51768cefdc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateArchive.java @@ -16,15 +16,17 @@ package org.hyperledger.besu.ethereum.bonsai; +import static org.hyperledger.besu.datatypes.Hash.fromPlugin; + import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.proof.WorldStateProof; import org.hyperledger.besu.ethereum.storage.StorageProvider; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.plugin.data.BlockHeader; import java.util.ArrayList; import java.util.HashMap; @@ -78,9 +80,12 @@ public BonsaiWorldStateArchive( layeredWorldStatesByHash.computeIfPresent( eventBlockHeader.getParentHash(), (hash, bonsaiLayeredWorldState) -> { - if (layeredWorldStatesByHash.containsKey(eventBlockHeader.getHash())) { + if (layeredWorldStatesByHash.containsKey( + fromPlugin(eventBlockHeader.getBlockHash()))) { bonsaiLayeredWorldState.setNextWorldView( - Optional.of(layeredWorldStatesByHash.get(eventBlockHeader.getHash()))); + Optional.of( + layeredWorldStatesByHash.get( + fromPlugin(eventBlockHeader.getBlockHash())))); } return bonsaiLayeredWorldState; }); @@ -161,7 +166,7 @@ public Optional getMutable( this, Optional.empty(), header.getNumber(), - header.getStateRoot(), + fromPlugin(header.getStateRoot()), trieLogLayer.get())); } } @@ -179,7 +184,7 @@ public Optional getMutable(final Hash rootHash, final Hash bl try { final Optional maybePersistedHeader = - blockchain.getBlockHeader(persistedState.blockHash()); + blockchain.getBlockHeader(persistedState.blockHash()).map(BlockHeader.class::cast); final List rollBacks = new ArrayList<>(); final List rollForwards = new ArrayList<>(); @@ -189,27 +194,34 @@ public Optional getMutable(final Hash rootHash, final Hash bl BlockHeader targetHeader = blockchain.getBlockHeader(blockHash).get(); BlockHeader persistedHeader = maybePersistedHeader.get(); // roll back from persisted to even with target + Hash persistedBlockHash = fromPlugin(persistedHeader.getBlockHash()); while (persistedHeader.getNumber() > targetHeader.getNumber()) { - LOG.debug("Rollback {}", persistedHeader.getHash()); - rollBacks.add(getTrieLogLayer(persistedHeader.getHash()).get()); - persistedHeader = blockchain.getBlockHeader(persistedHeader.getParentHash()).get(); + LOG.debug("Rollback {}", persistedBlockHash); + rollBacks.add(getTrieLogLayer(persistedBlockHash).get()); + persistedHeader = + blockchain.getBlockHeader(fromPlugin(persistedHeader.getParentHash())).get(); } // roll forward to target + Hash targetBlockHash = fromPlugin(targetHeader.getBlockHash()); while (persistedHeader.getNumber() < targetHeader.getNumber()) { - LOG.debug("Rollforward {}", targetHeader.getHash()); - rollForwards.add(getTrieLogLayer(targetHeader.getHash()).get()); - targetHeader = blockchain.getBlockHeader(targetHeader.getParentHash()).get(); + LOG.debug("Rollforward {}", targetBlockHash); + rollForwards.add(getTrieLogLayer(targetBlockHash).get()); + targetHeader = + blockchain.getBlockHeader(fromPlugin(targetHeader.getParentHash())).get(); + targetBlockHash = fromPlugin(targetHeader.getBlockHash()); } // roll back in tandem until we hit a shared state - while (!persistedHeader.getHash().equals(targetHeader.getHash())) { - LOG.debug("Paired Rollback {}", persistedHeader.getHash()); - LOG.debug("Paired Rollforward {}", targetHeader.getHash()); - rollForwards.add(getTrieLogLayer(targetHeader.getHash()).get()); - targetHeader = blockchain.getBlockHeader(targetHeader.getParentHash()).get(); - - rollBacks.add(getTrieLogLayer(persistedHeader.getHash()).get()); - persistedHeader = blockchain.getBlockHeader(persistedHeader.getParentHash()).get(); + while (!persistedBlockHash.equals(targetBlockHash)) { + LOG.debug("Paired Rollback {}", persistedBlockHash); + LOG.debug("Paired Rollforward {}", targetBlockHash); + rollForwards.add(getTrieLogLayer(targetBlockHash).get()); + targetHeader = + blockchain.getBlockHeader(fromPlugin(targetHeader.getParentHash())).get(); + + rollBacks.add(getTrieLogLayer(persistedBlockHash).get()); + persistedHeader = + blockchain.getBlockHeader(fromPlugin(persistedHeader.getParentHash())).get(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java index f023bf201ea..7f36e3c3e03 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java @@ -19,13 +19,13 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.UpdateTrackingAccount; -import org.hyperledger.besu.ethereum.core.WrappedEvmAccount; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater; +import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount; +import org.hyperledger.besu.evm.worldstate.WrappedEvmAccount; import java.util.Collection; import java.util.Comparator; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldView.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldView.java index f780a8a6e74..507e511f95b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldView.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldView.java @@ -18,8 +18,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.WorldView; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; +import org.hyperledger.besu.evm.worldstate.WorldView; import java.util.Map; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java index 98ea64e602f..fc8244bff2e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java @@ -24,15 +24,15 @@ 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.ethereum.core.LogsBloomFilter; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java index c20f845b27d..57ec179efde 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeader.java @@ -18,6 +18,7 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Objects; import java.util.Optional; @@ -164,7 +165,7 @@ public Hash getHash() { } @Override - public org.hyperledger.besu.plugin.data.Hash getBlockHash() { + public Hash getBlockHash() { return hash.get(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java index c43ebfd56b6..055ab095bf5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockHeaderBuilder.java @@ -20,6 +20,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.time.Instant; import java.util.OptionalLong; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Difficulty.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Difficulty.java index 438d2ea6636..3ea399db947 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Difficulty.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Difficulty.java @@ -77,6 +77,10 @@ public BigInteger getAsBigInteger() { return toBigInteger(); } + public Bytes32 getAsBytes32() { + return this; + } + @Override public String toHexString() { return super.toHexString(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/GasAndAccessedState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/GasAndAccessedState.java index 6d4d47a4d60..ad501fedd1f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/GasAndAccessedState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/GasAndAccessedState.java @@ -18,6 +18,7 @@ import static java.util.Collections.emptySet; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.evm.Gas; import java.util.Set; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogWithMetadata.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogWithMetadata.java index 299d181f963..0eb1485613b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogWithMetadata.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogWithMetadata.java @@ -19,6 +19,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.ArrayList; import java.util.List; @@ -64,7 +66,7 @@ public static List generate( final int transactionIndex, final boolean removed) { return generate( - receipt.getLogs(), number, blockHash, transactionHash, transactionIndex, removed); + receipt.getLogsList(), number, blockHash, transactionHash, transactionIndex, removed); } public static List generate( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldState.java index 7c6abfa52f4..de77e189385 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldState.java @@ -14,6 +14,10 @@ */ package org.hyperledger.besu.ethereum.core; +import org.hyperledger.besu.evm.worldstate.MutableWorldView; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.plugin.data.BlockHeader; + public interface MutableWorldState extends WorldState, MutableWorldView { /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java index 374de6124e0..18a4677c25f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/PrivacyParameters.java @@ -46,6 +46,17 @@ public class PrivacyParameters { + // Last address that can be generated for a pre-compiled contract + public static final Integer PRIVACY = Byte.MAX_VALUE - 1; + public static final Address DEFAULT_PRIVACY = Address.precompiled(PRIVACY); + public static final Address ONCHAIN_PRIVACY = Address.precompiled(PRIVACY - 1); + + // Onchain privacy management contracts (injected in private state) + public static final Address ONCHAIN_PRIVACY_PROXY = Address.precompiled(PRIVACY - 2); + public static final Address DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT = Address.precompiled(PRIVACY - 3); + + public static final Address PLUGIN_PRIVACY = Address.precompiled(PRIVACY - 4); + public static final URI DEFAULT_ENCLAVE_URL = URI.create("http://localhost:8888"); public static final PrivacyParameters DEFAULT = new PrivacyParameters(); @@ -68,11 +79,11 @@ public class PrivacyParameters { public Address getPrivacyAddress() { if (isPrivacyPluginEnabled()) { - return Address.PLUGIN_PRIVACY; + return PLUGIN_PRIVACY; } else if (isOnchainPrivacyGroupsEnabled()) { - return Address.ONCHAIN_PRIVACY; + return ONCHAIN_PRIVACY; } else { - return Address.DEFAULT_PRIVACY; + return DEFAULT_PRIVACY; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java index d40aea0321d..12a63dad92d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ProcessableBlockHeader.java @@ -16,11 +16,14 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.evm.frame.BlockValues; import java.util.Optional; +import org.apache.tuweni.bytes.Bytes; + /** A block header capable of being processed. */ -public class ProcessableBlockHeader { +public class ProcessableBlockHeader implements BlockValues { protected final Hash parentHash; @@ -81,11 +84,22 @@ public Difficulty getDifficulty() { return difficulty; } + /** + * Returns the block difficulty. + * + * @return the block difficulty + */ + @Override + public Bytes getDifficultyBytes() { + return difficulty.getAsBytes32(); + } + /** * Returns the block number. * * @return the block number */ + @Override public long getNumber() { return number; } @@ -95,6 +109,7 @@ public long getNumber() { * * @return the block gas limit */ + @Override public long getGasLimit() { return gasLimit; } @@ -104,6 +119,7 @@ public long getGasLimit() { * * @return the block timestamp */ + @Override public long getTimestamp() { return timestamp; } @@ -113,6 +129,7 @@ public long getTimestamp() { * * @return the raw bytes of the extra data field */ + @Override public Optional getBaseFee() { return Optional.ofNullable(baseFee); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java index 53f85634d2f..611e4ce5aef 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/SealableBlockHeader.java @@ -16,6 +16,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index 24630d9b599..345b4b2852e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -32,6 +32,7 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.transaction.GoQuorumPrivateTransactionDetector; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.Quantity; import org.hyperledger.besu.plugin.data.TransactionType; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java index b074ebba60f..0ed054a6382 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java @@ -21,14 +21,19 @@ import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.plugin.data.Address; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; import com.google.common.base.MoreObjects; import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; /** * A transaction receipt, containing information pertaining a transaction execution. @@ -291,7 +296,16 @@ public long getCumulativeGasUsed() { * @return the logs generated by the transaction */ @Override - public List getLogs() { + public List getLogs() { + return logs.stream().map(LogsWrapper::new).collect(Collectors.toList()); + } + + /** + * Returns the logs generated by the transaction. + * + * @return the logs generated by the transaction + */ + public List getLogsList() { return logs; } @@ -333,7 +347,7 @@ public boolean equals(final Object obj) { return false; } final TransactionReceipt other = (TransactionReceipt) obj; - return logs.equals(other.getLogs()) + return logs.equals(other.getLogsList()) && Objects.equals(stateRoot, other.stateRoot) && cumulativeGasUsed == other.getCumulativeGasUsed() && status == other.status; @@ -356,3 +370,27 @@ public String toString() { .toString(); } } + +class LogsWrapper implements org.hyperledger.besu.plugin.data.Log { + + final Log delegate; + + LogsWrapper(final Log delegate) { + this.delegate = delegate; + } + + @Override + public Address getLogger() { + return delegate.getLogger(); + } + + @Override + public List getTopics() { + return delegate.getTopics(); + } + + @Override + public Bytes getData() { + return delegate.getData(); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java index 9ecc66df0c8..a922be0488f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java @@ -27,11 +27,11 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.transaction.GoQuorumPrivateTransactionDetector; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java index 82d624f5ce9..9123bd0a1fb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java @@ -18,10 +18,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPOutput; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculator.java index 9f83da6102d..c5d9c22ad33 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculator.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.core.feemarket; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/GasDeserializer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/GasDeserializer.java index 31e97a8ffa6..4fc73e364be 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/GasDeserializer.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/GasDeserializer.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.ethereum.core.json; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import java.io.IOException; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/debug/TraceFrame.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/debug/TraceFrame.java index 0ba3220678a..ab7bdb0d7a2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/debug/TraceFrame.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/debug/TraceFrame.java @@ -16,11 +16,11 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.internal.MemoryEntry; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.internal.MemoryEntry; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Map; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java index 6d97fe5bd41..c66554a01ef 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/goquorum/GoQuorumBlockProcessor.java @@ -22,13 +22,10 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.EvmAccount; import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; @@ -39,8 +36,11 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.GoQuorumMutablePrivateWorldStateUpdater; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.Collections; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 9183f21d052..75a2f4af373 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -23,12 +23,12 @@ import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.ArrayList; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java index 9e5eedd41fb..8d8fe3efd84 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java @@ -18,13 +18,13 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.SimpleMerklePatriciaTrie; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.List; import java.util.stream.IntStream; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java index 93092eedfae..38406123623 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicBlockProcessor.java @@ -16,9 +16,9 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.math.BigInteger; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java index b006d195847..49b11185615 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ClassicProtocolSpecs.java @@ -19,12 +19,21 @@ import org.hyperledger.besu.config.PowAlgorithm; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator; -import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.MainnetEVMs; +import org.hyperledger.besu.evm.contractvalidation.MaxCodeSizeRule; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.DieHardGasCalculator; +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.processor.ContractCreationProcessor; +import org.hyperledger.besu.evm.processor.MessageCallProcessor; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; @@ -138,12 +147,10 @@ public static ProtocolSpecBuilder atlantisDefinition( configStackSizeLimit, ecip1017EraRounds, quorumCompatibilityMode) - .evmBuilder(MainnetEvmRegistries::byzantium) + .evmBuilder(MainnetEVMs::byzantium) .gasCalculator(SpuriousDragonGasCalculator::new) .skipZeroBlockRewards(true) - .messageCallProcessorBuilder( - (evm, precompileContractRegistry) -> - new MainnetMessageCallProcessor(evm, precompileContractRegistry)) + .messageCallProcessorBuilder(MessageCallProcessor::new) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium) .difficultyCalculator(ClassicDifficultyCalculators.EIP100) .transactionReceiptFactory( @@ -152,7 +159,7 @@ public static ProtocolSpecBuilder atlantisDefinition( : ClassicProtocolSpecs::byzantiumTransactionReceiptFactory) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -189,9 +196,9 @@ public static ProtocolSpecBuilder aghartaDefinition( enableRevertReason, ecip1017EraRounds, quorumCompatibilityMode) - .evmBuilder(MainnetEvmRegistries::constantinople) + .evmBuilder(MainnetEVMs::constantinople) .gasCalculator(PetersburgGasCalculator::new) - .evmBuilder(gasCalculator -> MainnetEvmRegistries.constantinople(gasCalculator)) + .evmBuilder(MainnetEVMs::constantinople) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::istanbul) .name("Agharta"); } @@ -212,8 +219,7 @@ public static ProtocolSpecBuilder phoenixDefinition( quorumCompatibilityMode) .gasCalculator(IstanbulGasCalculator::new) .evmBuilder( - gasCalculator -> - MainnetEvmRegistries.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO))) + gasCalculator -> MainnetEVMs.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO))) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::istanbul) .name("Phoenix"); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java index 1989e03c272..55272aa0a7c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidator.java @@ -19,8 +19,8 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.TransactionReceipt; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.HashSet; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java index 7572b5ea613..9ff3562bba0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockProcessor.java @@ -18,9 +18,9 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.GoQuorumPrivacyParameters; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.List; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetEvmRegistries.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetEvmRegistries.java deleted file mode 100644 index 0eda95bee70..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetEvmRegistries.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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.ethereum.mainnet; - -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.OperationRegistry; -import org.hyperledger.besu.ethereum.vm.operations.AddModOperation; -import org.hyperledger.besu.ethereum.vm.operations.AddOperation; -import org.hyperledger.besu.ethereum.vm.operations.AddressOperation; -import org.hyperledger.besu.ethereum.vm.operations.AndOperation; -import org.hyperledger.besu.ethereum.vm.operations.BalanceOperation; -import org.hyperledger.besu.ethereum.vm.operations.BaseFeeOperation; -import org.hyperledger.besu.ethereum.vm.operations.BlockHashOperation; -import org.hyperledger.besu.ethereum.vm.operations.ByteOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallCodeOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallDataCopyOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallDataLoadOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallDataSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallValueOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallerOperation; -import org.hyperledger.besu.ethereum.vm.operations.ChainIdOperation; -import org.hyperledger.besu.ethereum.vm.operations.CodeCopyOperation; -import org.hyperledger.besu.ethereum.vm.operations.CodeSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.CoinbaseOperation; -import org.hyperledger.besu.ethereum.vm.operations.Create2Operation; -import org.hyperledger.besu.ethereum.vm.operations.CreateOperation; -import org.hyperledger.besu.ethereum.vm.operations.DelegateCallOperation; -import org.hyperledger.besu.ethereum.vm.operations.DifficultyOperation; -import org.hyperledger.besu.ethereum.vm.operations.DivOperation; -import org.hyperledger.besu.ethereum.vm.operations.DupOperation; -import org.hyperledger.besu.ethereum.vm.operations.EqOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExpOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeCopyOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeHashOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.GasLimitOperation; -import org.hyperledger.besu.ethereum.vm.operations.GasOperation; -import org.hyperledger.besu.ethereum.vm.operations.GasPriceOperation; -import org.hyperledger.besu.ethereum.vm.operations.GtOperation; -import org.hyperledger.besu.ethereum.vm.operations.InvalidOperation; -import org.hyperledger.besu.ethereum.vm.operations.IsZeroOperation; -import org.hyperledger.besu.ethereum.vm.operations.JumpDestOperation; -import org.hyperledger.besu.ethereum.vm.operations.JumpOperation; -import org.hyperledger.besu.ethereum.vm.operations.JumpiOperation; -import org.hyperledger.besu.ethereum.vm.operations.LogOperation; -import org.hyperledger.besu.ethereum.vm.operations.LtOperation; -import org.hyperledger.besu.ethereum.vm.operations.MLoadOperation; -import org.hyperledger.besu.ethereum.vm.operations.MSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.MStore8Operation; -import org.hyperledger.besu.ethereum.vm.operations.MStoreOperation; -import org.hyperledger.besu.ethereum.vm.operations.ModOperation; -import org.hyperledger.besu.ethereum.vm.operations.MulModOperation; -import org.hyperledger.besu.ethereum.vm.operations.MulOperation; -import org.hyperledger.besu.ethereum.vm.operations.NotOperation; -import org.hyperledger.besu.ethereum.vm.operations.NumberOperation; -import org.hyperledger.besu.ethereum.vm.operations.OrOperation; -import org.hyperledger.besu.ethereum.vm.operations.OriginOperation; -import org.hyperledger.besu.ethereum.vm.operations.PCOperation; -import org.hyperledger.besu.ethereum.vm.operations.PopOperation; -import org.hyperledger.besu.ethereum.vm.operations.PushOperation; -import org.hyperledger.besu.ethereum.vm.operations.ReturnDataCopyOperation; -import org.hyperledger.besu.ethereum.vm.operations.ReturnDataSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.ReturnOperation; -import org.hyperledger.besu.ethereum.vm.operations.RevertOperation; -import org.hyperledger.besu.ethereum.vm.operations.SDivOperation; -import org.hyperledger.besu.ethereum.vm.operations.SGtOperation; -import org.hyperledger.besu.ethereum.vm.operations.SLoadOperation; -import org.hyperledger.besu.ethereum.vm.operations.SLtOperation; -import org.hyperledger.besu.ethereum.vm.operations.SModOperation; -import org.hyperledger.besu.ethereum.vm.operations.SStoreOperation; -import org.hyperledger.besu.ethereum.vm.operations.SarOperation; -import org.hyperledger.besu.ethereum.vm.operations.SelfBalanceOperation; -import org.hyperledger.besu.ethereum.vm.operations.SelfDestructOperation; -import org.hyperledger.besu.ethereum.vm.operations.Sha3Operation; -import org.hyperledger.besu.ethereum.vm.operations.ShlOperation; -import org.hyperledger.besu.ethereum.vm.operations.ShrOperation; -import org.hyperledger.besu.ethereum.vm.operations.SignExtendOperation; -import org.hyperledger.besu.ethereum.vm.operations.StaticCallOperation; -import org.hyperledger.besu.ethereum.vm.operations.StopOperation; -import org.hyperledger.besu.ethereum.vm.operations.SubOperation; -import org.hyperledger.besu.ethereum.vm.operations.SwapOperation; -import org.hyperledger.besu.ethereum.vm.operations.TimestampOperation; -import org.hyperledger.besu.ethereum.vm.operations.XorOperation; - -import java.math.BigInteger; - -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.bytes.Bytes32; - -/** Provides EVMs supporting the appropriate operations for mainnet hard forks. */ -abstract class MainnetEvmRegistries { - - static EVM frontier(final GasCalculator gasCalculator) { - final OperationRegistry registry = new OperationRegistry(); - - registerFrontierOpcodes(registry, gasCalculator); - - return new EVM(registry, gasCalculator); - } - - static EVM homestead(final GasCalculator gasCalculator) { - final OperationRegistry registry = new OperationRegistry(); - - registerHomesteadOpcodes(registry, gasCalculator); - - return new EVM(registry, gasCalculator); - } - - static EVM byzantium(final GasCalculator gasCalculator) { - final OperationRegistry registry = new OperationRegistry(); - - registerByzantiumOpcodes(registry, gasCalculator); - - return new EVM(registry, gasCalculator); - } - - static EVM constantinople(final GasCalculator gasCalculator) { - final OperationRegistry registry = new OperationRegistry(); - - registerConstantinopleOpcodes(registry, gasCalculator); - - return new EVM(registry, gasCalculator); - } - - static EVM istanbul(final GasCalculator gasCalculator, final BigInteger chainId) { - final OperationRegistry registry = new OperationRegistry(); - - registerIstanbulOpcodes(registry, gasCalculator, chainId); - - return new EVM(registry, gasCalculator); - } - - static EVM london(final GasCalculator gasCalculator, final BigInteger chainId) { - final OperationRegistry registry = new OperationRegistry(); - - registerLondonOpcodes(registry, gasCalculator, chainId); - - return new EVM(registry, gasCalculator); - } - - private static void registerFrontierOpcodes( - final OperationRegistry registry, final GasCalculator gasCalculator) { - registry.put(new AddOperation(gasCalculator)); - registry.put(new MulOperation(gasCalculator)); - registry.put(new SubOperation(gasCalculator)); - registry.put(new DivOperation(gasCalculator)); - registry.put(new SDivOperation(gasCalculator)); - registry.put(new ModOperation(gasCalculator)); - registry.put(new SModOperation(gasCalculator)); - registry.put(new ExpOperation(gasCalculator)); - registry.put(new AddModOperation(gasCalculator)); - registry.put(new MulModOperation(gasCalculator)); - registry.put(new SignExtendOperation(gasCalculator)); - registry.put(new LtOperation(gasCalculator)); - registry.put(new GtOperation(gasCalculator)); - registry.put(new SLtOperation(gasCalculator)); - registry.put(new SGtOperation(gasCalculator)); - registry.put(new EqOperation(gasCalculator)); - registry.put(new IsZeroOperation(gasCalculator)); - registry.put(new AndOperation(gasCalculator)); - registry.put(new OrOperation(gasCalculator)); - registry.put(new XorOperation(gasCalculator)); - registry.put(new NotOperation(gasCalculator)); - registry.put(new ByteOperation(gasCalculator)); - registry.put(new Sha3Operation(gasCalculator)); - registry.put(new AddressOperation(gasCalculator)); - registry.put(new BalanceOperation(gasCalculator)); - registry.put(new OriginOperation(gasCalculator)); - registry.put(new CallerOperation(gasCalculator)); - registry.put(new CallValueOperation(gasCalculator)); - registry.put(new CallDataLoadOperation(gasCalculator)); - registry.put(new CallDataSizeOperation(gasCalculator)); - registry.put(new CallDataCopyOperation(gasCalculator)); - registry.put(new CodeSizeOperation(gasCalculator)); - registry.put(new CodeCopyOperation(gasCalculator)); - registry.put(new GasPriceOperation(gasCalculator)); - registry.put(new ExtCodeCopyOperation(gasCalculator)); - registry.put(new ExtCodeSizeOperation(gasCalculator)); - registry.put(new BlockHashOperation(gasCalculator)); - registry.put(new CoinbaseOperation(gasCalculator)); - registry.put(new TimestampOperation(gasCalculator)); - registry.put(new NumberOperation(gasCalculator)); - registry.put(new DifficultyOperation(gasCalculator)); - registry.put(new GasLimitOperation(gasCalculator)); - registry.put(new PopOperation(gasCalculator)); - registry.put(new MLoadOperation(gasCalculator)); - registry.put(new MStoreOperation(gasCalculator)); - registry.put(new MStore8Operation(gasCalculator)); - registry.put(new SLoadOperation(gasCalculator)); - registry.put(new SStoreOperation(gasCalculator, SStoreOperation.FRONTIER_MINIMUM)); - registry.put(new JumpOperation(gasCalculator)); - registry.put(new JumpiOperation(gasCalculator)); - registry.put(new PCOperation(gasCalculator)); - registry.put(new MSizeOperation(gasCalculator)); - registry.put(new GasOperation(gasCalculator)); - registry.put(new JumpDestOperation(gasCalculator)); - registry.put(new ReturnOperation(gasCalculator)); - registry.put(new InvalidOperation(gasCalculator)); - registry.put(new StopOperation(gasCalculator)); - registry.put(new SelfDestructOperation(gasCalculator)); - registry.put(new CreateOperation(gasCalculator)); - registry.put(new CallOperation(gasCalculator)); - registry.put(new CallCodeOperation(gasCalculator)); - - // Register the PUSH1, PUSH2, ..., PUSH32 operations. - for (int i = 1; i <= 32; ++i) { - registry.put(new PushOperation(i, gasCalculator)); - } - - // Register the DUP1, DUP2, ..., DUP16 operations. - for (int i = 1; i <= 16; ++i) { - registry.put(new DupOperation(i, gasCalculator)); - } - - // Register the SWAP1, SWAP2, ..., SWAP16 operations. - for (int i = 1; i <= 16; ++i) { - registry.put(new SwapOperation(i, gasCalculator)); - } - - // Register the LOG0, LOG1, ..., LOG4 operations. - for (int i = 0; i < 5; ++i) { - registry.put(new LogOperation(i, gasCalculator)); - } - } - - private static void registerHomesteadOpcodes( - final OperationRegistry registry, final GasCalculator gasCalculator) { - registerFrontierOpcodes(registry, gasCalculator); - registry.put(new DelegateCallOperation(gasCalculator)); - } - - private static void registerByzantiumOpcodes( - final OperationRegistry registry, final GasCalculator gasCalculator) { - registerHomesteadOpcodes(registry, gasCalculator); - registry.put(new ReturnDataCopyOperation(gasCalculator)); - registry.put(new ReturnDataSizeOperation(gasCalculator)); - registry.put(new RevertOperation(gasCalculator)); - registry.put(new StaticCallOperation(gasCalculator)); - } - - private static void registerConstantinopleOpcodes( - final OperationRegistry registry, final GasCalculator gasCalculator) { - registerByzantiumOpcodes(registry, gasCalculator); - registry.put(new Create2Operation(gasCalculator)); - registry.put(new SarOperation(gasCalculator)); - registry.put(new ShlOperation(gasCalculator)); - registry.put(new ShrOperation(gasCalculator)); - registry.put(new ExtCodeHashOperation(gasCalculator)); - } - - private static void registerIstanbulOpcodes( - final OperationRegistry registry, - final GasCalculator gasCalculator, - final BigInteger chainId) { - registerConstantinopleOpcodes(registry, gasCalculator); - registry.put( - new ChainIdOperation(gasCalculator, Bytes32.leftPad(Bytes.of(chainId.toByteArray())))); - registry.put(new SelfBalanceOperation(gasCalculator)); - registry.put(new SStoreOperation(gasCalculator, SStoreOperation.EIP_1706_MINIMUM)); - } - - private static void registerLondonOpcodes( - final OperationRegistry registry, - final GasCalculator gasCalculator, - final BigInteger chainId) { - registerIstanbulOpcodes(registry, gasCalculator, chainId); - registry.put(new BaseFeeOperation(gasCalculator)); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java index 67bf319dac6..e70f8775b15 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistries.java @@ -14,43 +14,24 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.mainnet.precompiles.AltBN128AddPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.AltBN128MulPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.AltBN128PairingPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLAKE2BFPrecompileContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G1AddPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G1MulPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G1MultiExpPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G2AddPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G2MulPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12G2MultiExpPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12MapFp2ToG2PrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12MapFpToG1PrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BLS12PairingPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BigIntegerModularExponentiationPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.ECRECPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.IDPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.RIPEMD160PrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.SHA256PrecompiledContract; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; +import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForBLS12; +import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForByzantium; +import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForFrontier; +import static org.hyperledger.besu.evm.precompile.MainnetPrecompiledContracts.populateForIstanbul; + import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnChainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPluginPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; /** Provides the various precompiled contracts used on mainnet hard forks. */ public abstract class MainnetPrecompiledContractRegistries { private MainnetPrecompiledContractRegistries() {} - private static void populateForFrontier( - final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { - registry.put(Address.ECREC, new ECRECPrecompiledContract(gasCalculator)); - registry.put(Address.SHA256, new SHA256PrecompiledContract(gasCalculator)); - registry.put(Address.RIPEMD160, new RIPEMD160PrecompiledContract(gasCalculator)); - registry.put(Address.ID, new IDPrecompiledContract(gasCalculator)); - } - public static PrecompileContractRegistry frontier( final PrecompiledContractConfiguration precompiledContractConfiguration) { final PrecompileContractRegistry registry = new PrecompileContractRegistry(); @@ -58,17 +39,6 @@ public static PrecompileContractRegistry frontier( return registry; } - private static void populateForByzantium( - final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { - populateForFrontier(registry, gasCalculator); - registry.put( - Address.MODEXP, new BigIntegerModularExponentiationPrecompiledContract(gasCalculator)); - registry.put(Address.ALTBN128_ADD, AltBN128AddPrecompiledContract.byzantium(gasCalculator)); - registry.put(Address.ALTBN128_MUL, AltBN128MulPrecompiledContract.byzantium(gasCalculator)); - registry.put( - Address.ALTBN128_PAIRING, AltBN128PairingPrecompiledContract.byzantium(gasCalculator)); - } - public static PrecompileContractRegistry byzantium( final PrecompiledContractConfiguration precompiledContractConfiguration) { final PrecompileContractRegistry registry = new PrecompileContractRegistry(); @@ -76,16 +46,6 @@ public static PrecompileContractRegistry byzantium( return registry; } - private static void populateForIstanbul( - final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { - populateForByzantium(registry, gasCalculator); - registry.put(Address.ALTBN128_ADD, AltBN128AddPrecompiledContract.istanbul(gasCalculator)); - registry.put(Address.ALTBN128_MUL, AltBN128MulPrecompiledContract.istanbul(gasCalculator)); - registry.put( - Address.ALTBN128_PAIRING, AltBN128PairingPrecompiledContract.istanbul(gasCalculator)); - registry.put(Address.BLAKE2B_F_COMPRESSION, new BLAKE2BFPrecompileContract(gasCalculator)); - } - public static PrecompileContractRegistry istanbul( final PrecompiledContractConfiguration precompiledContractConfiguration) { final PrecompileContractRegistry registry = new PrecompileContractRegistry(); @@ -93,20 +53,6 @@ public static PrecompileContractRegistry istanbul( return registry; } - private static void populateForBLS12( - final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { - populateForIstanbul(registry, gasCalculator); - registry.put(Address.BLS12_G1ADD, new BLS12G1AddPrecompiledContract()); - registry.put(Address.BLS12_G1MUL, new BLS12G1MulPrecompiledContract()); - registry.put(Address.BLS12_G1MULTIEXP, new BLS12G1MultiExpPrecompiledContract()); - registry.put(Address.BLS12_G2ADD, new BLS12G2AddPrecompiledContract()); - registry.put(Address.BLS12_G2MUL, new BLS12G2MulPrecompiledContract()); - registry.put(Address.BLS12_G2MULTIEXP, new BLS12G2MultiExpPrecompiledContract()); - registry.put(Address.BLS12_PAIRING, new BLS12PairingPrecompiledContract()); - registry.put(Address.BLS12_MAP_FP_TO_G1, new BLS12MapFpToG1PrecompiledContract()); - registry.put(Address.BLS12_MAP_FP2_TO_G2, new BLS12MapFp2ToG2PrecompiledContract()); - } - public static PrecompileContractRegistry bls12( final PrecompiledContractConfiguration precompiledContractConfiguration) { final PrecompileContractRegistry registry = new PrecompileContractRegistry(); @@ -124,7 +70,7 @@ static void appendPrivacy( if (precompiledContractConfiguration.getPrivacyParameters().isPrivacyPluginEnabled()) { registry.put( - Address.PLUGIN_PRIVACY, + PLUGIN_PRIVACY, new PrivacyPluginPrecompiledContract( precompiledContractConfiguration.getGasCalculator(), precompiledContractConfiguration.getPrivacyParameters())); @@ -132,13 +78,13 @@ static void appendPrivacy( .getPrivacyParameters() .isOnchainPrivacyGroupsEnabled()) { registry.put( - Address.ONCHAIN_PRIVACY, + ONCHAIN_PRIVACY, new OnChainPrivacyPrecompiledContract( precompiledContractConfiguration.getGasCalculator(), precompiledContractConfiguration.getPrivacyParameters())); } else { registry.put( - Address.DEFAULT_PRIVACY, + DEFAULT_PRIVACY, new PrivacyPrecompiledContract( precompiledContractConfiguration.getGasCalculator(), precompiledContractConfiguration.getPrivacyParameters(), diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java index eabbbde7441..009cddadd24 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java @@ -21,26 +21,39 @@ import org.hyperledger.besu.ethereum.MainnetBlockValidator; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator; import org.hyperledger.besu.ethereum.goquorum.GoQuorumBlockProcessor; import org.hyperledger.besu.ethereum.goquorum.GoQuorumBlockValidator; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockProcessorBuilder; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder.BlockValidatorBuilder; -import org.hyperledger.besu.ethereum.mainnet.contractvalidation.MaxCodeSizeRule; -import org.hyperledger.besu.ethereum.mainnet.contractvalidation.PrefixCodeRule; import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.MainnetEVMs; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.contractvalidation.MaxCodeSizeRule; +import org.hyperledger.besu.evm.contractvalidation.PrefixCodeRule; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; +import org.hyperledger.besu.evm.gascalculator.HomesteadGasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +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.processor.ContractCreationProcessor; +import org.hyperledger.besu.evm.processor.MessageCallProcessor; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.io.IOException; @@ -93,12 +106,12 @@ public static ProtocolSpecBuilder frontierDefinition( return new ProtocolSpecBuilder() .gasCalculator(FrontierGasCalculator::new) .gasLimitCalculator(new FrontierTargetingGasLimitCalculator()) - .evmBuilder(MainnetEvmRegistries::frontier) + .evmBuilder(MainnetEVMs::frontier) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::frontier) - .messageCallProcessorBuilder(MainnetMessageCallProcessor::new) + .messageCallProcessorBuilder(MessageCallProcessor::new) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, false, @@ -197,10 +210,10 @@ public static ProtocolSpecBuilder homesteadDefinition( return frontierDefinition( configContractSizeLimit, configStackSizeLimit, quorumCompatibilityMode) .gasCalculator(HomesteadGasCalculator::new) - .evmBuilder(MainnetEvmRegistries::homestead) + .evmBuilder(MainnetEVMs::homestead) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -272,13 +285,13 @@ public static ProtocolSpecBuilder spuriousDragonDefinition( .skipZeroBlockRewards(true) .messageCallProcessorBuilder( (evm, precompileContractRegistry) -> - new MainnetMessageCallProcessor( + new MessageCallProcessor( evm, precompileContractRegistry, SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES)) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -316,7 +329,7 @@ public static ProtocolSpecBuilder byzantiumDefinition( return spuriousDragonDefinition( chainId, contractSizeLimit, configStackSizeLimit, quorumCompatibilityMode) .gasCalculator(ByzantiumGasCalculator::new) - .evmBuilder(MainnetEvmRegistries::byzantium) + .evmBuilder(MainnetEVMs::byzantium) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium) .difficultyCalculator(MainnetDifficultyCalculators.BYZANTIUM) .transactionReceiptFactory( @@ -356,7 +369,7 @@ public static ProtocolSpecBuilder constantinopleDefinition( quorumCompatibilityMode) .difficultyCalculator(MainnetDifficultyCalculators.CONSTANTINOPLE) .gasCalculator(ConstantinopleGasCalculator::new) - .evmBuilder(MainnetEvmRegistries::constantinople) + .evmBuilder(MainnetEVMs::constantinople) .blockReward(CONSTANTINOPLE_BLOCK_REWARD) .name("Constantinople"); } @@ -393,12 +406,11 @@ public static ProtocolSpecBuilder istanbulDefinition( quorumCompatibilityMode) .gasCalculator(IstanbulGasCalculator::new) .evmBuilder( - gasCalculator -> - MainnetEvmRegistries.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO))) + gasCalculator -> MainnetEVMs.istanbul(gasCalculator, chainId.orElse(BigInteger.ZERO))) .precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::istanbul) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -502,7 +514,7 @@ static ProtocolSpecBuilder londonDefinition( CoinbaseFeePriceCalculator.eip1559())) .contractCreationProcessorBuilder( (gasCalculator, evm) -> - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -510,8 +522,7 @@ static ProtocolSpecBuilder londonDefinition( 1, SPURIOUS_DRAGON_FORCE_DELETE_WHEN_EMPTY_ADDRESSES)) .evmBuilder( - gasCalculator -> - MainnetEvmRegistries.london(gasCalculator, chainId.orElse(BigInteger.ZERO))) + gasCalculator -> MainnetEVMs.london(gasCalculator, chainId.orElse(BigInteger.ZERO))) .feeMarket(londonFeeMarket) .difficultyCalculator(MainnetDifficultyCalculators.LONDON) .blockHeaderValidatorBuilder( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java index 470e908af05..c52a4338165 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java @@ -14,28 +14,35 @@ */ package org.hyperledger.besu.ethereum.mainnet; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH; + import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.AccessListEntry; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.AccountState; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.GoQuorumMutablePrivateWorldStateUpdater; +import org.hyperledger.besu.evm.AccessListEntry; +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; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.processor.AbstractMessageProcessor; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayDeque; import java.util.ArrayList; @@ -46,6 +53,7 @@ import java.util.Set; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -275,7 +283,7 @@ public TransactionProcessingResult processTransaction( return TransactionProcessingResult.invalid(validationResult); } - final var senderMutableAccount = sender.getMutable(); + final MutableAccount senderMutableAccount = sender.getMutable(); final long previousNonce = senderMutableAccount.incrementNonce(); final Wei transactionGasPrice = feeMarket.getTransactionPriceCalculator().price(transaction, blockHeader.getBaseFee()); @@ -323,29 +331,34 @@ public TransactionProcessingResult processTransaction( final WorldUpdater worldUpdater = worldState.updater(); final Deque messageFrameStack = new ArrayDeque<>(); + final ImmutableMap.Builder contextVariablesBuilder = + ImmutableMap.builder() + .put(KEY_IS_PERSISTING_PRIVATE_STATE, isPersistingPrivateState) + .put(KEY_TRANSACTION, transaction) + .put(KEY_TRANSACTION_HASH, transaction.getHash()); + if (privateMetadataUpdater != null) { + contextVariablesBuilder.put(KEY_PRIVATE_METADATA_UPDATER, privateMetadataUpdater); + } + final MessageFrame.Builder commonMessageFrameBuilder = MessageFrame.builder() .messageFrameStack(messageFrameStack) .maxStackSize(maxStackSize) - .blockchain(blockchain) - .worldState(worldUpdater.updater()) + .worldUpdater(worldUpdater.updater()) .initialGas(gasAvailable) .originator(senderAddress) .gasPrice(transactionGasPrice) .sender(senderAddress) .value(transaction.getValue()) .apparentValue(transaction.getValue()) - .blockHeader(blockHeader) + .blockValues(blockHeader) .depth(0) .completer(__ -> {}) .miningBeneficiary(miningBeneficiary) .blockHashLookup(blockHashLookup) - .isPersistingPrivateState(isPersistingPrivateState) - .transactionHash(transaction.getHash()) - .transaction(transaction) + .contextVariables(contextVariablesBuilder.build()) .accessListWarmAddresses(addressList) - .accessListWarmStorage(storageList) - .privateMetadataUpdater(privateMetadataUpdater); + .accessListWarmStorage(storageList); final MessageFrame initialFrame; if (transaction.isContractCreation()) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java index b0ff1b62ddf..b13f959e32c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java @@ -18,13 +18,13 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionFilter; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContractConfiguration.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContractConfiguration.java index bf56af301a0..b2956c36473 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContractConfiguration.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContractConfiguration.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.mainnet; import org.hyperledger.besu.ethereum.core.PrivacyParameters; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class PrecompiledContractConfiguration { private GasCalculator gasCalculator; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java index ea3e0288ac2..d636dc27952 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessor.java @@ -14,7 +14,8 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.datatypes.Address; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; + import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveClientException; @@ -160,7 +161,7 @@ void maybeRehydrate( private boolean onChainAddToGroupPrivateMarkerTransactions(final Transaction t) { return t.getTo().isPresent() - && t.getTo().equals(Optional.of(Address.ONCHAIN_PRIVACY)) + && t.getTo().equals(Optional.of(ONCHAIN_PRIVACY)) && t.getPayload().size() == 64; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivateStateUtils.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivateStateUtils.java new file mode 100644 index 00000000000..78e33790d56 --- /dev/null +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrivateStateUtils.java @@ -0,0 +1,23 @@ +/* + * 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.ethereum.mainnet; + +public class PrivateStateUtils { + + public static String KEY_IS_PERSISTING_PRIVATE_STATE = "isPersistingPrivateState"; + public static String KEY_TRANSACTION = "transaction"; + public static String KEY_TRANSACTION_HASH = "transactionHash"; + public static String KEY_PRIVATE_METADATA_UPDATER = "privateMetadataUpdater"; +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java index 4204bb7e81c..f2828012654 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpec.java @@ -22,8 +22,9 @@ import org.hyperledger.besu.ethereum.core.BlockImporter; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java index d5ec69e4434..99c7d0247fd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java @@ -15,8 +15,10 @@ package org.hyperledger.besu.ethereum.mainnet; import static com.google.common.base.Preconditions.checkNotNull; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.PLUGIN_PRIVACY; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.BlockValidator; import org.hyperledger.besu.ethereum.GasLimitCalculator; @@ -31,8 +33,10 @@ import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; +import org.hyperledger.besu.evm.processor.AbstractMessageProcessor; import java.util.Optional; import java.util.function.BiFunction; @@ -310,19 +314,17 @@ public ProtocolSpec build(final ProtocolSchedule protocolSchedule) { if (privacyParameters.isPrivacyPluginEnabled()) { final PrivacyPluginPrecompiledContract privacyPluginPrecompiledContract = - (PrivacyPluginPrecompiledContract) - precompileContractRegistry.get(Address.PLUGIN_PRIVACY); + (PrivacyPluginPrecompiledContract) precompileContractRegistry.get(PLUGIN_PRIVACY); privacyPluginPrecompiledContract.setPrivateTransactionProcessor( privateTransactionProcessor); } else if (privacyParameters.isOnchainPrivacyGroupsEnabled()) { final OnChainPrivacyPrecompiledContract onChainPrivacyPrecompiledContract = - (OnChainPrivacyPrecompiledContract) - precompileContractRegistry.get(Address.ONCHAIN_PRIVACY); + (OnChainPrivacyPrecompiledContract) precompileContractRegistry.get(ONCHAIN_PRIVACY); onChainPrivacyPrecompiledContract.setPrivateTransactionProcessor( privateTransactionProcessor); } else { final PrivacyPrecompiledContract privacyPrecompiledContract = - (PrivacyPrecompiledContract) precompileContractRegistry.get(Address.DEFAULT_PRIVACY); + (PrivacyPrecompiledContract) precompileContractRegistry.get(DEFAULT_PRIVACY); privacyPrecompiledContract.setPrivateTransactionProcessor(privateTransactionProcessor); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java index ae35bd0c392..175659d0895 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContract.java @@ -14,17 +14,19 @@ */ package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.datatypes.Hash; +import static org.hyperledger.besu.datatypes.Hash.fromPlugin; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH; + import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveClientException; import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.ReceiveResponse; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.privacy.OnchainPrivacyGroupContract; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; @@ -37,9 +39,11 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.plugin.data.Hash; import org.hyperledger.besu.util.Subscribers; import java.util.ArrayList; @@ -100,7 +104,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { return Bytes.EMPTY; } - final Hash pmtHash = messageFrame.getTransactionHash(); + final Hash pmtHash = messageFrame.getContextVariable(KEY_TRANSACTION_HASH); final String key = input.slice(0, 32).toBase64String(); @@ -134,14 +138,16 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { LOG.debug("Processing private transaction {} in privacy group {}", pmtHash, privacyGroupId); - final ProcessableBlockHeader currentBlockHeader = messageFrame.getBlockHeader(); + final ProcessableBlockHeader currentBlockHeader = + (ProcessableBlockHeader) messageFrame.getBlockValues(); - final PrivateMetadataUpdater privateMetadataUpdater = messageFrame.getPrivateMetadataUpdater(); + final PrivateMetadataUpdater privateMetadataUpdater = + messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER); final Hash lastRootHash = privateStateRootResolver.resolveLastStateRoot(privacyGroupId, privateMetadataUpdater); final MutableWorldState disposablePrivateState = - privateWorldStateArchive.getMutable(lastRootHash, null).get(); + privateWorldStateArchive.getMutable(fromPlugin(lastRootHash), null).get(); final WorldUpdater privateWorldStateUpdater = disposablePrivateState.updater(); @@ -152,15 +158,12 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { privacyGroupId, currentBlockHeader.getNumber()); - final Blockchain blockchain = messageFrame.getBlockchain(); - if (!canExecute( messageFrame, currentBlockHeader, privateTransaction, versionedPrivateTransaction.getVersion(), privacyGroupId, - blockchain, disposablePrivateState, privateWorldStateUpdater, privateFrom)) { @@ -184,7 +187,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { sendParticipantRemovedEvent(privateTransaction); - if (messageFrame.isPersistingPrivateState()) { + if (messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)) { privateWorldStateUpdater.commit(); disposablePrivateState.persist(null); @@ -216,7 +219,6 @@ boolean canExecute( final PrivateTransaction privateTransaction, final Bytes32 version, final Bytes32 privacyGroupId, - final Blockchain blockchain, final MutableWorldState disposablePrivateState, final WorldUpdater privateWorldStateUpdater, final Bytes privateFrom) { @@ -236,7 +238,7 @@ boolean canExecute( LOG.debug( "Privacy Group {} is not locked while trying to add to group with commitment {}", privacyGroupId.toHexString(), - messageFrame.getTransactionHash()); + messageFrame.getContextVariable(KEY_TRANSACTION_HASH)); return false; } @@ -244,14 +246,14 @@ boolean canExecute( LOG.debug( "Privacy Group {} is locked while trying to execute transaction with commitment {}", privacyGroupId.toHexString(), - messageFrame.getTransactionHash()); + messageFrame.getContextVariable(KEY_TRANSACTION_HASH)); return false; } if (!onChainPrivacyGroupVersionMatches(onchainPrivacyGroupContract, privacyGroupId, version)) { LOG.debug( "Privacy group version mismatch while trying to execute transaction with commitment {}", - messageFrame.getTransactionHash()); + (Hash) messageFrame.getContextVariable(KEY_TRANSACTION_HASH)); return false; } @@ -264,7 +266,7 @@ boolean canExecute( LOG.debug( "PrivateTransaction with hash {} cannot execute in privacy group {} because privateFrom" + " {} is not a member.", - messageFrame.getTransactionHash(), + messageFrame.getContextVariable(KEY_TRANSACTION_HASH), privacyGroupId.toBase64String(), privateFrom.toBase64String()); return false; @@ -283,7 +285,7 @@ private boolean isMemberOfPrivacyGroup( onchainPrivacyGroupContract .getPrivacyGroupByIdAndBlockHash(privacyGroupId.toBase64String(), Optional.empty()) .map(PrivacyGroup::getMembers) - .orElse(Collections.emptyList()); + .orElse(Collections.emptyList()); List participantsFromParameter = Collections.emptyList(); if (members.isEmpty() && isAddingParticipant) { @@ -312,7 +314,7 @@ private String getRemovedParticipantFromParameter(final Bytes input) { private boolean isTargettingOnchainPrivacyProxy(final PrivateTransaction privateTransaction) { return privateTransaction.getTo().isPresent() - && privateTransaction.getTo().get().equals(Address.ONCHAIN_PRIVACY_PROXY); + && privateTransaction.getTo().get().equals(ONCHAIN_PRIVACY_PROXY); } private boolean isAddingParticipant(final PrivateTransaction privateTransaction) { @@ -336,8 +338,7 @@ protected boolean isContractLocked( final Optional canExecuteResult = onchainPrivacyGroupContract.getCanExecute( privacyGroupId.toBase64String(), Optional.empty()); - final boolean isLocked = canExecuteResult.map(Bytes::isZero).orElse(true); - return isLocked; + return canExecuteResult.map(Bytes::isZero).orElse(true); } protected boolean onChainPrivacyGroupVersionMatches( @@ -346,8 +347,7 @@ protected boolean onChainPrivacyGroupVersionMatches( final Bytes32 version) { final Optional contractVersionResult = onchainPrivacyGroupContract.getVersion(privacyGroupId.toBase64String(), Optional.empty()); - final boolean versionEqual = - contractVersionResult.map(contractVersion -> version.equals(contractVersion)).orElse(false); + final boolean versionEqual = contractVersionResult.map(version::equals).orElse(false); if (!versionEqual) { LOG.debug( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java index a493b71eead..9f0f50e29af 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContract.java @@ -17,13 +17,14 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Optional; @@ -53,7 +54,8 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { privacyParameters .getPrivacyService() .getPayloadProvider() - .getPrivateTransactionFromPayload(messageFrame.getTransaction()); + .getPrivateTransactionFromPayload( + messageFrame.getContextVariable(PrivateStateUtils.KEY_TRANSACTION)); if (pluginPrivateTransaction.isEmpty()) { return Bytes.EMPTY; @@ -63,14 +65,15 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { PrivateTransaction.readFrom(pluginPrivateTransaction.get()); final Bytes32 privacyGroupId = privateTransaction.determinePrivacyGroupId(); - final Hash pmtHash = messageFrame.getTransactionHash(); + final Hash pmtHash = messageFrame.getContextVariable(PrivateStateUtils.KEY_TRANSACTION_HASH); LOG.debug( "Processing unrestricted private transaction {} in privacy group {}", pmtHash, privacyGroupId); - final PrivateMetadataUpdater privateMetadataUpdater = messageFrame.getPrivateMetadataUpdater(); + final PrivateMetadataUpdater privateMetadataUpdater = + messageFrame.getContextVariable(PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER); final Hash lastRootHash = privateStateRootResolver.resolveLastStateRoot(privacyGroupId, privateMetadataUpdater); @@ -84,7 +87,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { disposablePrivateState, privateWorldStateUpdater, privacyGroupId, - messageFrame.getBlockHeader().getNumber()); + messageFrame.getBlockValues().getNumber()); final TransactionProcessingResult result = processPrivateTransaction( @@ -101,7 +104,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { return Bytes.EMPTY; } - if (messageFrame.isPersistingPrivateState()) { + if (messageFrame.getContextVariable(PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE, false)) { privateWorldStateUpdater.commit(); disposablePrivateState.persist(null); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java index fc36a6d3f86..52f4688e873 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContract.java @@ -14,21 +14,22 @@ */ package org.hyperledger.besu.ethereum.mainnet.precompiles.privacy; +import static org.hyperledger.besu.datatypes.Hash.fromPlugin; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH; import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH; -import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.EnclaveClientException; +import org.hyperledger.besu.enclave.EnclaveConfigurationException; import org.hyperledger.besu.enclave.EnclaveIOException; import org.hyperledger.besu.enclave.EnclaveServerException; import org.hyperledger.besu.enclave.types.ReceiveResponse; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; @@ -38,10 +39,15 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.BlockValues; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.precompile.AbstractPrecompiledContract; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.plugin.data.Hash; import java.util.Base64; @@ -103,7 +109,8 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { return Bytes.EMPTY; } - final Hash pmtHash = messageFrame.getTransactionHash(); + final org.hyperledger.besu.plugin.data.Hash pmtHash = + messageFrame.getContextVariable(KEY_TRANSACTION_HASH); final String key = input.toBase64String(); final ReceiveResponse receiveResponse; @@ -149,12 +156,13 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { LOG.debug("Processing private transaction {} in privacy group {}", pmtHash, privacyGroupId); - final PrivateMetadataUpdater privateMetadataUpdater = messageFrame.getPrivateMetadataUpdater(); + final PrivateMetadataUpdater privateMetadataUpdater = + messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER); final Hash lastRootHash = privateStateRootResolver.resolveLastStateRoot(privacyGroupId, privateMetadataUpdater); final MutableWorldState disposablePrivateState = - privateWorldStateArchive.getMutable(lastRootHash, null).get(); + privateWorldStateArchive.getMutable(fromPlugin(lastRootHash), null).get(); final WorldUpdater privateWorldStateUpdater = disposablePrivateState.updater(); @@ -163,7 +171,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { disposablePrivateState, privateWorldStateUpdater, privacyGroupId, - messageFrame.getBlockHeader().getNumber()); + messageFrame.getBlockValues().getNumber()); final TransactionProcessingResult result = processPrivateTransaction( @@ -180,8 +188,7 @@ public Bytes compute(final Bytes input, final MessageFrame messageFrame) { return Bytes.EMPTY; } - if (messageFrame.isPersistingPrivateState()) { - + if (messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)) { privateWorldStateUpdater.commit(); disposablePrivateState.persist(null); @@ -205,7 +212,7 @@ protected void maybeApplyGenesisToPrivateWorldState( } void storePrivateMetadata( - final Hash commitmentHash, + final org.hyperledger.besu.plugin.data.Hash commitmentHash, final Bytes32 privacyGroupId, final MutableWorldState disposablePrivateState, final PrivateMetadataUpdater privateMetadataUpdater, @@ -222,7 +229,8 @@ void storePrivateMetadata( privateMetadataUpdater.updatePrivacyGroupHeadBlockMap(privacyGroupId); privateMetadataUpdater.addPrivateTransactionMetadata( privacyGroupId, - new PrivateTransactionMetadata(commitmentHash, disposablePrivateState.rootHash())); + new PrivateTransactionMetadata( + fromPlugin(commitmentHash), disposablePrivateState.rootHash())); } TransactionProcessingResult processPrivateTransaction( @@ -232,11 +240,10 @@ TransactionProcessingResult processPrivateTransaction( final WorldUpdater privateWorldStateUpdater) { return privateTransactionProcessor.processTransaction( - messageFrame.getBlockchain(), - messageFrame.getWorldState(), + messageFrame.getWorldUpdater(), privateWorldStateUpdater, - messageFrame.getBlockHeader(), - messageFrame.getTransactionHash(), + (ProcessableBlockHeader) messageFrame.getBlockValues(), + messageFrame.getContextVariable(KEY_TRANSACTION_HASH), privateTransaction, messageFrame.getMiningBeneficiary(), OperationTracer.NO_TRACING, @@ -266,19 +273,43 @@ boolean isSimulatingPMT(final MessageFrame messageFrame) { // If there's no PrivateMetadataUpdater, the precompile has not been called through the // PrivacyBlockProcessor. This indicates the PMT is being simulated and execution of the // precompile is not required. - return messageFrame.getPrivateMetadataUpdater() == null; + return !messageFrame.hasContextVariable(KEY_PRIVATE_METADATA_UPDATER); } boolean isMining(final MessageFrame messageFrame) { - final ProcessableBlockHeader currentBlockHeader = messageFrame.getBlockHeader(); - if (BlockHeader.class.isAssignableFrom(currentBlockHeader.getClass())) { + boolean isMining = false; + final BlockValues currentBlockHeader = messageFrame.getBlockValues(); + if (!BlockHeader.class.isAssignableFrom(currentBlockHeader.getClass())) { + if (messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)) { + throw new IllegalArgumentException( + "The MessageFrame contains an illegal block header type. Cannot persist private block" + + " metadata without current block hash."); + } else { + isMining = true; + } + } + return isMining; + } + + protected boolean privateFromMatchesSenderKey( + final Bytes transactionPrivateFrom, final String payloadSenderKey) { + if (payloadSenderKey == null) { + LOG.warn( + "Missing sender key from Orion response. Upgrade Orion to 1.6 to enforce privateFrom check."); + throw new EnclaveConfigurationException( + "Incompatible Orion version. Orion version must be 1.6.0 or greater."); + } + + if (transactionPrivateFrom == null || transactionPrivateFrom.isEmpty()) { + LOG.warn("Private transaction is missing privateFrom"); return false; } - if (messageFrame.isPersistingPrivateState()) { - throw new IllegalArgumentException( - "The MessageFrame contains an illegal block header type. Cannot persist private block" - + " metadata without current block hash."); + + if (!payloadSenderKey.equals(transactionPrivateFrom.toBase64String())) { + LOG.warn("Private transaction privateFrom doesn't match payload sender key"); + return false; } + return true; } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProvider.java index d03da52d909..a7e7710e827 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProvider.java @@ -17,9 +17,9 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java index 2e9ce46c4c5..652ab2c59d9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/OnchainPrivacyGroupContract.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.ethereum.privacy; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.CAN_EXECUTE_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.GET_VERSION_METHOD_SIGNATURE; @@ -27,14 +28,15 @@ import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.transaction.CallParameter; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.Restriction; import java.util.ArrayList; @@ -115,11 +117,10 @@ public OnchainPrivacyGroupContract( return Optional.of( privateTransactionProcessor.processTransaction( - messageFrame.getBlockchain(), - messageFrame.getWorldState(), + messageFrame.getWorldUpdater(), updater, currentBlockHeader, - messageFrame.getTransactionHash(), + messageFrame.getContextVariable(PrivateStateUtils.KEY_TRANSACTION_HASH), privateTransaction, messageFrame.getMiningBeneficiary(), OperationTracer.NO_TRACING, @@ -215,7 +216,7 @@ private PrivateTransaction buildTransaction( : 0) .gasPrice(Wei.of(1000)) .gasLimit(3000000) - .to(Address.ONCHAIN_PRIVACY_PROXY) + .to(ONCHAIN_PRIVACY_PROXY) .sender(Address.ZERO) .value(Wei.ZERO) .payload(payload) @@ -225,7 +226,7 @@ private PrivateTransaction buildTransaction( private CallParameter buildCallParams(final Bytes methodCall) { return new CallParameter( - Address.ZERO, Address.ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); + Address.ZERO, ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); } private List decodeList(final Bytes rlpEncodedList) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java index f57f65d0ce0..955461ef41c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateGroupRehydrationBlockProcessor.java @@ -22,12 +22,10 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; @@ -37,8 +35,10 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.List; @@ -139,7 +139,6 @@ public AbstractBlockProcessor.Result processBlock( final TransactionProcessingResult privateResult = privateTransactionProcessor.processTransaction( - blockchain, worldStateUpdater.updater(), privateWorldStateUpdater, blockHeader, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java index 31750fded69..8c3fb01d0d7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocator.java @@ -14,12 +14,15 @@ */ package org.hyperledger.besu.ethereum.privacy; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; + import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.PrivacyGenesis; import org.hyperledger.besu.plugin.services.privacy.PrivacyGroupGenesisProvider; @@ -87,23 +90,20 @@ public void applyGenesisToPrivateWorldState( if (isOnchainPrivacyEnabled) { // inject management final MutableAccount managementContract = - privateWorldStateUpdater - .createAccount(Address.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT) - .getMutable(); + privateWorldStateUpdater.createAccount(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT).getMutable(); // this is the code for the simple management contract managementContract.setCode(OnChainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE); // inject proxy final MutableAccount procyContract = - privateWorldStateUpdater.createAccount(Address.ONCHAIN_PRIVACY_PROXY).getMutable(); + privateWorldStateUpdater.createAccount(ONCHAIN_PRIVACY_PROXY).getMutable(); // this is the code for the proxy contract procyContract.setCode(OnChainGroupManagement.PROXY_RUNTIME_BYTECODE); // manually set the management contract address so the proxy can trust it procyContract.setStorageValue( - UInt256.ZERO, - UInt256.fromBytes(Bytes32.leftPad(Address.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT))); + UInt256.ZERO, UInt256.fromBytes(Bytes32.leftPad(DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT))); } privateWorldStateUpdater.commit(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java index ca395a709e0..14c70cd2696 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionProcessor.java @@ -14,33 +14,34 @@ */ package org.hyperledger.besu.ethereum.privacy; +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.Account; -import org.hyperledger.besu.ethereum.core.AccountState; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.AbstractMessageProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionValidator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; -import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.DefaultMutablePrivateWorldStateUpdater; +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.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.processor.AbstractMessageProcessor; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayDeque; import java.util.Deque; +import java.util.Map; import java.util.Optional; +import java.util.function.Function; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -83,9 +84,7 @@ public PrivateTransactionProcessor( this.privateTransactionValidator = privateTransactionValidator; } - @SuppressWarnings("unused") public TransactionProcessingResult processTransaction( - final Blockchain blockchain, final WorldUpdater publicWorldState, final WorldUpdater privateWorldState, final ProcessableBlockHeader blockHeader, @@ -93,7 +92,7 @@ public TransactionProcessingResult processTransaction( final PrivateTransaction transaction, final Address miningBeneficiary, final OperationTracer operationTracer, - final BlockHashLookup blockHashLookup, + final Function blockHashLookup, final Bytes privacyGroupId) { try { LOG.trace("Starting private execution of {}", transaction); @@ -125,20 +124,19 @@ public TransactionProcessingResult processTransaction( MessageFrame.builder() .messageFrameStack(messageFrameStack) .maxStackSize(maxStackSize) - .blockchain(blockchain) - .worldState(mutablePrivateWorldStateUpdater) + .worldUpdater(mutablePrivateWorldStateUpdater) .initialGas(Gas.MAX_VALUE) .originator(senderAddress) .gasPrice(transaction.getGasPrice()) .sender(senderAddress) .value(transaction.getValue()) .apparentValue(transaction.getValue()) - .blockHeader(blockHeader) + .blockValues(blockHeader) .depth(0) .completer(__ -> {}) .miningBeneficiary(miningBeneficiary) .blockHashLookup(blockHashLookup) - .transactionHash(pmtHash); + .contextVariables(Map.of(KEY_TRANSACTION_HASH, pmtHash)); final MessageFrame initialFrame; if (transaction.isContractCreation()) { @@ -169,7 +167,7 @@ public TransactionProcessingResult processTransaction( .address(to) .contract(to) .inputData(transaction.getPayload()) - .code(new Code(maybeContract.map(AccountState::getCode).orElse(Bytes.EMPTY))) + .code(new Code(maybeContract.map(Account::getCode).orElse(Bytes.EMPTY))) .build(); } @@ -197,8 +195,7 @@ public TransactionProcessingResult processTransaction( LOG.error("Critical Exception Processing Transaction", re); return TransactionProcessingResult.invalid( ValidationResult.invalid( - TransactionInvalidReason.INTERNAL_ERROR, - "Internal Error in Besu - " + re.toString())); + TransactionInvalidReason.INTERNAL_ERROR, "Internal Error in Besu - " + re)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java index bb5ddc99cac..34ae107af92 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionReceipt.java @@ -14,10 +14,10 @@ */ package org.hyperledger.besu.ethereum.privacy; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; +import org.hyperledger.besu.evm.log.Log; import java.util.Collections; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java index 56fee7ee155..d3912572353 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/PrivateTransactionSimulator.java @@ -21,7 +21,6 @@ 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.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; @@ -30,8 +29,9 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.tracing.OperationTracer; import org.hyperledger.besu.plugin.data.Restriction; import java.util.Optional; @@ -132,7 +132,6 @@ private Optional process( final TransactionProcessingResult result = privateTransactionProcessor.processTransaction( - blockchain, publicWorldState.updater(), disposablePrivateState.updater(), header, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java index c87cf7271ac..a93ac6ccb12 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyController.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.privacy; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.ADD_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.GET_PARTICIPANTS_METHOD_SIGNATURE; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.GET_VERSION_METHOD_SIGNATURE; @@ -362,7 +363,7 @@ private List getParticipantsFromParameter(final Bytes input) { private CallParameter buildCallParams(final Bytes methodCall) { return new CallParameter( - Address.ZERO, Address.ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); + Address.ZERO, ONCHAIN_PRIVACY_PROXY, 3000000, Wei.of(1000), Wei.ZERO, methodCall); } private List buildTransactionMetadataList( @@ -430,7 +431,7 @@ private List retrievePrivateTransactions( @Override public boolean isGroupAdditionTransaction(final PrivateTransaction privateTransaction) { return privateTransaction.getTo().isPresent() - && privateTransaction.getTo().get().equals(Address.ONCHAIN_PRIVACY_PROXY) + && privateTransaction.getTo().get().equals(ONCHAIN_PRIVACY_PROXY) && privateTransaction .getPayload() .toHexString() diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateKeyValueStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateKeyValueStorage.java index 5b59c130e99..91475652c57 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateKeyValueStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateKeyValueStorage.java @@ -17,9 +17,9 @@ import static java.nio.charset.StandardCharsets.UTF_8; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.RLP; +import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateStorage.java index 7528592629c..3c807669290 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/LegacyPrivateStateStorage.java @@ -15,7 +15,7 @@ package org.hyperledger.besu.ethereum.privacy.storage; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Log; +import org.hyperledger.besu.evm.log.Log; import java.util.List; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java index ef798b9295e..b7b3fabbc74 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateMigrationBlockProcessor.java @@ -18,12 +18,10 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.AbstractBlockProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MiningBeneficiaryCalculator; @@ -31,6 +29,8 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java index 9053ef416f3..66a7837e39c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/processing/TransactionProcessingResult.java @@ -14,9 +14,9 @@ */ package org.hyperledger.besu.ethereum.processing; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.evm.log.Log; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/GoQuorumKeyValueStoragePrefixedKeyBlockchainStorage.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/GoQuorumKeyValueStoragePrefixedKeyBlockchainStorage.java index dff54890e5f..55254d7ebd3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/GoQuorumKeyValueStoragePrefixedKeyBlockchainStorage.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/storage/keyvalue/GoQuorumKeyValueStoragePrefixedKeyBlockchainStorage.java @@ -17,8 +17,8 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.rlp.RLP; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java index 6cc07c29678..4b0eb62f758 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java @@ -24,23 +24,23 @@ 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.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.GoQuorumMutablePrivateAndPublicWorldStateUpdater; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.math.BigInteger; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/BlockHashLookup.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/BlockHashLookup.java index 98c8c85f2da..0b7fbb7074a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/BlockHashLookup.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/BlockHashLookup.java @@ -14,13 +14,16 @@ */ package org.hyperledger.besu.ethereum.vm; +import static org.hyperledger.besu.datatypes.Hash.ZERO; + import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.vm.operations.BlockHashOperation; +import org.hyperledger.besu.evm.operation.BlockHashOperation; import java.util.HashMap; import java.util.Map; +import java.util.function.Function; /** * Calculates and caches block hashes by number following the chain for a specific branch. This is @@ -30,7 +33,7 @@ *

A new BlockHashCache must be created for each block being processed but should be reused for * all transactions within that block. */ -public class BlockHashLookup { +public class BlockHashLookup implements Function { private ProcessableBlockHeader searchStartHeader; private final Blockchain blockchain; @@ -42,7 +45,8 @@ public BlockHashLookup(final ProcessableBlockHeader currentBlock, final Blockcha hashByNumber.put(currentBlock.getNumber() - 1, currentBlock.getParentHash()); } - public Hash getBlockHash(final long blockNumber) { + @Override + public Hash apply(final Long blockNumber) { final Hash cachedHash = hashByNumber.get(blockNumber); if (cachedHash != null) { return cachedHash; @@ -53,6 +57,6 @@ public Hash getBlockHash(final long blockNumber) { hashByNumber.put(searchStartHeader.getNumber() - 1, searchStartHeader.getParentHash()); } } - return hashByNumber.getOrDefault(blockNumber, Hash.ZERO); + return hashByNumber.getOrDefault(blockNumber, ZERO); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracer.java index b4020a2b5fd..1db3334ae17 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracer.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracer.java @@ -16,12 +16,15 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.ModificationNotAllowedException; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceOptions; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.List; @@ -54,9 +57,9 @@ public void traceExecution(final MessageFrame frame, final ExecuteOperation exec final Gas gasRemaining = frame.getRemainingGas(); final Bytes inputData = frame.getInputData(); final Optional stack = captureStack(frame); - final WorldUpdater worldUpdater = frame.getWorldState(); + final WorldUpdater worldUpdater = frame.getWorldUpdater(); final Optional stackPostExecution; - final OperationResult operationResult = executeOperation.execute(); + final Operation.OperationResult operationResult = executeOperation.execute(); final Bytes outputData = frame.getOutputData(); final Optional memory = captureMemory(frame); stackPostExecution = captureStack(frame); @@ -115,7 +118,7 @@ public void tracePrecompileCall( Optional.empty(), Optional.empty(), Optional.empty(), - frame.getWorldState(), + frame.getWorldUpdater(), Optional.empty(), Optional.ofNullable(frame.getRefunds()), Optional.ofNullable(frame.getCode()), @@ -161,7 +164,7 @@ public void traceAccountCreationResult( Optional.empty(), Optional.empty(), Optional.empty(), - frame.getWorldState(), + frame.getWorldUpdater(), Optional.empty(), Optional.ofNullable(frame.getRefunds()), Optional.ofNullable(frame.getCode()), @@ -183,7 +186,7 @@ private Optional> captureStorage(final MessageFrame frame) final Map storageContents = new TreeMap<>( frame - .getWorldState() + .getWorldUpdater() .getAccount(frame.getRecipientAddress()) .getMutable() .getUpdatedStorage()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java deleted file mode 100644 index e09ba905ece..00000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/StandardJsonTracer.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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.ethereum.vm; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; - -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; -import java.util.Optional; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.tuweni.bytes.Bytes; -import org.apache.tuweni.units.bigints.UInt256; - -public class StandardJsonTracer implements OperationTracer { - - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - - private final PrintStream out; - private final boolean showMemory; - - public StandardJsonTracer(final PrintStream out, final boolean showMemory) { - this.out = out; - this.showMemory = showMemory; - } - - public static String shortNumber(final UInt256 number) { - return number.isZero() ? "0x0" : number.toShortHexString(); - } - - private static String shortBytes(final Bytes bytes) { - return bytes.isZero() ? "0x0" : bytes.toShortHexString(); - } - - public static String summaryTrace( - final Transaction transaction, final long timer, final TransactionProcessingResult result) { - final ObjectNode summaryLine = OBJECT_MAPPER.createObjectNode(); - summaryLine.put("output", result.getOutput().toUnprefixedHexString()); - summaryLine.put( - "gasUsed", - StandardJsonTracer.shortNumber( - UInt256.valueOf(transaction.getGasLimit() - result.getGasRemaining()))); - summaryLine.put("time", timer); - return summaryLine.toString(); - } - - @Override - public void traceExecution( - final MessageFrame messageFrame, final ExecuteOperation executeOperation) { - final ObjectNode traceLine = OBJECT_MAPPER.createObjectNode(); - - final Operation currentOp = messageFrame.getCurrentOperation(); - traceLine.put("pc", messageFrame.getPC()); - traceLine.put("op", Bytes.of(currentOp.getOpcode()).toInt()); - traceLine.put("gas", shortNumber(messageFrame.getRemainingGas().asUInt256())); - traceLine.putNull("gasCost"); - traceLine.putNull("memory"); - traceLine.putNull("memSize"); - final ArrayNode stack = traceLine.putArray("stack"); - for (int i = messageFrame.stackSize() - 1; i >= 0; i--) { - stack.add(shortBytes(messageFrame.getStackItem(i))); - } - Bytes returnData = messageFrame.getReturnData(); - traceLine.put("returnData", returnData.size() > 0 ? returnData.toHexString() : null); - traceLine.put("depth", messageFrame.getMessageStackDepth() + 1); - - final OperationResult executeResult = executeOperation.execute(); - - traceLine.put("refund", messageFrame.getGasRefund().toLong()); - traceLine.put( - "gasCost", executeResult.getGasCost().map(gas -> shortNumber(gas.asUInt256())).orElse("")); - - if (showMemory) { - traceLine.put( - "memory", - messageFrame - .readMemory(UInt256.ZERO, messageFrame.memoryWordSize().multiply(32)) - .toHexString()); - } else { - traceLine.put("memory", "0x"); - } - traceLine.put("memSize", messageFrame.memoryByteSize()); - - final String error = - executeResult - .getHaltReason() - .map(ExceptionalHaltReason::getDescription) - .orElse( - messageFrame - .getRevertReason() - .map(bytes -> new String(bytes.toArrayUnsafe(), StandardCharsets.UTF_8)) - .orElse("")); - traceLine.put("opName", currentOp.getName()); - traceLine.put("error", error); - out.println(traceLine); - } - - @Override - public void tracePrecompileCall( - final MessageFrame frame, final Gas gasRequirement, final Bytes output) {} - - @Override - public void traceAccountCreationResult( - final MessageFrame frame, final Optional haltReason) {} -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java index 5812fafafee..7586f28fece 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutablePrivateWorldStateUpdater.java @@ -16,10 +16,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.core.WrappedEvmAccount; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.evm.worldstate.WrappedEvmAccount; import java.util.Collection; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java index 2830e2765d0..8e305f27c77 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldState.java @@ -17,20 +17,20 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AbstractWorldUpdater; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.AccountState; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.UpdateTrackingAccount; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.StoredMerklePatriciaTrie; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.AccountState; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.worldstate.AbstractWorldUpdater; +import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.plugin.data.BlockHeader; import java.util.ArrayList; import java.util.Collection; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java index e31a95b09cf..5e662299e41 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/DefaultWorldStateArchive.java @@ -17,12 +17,12 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.proof.WorldStateProof; import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.plugin.data.BlockHeader; import java.util.List; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateAndPublicWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateAndPublicWorldStateUpdater.java index 90dd170e328..824c12a06a0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateAndPublicWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateAndPublicWorldStateUpdater.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.worldstate; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; // This class uses a public WorldUpdater and a private WorldUpdater to provide a // MutableWorldStateUpdater that can read and write from BOTH the private world state and the public diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateWorldStateUpdater.java index 830bef88abb..fb1df6894b4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/GoQuorumMutablePrivateWorldStateUpdater.java @@ -15,10 +15,10 @@ package org.hyperledger.besu.ethereum.worldstate; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.UpdateTrackingAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.worldstate.UpdateTrackingAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; // This class uses a public WorldUpdater and a private WorldUpdater to provide a // MutableWorldStateUpdater that can read and write from the private world state and can read from diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java index 06bc04d3ac1..e5132310381 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/worldstate/WorldStateArchive.java @@ -16,11 +16,11 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.proof.WorldStateProof; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.plugin.data.BlockHeader; import java.util.List; import java.util.Optional; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java index 6c2c020944b..dfe747bb9a7 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java @@ -29,6 +29,13 @@ import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.AccessListEntry; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java index 1a9dbe1b118..330e33a4b5a 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockHeaderTestFixture.java @@ -17,6 +17,7 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Optional; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/MessageFrameTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/MessageFrameTestFixture.java index 057adf616e4..4e4a71347d8 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/MessageFrameTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/MessageFrameTestFixture.java @@ -14,14 +14,16 @@ */ package org.hyperledger.besu.ethereum.core; -import static org.hyperledger.besu.ethereum.vm.MessageFrame.DEFAULT_MAX_STACK_SIZE; +import static org.hyperledger.besu.evm.frame.MessageFrame.DEFAULT_MAX_STACK_SIZE; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayDeque; import java.util.ArrayList; @@ -40,7 +42,7 @@ public class MessageFrameTestFixture { private MessageFrame.Type type = MessageFrame.Type.MESSAGE_CALL; private Deque messageFrameStack = new ArrayDeque<>(); private Optional blockchain = Optional.empty(); - private Optional worldState = Optional.empty(); + private Optional worldUpdater = Optional.empty(); private Gas initialGas = Gas.MAX_VALUE; private Address address = DEFAUT_ADDRESS; private Address sender = DEFAUT_ADDRESS; @@ -77,13 +79,13 @@ public MessageFrameTestFixture blockchain(final Blockchain blockchain) { return this; } - public MessageFrameTestFixture worldState(final WorldUpdater worldState) { - this.worldState = Optional.of(worldState); + public MessageFrameTestFixture worldUpdater(final WorldUpdater worldUpdater) { + this.worldUpdater = Optional.of(worldUpdater); return this; } - public MessageFrameTestFixture worldState(final MutableWorldState worldState) { - this.worldState = Optional.of(worldState.updater()); + public MessageFrameTestFixture worldUpdater(final MutableWorldState worldState) { + this.worldUpdater = Optional.of(worldState.updater()); return this; } @@ -160,8 +162,7 @@ public MessageFrame build() { MessageFrame.builder() .type(type) .messageFrameStack(messageFrameStack) - .blockchain(blockchain) - .worldState(worldState.orElseGet(this::createDefaultWorldState)) + .worldUpdater(worldUpdater.orElseGet(this::createDefaultWorldUpdater)) .initialGas(initialGas) .address(address) .originator(originator) @@ -172,7 +173,7 @@ public MessageFrame build() { .apparentValue(value) .contract(contract) .code(code) - .blockHeader(blockHeader) + .blockValues(blockHeader) .depth(depth) .completer(c -> {}) .miningBeneficiary(blockHeader.getCoinbase()) @@ -184,7 +185,7 @@ public MessageFrame build() { return frame; } - private WorldUpdater createDefaultWorldState() { + private WorldUpdater createDefaultWorldUpdater() { return getOrCreateExecutionContextTestFixture().getStateArchive().getMutable().updater(); } diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java index ce306378ca9..9f90b4388c7 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionDataFixture.java @@ -15,6 +15,8 @@ package org.hyperledger.besu.ethereum.core; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import org.hyperledger.besu.crypto.KeyPair; import org.hyperledger.besu.crypto.SignatureAlgorithm; @@ -84,17 +86,16 @@ public class PrivateTransactionDataFixture { Address.fromHexString("0x0bac79b78b9866ef11c989ad21a7fcf15f7a18d7"); public static Transaction privateMarkerTransaction() { - return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, Address.DEFAULT_PRIVACY); + return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, DEFAULT_PRIVACY); } public static Transaction privateMarkerTransactionOnChain() { - return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, Address.ONCHAIN_PRIVACY); + return privateMarkerTransaction(VALID_BASE64_ENCLAVE_KEY, ONCHAIN_PRIVACY); } public static Transaction privateMarkerTransactionOnChainAdd() { return privateMarkerTransaction( - Bytes.concatenate(VALID_BASE64_ENCLAVE_KEY, VALID_BASE64_ENCLAVE_KEY), - Address.ONCHAIN_PRIVACY); + Bytes.concatenate(VALID_BASE64_ENCLAVE_KEY, VALID_BASE64_ENCLAVE_KEY), ONCHAIN_PRIVACY); } private static Transaction privateMarkerTransaction( diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionReceiptTestFixture.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionReceiptTestFixture.java index 47a490a35ff..fc8485201fa 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionReceiptTestFixture.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/PrivateTransactionReceiptTestFixture.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionReceipt; +import org.hyperledger.besu.evm.log.Log; import java.util.Collections; import java.util.List; diff --git a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TestCodeExecutor.java b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TestCodeExecutor.java index 72bda1c739c..29831db27e7 100644 --- a/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TestCodeExecutor.java +++ b/ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TestCodeExecutor.java @@ -17,14 +17,17 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.mainnet.MainnetMessageCallProcessor; -import org.hyperledger.besu.ethereum.mainnet.PrecompileContractRegistry; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; +import org.hyperledger.besu.evm.processor.MessageCallProcessor; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; @@ -47,12 +50,12 @@ public TestCodeExecutor(final ProtocolSchedule protocolSchedule) { public MessageFrame executeCode( final String code, final long gasLimit, final Consumer accountSetup) { final ProtocolSpec protocolSpec = fixture.getProtocolSchedule().getByBlockNumber(0); - final WorldUpdater worldState = + final WorldUpdater worldUpdater = createInitialWorldState(accountSetup, fixture.getStateArchive()); final Deque messageFrameStack = new ArrayDeque<>(); - final MainnetMessageCallProcessor messageCallProcessor = - new MainnetMessageCallProcessor(protocolSpec.getEvm(), new PrecompileContractRegistry()); + final MessageCallProcessor messageCallProcessor = + new MessageCallProcessor(protocolSpec.getEvm(), new PrecompileContractRegistry()); final Transaction transaction = Transaction.builder() @@ -72,7 +75,7 @@ public MessageFrame executeCode( new MessageFrameTestFixture() .messageFrameStack(messageFrameStack) .blockchain(fixture.getBlockchain()) - .worldState(worldState) + .worldUpdater(worldUpdater) .initialGas(Gas.of(gasLimit)) .address(SENDER_ADDRESS) .originator(SENDER_ADDRESS) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java index 0ac390bcbc2..5cb81456140 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/bonsai/LogRollingTests.java @@ -26,12 +26,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.storage.keyvalue.KeyValueSegmentIdentifier; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java index e87b4b0bdce..16347e80bbc 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/chain/GenesisStateTest.java @@ -18,12 +18,12 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; +import org.hyperledger.besu.evm.account.Account; import com.google.common.base.Charsets; import com.google.common.io.Resources; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogTest.java index 60a1a080f0e..854ab2aadd7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogTest.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.ethereum.rlp.RLP; +import org.hyperledger.besu.evm.log.Log; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTest.java index e46ea1b24c9..2d71e277917 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTest.java @@ -17,6 +17,9 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.ArrayList; import java.util.List; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTestCaseSpec.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTestCaseSpec.java index ba41c9c883a..8cbe7bfc3d4 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTestCaseSpec.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/LogsBloomFilterTestCaseSpec.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.ethereum.vm.LogMock; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.List; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java index 7c01cfb3d25..87e6ba758b7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java @@ -19,6 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.AccessListEntry; import org.hyperledger.besu.plugin.data.TransactionType; import java.util.List; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionEIP1559Test.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionEIP1559Test.java index d30ff1366f7..cf087980b6c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionEIP1559Test.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionEIP1559Test.java @@ -21,6 +21,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; +import org.hyperledger.besu.evm.AccessListEntry; import java.math.BigInteger; import java.util.List; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculatorTest.java index 03a6def8f36..e5041ca380c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/feemarket/CoinbaseFeePriceCalculatorTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import java.util.Arrays; import java.util.Collection; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java index d9ec19d7f91..6ec164a1d99 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DifficultyCalculatorTests.java @@ -25,7 +25,7 @@ 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.ethereum.core.LogsBloomFilter; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.io.IOException; import java.nio.charset.StandardCharsets; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java index 4abc86897a7..3b6a9445619 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java @@ -14,10 +14,12 @@ */ package org.hyperledger.besu.ethereum.mainnet; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.RLP; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; import java.util.Arrays; import java.util.Collection; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/KeccakHasherTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/KeccakHasherTest.java index 8af4ae878c8..ab5c3a75c88 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/KeccakHasherTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/KeccakHasherTest.java @@ -19,8 +19,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.SealableBlockHeader; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessorTest.java index f377103e592..08c67c79b90 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessorTest.java @@ -15,17 +15,18 @@ package org.hyperledger.besu.ethereum.mainnet; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.ethereum.vm.MessageFrame.State.COMPLETED_SUCCESS; -import static org.hyperledger.besu.ethereum.vm.MessageFrame.State.EXCEPTIONAL_HALT; +import static org.hyperledger.besu.evm.frame.MessageFrame.State.COMPLETED_SUCCESS; +import static org.hyperledger.besu.evm.frame.MessageFrame.State.EXCEPTIONAL_HALT; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.mainnet.contractvalidation.PrefixCodeRule; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.contractvalidation.PrefixCodeRule; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.processor.ContractCreationProcessor; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Collections; @@ -41,12 +42,12 @@ public class MainnetContractCreationProcessorTest { @Mock GasCalculator gasCalculator; @Mock EVM evm; - private MainnetContractCreationProcessor processor; + private ContractCreationProcessor processor; @Test public void shouldThrowAnExceptionWhenCodeContractFormatInvalid() { processor = - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -66,7 +67,7 @@ public void shouldThrowAnExceptionWhenCodeContractFormatInvalid() { @Test public void shouldNotThrowAnExceptionWhenCodeContractIsValid() { processor = - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, @@ -86,7 +87,7 @@ public void shouldNotThrowAnExceptionWhenCodeContractIsValid() { @Test public void shouldNotThrowAnExceptionWhenPrefixCodeRuleNotAdded() { processor = - new MainnetContractCreationProcessor( + new ContractCreationProcessor( gasCalculator, evm, true, Collections.emptyList(), 1, Collections.emptyList()); final Bytes contractCode = Bytes.fromHexString("0F01010101010101"); MessageFrame messageFrame = new MessageFrameTestFixture().build(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java index a5558b75325..e03a32bb4c8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetPrecompiledContractRegistriesTest.java @@ -16,17 +16,19 @@ package org.hyperledger.besu.ethereum.mainnet; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY; import static org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries.appendPrivacy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.OnChainPrivacyPrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.precompiles.privacy.PrivacyPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; import org.junit.Test; @@ -47,8 +49,8 @@ public void whenOnchainPrivacyGroupsNotEnabled_defaultPrivacyPrecompileIsInRegis verify(privacyParameters).isEnabled(); verify(privacyParameters).isOnchainPrivacyGroupsEnabled(); - assertThat(reg.get(Address.DEFAULT_PRIVACY)).isInstanceOf(PrivacyPrecompiledContract.class); - assertThat(reg.get(Address.ONCHAIN_PRIVACY)).isNull(); + assertThat(reg.get(DEFAULT_PRIVACY)).isInstanceOf(PrivacyPrecompiledContract.class); + assertThat(reg.get(ONCHAIN_PRIVACY)).isNull(); } @Test @@ -60,9 +62,8 @@ public void whenOnchainPrivacyGroupsEnabled_onchainPrivacyPrecompileIsInRegistry verify(privacyParameters).isEnabled(); verify(privacyParameters).isOnchainPrivacyGroupsEnabled(); - assertThat(reg.get(Address.ONCHAIN_PRIVACY)) - .isInstanceOf(OnChainPrivacyPrecompiledContract.class); - assertThat(reg.get(Address.DEFAULT_PRIVACY)).isNull(); + assertThat(reg.get(ONCHAIN_PRIVACY)).isInstanceOf(OnChainPrivacyPrecompiledContract.class); + assertThat(reg.get(DEFAULT_PRIVACY)).isNull(); } @Test @@ -73,7 +74,7 @@ public void whenPrivacyNotEnabled_noPrivacyPrecompileInRegistry() { verify(privacyParameters).isEnabled(); verifyNoMoreInteractions(privacyParameters); - assertThat(reg.get(Address.ONCHAIN_PRIVACY)).isNull(); - assertThat(reg.get(Address.DEFAULT_PRIVACY)).isNull(); + assertThat(reg.get(ONCHAIN_PRIVACY)).isNull(); + assertThat(reg.get(DEFAULT_PRIVACY)).isNull(); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java index 79169c1ff1e..10a466ed456 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessorTest.java @@ -22,12 +22,13 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.processor.AbstractMessageProcessor; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.junit.Before; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java index 03215b0a6c2..f44d8861642 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidatorTest.java @@ -31,14 +31,14 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionFilter; import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java index fe8ca80ba7c..e79deb7ce0c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/PrivacyBlockProcessorTest.java @@ -31,12 +31,9 @@ import org.hyperledger.besu.ethereum.chain.TransactionLocation; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.core.WrappedEvmAccount; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; @@ -46,6 +43,9 @@ import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.evm.worldstate.WrappedEvmAccount; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import java.util.Collections; @@ -204,7 +204,7 @@ private ProtocolSpec mockProtocolSpec() { final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( - any(), any(), any(), any(), any(), any(), any(), any(), any(), any())) + any(), any(), any(), any(), any(), any(), any(), any(), any())) .thenReturn( TransactionProcessingResult.successful( Collections.emptyList(), 0, 0, Bytes.EMPTY, ValidationResult.valid())); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/RefundSstoreGasTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/RefundSstoreGasTest.java index 010f409ef8a..cc73269f0ac 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/RefundSstoreGasTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/RefundSstoreGasTest.java @@ -19,9 +19,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator; import org.apache.tuweni.units.bigints.UInt256; import org.assertj.core.api.Assertions; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractPrecompiledContractTest.java index 8a0d63638ca..eb4cc5cc670 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractPrecompiledContractTest.java @@ -18,10 +18,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.core.PrivacyParameters; -import org.hyperledger.besu.ethereum.mainnet.IstanbulGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.PrecompileContractRegistry; -import org.hyperledger.besu.ethereum.mainnet.PrecompiledContract; import org.hyperledger.besu.ethereum.mainnet.PrecompiledContractConfiguration; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; +import org.hyperledger.besu.evm.precompile.PrecompiledContract; import java.util.function.Function; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java index 32eed996fa4..6c3f655ada1 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/OnChainPrivacyPrecompiledContractTest.java @@ -18,6 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.versionedPrivateTransactionBesu; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; @@ -31,14 +33,10 @@ import org.hyperledger.besu.enclave.EnclaveClientException; import org.hyperledger.besu.enclave.EnclaveConfigurationException; import org.hyperledger.besu.enclave.types.ReceiveResponse; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; @@ -52,9 +50,12 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.List; @@ -74,7 +75,6 @@ public class OnChainPrivacyPrecompiledContractTest { private final Bytes privateTransactionLookupId = Bytes.random(32); private MessageFrame messageFrame; - private Blockchain blockchain; private final String DEFAULT_OUTPUT = "0x01"; final String PAYLOAD_TEST_PRIVACY_GROUP_ID = "8lDVI66RZHIrBsolz6Kn88Rd+WsJ4hUjb4hsh29xW/o="; private final WorldStateArchive worldStateArchive = mock(WorldStateArchive.class); @@ -90,7 +90,6 @@ private PrivateTransactionProcessor mockPrivateTxProcessor( final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( - nullable(Blockchain.class), nullable(WorldUpdater.class), nullable(WorldUpdater.class), nullable(ProcessableBlockHeader.class), @@ -127,20 +126,18 @@ public void setUp() { when(privateStateStorage.updater()).thenReturn(storageUpdater); messageFrame = mock(MessageFrame.class); - blockchain = mock(Blockchain.class); final BlockDataGenerator blockGenerator = new BlockDataGenerator(); final Block genesis = blockGenerator.genesisBlock(); final Block block = blockGenerator.block( new BlockDataGenerator.BlockOptions().setParentHash(genesis.getHeader().getHash())); - when(blockchain.getGenesisBlock()).thenReturn(genesis); - when(blockchain.getBlockByHash(block.getHash())).thenReturn(Optional.of(block)); - when(blockchain.getBlockByHash(genesis.getHash())).thenReturn(Optional.of(genesis)); - when(messageFrame.getBlockchain()).thenReturn(blockchain); - when(messageFrame.getBlockHeader()).thenReturn(block.getHeader()); + when(messageFrame.getBlockValues()).thenReturn(block.getHeader()); final PrivateMetadataUpdater privateMetadataUpdater = mock(PrivateMetadataUpdater.class); final PrivacyGroupHeadBlockMap privacyGroupHeadBlockMap = mock(PrivacyGroupHeadBlockMap.class); - when(messageFrame.getPrivateMetadataUpdater()).thenReturn(privateMetadataUpdater); + when(messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER)) + .thenReturn(privateMetadataUpdater); + when(messageFrame.hasContextVariable(KEY_PRIVATE_METADATA_UPDATER)).thenReturn(true); + when(messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)).thenReturn(false); when(privateMetadataUpdater.getPrivacyGroupHeadBlockMap()).thenReturn(privacyGroupHeadBlockMap); } @@ -167,7 +164,7 @@ public void testPayloadFoundInEnclave() { final OnChainPrivacyPrecompiledContract contractSpy = spy(contract); Mockito.doReturn(true) .when(contractSpy) - .canExecute(any(), any(), any(), any(), any(), any(), any(), any(), any()); + .canExecute(any(), any(), any(), any(), any(), any(), any(), any()); final Bytes actual = contractSpy.compute(privateTransactionLookupId, messageFrame); @@ -308,7 +305,7 @@ public void testInvalidPrivateTransaction() { final OnChainPrivacyPrecompiledContract contractSpy = spy(contract); Mockito.doReturn(true) .when(contractSpy) - .canExecute(any(), any(), any(), any(), any(), any(), any(), any(), any()); + .canExecute(any(), any(), any(), any(), any(), any(), any(), any()); final VersionedPrivateTransaction privateTransaction = versionedPrivateTransactionBesu(); final byte[] payload = convertVersionedPrivateTransactionToBytes(privateTransaction); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContractTest.java index 683d4df846a..ecacb0acd67 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPluginPrecompiledContractTest.java @@ -16,6 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.privateTransactionBesu; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION; import static org.hyperledger.besu.ethereum.privacy.PrivateTransaction.readFrom; import static org.hyperledger.besu.ethereum.privacy.PrivateTransaction.serialize; import static org.mockito.ArgumentMatchers.any; @@ -26,16 +29,12 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.enclave.EnclaveFactory; -import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.InMemoryPrivacyStorageProvider; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; @@ -45,8 +44,11 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.PrivacyGenesis; import org.hyperledger.besu.plugin.services.PrivacyPluginService; import org.hyperledger.besu.plugin.services.privacy.PrivacyGroupAuthProvider; @@ -65,7 +67,6 @@ public class PrivacyPluginPrecompiledContractTest { private final String DEFAULT_OUTPUT = "0x01"; - private final Blockchain blockchain = mock(Blockchain.class); MessageFrame messageFrame; @@ -83,18 +84,21 @@ public void setup() { blockGenerator.block( new BlockDataGenerator.BlockOptions().setParentHash(genesis.getHeader().getHash())); - when(messageFrame.getPrivateMetadataUpdater()).thenReturn(mock(PrivateMetadataUpdater.class)); - when(messageFrame.getBlockHeader()).thenReturn(block.getHeader()); + when(messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)).thenReturn(false); + when(messageFrame.hasContextVariable(KEY_PRIVATE_METADATA_UPDATER)).thenReturn(true); + when(messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER)) + .thenReturn(mock(PrivateMetadataUpdater.class)); + when(messageFrame.getBlockValues()).thenReturn(block.getHeader()); when(privateStateStorage.getPrivacyGroupHeadBlockMap(any())) .thenReturn(Optional.of(PrivacyGroupHeadBlockMap.empty())); final PrivateMetadataUpdater privateMetadataUpdater = mock(PrivateMetadataUpdater.class); - when(messageFrame.getPrivateMetadataUpdater()).thenReturn(privateMetadataUpdater); + when(messageFrame.hasContextVariable(KEY_PRIVATE_METADATA_UPDATER)).thenReturn(true); + when(messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER)) + .thenReturn(privateMetadataUpdater); when(privateMetadataUpdater.getPrivacyGroupHeadBlockMap()) .thenReturn(PrivacyGroupHeadBlockMap.empty()); - when(messageFrame.getBlockchain()).thenReturn(blockchain); - contract = new PrivacyPluginPrecompiledContract( new SpuriousDragonGasCalculator(), @@ -175,7 +179,7 @@ public void testPayloadFoundInPayloadOfMarker() { final Transaction transaction = Transaction.builder().payload(payload).build(); - when(messageFrame.getTransaction()).thenReturn(transaction); + when(messageFrame.getContextVariable(KEY_TRANSACTION)).thenReturn(transaction); final Bytes actual = contract.compute(payload, messageFrame); @@ -194,7 +198,6 @@ private PrivateTransactionProcessor mockPrivateTxProcessor( final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( - nullable(Blockchain.class), nullable(WorldUpdater.class), nullable(WorldUpdater.class), nullable(ProcessableBlockHeader.class), diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java index aaa236d541f..aca981a4183 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/privacy/PrivacyPrecompiledContractTest.java @@ -19,6 +19,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.VALID_BASE64_ENCLAVE_KEY; import static org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.privateTransactionBesu; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_IS_PERSISTING_PRIVATE_STATE; +import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVATE_METADATA_UPDATER; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; @@ -36,11 +38,8 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.PrivateStateGenesisAllocator; import org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver; @@ -54,9 +53,12 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.Arrays; @@ -95,7 +97,6 @@ private PrivateTransactionProcessor mockPrivateTxProcessor( final PrivateTransactionProcessor mockPrivateTransactionProcessor = mock(PrivateTransactionProcessor.class); when(mockPrivateTransactionProcessor.processTransaction( - nullable(Blockchain.class), nullable(WorldUpdater.class), nullable(WorldUpdater.class), nullable(ProcessableBlockHeader.class), @@ -132,10 +133,12 @@ public void setUp() { when(blockchain.getGenesisBlock()).thenReturn(genesis); when(blockchain.getBlockByHash(block.getHash())).thenReturn(Optional.of(block)); when(blockchain.getBlockByHash(genesis.getHash())).thenReturn(Optional.of(genesis)); - when(messageFrame.getBlockchain()).thenReturn(blockchain); - when(messageFrame.getBlockHeader()).thenReturn(block.getHeader()); + when(messageFrame.getBlockValues()).thenReturn(block.getHeader()); final PrivateMetadataUpdater privateMetadataUpdater = mock(PrivateMetadataUpdater.class); - when(messageFrame.getPrivateMetadataUpdater()).thenReturn(privateMetadataUpdater); + when(messageFrame.getContextVariable(KEY_IS_PERSISTING_PRIVATE_STATE, false)).thenReturn(false); + when(messageFrame.hasContextVariable(KEY_PRIVATE_METADATA_UPDATER)).thenReturn(true); + when(messageFrame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER)) + .thenReturn(privateMetadataUpdater); when(privateMetadataUpdater.getPrivacyGroupHeadBlockMap()) .thenReturn(PrivacyGroupHeadBlockMap.empty()); } @@ -319,7 +322,7 @@ public void testSimulatedPublicTransactionIsSkipped() { // A simulated public transaction doesn't contain a PrivateMetadataUpdater final MessageFrame frame = mock(MessageFrame.class); - when(frame.getPrivateMetadataUpdater()).thenReturn(null); + when(frame.getContextVariable(KEY_PRIVATE_METADATA_UPDATER)).thenReturn(null); final Bytes result = emptyContract.compute(null, frame); assertThat(result).isEqualTo(Bytes.EMPTY); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProviderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProviderTest.java index 02c58ac4564..43ce89a0853 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProviderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/ChainHeadPrivateNonceProviderTest.java @@ -23,10 +23,10 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.Optional; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java index 59762b614d3..0f920a37594 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateStateGenesisAllocatorTest.java @@ -16,19 +16,19 @@ package org.hyperledger.besu.ethereum.privacy; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.datatypes.Address.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT; -import static org.hyperledger.besu.datatypes.Address.ONCHAIN_PRIVACY_PROXY; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_ONCHAIN_PRIVACY_MANAGEMENT; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.ONCHAIN_PRIVACY_PROXY; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.DEFAULT_GROUP_MANAGEMENT_RUNTIME_BYTECODE; import static org.hyperledger.besu.ethereum.privacy.group.OnChainGroupManagement.PROXY_RUNTIME_BYTECODE; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.PrivacyGenesis; import org.hyperledger.besu.plugin.data.PrivacyGenesisAccount; import org.hyperledger.besu.plugin.data.Quantity; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateWorldStateReaderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateWorldStateReaderTest.java index bbb180ea529..475ddb33c9c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateWorldStateReaderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/PrivateWorldStateReaderTest.java @@ -23,13 +23,13 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.PrivateTransactionReceiptTestFixture; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.privacy.storage.PrivateBlockMetadata; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.privacy.storage.PrivateTransactionMetadata; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.List; import java.util.Optional; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyControllerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyControllerTest.java index 095350e9114..7198bbe48a6 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyControllerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedDefaultPrivacyControllerTest.java @@ -41,13 +41,13 @@ import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.ReceiveResponse; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.privacy.storage.PrivacyGroupHeadBlockMap; import org.hyperledger.besu.ethereum.privacy.storage.PrivateStateStorage; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.plugin.data.Restriction; import org.hyperledger.enclave.testutil.EnclaveKeyUtils; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerOnchainTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerOnchainTest.java index e189638678e..6ee5a3914a5 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerOnchainTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerOnchainTest.java @@ -23,10 +23,10 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.types.PrivacyGroup; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; +import org.hyperledger.besu.evm.log.Log; import java.math.BigInteger; import java.util.ArrayList; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerTest.java index eb62982f0ce..3cfb1658d0b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/RestrictedMultiTenancyPrivacyControllerTest.java @@ -28,10 +28,10 @@ import org.hyperledger.besu.enclave.Enclave; import org.hyperledger.besu.enclave.types.PrivacyGroup; import org.hyperledger.besu.enclave.types.ReceiveResponse; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.transaction.CallParameter; +import org.hyperledger.besu.evm.log.Log; import java.math.BigInteger; import java.util.ArrayList; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java index 3db12ab63d8..2c6612d1b3e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/storage/migration/PrivateStorageMigrationTest.java @@ -16,6 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.hyperledger.besu.ethereum.core.PrivacyParameters.DEFAULT_PRIVACY; import static org.hyperledger.besu.ethereum.core.PrivateTransactionDataFixture.privateMarkerTransaction; import static org.hyperledger.besu.ethereum.privacy.PrivateStateRootResolver.EMPTY_ROOT_HASH; import static org.hyperledger.besu.ethereum.privacy.storage.PrivateStateKeyValueStorage.SCHEMA_VERSION_1_0_0; @@ -78,7 +79,7 @@ public class PrivateStorageMigrationTest { private static final String PRIVACY_GROUP_ID = "tJw12cPM6EZRF5zfHv2zLePL0cqlaDjLn0x1T/V0yzE="; public static final Bytes32 PRIVACY_GROUP_BYTES = Bytes32.wrap(Bytes.fromBase64String(PRIVACY_GROUP_ID)); - private static final Address PRIVACY_ADDRESS = Address.DEFAULT_PRIVACY; + private static final Address PRIVACY_ADDRESS = DEFAULT_PRIVACY; @Mock private Blockchain blockchain; @Mock private ProtocolSchedule protocolSchedule; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java index 311027bdb37..223b94cbaf4 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java @@ -30,21 +30,21 @@ 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.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.EvmAccount; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.ImmutableTransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult.Status; -import org.hyperledger.besu.ethereum.vm.OperationTracer; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.data.TransactionType; import java.math.BigInteger; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/BlockHashLookupTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/BlockHashLookupTest.java index 1ba90c92349..d8dbc147e64 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/BlockHashLookupTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/BlockHashLookupTest.java @@ -80,7 +80,7 @@ public void shouldGetHashForRecentBlockAfterOlderBlock() { @Test public void shouldReturnEmptyHashWhenRequestedBlockNotOnChain() { - Assertions.assertThat(lookup.getBlockHash(CURRENT_BLOCK_NUMBER + 20)).isEqualTo(Hash.ZERO); + Assertions.assertThat(lookup.apply(CURRENT_BLOCK_NUMBER + 20L)).isEqualTo(Hash.ZERO); } @Test @@ -89,7 +89,7 @@ public void shouldReturnEmptyHashWhenParentBlockNotOnChain() { new BlockHashLookup( new BlockHeaderTestFixture().number(CURRENT_BLOCK_NUMBER + 20).buildHeader(), blockchain); - Assertions.assertThat(lookupWithUnavailableParent.getBlockHash(CURRENT_BLOCK_NUMBER)) + Assertions.assertThat(lookupWithUnavailableParent.apply((long) CURRENT_BLOCK_NUMBER)) .isEqualTo(Hash.ZERO); } @@ -110,7 +110,7 @@ public void shouldCacheBlockHashesWhileIteratingBackToPreviousHeader() { } private void assertHashForBlockNumber(final int blockNumber) { - Assertions.assertThat(lookup.getBlockHash(blockNumber)) + Assertions.assertThat(lookup.apply((long) blockNumber)) .isEqualTo(headers[blockNumber].getHash()); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracerTest.java index cdca11afdba..8cc8ec7ae33 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/DebugOperationTracerTest.java @@ -21,15 +21,20 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.core.WrappedEvmAccount; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.operation.AbstractOperation; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; +import org.hyperledger.besu.evm.worldstate.WrappedEvmAccount; import java.util.Map; import java.util.Optional; @@ -196,7 +201,7 @@ private MessageFrameTestFixture validMessageFrameBuilder() { final ReferenceTestBlockchain blockchain = new ReferenceTestBlockchain(blockHeader.getNumber()); return new MessageFrameTestFixture() .initialGas(INITIAL_GAS) - .worldState(worldUpdater) + .worldUpdater(worldUpdater) .gasPrice(Wei.of(25)) .blockHeader(blockHeader) .blockchain(blockchain) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EVMTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EVMTest.java index 3f7416236be..8d218332572 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EVMTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EVMTest.java @@ -18,8 +18,13 @@ import static org.mockito.ArgumentMatchers.anyByte; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.mainnet.FrontierGasCalculator; -import org.hyperledger.besu.ethereum.vm.operations.StopOperation; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.OperationRegistry; +import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.operation.StopOperation; import org.apache.tuweni.bytes.Bytes; import org.junit.Before; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracerTest.java index ceb731455e9..87ad80e83ec 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracerTest.java @@ -17,11 +17,14 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.vm.OperationTracer.ExecuteOperation; -import org.hyperledger.besu.ethereum.vm.operations.CallCodeOperation; -import org.hyperledger.besu.ethereum.vm.operations.SStoreOperation; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.operation.CallCodeOperation; +import org.hyperledger.besu.evm.operation.SStoreOperation; +import org.hyperledger.besu.evm.tracing.EstimateGasOperationTracer; +import org.hyperledger.besu.evm.tracing.OperationTracer.ExecuteOperation; import org.junit.Before; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java index c26612406fe..0006b539842 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTestTools.java @@ -17,13 +17,9 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult; @@ -33,6 +29,10 @@ import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.testutil.JsonTestParameters; import java.util.Arrays; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/LogMock.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/LogMock.java index 26b543a203f..a097f53ab19 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/LogMock.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/LogMock.java @@ -15,8 +15,8 @@ package org.hyperledger.besu.ethereum.vm; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Arrays; import java.util.stream.Collectors; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/MemoryTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/MemoryTest.java index 1ba0935554b..0d19d5b80a8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/MemoryTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/MemoryTest.java @@ -16,6 +16,8 @@ import static org.assertj.core.api.Assertions.assertThat; +import org.hyperledger.besu.evm.frame.Memory; + import com.google.common.base.Strings; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/OperandStackTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/OperandStackTest.java index 53753f59783..4cc864228af 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/OperandStackTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/OperandStackTest.java @@ -16,8 +16,9 @@ import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.OperandStack; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/VMReferenceTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/VMReferenceTest.java index 4f16b32c6a2..fdfcabb74a3 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/VMReferenceTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/VMReferenceTest.java @@ -18,7 +18,6 @@ import static org.junit.Assume.assumeTrue; import org.hyperledger.besu.ethereum.chain.BadBlockManager; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSpecs; @@ -29,6 +28,9 @@ import org.hyperledger.besu.ethereum.referencetests.ReferenceTestBlockchain; 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.tracing.OperationTracer; import org.hyperledger.besu.testutil.JsonTestParameters; import java.math.BigInteger; @@ -108,8 +110,7 @@ protected void runTest() { MessageFrame.builder() .type(MessageFrame.Type.MESSAGE_CALL) .messageFrameStack(new ArrayDeque<>()) - .blockchain(blockchain) - .worldState(worldState.updater()) + .worldUpdater(worldState.updater()) .initialGas(spec.getExec().getGas()) .contract(execEnv.getAccountAddress()) .address(execEnv.getAccountAddress()) @@ -120,7 +121,7 @@ protected void runTest() { .value(execEnv.getValue()) .apparentValue(execEnv.getValue()) .code(execEnv.getCode()) - .blockHeader(execEnv.getBlockHeader()) + .blockValues(execEnv.getBlockHeader()) .depth(execEnv.getDepth()) .completer(c -> {}) .miningBeneficiary(execEnv.getBlockHeader().getCoinbase()) @@ -140,7 +141,7 @@ protected void runTest() { } else { // This is normally performed when the message processor executing the VM // executes to completion successfully. - frame.getWorldState().commit(); + frame.getWorldUpdater().commit(); assertThat(frame.getState() == MessageFrame.State.EXCEPTIONAL_HALT) .withFailMessage( diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperationTest.java index 2f8b0f3e4e6..387d065ecef 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperationTest.java @@ -21,13 +21,14 @@ import static org.mockito.Mockito.when; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.BerlinGasCalculator; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Operation; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; +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.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.operation.BaseFeeOperation; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; import java.util.Optional; @@ -85,7 +86,7 @@ private MessageFrame createMessageFrame(final Gas initialGas, final Optional {}) .address(Address.fromHexString(sender)) .blockHashLookup(mock(BlockHashLookup.class)) - .blockHeader(mock(ProcessableBlockHeader.class)) - .blockchain(mock(Blockchain.class)) + .blockValues(mock(ProcessableBlockHeader.class)) .gasPrice(Wei.ZERO) .messageFrameStack(new ArrayDeque<>()) .miningBeneficiary(Address.ZERO) .originator(Address.ZERO) .initialGas(Gas.of(100000)) - .worldState(worldUpdater) + .worldUpdater(worldUpdater) .build(); messageFrame.pushStackItem(UInt256.fromHexString(salt)); messageFrame.pushStackItem(memoryLength); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperationTest.java index 97efa5f618f..516fa8db256 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperationTest.java @@ -25,16 +25,17 @@ import org.hyperledger.besu.ethereum.core.AddressHelpers; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.ConstantinopleGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.IstanbulGasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; -import org.hyperledger.besu.ethereum.vm.Words; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +import org.hyperledger.besu.evm.internal.Words; +import org.hyperledger.besu.evm.operation.ExtCodeHashOperation; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; @@ -135,7 +136,7 @@ private MessageFrame createMessageFrame(final UInt256 stackItem) { final BlockHeader blockHeader = new BlockHeaderTestFixture().buildHeader(); final MessageFrame frame = new MessageFrameTestFixture() - .worldState(worldStateUpdater) + .worldUpdater(worldStateUpdater) .blockHeader(blockHeader) .blockchain(blockchain) .build(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperationTest.java index 0c333bbe1fc..ed5c87957f8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperationTest.java @@ -23,17 +23,19 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.IstanbulGasCalculator; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; -import org.hyperledger.besu.ethereum.vm.OperationRegistry; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.OperationRegistry; +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.operation.JumpDestOperation; +import org.hyperledger.besu.evm.operation.JumpOperation; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; @@ -55,7 +57,7 @@ private MessageFrameTestFixture createMessageFrameBuilder(final Gas initialGas) final BlockHeader blockHeader = new BlockHeaderTestFixture().buildHeader(); return new MessageFrameTestFixture() .address(address) - .worldState(worldStateUpdater) + .worldUpdater(worldStateUpdater) .blockHeader(blockHeader) .blockchain(blockchain) .initialGas(initialGas); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/LondonSStoreOperationGasCostTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/LondonSStoreOperationGasCostTest.java index 1632721a7c4..a349ee12208 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/LondonSStoreOperationGasCostTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/LondonSStoreOperationGasCostTest.java @@ -17,12 +17,12 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.config.StubGenesisConfigOptions; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.TestCodeExecutor; import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.MessageFrame.State; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame.State; import org.apache.tuweni.units.bigints.UInt256; import org.junit.Before; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperationTest.java index 80a96c5e06b..6ce9d04ee25 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperationTest.java @@ -18,9 +18,10 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.ConstantinopleGasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.operation.RevertOperation; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperationTest.java index 2ee035be991..41d028eda06 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperationTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryWorldStateArchive; -import static org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason.INSUFFICIENT_GAS; +import static org.hyperledger.besu.evm.frame.ExceptionalHaltReason.INSUFFICIENT_GAS; import static org.mockito.Mockito.mock; import org.hyperledger.besu.datatypes.Address; @@ -24,15 +24,16 @@ import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.MessageFrameTestFixture; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.ConstantinopleGasCalculator; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +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.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; +import org.hyperledger.besu.evm.operation.SStoreOperation; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Arrays; import java.util.Optional; @@ -100,7 +101,7 @@ private MessageFrame createMessageFrame( final MessageFrame frame = new MessageFrameTestFixture() .address(address) - .worldState(worldStateUpdater) + .worldUpdater(worldStateUpdater) .blockHeader(blockHeader) .blockchain(blockchain) .initialGas(initialGas) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SarOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SarOperationTest.java index 08c090295fd..f26c1510a88 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SarOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/SarOperationTest.java @@ -18,10 +18,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.operation.SarOperation; import java.util.Arrays; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperationTest.java index eae5af43b11..ca494676057 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperationTest.java @@ -18,10 +18,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.operation.ShlOperation; import java.util.Arrays; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperationTest.java index 3a0e33d799c..1aa400d68b7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperationTest.java @@ -18,10 +18,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; +import org.hyperledger.besu.evm.operation.ShrOperation; import java.util.Arrays; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java index 11fc714dd9a..5745d24226e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/DefaultMutableWorldStateTest.java @@ -20,15 +20,15 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; -import org.hyperledger.besu.ethereum.core.MutableAccount; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldState.StreamableAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldState.StreamableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java index c7369141405..e3ef5f43efd 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/worldstate/MarkSweepPrunerTest.java @@ -28,12 +28,12 @@ import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.TransactionReceipt; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.trie.MerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.StoredMerklePatriciaTrie; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; diff --git a/ethereum/eth/build.gradle b/ethereum/eth/build.gradle index 17af866f4b3..c2eda037b7a 100644 --- a/ethereum/eth/build.gradle +++ b/ethereum/eth/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation project(':ethereum:permissioning') implementation project(':ethereum:rlp') implementation project(':ethereum:trie') + implementation project(':evm') implementation project(':metrics:core') implementation project(':services:kvstore') implementation project(':services:pipeline') diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index f1eaf5dbdfb..05514038bfc 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -26,7 +26,6 @@ import org.hyperledger.besu.ethereum.chain.BlockAddedEvent; import org.hyperledger.besu.ethereum.chain.BlockAddedObserver; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.eth.EthProtocol; @@ -40,6 +39,7 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.evm.account.Account; import org.hyperledger.besu.metrics.BesuMetricCategory; import org.hyperledger.besu.plugin.data.TransactionType; import org.hyperledger.besu.plugin.services.MetricsSystem; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/RequestIdMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/RequestIdMessageTest.java index ad02eb81feb..65df8714fd1 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/RequestIdMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/RequestIdMessageTest.java @@ -31,12 +31,12 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogTopic; import org.hyperledger.besu.ethereum.core.LogWithMetadata; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.evm.log.LogTopic; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.hyperledger.besu.plugin.data.TransactionType; import java.io.IOException; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java index 59b233db60f..f9671176251 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java @@ -28,15 +28,12 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.AccountStorageEntry; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ProtocolScheduleFixture; -import org.hyperledger.besu.ethereum.core.WorldState; import org.hyperledger.besu.ethereum.eth.manager.DeterministicEthScheduler; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthProtocolManager; @@ -61,6 +58,9 @@ import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage.Updater; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import org.hyperledger.besu.services.tasks.CachingTaskCollection; diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java index 5bece03c6bf..0bc2bca73dc 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolTest.java @@ -42,7 +42,6 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; @@ -68,6 +67,7 @@ import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket; import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason; +import org.hyperledger.besu.evm.account.Account; import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem; import org.hyperledger.besu.plugin.data.TransactionType; import org.hyperledger.besu.plugin.services.MetricsSystem; diff --git a/ethereum/ethstats/build.gradle b/ethereum/ethstats/build.gradle index 69a5158a317..14d5ad6bff3 100644 --- a/ethereum/ethstats/build.gradle +++ b/ethereum/ethstats/build.gradle @@ -45,6 +45,7 @@ dependencies { implementation project(':ethereum:core') implementation project(':ethereum:eth') implementation project(':ethereum:p2p') + implementation project(':evm') implementation project(':plugin-api') annotationProcessor "org.immutables:value" diff --git a/ethereum/evmtool/build.gradle b/ethereum/evmtool/build.gradle index 5e173e6eeeb..a746548f5ff 100644 --- a/ethereum/evmtool/build.gradle +++ b/ethereum/evmtool/build.gradle @@ -42,6 +42,7 @@ dependencies { implementation project(':ethereum:core') implementation project(':ethereum:referencetests') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':metrics:core') implementation project(':plugins:rocksdb') implementation project(':services:kvstore') diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java index 837867cdbf2..a01519e0402 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/BlockchainModule.java @@ -23,13 +23,13 @@ import org.hyperledger.besu.ethereum.chain.GenesisState; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.MutableWorldState; -import org.hyperledger.besu.ethereum.core.MutableWorldView; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; import org.hyperledger.besu.ethereum.worldstate.WorldStatePreimageStorage; import org.hyperledger.besu.ethereum.worldstate.WorldStateStorage; +import org.hyperledger.besu.evm.worldstate.MutableWorldView; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.plugin.services.MetricsSystem; import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java index dbfd66bf609..feab45ad11a 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java @@ -24,19 +24,19 @@ 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.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; -import org.hyperledger.besu.ethereum.mainnet.MainnetMessageCallProcessor; -import org.hyperledger.besu.ethereum.mainnet.PrecompileContractRegistry; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; -import org.hyperledger.besu.ethereum.vm.StandardJsonTracer; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; +import org.hyperledger.besu.evm.processor.MessageCallProcessor; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.tracing.StandardJsonTracer; import java.io.File; import java.io.IOException; @@ -227,8 +227,7 @@ public void run() { MessageFrame.builder() .type(MessageFrame.Type.MESSAGE_CALL) .messageFrameStack(messageFrameStack) - .blockchain(component.getBlockchain()) - .worldState(component.getWorldUpdater()) + .worldUpdater(component.getWorldUpdater()) .initialGas(gas) .contract(Address.ZERO) .address(receiver) @@ -239,15 +238,14 @@ public void run() { .value(ethValue) .apparentValue(ethValue) .code(new Code(codeHexString)) - .blockHeader(blockHeader) + .blockValues(blockHeader) .depth(0) .completer(c -> {}) .miningBeneficiary(blockHeader.getCoinbase()) .blockHashLookup(new BlockHashLookup(blockHeader, component.getBlockchain())) .build()); - final MainnetMessageCallProcessor mcp = - new MainnetMessageCallProcessor(evm, precompileContractRegistry); + final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry); stopwatch.start(); while (!messageFrameStack.isEmpty()) { final MessageFrame messageFrame = messageFrameStack.peek(); diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolComponent.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolComponent.java index a7fa31e3451..22c13f30a1a 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolComponent.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolComponent.java @@ -16,8 +16,8 @@ package org.hyperledger.besu.evmtool; import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.function.Function; import javax.inject.Singleton; diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java index 0462999596d..b67f62049ba 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/StateTestSubCommand.java @@ -20,13 +20,9 @@ import static org.hyperledger.besu.evmtool.StateTestSubCommand.COMMAND_NAME; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Account; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; @@ -37,9 +33,13 @@ import org.hyperledger.besu.ethereum.referencetests.ReferenceTestProtocolSchedules; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.OperationTracer; -import org.hyperledger.besu.ethereum.vm.StandardJsonTracer; import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.tracing.OperationTracer; +import org.hyperledger.besu.evm.tracing.StandardJsonTracer; +import org.hyperledger.besu.evm.worldstate.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.evmtool.exception.UnsupportedForkException; import java.io.BufferedReader; diff --git a/ethereum/permissioning/build.gradle b/ethereum/permissioning/build.gradle index bb0a9e4ba3b..955f554fdf1 100644 --- a/ethereum/permissioning/build.gradle +++ b/ethereum/permissioning/build.gradle @@ -32,6 +32,7 @@ dependencies { implementation project(':datatypes') implementation project(':ethereum:core') implementation project(':ethereum:p2p') + implementation project(':evm') implementation project(':metrics:core') implementation project(':util') diff --git a/ethereum/referencetests/build.gradle b/ethereum/referencetests/build.gradle index ac9f19fec7e..e9f25970499 100644 --- a/ethereum/referencetests/build.gradle +++ b/ethereum/referencetests/build.gradle @@ -30,6 +30,7 @@ dependencies { implementation project(':ethereum:core') implementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':services:kvstore') implementation 'com.fasterxml.jackson.core:jackson-databind' diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java index 79f4b27f178..f3fdf8ce1b2 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java @@ -27,15 +27,15 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.ParsedExtraData; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive; +import org.hyperledger.besu.evm.log.LogsBloomFilter; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.Map; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/EnvironmentInformation.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/EnvironmentInformation.java index 48a8a9d878f..e2425c4514f 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/EnvironmentInformation.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/EnvironmentInformation.java @@ -18,8 +18,8 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.Code; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/GeneralStateTestCaseEipSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/GeneralStateTestCaseEipSpec.java index f22ba21dbcc..5d50328d90e 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/GeneralStateTestCaseEipSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/GeneralStateTestCaseEipSpec.java @@ -18,7 +18,7 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldState; +import org.hyperledger.besu.evm.worldstate.WorldState; import java.util.function.Supplier; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestCode.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestCode.java index 3144b333027..0264cc8abd4 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestCode.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestCode.java @@ -15,7 +15,7 @@ */ package org.hyperledger.besu.ethereum.referencetests; -import org.hyperledger.besu.ethereum.vm.Code; +import org.hyperledger.besu.evm.Code; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java index e8d7553f5c1..cfee38b7887 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestEnv.java @@ -22,8 +22,8 @@ import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.core.LogsBloomFilter; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; +import org.hyperledger.besu.evm.log.LogsBloomFilter; import java.util.Optional; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestWorldState.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestWorldState.java index 6fd1f1ad24f..f576fed5c08 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestWorldState.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/ReferenceTestWorldState.java @@ -17,11 +17,11 @@ import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.core.WorldUpdater; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStateKeyValueStorage; import org.hyperledger.besu.ethereum.storage.keyvalue.WorldStatePreimageKeyValueStorage; import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage; import java.util.HashMap; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestAccessListDeserializer.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestAccessListDeserializer.java index e771f1a4993..be6888f0323 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestAccessListDeserializer.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestAccessListDeserializer.java @@ -15,7 +15,7 @@ */ package org.hyperledger.besu.ethereum.referencetests; -import org.hyperledger.besu.ethereum.core.AccessListEntry; +import org.hyperledger.besu.evm.AccessListEntry; import java.io.IOException; import java.util.ArrayList; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java index dd6735a0de6..76ab30c82b8 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java @@ -20,9 +20,9 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; -import org.hyperledger.besu.ethereum.core.Gas; import org.hyperledger.besu.ethereum.core.Transaction; +import org.hyperledger.besu.evm.AccessListEntry; +import org.hyperledger.besu.evm.Gas; import java.math.BigInteger; import java.util.ArrayList; diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/VMReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/VMReferenceTestCaseSpec.java index 712b44a2e17..e92bfcd3c41 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/VMReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/VMReferenceTestCaseSpec.java @@ -15,8 +15,8 @@ */ package org.hyperledger.besu.ethereum.referencetests; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.WorldState; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.worldstate.WorldState; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/ethereum/retesteth/build.gradle b/ethereum/retesteth/build.gradle index f7a9c85a016..c490b509546 100644 --- a/ethereum/retesteth/build.gradle +++ b/ethereum/retesteth/build.gradle @@ -35,6 +35,7 @@ dependencies { implementation project(':ethereum:eth') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') + implementation project(':evm') implementation project(':metrics:core') implementation project(':nat') implementation project(':services:kvstore') diff --git a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java index 55dc0ddc0b9..637110b74a5 100644 --- a/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java +++ b/ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/methods/TestGetLogHash.java @@ -20,9 +20,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.query.TransactionReceiptWithMetadata; -import org.hyperledger.besu.ethereum.core.Log; import org.hyperledger.besu.ethereum.retesteth.RetestethContext; import org.hyperledger.besu.ethereum.rlp.RLP; +import org.hyperledger.besu.evm.log.Log; import java.util.Optional; @@ -55,6 +55,6 @@ private Hash calculateLogHash( RLP.encode( out -> out.writeList( - transactionReceiptWithMetadata.getReceipt().getLogs(), Log::writeTo))); + transactionReceiptWithMetadata.getReceipt().getLogsList(), Log::writeTo))); } } diff --git a/evm/build.gradle b/evm/build.gradle new file mode 100644 index 00000000000..265a25de5e3 --- /dev/null +++ b/evm/build.gradle @@ -0,0 +1,60 @@ +/* + * 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 + * + */ + +apply plugin: 'java-library' +apply plugin: 'idea' + +jar { + archiveBaseName = 'besu-evm' + manifest { + attributes( + 'Specification-Title': archiveBaseName, + 'Specification-Version': project.version, + 'Implementation-Title': archiveBaseName, + 'Implementation-Version': calculateVersion() + ) + } +} + +dependencies { + implementation project(':crypto') + implementation project(':datatypes') + implementation project(':ethereum:rlp') + + compileOnly 'com.fasterxml.jackson.core:jackson-databind' + + implementation 'org.apache.tuweni:tuweni-bytes' + implementation 'org.apache.logging.log4j:log4j-api' + implementation 'org.hyperledger.besu:bls12-381' + implementation 'net.java.dev.jna:jna' + + testImplementation 'info.picocli:picocli' + testImplementation 'junit:junit' + testImplementation 'org.assertj:assertj-core' + testImplementation 'org.mockito:mockito-core' +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId 'org.hyperledger.besu' + pom { + name = 'Besu EVM' + description = 'EVM Engine component' + } + } + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccessListEntry.java b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntry.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccessListEntry.java rename to evm/src/main/java/org/hyperledger/besu/evm/AccessListEntry.java index 55244cb6e45..d81a933b70c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccessListEntry.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntry.java @@ -12,11 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.json.AccessListEntryDeserializer; -import org.hyperledger.besu.ethereum.core.json.AccessListEntrySerializer; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntryDeserializer.java b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntryDeserializer.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntryDeserializer.java rename to evm/src/main/java/org/hyperledger/besu/evm/AccessListEntryDeserializer.java index 04f37f76adf..f3b3b4f0623 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntryDeserializer.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntryDeserializer.java @@ -13,12 +13,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core.json; +package org.hyperledger.besu.evm; import static com.google.common.base.Preconditions.checkState; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.AccessListEntry; import java.io.IOException; import java.util.ArrayList; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntrySerializer.java b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntrySerializer.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntrySerializer.java rename to evm/src/main/java/org/hyperledger/besu/evm/AccessListEntrySerializer.java index 7106d521a7f..13341d7a65e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/json/AccessListEntrySerializer.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/AccessListEntrySerializer.java @@ -12,9 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core.json; - -import org.hyperledger.besu.ethereum.core.AccessListEntry; +package org.hyperledger.besu.evm; import java.io.IOException; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Code.java b/evm/src/main/java/org/hyperledger/besu/evm/Code.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Code.java rename to evm/src/main/java/org/hyperledger/besu/evm/Code.java index e184cca826c..79f4f92ec5e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Code.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/Code.java @@ -12,9 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm; -import org.hyperledger.besu.ethereum.vm.operations.JumpDestOperation; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.operation.JumpDestOperation; +import org.hyperledger.besu.evm.operation.Operation; import java.util.BitSet; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EVM.java b/evm/src/main/java/org/hyperledger/besu/evm/EVM.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EVM.java rename to evm/src/main/java/org/hyperledger/besu/evm/EVM.java index 4a8e1db195a..dc3ddcfe55d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EVM.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/EVM.java @@ -12,18 +12,22 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm; import static org.apache.logging.log4j.LogManager.getLogger; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.MessageFrame.State; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; -import org.hyperledger.besu.ethereum.vm.operations.InvalidOperation; -import org.hyperledger.besu.ethereum.vm.operations.StopOperation; -import org.hyperledger.besu.ethereum.vm.operations.VirtualOperation; +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.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.operation.InvalidOperation; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.operation.Operation.OperationResult; +import org.hyperledger.besu.evm.operation.StopOperation; +import org.hyperledger.besu.evm.operation.VirtualOperation; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Optional; import java.util.function.BiConsumer; @@ -124,7 +128,7 @@ private static void logState(final MessageFrame frame, final Gas currentGasCost) } @VisibleForTesting - Operation operationAtOffset(final Code code, final int offset) { + public Operation operationAtOffset(final Code code, final int offset) { final Bytes bytecode = code.getBytes(); // If the length of the program code is shorter than the required offset, halt execution. if (offset >= bytecode.size()) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Gas.java b/evm/src/main/java/org/hyperledger/besu/evm/Gas.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Gas.java rename to evm/src/main/java/org/hyperledger/besu/evm/Gas.java index 0c2aad89741..320dbbc11e6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Gas.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/Gas.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm; import org.hyperledger.besu.datatypes.Wei; @@ -66,7 +66,7 @@ public static Gas of(final Bytes32 value) { public static Gas fromHexString(final String str) { try { final long value = Long.decode(str); - return Gas.of(value); + return of(value); } catch (final NumberFormatException e) { return MAX_VALUE; } diff --git a/evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java b/evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java new file mode 100644 index 00000000000..50bf95d4f63 --- /dev/null +++ b/evm/src/main/java/org/hyperledger/besu/evm/MainnetEVMs.java @@ -0,0 +1,359 @@ +/* + * Copyright ConsenSys AG. + * + * 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; + +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ConstantinopleGasCalculator; +import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +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.operation.AddModOperation; +import org.hyperledger.besu.evm.operation.AddOperation; +import org.hyperledger.besu.evm.operation.AddressOperation; +import org.hyperledger.besu.evm.operation.AndOperation; +import org.hyperledger.besu.evm.operation.BalanceOperation; +import org.hyperledger.besu.evm.operation.BaseFeeOperation; +import org.hyperledger.besu.evm.operation.BlockHashOperation; +import org.hyperledger.besu.evm.operation.ByteOperation; +import org.hyperledger.besu.evm.operation.CallCodeOperation; +import org.hyperledger.besu.evm.operation.CallDataCopyOperation; +import org.hyperledger.besu.evm.operation.CallDataLoadOperation; +import org.hyperledger.besu.evm.operation.CallDataSizeOperation; +import org.hyperledger.besu.evm.operation.CallOperation; +import org.hyperledger.besu.evm.operation.CallValueOperation; +import org.hyperledger.besu.evm.operation.CallerOperation; +import org.hyperledger.besu.evm.operation.ChainIdOperation; +import org.hyperledger.besu.evm.operation.CodeCopyOperation; +import org.hyperledger.besu.evm.operation.CodeSizeOperation; +import org.hyperledger.besu.evm.operation.CoinbaseOperation; +import org.hyperledger.besu.evm.operation.Create2Operation; +import org.hyperledger.besu.evm.operation.CreateOperation; +import org.hyperledger.besu.evm.operation.DelegateCallOperation; +import org.hyperledger.besu.evm.operation.DifficultyOperation; +import org.hyperledger.besu.evm.operation.DivOperation; +import org.hyperledger.besu.evm.operation.DupOperation; +import org.hyperledger.besu.evm.operation.EqOperation; +import org.hyperledger.besu.evm.operation.ExpOperation; +import org.hyperledger.besu.evm.operation.ExtCodeCopyOperation; +import org.hyperledger.besu.evm.operation.ExtCodeHashOperation; +import org.hyperledger.besu.evm.operation.ExtCodeSizeOperation; +import org.hyperledger.besu.evm.operation.GasLimitOperation; +import org.hyperledger.besu.evm.operation.GasOperation; +import org.hyperledger.besu.evm.operation.GasPriceOperation; +import org.hyperledger.besu.evm.operation.GtOperation; +import org.hyperledger.besu.evm.operation.InvalidOperation; +import org.hyperledger.besu.evm.operation.IsZeroOperation; +import org.hyperledger.besu.evm.operation.JumpDestOperation; +import org.hyperledger.besu.evm.operation.JumpOperation; +import org.hyperledger.besu.evm.operation.JumpiOperation; +import org.hyperledger.besu.evm.operation.LogOperation; +import org.hyperledger.besu.evm.operation.LtOperation; +import org.hyperledger.besu.evm.operation.MLoadOperation; +import org.hyperledger.besu.evm.operation.MSizeOperation; +import org.hyperledger.besu.evm.operation.MStore8Operation; +import org.hyperledger.besu.evm.operation.MStoreOperation; +import org.hyperledger.besu.evm.operation.ModOperation; +import org.hyperledger.besu.evm.operation.MulModOperation; +import org.hyperledger.besu.evm.operation.MulOperation; +import org.hyperledger.besu.evm.operation.NotOperation; +import org.hyperledger.besu.evm.operation.NumberOperation; +import org.hyperledger.besu.evm.operation.OrOperation; +import org.hyperledger.besu.evm.operation.OriginOperation; +import org.hyperledger.besu.evm.operation.PCOperation; +import org.hyperledger.besu.evm.operation.PopOperation; +import org.hyperledger.besu.evm.operation.PushOperation; +import org.hyperledger.besu.evm.operation.ReturnDataCopyOperation; +import org.hyperledger.besu.evm.operation.ReturnDataSizeOperation; +import org.hyperledger.besu.evm.operation.ReturnOperation; +import org.hyperledger.besu.evm.operation.RevertOperation; +import org.hyperledger.besu.evm.operation.SDivOperation; +import org.hyperledger.besu.evm.operation.SGtOperation; +import org.hyperledger.besu.evm.operation.SLoadOperation; +import org.hyperledger.besu.evm.operation.SLtOperation; +import org.hyperledger.besu.evm.operation.SModOperation; +import org.hyperledger.besu.evm.operation.SStoreOperation; +import org.hyperledger.besu.evm.operation.SarOperation; +import org.hyperledger.besu.evm.operation.SelfBalanceOperation; +import org.hyperledger.besu.evm.operation.SelfDestructOperation; +import org.hyperledger.besu.evm.operation.Sha3Operation; +import org.hyperledger.besu.evm.operation.ShlOperation; +import org.hyperledger.besu.evm.operation.ShrOperation; +import org.hyperledger.besu.evm.operation.SignExtendOperation; +import org.hyperledger.besu.evm.operation.StaticCallOperation; +import org.hyperledger.besu.evm.operation.StopOperation; +import org.hyperledger.besu.evm.operation.SubOperation; +import org.hyperledger.besu.evm.operation.SwapOperation; +import org.hyperledger.besu.evm.operation.TimestampOperation; +import org.hyperledger.besu.evm.operation.XorOperation; + +import java.math.BigInteger; + +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.bytes.Bytes32; + +/** Provides EVMs supporting the appropriate operations for mainnet hard forks. */ +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 GasCalculator gasCalculator) { + + return new EVM(frontierOperations(gasCalculator), gasCalculator); + } + + public static OperationRegistry frontierOperations(final GasCalculator gasCalculator) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerFrontierOperations(operationRegistry, gasCalculator); + return operationRegistry; + } + + public static void registerFrontierOperations( + final OperationRegistry registry, final GasCalculator gasCalculator) { + registry.put(new AddOperation(gasCalculator)); + registry.put(new MulOperation(gasCalculator)); + registry.put(new SubOperation(gasCalculator)); + registry.put(new DivOperation(gasCalculator)); + registry.put(new SDivOperation(gasCalculator)); + registry.put(new ModOperation(gasCalculator)); + registry.put(new SModOperation(gasCalculator)); + registry.put(new ExpOperation(gasCalculator)); + registry.put(new AddModOperation(gasCalculator)); + registry.put(new MulModOperation(gasCalculator)); + registry.put(new SignExtendOperation(gasCalculator)); + registry.put(new LtOperation(gasCalculator)); + registry.put(new GtOperation(gasCalculator)); + registry.put(new SLtOperation(gasCalculator)); + registry.put(new SGtOperation(gasCalculator)); + registry.put(new EqOperation(gasCalculator)); + registry.put(new IsZeroOperation(gasCalculator)); + registry.put(new AndOperation(gasCalculator)); + registry.put(new OrOperation(gasCalculator)); + registry.put(new XorOperation(gasCalculator)); + registry.put(new NotOperation(gasCalculator)); + registry.put(new ByteOperation(gasCalculator)); + registry.put(new Sha3Operation(gasCalculator)); + registry.put(new AddressOperation(gasCalculator)); + registry.put(new BalanceOperation(gasCalculator)); + registry.put(new OriginOperation(gasCalculator)); + registry.put(new CallerOperation(gasCalculator)); + registry.put(new CallValueOperation(gasCalculator)); + registry.put(new CallDataLoadOperation(gasCalculator)); + registry.put(new CallDataSizeOperation(gasCalculator)); + registry.put(new CallDataCopyOperation(gasCalculator)); + registry.put(new CodeSizeOperation(gasCalculator)); + registry.put(new CodeCopyOperation(gasCalculator)); + registry.put(new GasPriceOperation(gasCalculator)); + registry.put(new ExtCodeCopyOperation(gasCalculator)); + registry.put(new ExtCodeSizeOperation(gasCalculator)); + registry.put(new BlockHashOperation(gasCalculator)); + registry.put(new CoinbaseOperation(gasCalculator)); + registry.put(new TimestampOperation(gasCalculator)); + registry.put(new NumberOperation(gasCalculator)); + registry.put(new DifficultyOperation(gasCalculator)); + registry.put(new GasLimitOperation(gasCalculator)); + registry.put(new PopOperation(gasCalculator)); + registry.put(new MLoadOperation(gasCalculator)); + registry.put(new MStoreOperation(gasCalculator)); + registry.put(new MStore8Operation(gasCalculator)); + registry.put(new SLoadOperation(gasCalculator)); + registry.put(new SStoreOperation(gasCalculator, SStoreOperation.FRONTIER_MINIMUM)); + registry.put(new JumpOperation(gasCalculator)); + registry.put(new JumpiOperation(gasCalculator)); + registry.put(new PCOperation(gasCalculator)); + registry.put(new MSizeOperation(gasCalculator)); + registry.put(new GasOperation(gasCalculator)); + registry.put(new JumpDestOperation(gasCalculator)); + registry.put(new ReturnOperation(gasCalculator)); + registry.put(new InvalidOperation(gasCalculator)); + registry.put(new StopOperation(gasCalculator)); + registry.put(new SelfDestructOperation(gasCalculator)); + registry.put(new CreateOperation(gasCalculator)); + registry.put(new CallOperation(gasCalculator)); + registry.put(new CallCodeOperation(gasCalculator)); + + // Register the PUSH1, PUSH2, ..., PUSH32 operations. + for (int i = 1; i <= 32; ++i) { + registry.put(new PushOperation(i, gasCalculator)); + } + + // Register the DUP1, DUP2, ..., DUP16 operations. + for (int i = 1; i <= 16; ++i) { + registry.put(new DupOperation(i, gasCalculator)); + } + + // Register the SWAP1, SWAP2, ..., SWAP16 operations. + for (int i = 1; i <= 16; ++i) { + registry.put(new SwapOperation(i, gasCalculator)); + } + + // Register the LOG0, LOG1, ..., LOG4 operations. + for (int i = 0; i < 5; ++i) { + registry.put(new LogOperation(i, gasCalculator)); + } + } + + public static EVM homestead() { + return homestead(new FrontierGasCalculator()); + } + + public static EVM homestead(final GasCalculator gasCalculator) { + return new EVM(homesteadOperations(gasCalculator), gasCalculator); + } + + public static OperationRegistry homesteadOperations(final GasCalculator gasCalculator) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerHomesteadOperations(operationRegistry, gasCalculator); + return operationRegistry; + } + + public static void registerHomesteadOperations( + final OperationRegistry registry, final GasCalculator gasCalculator) { + registerFrontierOperations(registry, gasCalculator); + registry.put(new DelegateCallOperation(gasCalculator)); + } + + public static EVM spuriousDragon() { + return homestead(new SpuriousDragonGasCalculator()); + } + + public static EVM tangerineWhistle() { + return homestead(new TangerineWhistleGasCalculator()); + } + + public static EVM byzantium() { + return byzantium(new ByzantiumGasCalculator()); + } + + public static EVM byzantium(final GasCalculator gasCalculator) { + return new EVM(byzantiumOperations(gasCalculator), gasCalculator); + } + + public static OperationRegistry byzantiumOperations(final GasCalculator gasCalculator) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerByzantiumOperations(operationRegistry, gasCalculator); + return operationRegistry; + } + + public static void registerByzantiumOperations( + final OperationRegistry registry, final GasCalculator gasCalculator) { + registerHomesteadOperations(registry, gasCalculator); + registry.put(new ReturnDataCopyOperation(gasCalculator)); + registry.put(new ReturnDataSizeOperation(gasCalculator)); + registry.put(new RevertOperation(gasCalculator)); + registry.put(new StaticCallOperation(gasCalculator)); + } + + public static EVM constantinople() { + return constantinople(new ConstantinopleGasCalculator()); + } + + public static EVM constantinople(final GasCalculator gasCalculator) { + return new EVM(constantinopleOperations(gasCalculator), gasCalculator); + } + + public static OperationRegistry constantinopleOperations(final GasCalculator gasCalculator) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerConstantinopleOperations(operationRegistry, gasCalculator); + return operationRegistry; + } + + public static void registerConstantinopleOperations( + final OperationRegistry registry, final GasCalculator gasCalculator) { + registerByzantiumOperations(registry, gasCalculator); + registry.put(new Create2Operation(gasCalculator)); + registry.put(new SarOperation(gasCalculator)); + registry.put(new ShlOperation(gasCalculator)); + registry.put(new ShrOperation(gasCalculator)); + registry.put(new ExtCodeHashOperation(gasCalculator)); + } + + public static EVM petersburg() { + return constantinople(new PetersburgGasCalculator()); + } + + public static EVM istanbul() { + return istanbul(DEV_NET_CHAIN_ID); + } + + public static EVM istanbul(final BigInteger chainId) { + return istanbul(new IstanbulGasCalculator(), chainId); + } + + public static EVM istanbul(final GasCalculator gasCalculator, final BigInteger chainId) { + return new EVM(istanbulOperations(gasCalculator, chainId), gasCalculator); + } + + public static OperationRegistry istanbulOperations( + final GasCalculator gasCalculator, final BigInteger chainId) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerIstanbulOperations(operationRegistry, gasCalculator, chainId); + return operationRegistry; + } + + public static void registerIstanbulOperations( + final OperationRegistry registry, + final GasCalculator gasCalculator, + final BigInteger chainId) { + registerConstantinopleOperations(registry, gasCalculator); + registry.put( + new ChainIdOperation(gasCalculator, Bytes32.leftPad(Bytes.of(chainId.toByteArray())))); + registry.put(new SelfBalanceOperation(gasCalculator)); + registry.put(new SStoreOperation(gasCalculator, SStoreOperation.EIP_1706_MINIMUM)); + } + + public static EVM berlin() { + return berlin(DEV_NET_CHAIN_ID); + } + + public static EVM berlin(final BigInteger chainId) { + return istanbul(new BerlinGasCalculator(), chainId); + } + + public static EVM london() { + return london(DEV_NET_CHAIN_ID); + } + + public static EVM london(final BigInteger chainId) { + return london(new LondonGasCalculator(), chainId); + } + + public static EVM london(final GasCalculator gasCalculator, final BigInteger chainId) { + return new EVM(londonOperations(gasCalculator, chainId), gasCalculator); + } + + public static OperationRegistry londonOperations( + final GasCalculator gasCalculator, final BigInteger chainId) { + OperationRegistry operationRegistry = new OperationRegistry(); + registerLondonOperations(operationRegistry, gasCalculator, chainId); + return operationRegistry; + } + + public static void registerLondonOperations( + final OperationRegistry registry, + final GasCalculator gasCalculator, + final BigInteger chainId) { + registerIstanbulOperations(registry, gasCalculator, chainId); + registry.put(new BaseFeeOperation(gasCalculator)); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ModificationNotAllowedException.java b/evm/src/main/java/org/hyperledger/besu/evm/ModificationNotAllowedException.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ModificationNotAllowedException.java rename to evm/src/main/java/org/hyperledger/besu/evm/ModificationNotAllowedException.java index 6851a443e36..55f788f6334 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/ModificationNotAllowedException.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/ModificationNotAllowedException.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm; public class ModificationNotAllowedException extends RuntimeException { public ModificationNotAllowedException() { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationRegistry.java b/evm/src/main/java/org/hyperledger/besu/evm/OperationRegistry.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationRegistry.java rename to evm/src/main/java/org/hyperledger/besu/evm/OperationRegistry.java index 7d3f81dafc2..064b6eb7641 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationRegistry.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/OperationRegistry.java @@ -12,7 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm; + +import org.hyperledger.besu.evm.operation.Operation; /** Encapsulates a group of {@link Operation}s used together. */ public class OperationRegistry { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Account.java b/evm/src/main/java/org/hyperledger/besu/evm/account/Account.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Account.java rename to evm/src/main/java/org/hyperledger/besu/evm/account/Account.java index 3eda9e6b631..796225afa5f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Account.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/Account.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.account; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountState.java b/evm/src/main/java/org/hyperledger/besu/evm/account/AccountState.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountState.java rename to evm/src/main/java/org/hyperledger/besu/evm/account/AccountState.java index 59fd7cca0cc..a1bd0da1826 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountState.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/AccountState.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.account; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountStorageEntry.java b/evm/src/main/java/org/hyperledger/besu/evm/account/AccountStorageEntry.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountStorageEntry.java rename to evm/src/main/java/org/hyperledger/besu/evm/account/AccountStorageEntry.java index 828c2018b9d..d03611b1665 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AccountStorageEntry.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/AccountStorageEntry.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.account; import org.hyperledger.besu.datatypes.Hash; @@ -93,4 +93,16 @@ public boolean equals(final Object o) { public int hashCode() { return Objects.hash(value, key, keyHash); } + + @Override + public String toString() { + return "AccountStorageEntry{" + + "key=" + + key + + ", keyHash=" + + keyHash + + ", value=" + + value + + '}'; + } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/EvmAccount.java b/evm/src/main/java/org/hyperledger/besu/evm/account/EvmAccount.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/EvmAccount.java rename to evm/src/main/java/org/hyperledger/besu/evm/account/EvmAccount.java index 26621f29887..51840d51d98 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/EvmAccount.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/EvmAccount.java @@ -12,7 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.account; + +import org.hyperledger.besu.evm.ModificationNotAllowedException; public interface EvmAccount extends Account { public MutableAccount getMutable() throws ModificationNotAllowedException; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableAccount.java b/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java similarity index 98% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableAccount.java rename to evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java index 135463fc20c..e1a9f0eb8be 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableAccount.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/account/MutableAccount.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.account; import org.hyperledger.besu.datatypes.Wei; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ContractValidationRule.java b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/ContractValidationRule.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ContractValidationRule.java rename to evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/ContractValidationRule.java index 04a79a52a0b..fecee8684af 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ContractValidationRule.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/ContractValidationRule.java @@ -12,9 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.contractvalidation; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; @FunctionalInterface public interface ContractValidationRule { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/MaxCodeSizeRule.java b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/MaxCodeSizeRule.java rename to evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java index 7d49fbf0a4e..6d2671cba76 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/MaxCodeSizeRule.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/MaxCodeSizeRule.java @@ -12,10 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.contractvalidation; +package org.hyperledger.besu.evm.contractvalidation; -import org.hyperledger.besu.ethereum.mainnet.ContractValidationRule; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,7 +25,7 @@ public class MaxCodeSizeRule implements ContractValidationRule { private final int maxCodeSize; - private MaxCodeSizeRule(final int maxCodeSize) { + MaxCodeSizeRule(final int maxCodeSize) { this.maxCodeSize = maxCodeSize; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/PrefixCodeRule.java b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/PrefixCodeRule.java rename to evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java index b1016695e5e..b31b26989f2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/contractvalidation/PrefixCodeRule.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/contractvalidation/PrefixCodeRule.java @@ -12,10 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.contractvalidation; +package org.hyperledger.besu.evm.contractvalidation; -import org.hyperledger.besu.ethereum.mainnet.ContractValidationRule; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/frame/BlockValues.java b/evm/src/main/java/org/hyperledger/besu/evm/frame/BlockValues.java new file mode 100644 index 00000000000..d41d5fa2c0a --- /dev/null +++ b/evm/src/main/java/org/hyperledger/besu/evm/frame/BlockValues.java @@ -0,0 +1,71 @@ +/* + * 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.frame; + +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; + +/** + * Block Header Values used by various EVM Opcodes. This is not a complete BlocHeader, just the + * values that are returned by various operations. + */ +public interface BlockValues { + + /** + * Returns the block difficulty. + * + * @return the block difficulty + */ + default Bytes getDifficultyBytes() { + return null; + } + + /** + * Returns the basefee of the block. + * + * @return the raw bytes of the extra data field + */ + default Optional getBaseFee() { + return Optional.empty(); + } + + /** + * Returns the block number. + * + * @return the block number + */ + default long getNumber() { + return 0L; + } + + /** + * Return the block timestamp. + * + * @return the block timestamp + */ + default long getTimestamp() { + return 0L; + } + + /** + * Return the block gas limit. + * + * @return the block gas limit + */ + default long getGasLimit() { + return 0L; + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/ExceptionalHaltReason.java b/evm/src/main/java/org/hyperledger/besu/evm/frame/ExceptionalHaltReason.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/ExceptionalHaltReason.java rename to evm/src/main/java/org/hyperledger/besu/evm/frame/ExceptionalHaltReason.java index 48e4e111f71..55d7e951c72 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/ExceptionalHaltReason.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/frame/ExceptionalHaltReason.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.frame; public enum ExceptionalHaltReason { NONE(""), diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Memory.java b/evm/src/main/java/org/hyperledger/besu/evm/frame/Memory.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Memory.java rename to evm/src/main/java/org/hyperledger/besu/evm/frame/Memory.java index ae78ec0efbc..9550a463e3e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Memory.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/frame/Memory.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.frame; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/MessageFrame.java b/evm/src/main/java/org/hyperledger/besu/evm/frame/MessageFrame.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/MessageFrame.java rename to evm/src/main/java/org/hyperledger/besu/evm/frame/MessageFrame.java index 6b05951c3e2..d007ea7b51b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/MessageFrame.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/frame/MessageFrame.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.frame; import static com.google.common.base.Preconditions.checkState; import static java.util.Collections.emptySet; @@ -20,16 +20,14 @@ 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.Gas; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.AbstractMessageProcessor; -import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.internal.MemoryEntry; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.MemoryEntry; +import org.hyperledger.besu.evm.internal.OperandStack; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.operation.Operation; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.util.ArrayList; import java.util.Deque; @@ -40,6 +38,7 @@ import java.util.Optional; import java.util.Set; import java.util.function.Consumer; +import java.util.function.Function; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; @@ -51,13 +50,13 @@ /** * A container object for all of the state associated with a message. * - *

A message corresponds to an interaction between two accounts. A {@link Transaction} spawns at - * least one message when its processed. Messages can also spawn messages depending on the code - * executed within a message. + *

A message corresponds to an interaction between two accounts. A Transaction spawns at least + * one message when its processed. Messages can also spawn messages depending on the code executed + * within a message. * *

Note that there is no specific Message object in the code base. Instead message executions - * correspond to a {@code MessageFrame} and a specific {@link AbstractMessageProcessor}. Currently - * there are two such {@link AbstractMessageProcessor} types: + * correspond to a {@code MessageFrame} and a specific AbstractMessageProcessor. Currently there are + * two such AbstractMessageProcessor types: * *

Message Call ({@code MESSAGE_CALL}) * @@ -111,42 +110,42 @@ public class MessageFrame { * --------------------- --------------------- * * - *

Message Not Started ({@link #NOT_STARTED})

+ * Message Not Started ({@link #NOT_STARTED}) * *

The message has not begun to execute yet. * - *

Code Executing ({@link #CODE_EXECUTING})

+ *

Code Executing ({@link #CODE_EXECUTING}) * *

The message contains code and has begun executing it. The execution will continue until it * is halted due to (1) spawning a child message (2) encountering an exceptional halting condition * (2) completing successfully. * - *

Code Suspended Execution ({@link #CODE_SUSPENDED})

+ *

Code Suspended Execution ({@link #CODE_SUSPENDED}) * *

The message has spawned a child message and has suspended its execution until the child * message has completed and notified its parent message. The message will then continue executing * code ({@link #CODE_EXECUTING}) again. * - *

Code Execution Completed Successfully ({@link #CODE_SUSPENDED})

+ *

Code Execution Completed Successfully ({@link #CODE_SUSPENDED}) * *

The code within the message has executed to completion successfully. * - *

Message Exceptionally Halted ({@link #EXCEPTIONAL_HALT})

+ *

Message Exceptionally Halted ({@link #EXCEPTIONAL_HALT}) * *

The message execution has encountered an exceptional halting condition at some point during * its execution. * - *

Message Reverted ({@link #REVERT})

+ *

Message Reverted ({@link #REVERT}) * *

The message execution has requested to revert state during execution. * - *

Message Execution Failed ({@link #COMPLETED_FAILED})

+ *

Message Execution Failed ({@link #COMPLETED_FAILED}) * *

The message execution failed to execute successfully; most likely due to encountering an * exceptional halting condition. At this point the message frame is finalized and the parent is * notified. * - *

Message Execution Completed Successfully ({@link #COMPLETED_SUCCESS})

+ *

Message Execution Completed Successfully ({@link #COMPLETED_SUCCESS}) * *

The message execution completed successfully and needs to finalized and propagated to the * parent message that spawned it. @@ -191,8 +190,7 @@ public enum Type { public static final int DEFAULT_MAX_STACK_SIZE = 1024; // Global data fields. - private final WorldUpdater worldState; - private final Blockchain blockchain; + private final WorldUpdater worldUpdater; // Metadata fields. private final Type type; @@ -200,7 +198,7 @@ public enum Type { // Machine state fields. private Gas gasRemaining; - private final BlockHashLookup blockHashLookup; + private final Function blockHashLookup; private final int maxStackSize; private int pc; private final Memory memory; @@ -227,17 +225,13 @@ public enum Type { private final Wei value; private final Wei apparentValue; private final Code code; - private final ProcessableBlockHeader blockHeader; + private final BlockValues blockValues; private final int depth; private final Deque messageFrameStack; private final Address miningBeneficiary; - private final Boolean isPersistingPrivateState; - private final PrivateMetadataUpdater privateMetadataUpdater; private Optional revertReason; - // Privacy Execution Environment fields. - private final Hash transactionHash; - private final Transaction transaction; + private final Map contextVariables; // Miscellaneous fields. private Optional exceptionalHaltReason = Optional.empty(); @@ -253,9 +247,8 @@ public static Builder builder() { private MessageFrame( final Type type, - final Blockchain blockchain, final Deque messageFrameStack, - final WorldUpdater worldState, + final WorldUpdater worldUpdater, final Gas initialGas, final Address recipient, final Address originator, @@ -266,24 +259,20 @@ private MessageFrame( final Wei value, final Wei apparentValue, final Code code, - final ProcessableBlockHeader blockHeader, + final BlockValues blockValues, final int depth, final boolean isStatic, final Consumer completer, final Address miningBeneficiary, - final BlockHashLookup blockHashLookup, - final Boolean isPersistingPrivateState, - final PrivateMetadataUpdater privateMetadataUpdater, - final Hash transactionHash, - final Transaction transaction, + final Function blockHashLookup, + final Map contextVariables, final Optional revertReason, final int maxStackSize, final Set

accessListWarmAddresses, final Multimap accessListWarmStorage) { this.type = type; - this.blockchain = blockchain; this.messageFrameStack = messageFrameStack; - this.worldState = worldState; + this.worldUpdater = worldUpdater; this.gasRemaining = initialGas; this.blockHashLookup = blockHashLookup; this.maxStackSize = maxStackSize; @@ -305,16 +294,13 @@ private MessageFrame( this.value = value; this.apparentValue = apparentValue; this.code = code; - this.blockHeader = blockHeader; + this.blockValues = blockValues; this.depth = depth; this.state = State.NOT_STARTED; this.isStatic = isStatic; this.completer = completer; this.miningBeneficiary = miningBeneficiary; - this.isPersistingPrivateState = isPersistingPrivateState; - this.privateMetadataUpdater = privateMetadataUpdater; - this.transactionHash = transactionHash; - this.transaction = transaction; + this.contextVariables = contextVariables; this.revertReason = revertReason; this.warmedUpAddresses = new HashSet<>(accessListWarmAddresses); @@ -327,7 +313,7 @@ private MessageFrame( accessListWarmAddresses.parallelStream() .forEach( address -> - Optional.ofNullable(worldState.get(address)) + Optional.ofNullable(worldUpdater.get(address)) .ifPresent( account -> warmedUpStorage.get(address).parallelStream() @@ -563,7 +549,8 @@ public void setRevertReason(final Bytes revertReason) { } /** - * Read bytes in memory as mutable. + * Read bytes in memory as mutable. Contents should not be considered stable outside the scope of + * the current operation. * * @param offset The offset in memory * @param length The length of the bytes to read @@ -585,7 +572,8 @@ public Bytes readMemory(final UInt256 offset, final UInt256 length) { } /** - * Read bytes in memory. + * Read bytes in memory. Contents should not be considered stable outside the scope of the current + * operation. * * @param offset The offset in memory * @param length The length of the bytes to read @@ -808,7 +796,7 @@ public void addRefund(final Address beneficiary, final Wei amount) { * * @return the refunds map */ - Map getRefunds() { + public Map getRefunds() { return refunds; } @@ -851,22 +839,13 @@ public void mergeWarmedUpFields(final MessageFrame childFrame) { warmedUpStorage = childFrame.warmedUpStorage; } - /** - * Returns the current blockchain. - * - * @return the current blockchain - */ - public Blockchain getBlockchain() { - return blockchain; - } - /** * Return the world state. * * @return the world state */ - public WorldUpdater getWorldState() { - return worldState; + public WorldUpdater getWorldUpdater() { + return worldUpdater; } /** @@ -991,8 +970,8 @@ public Wei getApparentValue() { * * @return the current block header */ - public ProcessableBlockHeader getBlockHeader() { - return blockHeader; + public BlockValues getBlockValues() { + return blockValues; } /** Performs updates based on the message frame's execution. */ @@ -1009,7 +988,8 @@ public Deque getMessageFrameStack() { return messageFrameStack; } - void setExceptionalHaltReason(final Optional exceptionalHaltReason) { + public void setExceptionalHaltReason( + final Optional exceptionalHaltReason) { this.exceptionalHaltReason = exceptionalHaltReason; } @@ -1026,7 +1006,7 @@ public Address getMiningBeneficiary() { return miningBeneficiary; } - public BlockHashLookup getBlockHashLookup() { + public Function getBlockHashLookup() { return blockHashLookup; } @@ -1042,30 +1022,18 @@ public int getMaxStackSize() { return maxStackSize; } - /** - * Returns whether Message calls will be persisted - * - * @return whether Message calls will be persisted - */ - public Boolean isPersistingPrivateState() { - return isPersistingPrivateState; - } - - public PrivateMetadataUpdater getPrivateMetadataUpdater() { - return privateMetadataUpdater; + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) + public T getContextVariable(final String name) { + return (T) contextVariables.get(name); } - /** - * Returns the transaction hash of the transaction being processed - * - * @return the transaction hash of the transaction being processed - */ - public Hash getTransactionHash() { - return transactionHash; + @SuppressWarnings("unchecked") + public T getContextVariable(final String name, final T defaultValue) { + return (T) contextVariables.getOrDefault(name, defaultValue); } - public Transaction getTransaction() { - return transaction; + public boolean hasContextVariable(final String name) { + return contextVariables.containsKey(name); } public void setCurrentOperation(final Operation currentOperation) { @@ -1076,11 +1044,11 @@ public void setGasCost(final Optional gasCost) { this.gasCost = gasCost; } - Optional getMaybeUpdatedMemory() { + public Optional getMaybeUpdatedMemory() { return maybeUpdatedMemory; } - Optional getMaybeUpdatedStorage() { + public Optional getMaybeUpdatedStorage() { return maybeUpdatedStorage; } @@ -1092,9 +1060,8 @@ public void reset() { public static class Builder { private Type type; - private Blockchain blockchain; private Deque messageFrameStack; - private WorldUpdater worldState; + private WorldUpdater worldUpdater; private Gas initialGas; private Address address; private Address originator; @@ -1105,17 +1072,14 @@ public static class Builder { private Wei value; private Wei apparentValue; private Code code; - private ProcessableBlockHeader blockHeader; + private BlockValues blockValues; private int depth = -1; private int maxStackSize = DEFAULT_MAX_STACK_SIZE; private boolean isStatic = false; private Consumer completer; private Address miningBeneficiary; - private BlockHashLookup blockHashLookup; - private Boolean isPersistingPrivateState = false; - private PrivateMetadataUpdater privateMetadataUpdater = null; - private Hash transactionHash; - private Transaction transaction; + private Function blockHashLookup; + private Map contextVariables; private Optional reason = Optional.empty(); private Set
accessListWarmAddresses = emptySet(); private Multimap accessListWarmStorage = HashMultimap.create(); @@ -1130,13 +1094,8 @@ public Builder messageFrameStack(final Deque messageFrameStack) { return this; } - public Builder blockchain(final Blockchain blockchain) { - this.blockchain = blockchain; - return this; - } - - public Builder worldState(final WorldUpdater worldState) { - this.worldState = worldState; + public Builder worldUpdater(final WorldUpdater worldUpdater) { + this.worldUpdater = worldUpdater; return this; } @@ -1190,8 +1149,8 @@ public Builder code(final Code code) { return this; } - public Builder blockHeader(final ProcessableBlockHeader blockHeader) { - this.blockHeader = blockHeader; + public Builder blockValues(final BlockValues blockValues) { + this.blockValues = blockValues; return this; } @@ -1220,28 +1179,13 @@ public Builder miningBeneficiary(final Address miningBeneficiary) { return this; } - public Builder blockHashLookup(final BlockHashLookup blockHashLookup) { + public Builder blockHashLookup(final Function blockHashLookup) { this.blockHashLookup = blockHashLookup; return this; } - public Builder isPersistingPrivateState(final Boolean isPersistingPrivateState) { - this.isPersistingPrivateState = isPersistingPrivateState; - return this; - } - - public Builder privateMetadataUpdater(final PrivateMetadataUpdater privateMetadataUpdater) { - this.privateMetadataUpdater = privateMetadataUpdater; - return this; - } - - public Builder transactionHash(final Hash transactionHash) { - this.transactionHash = transactionHash; - return this; - } - - public Builder transaction(final Transaction transaction) { - this.transaction = transaction; + public Builder contextVariables(final Map contextVariables) { + this.contextVariables = contextVariables; return this; } @@ -1262,9 +1206,8 @@ public Builder accessListWarmStorage(final Multimap accessList private void validate() { checkState(type != null, "Missing message frame type"); - checkState(blockchain != null, "Missing message frame blockchain"); checkState(messageFrameStack != null, "Missing message frame message frame stack"); - checkState(worldState != null, "Missing message frame world state"); + checkState(worldUpdater != null, "Missing message frame world updater"); checkState(initialGas != null, "Missing message frame initial getGasRemaining"); checkState(address != null, "Missing message frame recipient"); checkState(originator != null, "Missing message frame originator"); @@ -1275,12 +1218,11 @@ private void validate() { checkState(value != null, "Missing message frame value"); checkState(apparentValue != null, "Missing message frame apparent value"); checkState(code != null, "Missing message frame code"); - checkState(blockHeader != null, "Missing message frame block header"); + checkState(blockValues != null, "Missing message frame block header"); checkState(depth > -1, "Missing message frame depth"); checkState(completer != null, "Missing message frame completer"); checkState(miningBeneficiary != null, "Missing mining beneficiary"); checkState(blockHashLookup != null, "Missing block hash lookup"); - checkState(isPersistingPrivateState != null, "Missing isPersistingPrivateState"); } public MessageFrame build() { @@ -1288,9 +1230,8 @@ public MessageFrame build() { return new MessageFrame( type, - blockchain, messageFrameStack, - worldState, + worldUpdater, initialGas, address, originator, @@ -1301,16 +1242,13 @@ public MessageFrame build() { value, apparentValue, code, - blockHeader, + blockValues, depth, isStatic, completer, miningBeneficiary, blockHashLookup, - isPersistingPrivateState, - privateMetadataUpdater, - transactionHash, - transaction, + contextVariables == null ? Map.of() : contextVariables, reason, maxStackSize, accessListWarmAddresses, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BerlinGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BerlinGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java index e6d9949ba18..efbc3c0e27d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BerlinGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/BerlinGasCalculator.java @@ -12,16 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; import static org.hyperledger.besu.datatypes.Address.BLAKE2B_F_COMPRESSION; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BigIntegerModularExponentiationPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ByzantiumGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ByzantiumGasCalculator.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ByzantiumGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ByzantiumGasCalculator.java index 334e48a9e3a..378e4362f53 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ByzantiumGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ByzantiumGasCalculator.java @@ -13,10 +13,10 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.precompiles.BigIntegerModularExponentiationPrecompiledContract; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.precompile.BigIntegerModularExponentiationPrecompiledContract; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ConstantinopleGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ConstantinopleGasCalculator.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ConstantinopleGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ConstantinopleGasCalculator.java index 6ce28667e17..09e57a0ba61 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ConstantinopleGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/ConstantinopleGasCalculator.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DieHardGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/DieHardGasCalculator.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DieHardGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/DieHardGasCalculator.java index 76e5a977d5f..f1747899c49 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/DieHardGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/DieHardGasCalculator.java @@ -12,9 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; public class DieHardGasCalculator extends TangerineWhistleGasCalculator { private static final Gas EXP_OPERATION_BYTE_GAS_COST = Gas.of(50L); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java index d199a3a7ec5..a6c3b370b97 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/FrontierGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/FrontierGasCalculator.java @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; -import org.hyperledger.besu.ethereum.vm.operations.ExpOperation; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.internal.Words; +import org.hyperledger.besu.evm.operation.ExpOperation; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/GasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/GasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java index 2959fabbda2..2e31698c01f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/GasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java @@ -12,32 +12,33 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.gascalculator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.AccessListEntry; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractMessageProcessor; -import org.hyperledger.besu.ethereum.mainnet.precompiles.ECRECPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.IDPrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.RIPEMD160PrecompiledContract; -import org.hyperledger.besu.ethereum.mainnet.precompiles.SHA256PrecompiledContract; -import org.hyperledger.besu.ethereum.vm.operations.BalanceOperation; -import org.hyperledger.besu.ethereum.vm.operations.BlockHashOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExpOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeCopyOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeHashOperation; -import org.hyperledger.besu.ethereum.vm.operations.ExtCodeSizeOperation; -import org.hyperledger.besu.ethereum.vm.operations.JumpDestOperation; -import org.hyperledger.besu.ethereum.vm.operations.LogOperation; -import org.hyperledger.besu.ethereum.vm.operations.MLoadOperation; -import org.hyperledger.besu.ethereum.vm.operations.MStore8Operation; -import org.hyperledger.besu.ethereum.vm.operations.MStoreOperation; -import org.hyperledger.besu.ethereum.vm.operations.SLoadOperation; -import org.hyperledger.besu.ethereum.vm.operations.SelfDestructOperation; -import org.hyperledger.besu.ethereum.vm.operations.Sha3Operation; +import org.hyperledger.besu.evm.AccessListEntry; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.operation.BalanceOperation; +import org.hyperledger.besu.evm.operation.BlockHashOperation; +import org.hyperledger.besu.evm.operation.ExpOperation; +import org.hyperledger.besu.evm.operation.ExtCodeCopyOperation; +import org.hyperledger.besu.evm.operation.ExtCodeHashOperation; +import org.hyperledger.besu.evm.operation.ExtCodeSizeOperation; +import org.hyperledger.besu.evm.operation.JumpDestOperation; +import org.hyperledger.besu.evm.operation.LogOperation; +import org.hyperledger.besu.evm.operation.MLoadOperation; +import org.hyperledger.besu.evm.operation.MStore8Operation; +import org.hyperledger.besu.evm.operation.MStoreOperation; +import org.hyperledger.besu.evm.operation.SLoadOperation; +import org.hyperledger.besu.evm.operation.SelfDestructOperation; +import org.hyperledger.besu.evm.operation.Sha3Operation; +import org.hyperledger.besu.evm.precompile.ECRECPrecompiledContract; +import org.hyperledger.besu.evm.precompile.IDPrecompiledContract; +import org.hyperledger.besu.evm.precompile.RIPEMD160PrecompiledContract; +import org.hyperledger.besu.evm.precompile.SHA256PrecompiledContract; +import org.hyperledger.besu.evm.processor.AbstractMessageProcessor; import java.util.List; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/HomesteadGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/HomesteadGasCalculator.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/HomesteadGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/HomesteadGasCalculator.java index ffa3d216e1e..bfd172635a0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/HomesteadGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/HomesteadGasCalculator.java @@ -12,9 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; public class HomesteadGasCalculator extends FrontierGasCalculator { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/IstanbulGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/IstanbulGasCalculator.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/IstanbulGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/IstanbulGasCalculator.java index 21683a3ae65..fda905069af 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/IstanbulGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/IstanbulGasCalculator.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/LondonGasCalculator.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/LondonGasCalculator.java index a4d70c2165c..4350d09728c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/LondonGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/LondonGasCalculator.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PetersburgGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/PetersburgGasCalculator.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PetersburgGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/PetersburgGasCalculator.java index 60d4184afeb..89e428a4547 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PetersburgGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/PetersburgGasCalculator.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SpuriousDragonGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/SpuriousDragonGasCalculator.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SpuriousDragonGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/SpuriousDragonGasCalculator.java index 735dab655ee..f84163d068a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SpuriousDragonGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/SpuriousDragonGasCalculator.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TangerineWhistleGasCalculator.java b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/TangerineWhistleGasCalculator.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TangerineWhistleGasCalculator.java rename to evm/src/main/java/org/hyperledger/besu/evm/gascalculator/TangerineWhistleGasCalculator.java index f090339921d..1d8719ae32e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/TangerineWhistleGasCalculator.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/gascalculator/TangerineWhistleGasCalculator.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.gascalculator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/FixedStack.java b/evm/src/main/java/org/hyperledger/besu/evm/internal/FixedStack.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/FixedStack.java rename to evm/src/main/java/org/hyperledger/besu/evm/internal/FixedStack.java index 45d2d6d7a80..c58cc985551 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/FixedStack.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/internal/FixedStack.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.internal; import static com.google.common.base.Preconditions.checkArgument; @@ -89,7 +89,7 @@ public T pop() { * @throws IllegalArgumentException if the items to pop is negative. * @throws UnderflowException when the items to pop is greater than {@link #size()} */ - void bulkPop(final int items) { + public void bulkPop(final int items) { if (items < 0) { throw new IllegalArgumentException( String.format("requested number of items to bulk pop (%d) is negative", items)); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/internal/MemoryEntry.java b/evm/src/main/java/org/hyperledger/besu/evm/internal/MemoryEntry.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/internal/MemoryEntry.java rename to evm/src/main/java/org/hyperledger/besu/evm/internal/MemoryEntry.java index 60acdcd34fa..4434977f8be 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/internal/MemoryEntry.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/internal/MemoryEntry.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -13,7 +13,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.internal; +package org.hyperledger.besu.evm.internal; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperandStack.java b/evm/src/main/java/org/hyperledger/besu/evm/internal/OperandStack.java similarity index 89% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperandStack.java rename to evm/src/main/java/org/hyperledger/besu/evm/internal/OperandStack.java index 51a74b40b2e..d2828af9983 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperandStack.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/internal/OperandStack.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -14,7 +14,7 @@ * */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.internal; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Words.java b/evm/src/main/java/org/hyperledger/besu/evm/internal/Words.java similarity index 65% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Words.java rename to evm/src/main/java/org/hyperledger/besu/evm/internal/Words.java index 00e91b04502..312537af200 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Words.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/internal/Words.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.internal; import org.hyperledger.besu.datatypes.Address; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.bytes.MutableBytes; import org.apache.tuweni.units.bigints.UInt256; /** Static utility methods to work with VM words (that is, {@link Bytes32} values). */ @@ -36,7 +37,7 @@ public static UInt256 fromAddress(final Address address) { } /** - * Extract an address from the the provided address. + * Extract an address from the provided address. * * @param bytes The word to extract the address from. * @return An address build from the right-most 160-bits of the {@code bytes} (as according to the @@ -46,10 +47,32 @@ public static Address toAddress(final Bytes32 bytes) { return Address.wrap(bytes.slice(bytes.size() - Address.SIZE, Address.SIZE)); } + /** + * Extract an address from the provided address. + * + * @param bytes The word to extract the address from. + * @return An address build from the right-most 160-bits of the {@code bytes} (as according to the + * VM specification (Appendix H. of the Yellow paper)). + */ + public static Address toAddress(final Bytes bytes) { + int size = bytes.size(); + if (size < 20) { + MutableBytes result = MutableBytes.create(20); + bytes.copyTo(result, 20 - size); + // Addresses get hashed alot in calls, and mutable bytes don't cache the `hashCode` + // so always return an immutable copy + return Address.wrap(result.copy()); + } else if (size == 20) { + return Address.wrap(bytes); + } else { + return Address.wrap(bytes.slice(size - Address.SIZE, Address.SIZE)); + } + } + /** * The number of words corresponding to the provided input. * - *

In other words, this compute {@code input.size() / 32} but rounded up. + *

In other words, this computes {@code input.size() / 32} but rounded up. * * @param input the input to check. * @return the number of (32 bytes) words that {@code input} spans. diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Log.java b/evm/src/main/java/org/hyperledger/besu/evm/log/Log.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Log.java rename to evm/src/main/java/org/hyperledger/besu/evm/log/Log.java index f0441690233..2bb47681919 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Log.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/log/Log.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.log; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.rlp.RLPInput; @@ -29,7 +29,7 @@ * A log entry is a tuple of a logger’s address (the address of the contract that added the logs), a * series of 32-bytes log topics, and some number of bytes of data. */ -public class Log implements org.hyperledger.besu.plugin.data.Log { +public class Log { private final Address logger; private final Bytes data; @@ -74,17 +74,14 @@ public static Log readFrom(final RLPInput in) { return new Log(logger, data, topics); } - @Override public Address getLogger() { return logger; } - @Override public Bytes getData() { return data; } - @Override public List getTopics() { return topics; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogTopic.java b/evm/src/main/java/org/hyperledger/besu/evm/log/LogTopic.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogTopic.java rename to evm/src/main/java/org/hyperledger/besu/evm/log/LogTopic.java index 2a6d9b93454..1ff846748ec 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogTopic.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/log/LogTopic.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.log; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogsBloomFilter.java b/evm/src/main/java/org/hyperledger/besu/evm/log/LogsBloomFilter.java similarity index 99% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogsBloomFilter.java rename to evm/src/main/java/org/hyperledger/besu/evm/log/LogsBloomFilter.java index 31d95246cbc..ada4bdf84d7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/LogsBloomFilter.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/log/LogsBloomFilter.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.log; import static com.google.common.base.Preconditions.checkArgument; import static org.hyperledger.besu.crypto.Hash.keccak256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractCallOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCallOperation.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractCallOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCallOperation.java index d4ee32f1702..f9f2d6534c0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractCallOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCallOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; @@ -169,10 +174,12 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { frame.clearReturnData(); final Address to = to(frame); - final Account contract = frame.getWorldState().get(to); + final var contract = frame.getWorldUpdater().get(to); - final Account account = frame.getWorldState().get(frame.getRecipientAddress()); - final Wei balance = account.getBalance(); + final Account account = frame.getWorldUpdater().get(frame.getRecipientAddress()); + final Wei balance = account == null ? Wei.ZERO : account.getBalance(); + // If the call is sending more value than the account has or the message frame is to deep + // return a failed call if (value(frame).compareTo(balance) > 0 || frame.getMessageStackDepth() >= 1024) { frame.expandMemory(inputDataOffset(frame), inputDataLength(frame)); frame.expandMemory(outputDataOffset(frame), outputDataLength(frame)); @@ -189,8 +196,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { MessageFrame.builder() .type(MessageFrame.Type.MESSAGE_CALL) .messageFrameStack(frame.getMessageFrameStack()) - .blockchain(frame.getBlockchain()) - .worldState(frame.getWorldState().updater()) + .worldUpdater(frame.getWorldUpdater().updater()) .initialGas(gasAvailableForChildCall(frame)) .address(address(frame)) .originator(frame.getOriginatorAddress()) @@ -201,7 +207,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { .value(value(frame)) .apparentValue(apparentValue(frame)) .code(new Code(contract != null ? contract.getCode() : Bytes.EMPTY)) - .blockHeader(frame.getBlockHeader()) + .blockValues(frame.getBlockValues()) .depth(frame.getMessageStackDepth() + 1) .isStatic(isStatic(frame)) .completer(child -> complete(frame, child)) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractCreateOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractCreateOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java index b04176fc40e..866e0a66228 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractCreateOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractCreateOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,19 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -75,7 +74,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { final Wei value = Wei.wrap(frame.getStackItem(0)); final Address address = frame.getRecipientAddress(); - final MutableAccount account = frame.getWorldState().getAccount(address).getMutable(); + final MutableAccount account = frame.getWorldUpdater().getAccount(address).getMutable(); frame.clearReturnData(); @@ -107,7 +106,7 @@ private void spawnChildMessage(final MessageFrame frame) { frame.decrementRemainingGas(cost); final Address address = frame.getRecipientAddress(); - final MutableAccount account = frame.getWorldState().getAccount(address).getMutable(); + final MutableAccount account = frame.getWorldUpdater().getAccount(address).getMutable(); account.incrementNonce(); @@ -125,8 +124,7 @@ private void spawnChildMessage(final MessageFrame frame) { MessageFrame.builder() .type(MessageFrame.Type.CONTRACT_CREATION) .messageFrameStack(frame.getMessageFrameStack()) - .blockchain(frame.getBlockchain()) - .worldState(frame.getWorldState().updater()) + .worldUpdater(frame.getWorldUpdater().updater()) .initialGas(childGasStipend) .address(contractAddress) .originator(frame.getOriginatorAddress()) @@ -137,7 +135,7 @@ private void spawnChildMessage(final MessageFrame frame) { .value(value) .apparentValue(value) .code(new Code(inputData)) - .blockHeader(frame.getBlockHeader()) + .blockValues(frame.getBlockValues()) .depth(frame.getMessageStackDepth() + 1) .completer(child -> complete(frame, child)) .miningBeneficiary(frame.getMiningBeneficiary()) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractFixedCostOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractFixedCostOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractFixedCostOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractFixedCostOperation.java index 91052bedcd5..21afcf2e9ca 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AbstractFixedCostOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractFixedCostOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -14,16 +14,15 @@ * */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractOperation.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractOperation.java index 8d5bdf64dd6..7f69514c05a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/AbstractOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AbstractOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,7 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.gascalculator.GasCalculator; /** * All {@link Operation} implementations should inherit from this class to get the setting of some diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddModOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddModOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddModOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AddModOperation.java index fc2d90b7c6f..8e0bc124498 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddModOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddModOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AddOperation.java index f4e4d472301..6ac363c89bc 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddressOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddressOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddressOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AddressOperation.java index cf3d7e897cd..eb17812f8e1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AddressOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AddressOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; public class AddressOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AndOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/AndOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AndOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/AndOperation.java index ca55b7aef54..be1847f6596 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/AndOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/AndOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BalanceOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/BalanceOperation.java similarity index 74% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BalanceOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/BalanceOperation.java index 6a663f349fc..950d442a006 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BalanceOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/BalanceOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,19 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -49,11 +48,11 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { final boolean accountIsWarm = frame.warmUpAddress(address) || gasCalculator().isPrecompile(address); final Optional optionalCost = accountIsWarm ? warmCost : coldCost; - if (frame.getRemainingGas().compareTo(optionalCost.get()) < 0) { + if (frame.getRemainingGas().compareTo(optionalCost.orElse(Gas.ZERO)) < 0) { return new OperationResult( optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS)); } else { - final Account account = frame.getWorldState().get(address); + final Account account = frame.getWorldUpdater().get(address); frame.pushStackItem(account == null ? UInt256.ZERO : account.getBalance().toUInt256()); return new OperationResult(optionalCost, Optional.empty()); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/BaseFeeOperation.java similarity index 76% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/BaseFeeOperation.java index fefe4de4efd..fa722988e1c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BaseFeeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/BaseFeeOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; @@ -33,13 +33,13 @@ public BaseFeeOperation(final GasCalculator gasCalculator) { @Override public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { - if (frame.getBlockHeader().getBaseFee().isEmpty()) { - return new OperationResult( + if (frame.getBlockValues().getBaseFee().isEmpty()) { + return new Operation.OperationResult( Optional.of(gasCost), Optional.of(ExceptionalHaltReason.INVALID_OPERATION)); } frame.pushStackItem( frame - .getBlockHeader() + .getBlockValues() .getBaseFee() .map(Bytes::ofUnsignedLong) .map(Bytes32::leftPad) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java similarity index 73% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java index 6c311243589..bb810ad1bf8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/BlockHashOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/BlockHashOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,15 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.BlockHeader; -import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.BlockValues; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; + +import java.util.function.Function; import org.apache.tuweni.units.bigints.UInt256; @@ -51,19 +51,19 @@ public OperationResult executeFixedCostOperation(final MessageFrame frame, final } final long soughtBlock = blockArg.toLong(); - final ProcessableBlockHeader blockHeader = frame.getBlockHeader(); + final BlockValues blockHeader = frame.getBlockValues(); final long currentBlockNumber = blockHeader.getNumber(); final long mostRecentBlockNumber = currentBlockNumber - 1; // If the current block is the genesis block or the sought block is // not within the last 256 completed blocks, zero is returned. - if (currentBlockNumber == BlockHeader.GENESIS_BLOCK_NUMBER + if (currentBlockNumber == 0 || soughtBlock < (mostRecentBlockNumber - MAX_RELATIVE_BLOCK) || soughtBlock > mostRecentBlockNumber) { frame.pushStackItem(UInt256.ZERO); } else { - final BlockHashLookup blockHashLookup = frame.getBlockHashLookup(); - final Hash blockHash = blockHashLookup.getBlockHash(soughtBlock); + final Function blockHashLookup = frame.getBlockHashLookup(); + final Hash blockHash = blockHashLookup.apply(soughtBlock); frame.pushStackItem(UInt256.fromBytes(blockHash)); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ByteOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ByteOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ByteOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ByteOperation.java index 7cf31705768..87094c4cf92 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ByteOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ByteOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.MutableBytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallCodeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallCodeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java index ab0f151ff6f..e32d941feb3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallCodeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallCodeOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractCallOperation; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import org.apache.tuweni.units.bigints.UInt256; @@ -98,7 +97,7 @@ public Gas cost(final MessageFrame frame) { final UInt256 inputDataLength = inputDataLength(frame); final UInt256 outputDataOffset = outputDataOffset(frame); final UInt256 outputDataLength = outputDataLength(frame); - final Account recipient = frame.getWorldState().get(address(frame)); + final Account recipient = frame.getWorldUpdater().get(address(frame)); return gasCalculator() .callOperationGasCost( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataCopyOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataCopyOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataCopyOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataCopyOperation.java index ab810b3a7f9..d294c0aa244 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataCopyOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataCopyOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataLoadOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataLoadOperation.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataLoadOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataLoadOperation.java index ebb05fbe0e9..77b4a4aa8e4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataLoadOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataLoadOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataSizeOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataSizeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataSizeOperation.java index e24956f3ebc..f1726a93b2e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallDataSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallDataSizeOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallOperation.java index 8ebcbb5d99f..1c42f03f686 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,18 +12,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractCallOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -102,7 +101,7 @@ public Gas cost(final MessageFrame frame) { final UInt256 inputDataLength = inputDataLength(frame); final UInt256 outputDataOffset = outputDataOffset(frame); final UInt256 outputDataLength = outputDataLength(frame); - final Account recipient = frame.getWorldState().get(address(frame)); + final Account recipient = frame.getWorldUpdater().get(address(frame)); return gasCalculator() .callOperationGasCost( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallValueOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallValueOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallValueOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallValueOperation.java index 832f65984e5..ba102c3ae91 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallValueOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallValueOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class CallValueOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallerOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallerOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallerOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CallerOperation.java index 454137dc77a..e18150764e4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CallerOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CallerOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; public class CallerOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ChainIdOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ChainIdOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ChainIdOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ChainIdOperation.java index a74896949d4..01f943fe249 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ChainIdOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ChainIdOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeCopyOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CodeCopyOperation.java similarity index 78% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeCopyOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CodeCopyOperation.java index 6881e696d2c..abe5d9c605d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeCopyOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CodeCopyOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,15 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CodeSizeOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeSizeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CodeSizeOperation.java index 6f0e7d57eb6..14b46e8f335 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CodeSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CodeSizeOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CoinbaseOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CoinbaseOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CoinbaseOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CoinbaseOperation.java index 171c3fc5924..22c96c5e26f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CoinbaseOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CoinbaseOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; public class CoinbaseOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Create2Operation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/Create2Operation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Create2Operation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/Create2Operation.java index 0dfcec3192b..45987ac1d69 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Create2Operation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/Create2Operation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; @@ -33,7 +33,7 @@ public Create2Operation(final GasCalculator gasCalculator) { } @Override - protected Address targetContractAddress(final MessageFrame frame) { + public Address targetContractAddress(final MessageFrame frame) { final Address sender = frame.getRecipientAddress(); final UInt256 offset = frame.getStackItem(1); final UInt256 length = frame.getStackItem(2); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CreateOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/CreateOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CreateOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/CreateOperation.java index 93c66aa92a0..5c235e6f571 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/CreateOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/CreateOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class CreateOperation extends AbstractCreateOperation { @@ -33,7 +33,7 @@ public Gas cost(final MessageFrame frame) { @Override protected Address targetContractAddress(final MessageFrame frame) { - final Account sender = frame.getWorldState().get(frame.getRecipientAddress()); + final Account sender = frame.getWorldUpdater().get(frame.getRecipientAddress()); // Decrement nonce by 1 to normalize the effect of transaction execution final Address address = Address.contractAddress(frame.getRecipientAddress(), sender.getNonce() - 1L); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DelegateCallOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/DelegateCallOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DelegateCallOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/DelegateCallOperation.java index c0b1889df39..0532c522d15 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DelegateCallOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/DelegateCallOperation.java @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractCallOperation; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import org.apache.tuweni.units.bigints.UInt256; @@ -98,7 +97,7 @@ public Gas cost(final MessageFrame frame) { final UInt256 inputDataLength = inputDataLength(frame); final UInt256 outputDataOffset = outputDataOffset(frame); final UInt256 outputDataLength = outputDataLength(frame); - final Account recipient = frame.getWorldState().get(address(frame)); + final Account recipient = frame.getWorldUpdater().get(address(frame)); return gasCalculator() .callOperationGasCost( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DifficultyOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/DifficultyOperation.java similarity index 63% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DifficultyOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/DifficultyOperation.java index 2067a972135..675454264f7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DifficultyOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/DifficultyOperation.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,12 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Difficulty; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; + +import org.apache.tuweni.units.bigints.UInt256; public class DifficultyOperation extends AbstractFixedCostOperation { @@ -26,9 +27,9 @@ public DifficultyOperation(final GasCalculator gasCalculator) { } @Override - public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { - final Difficulty difficulty = frame.getBlockHeader().getDifficulty(); - frame.pushStackItem(difficulty.toUInt256()); + public Operation.OperationResult executeFixedCostOperation( + final MessageFrame frame, final EVM evm) { + frame.pushStackItem(UInt256.fromBytes(frame.getBlockValues().getDifficultyBytes())); return successResponse; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DivOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/DivOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DivOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/DivOperation.java index 182cab89d8d..88e67b7e3a1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DivOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/DivOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DupOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/DupOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DupOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/DupOperation.java index ed143d90a46..459fa7389b4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/DupOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/DupOperation.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/EqOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/EqOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/EqOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/EqOperation.java index 82552d0d759..3754ce2ef45 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/EqOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/EqOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExpOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExpOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExpOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ExpOperation.java index 301a614b59a..da6b3bbad92 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExpOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExpOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeCopyOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeCopyOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeCopyOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeCopyOperation.java index 26ce3091616..ec61c810a3e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeCopyOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeCopyOperation.java @@ -12,17 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -57,7 +56,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { return new OperationResult(optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS)); } - final Account account = frame.getWorldState().get(address); + final Account account = frame.getWorldUpdater().get(address); final Bytes code = account != null ? account.getCode() : Bytes.EMPTY; frame.writeMemory(memOffset, sourceOffset, numBytes, code); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeHashOperation.java similarity index 78% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeHashOperation.java index 27107b1a35e..ca3c831664f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeHashOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeHashOperation.java @@ -12,19 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -53,7 +52,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { return new OperationResult( optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS)); } else { - final Account account = frame.getWorldState().get(address); + final Account account = frame.getWorldUpdater().get(address); if (account == null || account.isEmpty()) { frame.pushStackItem(UInt256.ZERO); } else { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java similarity index 77% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeSizeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java index 3c6401aeefe..6ac9f6de693 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ExtCodeSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ExtCodeSizeOperation.java @@ -12,19 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -53,7 +52,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { return new OperationResult( optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS)); } else { - final Account account = frame.getWorldState().get(address); + final Account account = frame.getWorldUpdater().get(address); frame.pushStackItem( account == null ? UInt256.ZERO : UInt256.valueOf(account.getCode().size())); return new OperationResult(optionalCost, Optional.empty()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasLimitOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasLimitOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasLimitOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/GasLimitOperation.java index 41232fcd329..a2476f74d31 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasLimitOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasLimitOperation.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; @@ -31,7 +31,7 @@ public GasLimitOperation(final GasCalculator gasCalculator) { @Override public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { - final Gas gasLimit = Gas.of(frame.getBlockHeader().getGasLimit()); + final Gas gasLimit = Gas.of(frame.getBlockValues().getGasLimit()); final UInt256 value = UInt256.fromBytes(Bytes32.leftPad(Bytes.of(gasLimit.getBytes()))); frame.pushStackItem(value); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/GasOperation.java index f709de4ea46..9d6cb844467 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasOperation.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasPriceOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasPriceOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasPriceOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/GasPriceOperation.java index 240b6dd783d..5b46e23e870 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GasPriceOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/GasPriceOperation.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class GasPriceOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GtOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/GtOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GtOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/GtOperation.java index 6658d0b062b..9b7986ccb27 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/GtOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/GtOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/InvalidOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/InvalidOperation.java similarity index 77% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/InvalidOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/InvalidOperation.java index 6bc1d927a98..1b793cdd907 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/InvalidOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/InvalidOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/IsZeroOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/IsZeroOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/IsZeroOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/IsZeroOperation.java index 721612deee2..23703f0899b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/IsZeroOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/IsZeroOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpDestOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpDestOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpDestOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/JumpDestOperation.java index a7b16b8a646..9184bc015c1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpDestOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpDestOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class JumpDestOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/JumpOperation.java index 3385836d32f..51ec7b3b9b0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpiOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpiOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpiOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/JumpiOperation.java index 9762684778d..1d34d4f0af6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/JumpiOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/JumpiOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LogOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/LogOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LogOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/LogOperation.java index 84f663aa66f..5a83452760c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LogOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/LogOperation.java @@ -12,17 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.Log; -import org.hyperledger.besu.ethereum.core.LogTopic; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; +import org.hyperledger.besu.evm.log.Log; +import org.hyperledger.besu.evm.log.LogTopic; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LtOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/LtOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LtOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/LtOperation.java index 2f4a6d5ffae..64c2b9f605c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/LtOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/LtOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MLoadOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MLoadOperation.java similarity index 81% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MLoadOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MLoadOperation.java index 97d9e82f167..f2500445cf4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MLoadOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MLoadOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MSizeOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MSizeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MSizeOperation.java index 5f5853bfdf3..be55d3825db 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MSizeOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStore8Operation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MStore8Operation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStore8Operation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MStore8Operation.java index 3471def51ac..220a3103272 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStore8Operation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MStore8Operation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStoreOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MStoreOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStoreOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MStoreOperation.java index 22b2b2ed8a6..86b9a570cc6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MStoreOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MStoreOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ModOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ModOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ModOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ModOperation.java index 152f9580191..2ba379d21c8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ModOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ModOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulModOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MulModOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulModOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MulModOperation.java index 0a088e1354c..b4c0a90176f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulModOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MulModOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/MulOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/MulOperation.java index 7f94548599f..08ef0ddbc12 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/MulOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/MulOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NotOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/NotOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NotOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/NotOperation.java index 04a1ac42bf1..b90e6c5a6d5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NotOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/NotOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NumberOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/NumberOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NumberOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/NumberOperation.java index 39ad73dcd0d..5aad7eb4c80 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/NumberOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/NumberOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; @@ -28,7 +28,7 @@ public NumberOperation(final GasCalculator gasCalculator) { @Override public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { - final long number = frame.getBlockHeader().getNumber(); + final long number = frame.getBlockValues().getNumber(); frame.pushStackItem(UInt256.valueOf(number)); return successResponse; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Operation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/Operation.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Operation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/Operation.java index 392232bd013..fd3ac41b3df 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/Operation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/Operation.java @@ -12,9 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OrOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/OrOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OrOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/OrOperation.java index f9f2d0e9ec6..4ec9ddb965a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OrOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/OrOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OriginOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/OriginOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OriginOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/OriginOperation.java index 51efa1ff742..fe0b65a42e3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/OriginOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/OriginOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; public class OriginOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PCOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/PCOperation.java similarity index 83% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PCOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/PCOperation.java index a022af84288..84255bc9544 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PCOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/PCOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PopOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/PopOperation.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PopOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/PopOperation.java index a2f5a51061d..df659fa7bcb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PopOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/PopOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; public class PopOperation extends AbstractFixedCostOperation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PushOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PushOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java index bfb7906dcd0..6f9b066aabf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/PushOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/PushOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import static java.lang.Math.min; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.MutableBytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataCopyOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataCopyOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataCopyOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataCopyOperation.java index ab4177ed0b9..a4d8cd6e462 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataCopyOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataCopyOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataSizeOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataSizeOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataSizeOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataSizeOperation.java index fce48d3468c..fc1b10016a5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnDataSizeOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnDataSizeOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnOperation.java index b8da981f6cd..97306597249 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ReturnOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ReturnOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/RevertOperation.java similarity index 81% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/RevertOperation.java index 57dab4f0bfc..00d4680896e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/RevertOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/RevertOperation.java @@ -12,14 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; - -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +package org.hyperledger.besu.evm.operation; + +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SDivOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SDivOperation.java similarity index 89% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SDivOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SDivOperation.java index b87b9b13031..c181119e722 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SDivOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SDivOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; import java.util.Arrays; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SGtOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SGtOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SGtOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SGtOperation.java index 70f89cc0b59..89a7fb7176e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SGtOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SGtOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLoadOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLoadOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java index 85386b85759..bd92b7892ee 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLoadOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLoadOperation.java @@ -12,18 +12,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.FixedStack.OverflowException; -import org.hyperledger.besu.ethereum.vm.FixedStack.UnderflowException; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.FixedStack.OverflowException; +import org.hyperledger.besu.evm.internal.FixedStack.UnderflowException; import java.util.Optional; @@ -51,7 +50,7 @@ public SLoadOperation(final GasCalculator gasCalculator) { @Override public OperationResult execute(final MessageFrame frame, final EVM evm) { try { - final Account account = frame.getWorldState().get(frame.getRecipientAddress()); + final Account account = frame.getWorldUpdater().get(frame.getRecipientAddress()); final Address address = account.getAddress(); final Bytes32 key = frame.popStackItem(); final boolean slotIsWarm = frame.warmUpStorage(address, key); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLtOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLtOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLtOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SLtOperation.java index 615a67b9018..8a362a186d6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SLtOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SLtOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SModOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SModOperation.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SModOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SModOperation.java index d92b9bdad33..2e89ebf5ada 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SModOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SModOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; import java.util.Arrays; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SStoreOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SStoreOperation.java index 9d41972a6f2..f6351420dbb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SStoreOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SStoreOperation.java @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; @@ -54,7 +53,7 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { final UInt256 value = frame.popStackItem(); final MutableAccount account = - frame.getWorldState().getAccount(frame.getRecipientAddress()).getMutable(); + frame.getWorldUpdater().getAccount(frame.getRecipientAddress()).getMutable(); if (account == null) { return ILLEGAL_STATE_CHANGE; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SarOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SarOperation.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SarOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SarOperation.java index 367b3fa569b..967c7854518 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SarOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SarOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfBalanceOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SelfBalanceOperation.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfBalanceOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SelfBalanceOperation.java index 7844834df54..0d8bb9c1346 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfBalanceOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SelfBalanceOperation.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; @@ -31,7 +31,7 @@ public SelfBalanceOperation(final GasCalculator gasCalculator) { @Override public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { final Address accountAddress = frame.getRecipientAddress(); - final Account account = frame.getWorldState().get(accountAddress); + final Account account = frame.getWorldUpdater().get(accountAddress); frame.pushStackItem(account == null ? UInt256.ZERO : account.getBalance().toUInt256()); return successResponse; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfDestructOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SelfDestructOperation.java similarity index 73% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfDestructOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SelfDestructOperation.java index 65232ed72eb..0eafaeeba89 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SelfDestructOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SelfDestructOperation.java @@ -12,19 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import java.util.Optional; @@ -39,8 +38,8 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { final Address recipientAddress = Words.toAddress(frame.popStackItem()); // because of weird EIP150/158 reasons we care about a null account so we can't merge this. - final Account recipientNullable = frame.getWorldState().get(recipientAddress); - final Wei inheritance = frame.getWorldState().get(frame.getRecipientAddress()).getBalance(); + final Account recipientNullable = frame.getWorldUpdater().get(recipientAddress); + final Wei inheritance = frame.getWorldUpdater().get(frame.getRecipientAddress()).getBalance(); final boolean accountIsWarm = frame.warmUpAddress(recipientAddress) || gasCalculator().isPrecompile(recipientAddress); @@ -59,12 +58,12 @@ public OperationResult execute(final MessageFrame frame, final EVM evm) { } final Address address = frame.getRecipientAddress(); - final MutableAccount account = frame.getWorldState().getAccount(address).getMutable(); + final MutableAccount account = frame.getWorldUpdater().getAccount(address).getMutable(); frame.addSelfDestruct(address); final MutableAccount recipient = - frame.getWorldState().getOrCreate(recipientAddress).getMutable(); + frame.getWorldUpdater().getOrCreate(recipientAddress).getMutable(); if (!account.getAddress().equals(recipient.getAddress())) { recipient.incrementBalance(account.getBalance()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Sha3Operation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/Sha3Operation.java similarity index 81% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Sha3Operation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/Sha3Operation.java index aaf3390588c..6f147b6c6f4 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/Sha3Operation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/Sha3Operation.java @@ -12,15 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractOperation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +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.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ShlOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ShlOperation.java index 2873103797c..a439bfa55c8 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShlOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ShlOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/ShrOperation.java similarity index 87% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/ShrOperation.java index 710472ab4b7..8a01feb8286 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/ShrOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/ShrOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SignExtendOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SignExtendOperation.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SignExtendOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SignExtendOperation.java index 0357d4f2ffa..2b7c6ebf52d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SignExtendOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SignExtendOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.MutableBytes32; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StaticCallOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/StaticCallOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StaticCallOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/StaticCallOperation.java index d1671f8a32a..71829cd7431 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StaticCallOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/StaticCallOperation.java @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.AbstractCallOperation; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Words; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.internal.Words; import org.apache.tuweni.units.bigints.UInt256; @@ -98,7 +97,7 @@ public Gas cost(final MessageFrame frame) { final UInt256 inputDataLength = inputDataLength(frame); final UInt256 outputDataOffset = outputDataOffset(frame); final UInt256 outputDataLength = outputDataLength(frame); - final Account recipient = frame.getWorldState().get(address(frame)); + final Account recipient = frame.getWorldUpdater().get(address(frame)); return gasCalculator() .callOperationGasCost( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StopOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/StopOperation.java similarity index 84% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StopOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/StopOperation.java index bb93191142f..5e8a5a08972 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/StopOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/StopOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SubOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SubOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SubOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SubOperation.java index 0ebb2c2f11e..2146a4465d6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SubOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SubOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SwapOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/SwapOperation.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SwapOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/SwapOperation.java index 25ea87171f4..8de3b49db86 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/SwapOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/SwapOperation.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/TimestampOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/TimestampOperation.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/TimestampOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/TimestampOperation.java index 3b43a82059d..c234f3068bf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/TimestampOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/TimestampOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; @@ -28,7 +28,7 @@ public TimestampOperation(final GasCalculator gasCalculator) { @Override public OperationResult executeFixedCostOperation(final MessageFrame frame, final EVM evm) { - final long timestamp = frame.getBlockHeader().getTimestamp(); + final long timestamp = frame.getBlockValues().getTimestamp(); frame.pushStackItem(UInt256.valueOf(timestamp)); return successResponse; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/VirtualOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/VirtualOperation.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/VirtualOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/VirtualOperation.java index bb03434bb4a..70529fa8156 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/VirtualOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/VirtualOperation.java @@ -13,11 +13,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.Operation; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; public class VirtualOperation implements Operation { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/XorOperation.java b/evm/src/main/java/org/hyperledger/besu/evm/operation/XorOperation.java similarity index 85% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/XorOperation.java rename to evm/src/main/java/org/hyperledger/besu/evm/operation/XorOperation.java index 5389d84e339..bbd79fff540 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/operations/XorOperation.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/operation/XorOperation.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm.operations; +package org.hyperledger.besu.evm.operation; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.units.bigints.UInt256; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractAltBnPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractAltBnPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java index 7dc755c3b32..ded1e740bb3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractAltBnPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractAltBnPrecompiledContract.java @@ -13,13 +13,12 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import com.sun.jna.ptr.IntByReference; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractBLS12PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractBLS12PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java index 64360071638..4938859abef 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AbstractBLS12PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractBLS12PrecompiledContract.java @@ -13,12 +13,11 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; -import org.hyperledger.besu.ethereum.mainnet.PrecompiledContract; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import javax.annotation.Nonnull; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java similarity index 57% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java index 6913fc41fc9..75b2ba85ff7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AbstractPrecompiledContract.java @@ -1,5 +1,5 @@ /* - * Copyright ConsenSys AG. + * 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 @@ -12,18 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.enclave.EnclaveConfigurationException; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; /** Skeleton class for @{link PrecompileContract} implementations. */ +@SuppressWarnings("unused") public abstract class AbstractPrecompiledContract implements PrecompiledContract { private static final Logger LOG = LogManager.getLogger(); @@ -51,26 +51,4 @@ public String getName() { @Override public abstract Bytes compute(Bytes input, MessageFrame messageFrame); - - protected boolean privateFromMatchesSenderKey( - final Bytes transactionPrivateFrom, final String payloadSenderKey) { - if (payloadSenderKey == null) { - LOG.warn( - "Missing sender key from Orion response. Upgrade Orion to 1.6 to enforce privateFrom check."); - throw new EnclaveConfigurationException( - "Incompatible Orion version. Orion version must be 1.6.0 or greater."); - } - - if (transactionPrivateFrom == null || transactionPrivateFrom.isEmpty()) { - LOG.warn("Private transaction is missing privateFrom"); - return false; - } - - if (!payloadSenderKey.equals(transactionPrivateFrom.toBase64String())) { - LOG.warn("Private transaction privateFrom doesn't match payload sender key"); - return false; - } - - return true; - } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128AddPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128AddPrecompiledContract.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128AddPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128AddPrecompiledContract.java index 846ad9bf10c..e739dc418e0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128AddPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128AddPrecompiledContract.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.altbn128.AltBn128Point; import org.hyperledger.besu.crypto.altbn128.Fq; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128MulPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128MulPrecompiledContract.java similarity index 93% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128MulPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128MulPrecompiledContract.java index 7ca6e2c2127..2fd64654176 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128MulPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128MulPrecompiledContract.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.altbn128.AltBn128Point; import org.hyperledger.besu.crypto.altbn128.Fq; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContract.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContract.java index 87e9d00d8ce..4083da84b36 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContract.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.altbn128.AltBn128Fq12Pairer; import org.hyperledger.besu.crypto.altbn128.AltBn128Fq2Point; @@ -20,9 +20,9 @@ import org.hyperledger.besu.crypto.altbn128.Fq; import org.hyperledger.besu.crypto.altbn128.Fq12; import org.hyperledger.besu.crypto.altbn128.Fq2; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import java.math.BigInteger; @@ -39,7 +39,7 @@ public class AltBN128PairingPrecompiledContract extends AbstractAltBnPrecompiled static final Bytes FALSE = Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000000"); - static final Bytes TRUE = + public static final Bytes TRUE = Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000001"); private final Gas pairingGasCost; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java index 186e707ab2a..38151cd8e23 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContract.java @@ -12,16 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.util.Arrays.copyOfRange; import static org.hyperledger.besu.crypto.Blake2bfMessageDigest.Blake2bfDigest.MESSAGE_LENGTH_BYTES; import org.hyperledger.besu.crypto.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContract.java index c91b502a27c..3ad32db5db2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContract.java index e58fd0b76d0..a6a2bcc1d81 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContract.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContract.java index 2756e1dd3b9..0fc7e984e54 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContract.java index 45998221471..ed4c6205487 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContract.java index a79391b797b..2a2dfe8f21e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContract.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContract.java index 61aa6dc1020..847d13222fd 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContract.java index 5530aa8375f..77b44b2caa7 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContract.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContract.java index fb0902bd6b8..18452265b9f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContract.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContract.java index 3da76d64664..f3af5143345 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContract.java @@ -13,9 +13,9 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; +import org.hyperledger.besu.evm.Gas; import org.hyperledger.besu.nativelib.bls12_381.LibEthPairings; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BigIntegerModularExponentiationPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BigIntegerModularExponentiationPrecompiledContract.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BigIntegerModularExponentiationPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/BigIntegerModularExponentiationPrecompiledContract.java index 236ab742710..214942a5967 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BigIntegerModularExponentiationPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/BigIntegerModularExponentiationPrecompiledContract.java @@ -12,12 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; import java.util.Arrays; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContract.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContract.java index 47a792c23c6..edec31206c9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContract.java @@ -12,17 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.SECPPublicKey; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import java.math.BigInteger; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/IDPrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/IDPrecompiledContract.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/IDPrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/IDPrecompiledContract.java index 5672b4c82d3..4cbf89191f9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/IDPrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/IDPrecompiledContract.java @@ -12,12 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/precompile/MainnetPrecompiledContracts.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/MainnetPrecompiledContracts.java new file mode 100644 index 00000000000..f09a39cfdf7 --- /dev/null +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/MainnetPrecompiledContracts.java @@ -0,0 +1,89 @@ +/* + * Copyright ConsenSys AG. + * + * 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.precompile; + +import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; + +/** Provides the various precompiled contracts used on mainnet hard forks. */ +public abstract class MainnetPrecompiledContracts { + + private MainnetPrecompiledContracts() {} + + public static PrecompileContractRegistry frontier(final GasCalculator gasCalculator) { + PrecompileContractRegistry precompileContractRegistry = new PrecompileContractRegistry(); + populateForFrontier(precompileContractRegistry, gasCalculator); + return precompileContractRegistry; + } + + public static void populateForFrontier( + final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { + registry.put(Address.ECREC, new ECRECPrecompiledContract(gasCalculator)); + registry.put(Address.SHA256, new SHA256PrecompiledContract(gasCalculator)); + registry.put(Address.RIPEMD160, new RIPEMD160PrecompiledContract(gasCalculator)); + registry.put(Address.ID, new IDPrecompiledContract(gasCalculator)); + } + + public static PrecompileContractRegistry homestead(final GasCalculator gasCalculator) { + return frontier(gasCalculator); + } + + public static PrecompileContractRegistry byzantium(final GasCalculator gasCalculator) { + PrecompileContractRegistry precompileContractRegistry = new PrecompileContractRegistry(); + populateForByzantium(precompileContractRegistry, gasCalculator); + return precompileContractRegistry; + } + + public static void populateForByzantium( + final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { + populateForFrontier(registry, gasCalculator); + registry.put( + Address.MODEXP, new BigIntegerModularExponentiationPrecompiledContract(gasCalculator)); + registry.put(Address.ALTBN128_ADD, AltBN128AddPrecompiledContract.byzantium(gasCalculator)); + registry.put(Address.ALTBN128_MUL, AltBN128MulPrecompiledContract.byzantium(gasCalculator)); + registry.put( + Address.ALTBN128_PAIRING, AltBN128PairingPrecompiledContract.byzantium(gasCalculator)); + } + + public static PrecompileContractRegistry istanbul(final GasCalculator gasCalculator) { + PrecompileContractRegistry precompileContractRegistry = new PrecompileContractRegistry(); + populateForIstanbul(precompileContractRegistry, gasCalculator); + return precompileContractRegistry; + } + + public static void populateForIstanbul( + final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { + populateForByzantium(registry, gasCalculator); + registry.put(Address.ALTBN128_ADD, AltBN128AddPrecompiledContract.istanbul(gasCalculator)); + registry.put(Address.ALTBN128_MUL, AltBN128MulPrecompiledContract.istanbul(gasCalculator)); + registry.put( + Address.ALTBN128_PAIRING, AltBN128PairingPrecompiledContract.istanbul(gasCalculator)); + registry.put(Address.BLAKE2B_F_COMPRESSION, new BLAKE2BFPrecompileContract(gasCalculator)); + } + + public static void populateForBLS12( + final PrecompileContractRegistry registry, final GasCalculator gasCalculator) { + populateForIstanbul(registry, gasCalculator); + registry.put(Address.BLS12_G1ADD, new BLS12G1AddPrecompiledContract()); + registry.put(Address.BLS12_G1MUL, new BLS12G1MulPrecompiledContract()); + registry.put(Address.BLS12_G1MULTIEXP, new BLS12G1MultiExpPrecompiledContract()); + registry.put(Address.BLS12_G2ADD, new BLS12G2AddPrecompiledContract()); + registry.put(Address.BLS12_G2MUL, new BLS12G2MulPrecompiledContract()); + registry.put(Address.BLS12_G2MULTIEXP, new BLS12G2MultiExpPrecompiledContract()); + registry.put(Address.BLS12_PAIRING, new BLS12PairingPrecompiledContract()); + registry.put(Address.BLS12_MAP_FP_TO_G1, new BLS12MapFpToG1PrecompiledContract()); + registry.put(Address.BLS12_MAP_FP2_TO_G2, new BLS12MapFp2ToG2PrecompiledContract()); + } +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompileContractRegistry.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompileContractRegistry.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompileContractRegistry.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompileContractRegistry.java index cf60ab0aa25..37a4084c943 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompileContractRegistry.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompileContractRegistry.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.datatypes.Address; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompiledContract.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompiledContract.java index 7b6f17da9d7..975e33168b6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/PrecompiledContract.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.precompile; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import javax.annotation.Nonnull; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/RIPEMD160PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/RIPEMD160PrecompiledContract.java similarity index 80% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/RIPEMD160PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/RIPEMD160PrecompiledContract.java index 8b2596438d0..0203e5db67f 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/RIPEMD160PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/RIPEMD160PrecompiledContract.java @@ -12,13 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/SHA256PrecompiledContract.java b/evm/src/main/java/org/hyperledger/besu/evm/precompile/SHA256PrecompiledContract.java similarity index 79% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/SHA256PrecompiledContract.java rename to evm/src/main/java/org/hyperledger/besu/evm/precompile/SHA256PrecompiledContract.java index 46dc10024e4..2965991d6c3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/precompiles/SHA256PrecompiledContract.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/precompile/SHA256PrecompiledContract.java @@ -12,13 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import org.hyperledger.besu.crypto.Hash; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.AbstractPrecompiledContract; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractMessageProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java similarity index 91% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractMessageProcessor.java rename to evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java index 78d24dafee3..d86b7ec42a3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractMessageProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/AbstractMessageProcessor.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.processor; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.ModificationNotAllowedException; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.ArrayList; import java.util.Collection; @@ -84,17 +84,17 @@ public abstract class AbstractMessageProcessor { private void clearAccumulatedStateBesidesGasAndOutput(final MessageFrame frame) { final Collection

addressesToForceCommit = - frame.getWorldState().getTouchedAccounts().stream() + frame.getWorldUpdater().getTouchedAccounts().stream() .filter(a -> forceDeleteAccountsWhenEmpty.contains(a.getAddress()) && a.isEmpty()) .map(Account::getAddress) .collect(Collectors.toCollection(ArrayList::new)); // Clear any pending changes. - frame.getWorldState().revert(); + frame.getWorldUpdater().revert(); // Force delete any requested accounts and commit the changes. - addressesToForceCommit.forEach(h -> frame.getWorldState().deleteAccount(h)); - frame.getWorldState().commit(); + addressesToForceCommit.forEach(h -> frame.getWorldUpdater().deleteAccount(h)); + frame.getWorldUpdater().commit(); frame.clearLogs(); frame.clearSelfDestructs(); @@ -129,7 +129,7 @@ protected void revert(final MessageFrame frame) { * @param frame The message frame */ private void completedSuccess(final MessageFrame frame) { - frame.getWorldState().commit(); + frame.getWorldUpdater().commit(); frame.getMessageFrameStack().removeFirst(); frame.notifyCompletion(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessor.java rename to evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java index 5fab63dee38..936b6c6ca41 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetContractCreationProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/ContractCreationProcessor.java @@ -12,18 +12,19 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.processor; import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Account; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.ModificationNotAllowedException; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.ExceptionalHaltReason; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.contractvalidation.ContractValidationRule; +import org.hyperledger.besu.evm.frame.ExceptionalHaltReason; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Collection; import java.util.List; @@ -35,7 +36,7 @@ import org.apache.tuweni.bytes.Bytes; /** A contract creation message processor. */ -public class MainnetContractCreationProcessor extends AbstractMessageProcessor { +public class ContractCreationProcessor extends AbstractMessageProcessor { private static final Logger LOG = LogManager.getLogger(); @@ -47,7 +48,7 @@ public class MainnetContractCreationProcessor extends AbstractMessageProcessor { private final List contractValidationRules; - public MainnetContractCreationProcessor( + public ContractCreationProcessor( final GasCalculator gasCalculator, final EVM evm, final boolean requireCodeDepositToSucceed, @@ -61,7 +62,7 @@ public MainnetContractCreationProcessor( this.initialContractNonce = initialContractNonce; } - public MainnetContractCreationProcessor( + public ContractCreationProcessor( final GasCalculator gasCalculator, final EVM evm, final boolean requireCodeDepositToSucceed, @@ -89,11 +90,11 @@ public void start(final MessageFrame frame, final OperationTracer operationTrace } try { - final MutableAccount sender = frame.getWorldState().getSenderAccount(frame).getMutable(); + final MutableAccount sender = frame.getWorldUpdater().getSenderAccount(frame).getMutable(); sender.decrementBalance(frame.getValue()); final MutableAccount contract = - frame.getWorldState().getOrCreate(frame.getContractAddress()).getMutable(); + frame.getWorldUpdater().getOrCreate(frame.getContractAddress()).getMutable(); if (accountExists(contract)) { LOG.trace( "Contract creation error: account as already been created for address {}", @@ -114,7 +115,7 @@ public void start(final MessageFrame frame, final OperationTracer operationTrace } @Override - protected void codeSuccess(final MessageFrame frame, final OperationTracer operationTracer) { + public void codeSuccess(final MessageFrame frame, final OperationTracer operationTracer) { final Bytes contractCode = frame.getOutputData(); final Gas depositFee = gasCalculator.codeDepositGasCost(contractCode.size()); @@ -140,7 +141,7 @@ protected void codeSuccess(final MessageFrame frame, final OperationTracer opera // Finalize contract creation, setting the contract code. final MutableAccount contract = - frame.getWorldState().getOrCreate(frame.getContractAddress()).getMutable(); + frame.getWorldUpdater().getOrCreate(frame.getContractAddress()).getMutable(); contract.setCode(contractCode); LOG.trace( "Successful creation of contract {} with code of size {} (Gas remaining: {})", diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetMessageCallProcessor.java b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetMessageCallProcessor.java rename to evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java index ad3fcc04ed6..1d5f5727d71 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetMessageCallProcessor.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/processor/MessageCallProcessor.java @@ -12,16 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet; +package org.hyperledger.besu.evm.processor; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.ModificationNotAllowedException; -import org.hyperledger.besu.ethereum.core.MutableAccount; -import org.hyperledger.besu.ethereum.vm.EVM; -import org.hyperledger.besu.ethereum.vm.MessageFrame; -import org.hyperledger.besu.ethereum.vm.OperationTracer; +import org.hyperledger.besu.evm.EVM; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.precompile.PrecompileContractRegistry; +import org.hyperledger.besu.evm.precompile.PrecompiledContract; +import org.hyperledger.besu.evm.tracing.OperationTracer; import java.util.Collection; @@ -30,12 +32,12 @@ import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; -public class MainnetMessageCallProcessor extends AbstractMessageProcessor { +public class MessageCallProcessor extends AbstractMessageProcessor { private static final Logger LOG = LogManager.getLogger(); private final PrecompileContractRegistry precompiles; - public MainnetMessageCallProcessor( + public MessageCallProcessor( final EVM evm, final PrecompileContractRegistry precompiles, final Collection
forceCommitAddresses) { @@ -43,7 +45,7 @@ public MainnetMessageCallProcessor( this.precompiles = precompiles; } - public MainnetMessageCallProcessor(final EVM evm, final PrecompileContractRegistry precompiles) { + public MessageCallProcessor(final EVM evm, final PrecompileContractRegistry precompiles) { super(evm, ImmutableSet.of()); this.precompiles = precompiles; } @@ -84,11 +86,12 @@ protected void codeSuccess(final MessageFrame frame, final OperationTracer opera * of the world state of this executor. */ private void transferValue(final MessageFrame frame) { - final MutableAccount senderAccount = frame.getWorldState().getSenderAccount(frame).getMutable(); + final MutableAccount senderAccount = + frame.getWorldUpdater().getSenderAccount(frame).getMutable(); // The yellow paper explicitly states that if the recipient account doesn't exist at this // point, it is created. final MutableAccount recipientAccount = - frame.getWorldState().getOrCreate(frame.getRecipientAddress()).getMutable(); + frame.getWorldUpdater().getOrCreate(frame.getRecipientAddress()).getMutable(); if (frame.getRecipientAddress().equals(frame.getSenderAddress())) { LOG.trace("Message call of {} to itself: no fund transferred", frame.getSenderAddress()); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracer.java b/evm/src/main/java/org/hyperledger/besu/evm/tracing/EstimateGasOperationTracer.java similarity index 88% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracer.java rename to evm/src/main/java/org/hyperledger/besu/evm/tracing/EstimateGasOperationTracer.java index b32a1837442..92544606bf0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/EstimateGasOperationTracer.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/tracing/EstimateGasOperationTracer.java @@ -12,10 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.tracing; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.operations.SStoreOperation; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.operation.SStoreOperation; public class EstimateGasOperationTracer implements OperationTracer { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationTracer.java b/evm/src/main/java/org/hyperledger/besu/evm/tracing/OperationTracer.java similarity index 82% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationTracer.java rename to evm/src/main/java/org/hyperledger/besu/evm/tracing/OperationTracer.java index 7a6be24bc6f..5b7c9b827f2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/vm/OperationTracer.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/tracing/OperationTracer.java @@ -12,10 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.vm; +package org.hyperledger.besu.evm.tracing; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.Operation.OperationResult; +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.operation.Operation.OperationResult; import java.util.Optional; diff --git a/evm/src/main/java/org/hyperledger/besu/evm/tracing/StandardJsonTracer.java b/evm/src/main/java/org/hyperledger/besu/evm/tracing/StandardJsonTracer.java new file mode 100644 index 00000000000..4697316445e --- /dev/null +++ b/evm/src/main/java/org/hyperledger/besu/evm/tracing/StandardJsonTracer.java @@ -0,0 +1,144 @@ +/* + * 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.tracing; + +import static com.google.common.base.Strings.padStart; + +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.operation.Operation; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import com.google.common.base.Joiner; +import org.apache.tuweni.bytes.Bytes; +import org.apache.tuweni.units.bigints.UInt256; + +public class StandardJsonTracer implements OperationTracer { + + private final PrintStream out; + private final boolean showMemory; + + public StandardJsonTracer(final PrintStream out, final boolean showMemory) { + this.out = out; + this.showMemory = showMemory; + } + + public static String shortNumber(final UInt256 number) { + return number.isZero() ? "0x0" : number.toShortHexString(); + } + + private static String shortBytes(final Bytes bytes) { + return bytes.isZero() ? "0x0" : bytes.toShortHexString(); + } + + Joiner commaJoiner = Joiner.on(','); + + @Override + public void traceExecution( + final MessageFrame messageFrame, final ExecuteOperation executeOperation) { + final Operation currentOp = messageFrame.getCurrentOperation(); + int pc = messageFrame.getPC(); + int opcode = currentOp.getOpcode(); + String remainingGas = shortNumber(messageFrame.getRemainingGas().asUInt256()); + List stack = new ArrayList<>(messageFrame.stackSize()); + for (int i = messageFrame.stackSize() - 1; i >= 0; i--) { + stack.add("\"" + shortBytes(messageFrame.getStackItem(i)) + "\""); + } + Bytes returnData = messageFrame.getReturnData(); + int depth = messageFrame.getMessageStackDepth() + 1; + + final Operation.OperationResult executeResult = executeOperation.execute(); + + StringBuilder sb = new StringBuilder(1024); + sb.append("{"); + sb.append("\"pc\":").append(pc).append(","); + sb.append("\"op\":").append(opcode).append(","); + sb.append("\"gas\":\"").append(remainingGas).append("\","); + sb.append("\"gasCost\":\"") + .append(executeResult.getGasCost().map(gas -> shortNumber(gas.asUInt256())).orElse("")) + .append("\","); + if (showMemory) { + Bytes memory = + messageFrame.readMemory(UInt256.ZERO, messageFrame.memoryWordSize().multiply(32L)); + sb.append("\"memory\":\"").append(memory.toHexString()).append("\","); + sb.append("\"memSize\":").append(memory.size()).append(","); + } else { + sb.append("\"memory\":\"0x\","); + sb.append("\"memSize\":").append(messageFrame.memoryByteSize()).append(","); + } + sb.append("\"stack\":[").append(commaJoiner.join(stack)).append("],"); + sb.append("\"returnData\":") + .append(returnData.size() > 0 ? '"' + returnData.toHexString() + '"' : "null") + .append(","); + sb.append("\"depth\":").append(depth).append(","); + sb.append("\"refund\":").append(messageFrame.getGasRefund().toLong()).append(","); + sb.append("\"opName\":\"").append(currentOp.getName()).append("\","); + sb.append("\"error\":\"") + .append( + executeResult + .getHaltReason() + .map(ExceptionalHaltReason::getDescription) + .orElse( + messageFrame.getRevertReason().map(StandardJsonTracer::quoteEscape).orElse(""))) + .append("\"}"); + out.println(sb); + } + + static String quoteEscape(final Bytes bytes) { + StringBuilder result = new StringBuilder(bytes.size()); + for (byte b : bytes.toArrayUnsafe()) { + int c = ((int) b) & 0xff; + // list from RFC-4627 section 2 + if (c == '"') { + result.append("\\\""); + } else if (c == '\\') { + result.append("\\\\"); + } else if (c == '/') { + result.append("\\/"); + } else if (c == '\b') { + result.append("\\b"); + } else if (c == '\f') { + result.append("\\f"); + } else if (c == '\n') { + result.append("\\n"); + } else if (c == '\r') { + result.append("\\r"); + } else if (c == '\t') { + result.append("\\t"); + } else if (c <= 0x1F) { + result.append("\\u"); + result.append(padStart(Integer.toHexString(c), 4, '0')); + } else { + result.append((char) b); + } + } + return result.toString(); + } + + @Override + public void tracePrecompileCall( + final MessageFrame frame, final Gas gasRequirement, final Bytes output) {} + + @Override + public void traceAccountCreationResult( + final MessageFrame frame, final Optional haltReason) {} +} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AbstractWorldUpdater.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/AbstractWorldUpdater.java similarity index 97% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AbstractWorldUpdater.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/AbstractWorldUpdater.java index dcac182170b..1af0f48a1ec 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/AbstractWorldUpdater.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/AbstractWorldUpdater.java @@ -12,10 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; import java.util.ArrayList; import java.util.Collection; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldView.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/MutableWorldView.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldView.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/MutableWorldView.java index e80e8a8896d..84eada5a2d1 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/MutableWorldView.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/MutableWorldView.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; public interface MutableWorldView extends WorldView { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/UpdateTrackingAccount.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/UpdateTrackingAccount.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/UpdateTrackingAccount.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/UpdateTrackingAccount.java index e822b74477d..857ff4edc31 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/UpdateTrackingAccount.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/UpdateTrackingAccount.java @@ -14,13 +14,18 @@ * */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import static com.google.common.base.Preconditions.checkNotNull; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; import java.util.Map; import java.util.NavigableMap; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldState.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldState.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldState.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldState.java index c2cdff389f8..10667e69c04 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldState.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldState.java @@ -12,11 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.account.AccountState; +import org.hyperledger.besu.evm.account.AccountStorageEntry; import java.util.NavigableMap; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldUpdater.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldUpdater.java similarity index 95% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldUpdater.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldUpdater.java index 8c739206508..b32594b1e22 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldUpdater.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldUpdater.java @@ -12,11 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.account.Account; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.util.Collection; import java.util.Optional; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldView.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldView.java similarity index 92% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldView.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldView.java index f394886c4ef..657ba6a330a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WorldView.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldView.java @@ -12,9 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import org.hyperledger.besu.datatypes.Address; +import org.hyperledger.besu.evm.account.Account; /** Generic interface for a view over the accounts of the world state. */ public interface WorldView { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WrappedEvmAccount.java b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WrappedEvmAccount.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WrappedEvmAccount.java rename to evm/src/main/java/org/hyperledger/besu/evm/worldstate/WrappedEvmAccount.java index d060dca6370..dcafaf1f85a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WrappedEvmAccount.java +++ b/evm/src/main/java/org/hyperledger/besu/evm/worldstate/WrappedEvmAccount.java @@ -12,11 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.core; +package org.hyperledger.besu.evm.worldstate; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.evm.ModificationNotAllowedException; +import org.hyperledger.besu.evm.account.AccountStorageEntry; +import org.hyperledger.besu.evm.account.EvmAccount; +import org.hyperledger.besu.evm.account.MutableAccount; import java.util.NavigableMap; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContractTest.java similarity index 96% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContractTest.java index ee7da91ea66..8e5f897318c 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/AltBN128PairingPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/AltBN128PairingPrecompiledContractTest.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.vm.GasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContractTest.java similarity index 95% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContractTest.java index 865713ea544..ee1511af055 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLAKE2BFPrecompileContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLAKE2BFPrecompileContractTest.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.PetersburgGasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContractTest.java similarity index 77% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContractTest.java index 4d381cb9b68..3b0f0094b27 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1AddPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1AddPrecompiledContractTest.java @@ -13,20 +13,18 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -35,13 +33,12 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; @RunWith(Parameterized.class) -public class BLS12G1AddPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G1AddPrecompiledContractTest { - public BLS12G1AddPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G1ADD); - } + BLS12G1AddPrecompiledContract contract = new BLS12G1AddPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G1AddPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G1AddPrecompiledContractTest.class.getResourceAsStream("g1_add.csv"), UTF_8)) + Objects.requireNonNull( + BLS12G1AddPrecompiledContractTest.class.getResourceAsStream("g1_add.csv")), + UTF_8)) .stream() .map(line -> line.split(",", 4)) .collect(Collectors.toList()); @@ -79,7 +78,7 @@ public void shouldCalculate() { final Bytes actualComputation = contract.compute(input, messageFrame); if (actualComputation == null) { final ArgumentCaptor revertReason = ArgumentCaptor.forClass(Bytes.class); - verify(messageFrame).setRevertReason(revertReason.capture()); + Mockito.verify(messageFrame).setRevertReason(revertReason.capture()); assertThat(new String(revertReason.getValue().toArrayUnsafe(), UTF_8)).isEqualTo(notes); assertThat(expectedComputation.size()).isZero(); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContractTest.java index 8cb5fa5ce10..b44de37c0be 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MulPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MulPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12G1MulPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G1MulPrecompiledContractTest { - public BLS12G1MulPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G1MUL); - } + BLS12G1MulPrecompiledContract contract = new BLS12G1MulPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G1MulPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G1MulPrecompiledContractTest.class.getResourceAsStream("g1_mul.csv"), UTF_8)) + Objects.requireNonNull( + BLS12G1MulPrecompiledContractTest.class.getResourceAsStream("g1_mul.csv")), + UTF_8)) .stream() .map(line -> line.split(",", 4)) .collect(Collectors.toList()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContractTest.java index 05d8e9be5db..8a5fcee8af5 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G1MultiExpPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G1MultiExpPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12G1MultiExpPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G1MultiExpPrecompiledContractTest { - public BLS12G1MultiExpPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G1MULTIEXP); - } + BLS12G1MultiExpPrecompiledContract contract = new BLS12G1MultiExpPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G1MultiExpPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G1MultiExpPrecompiledContractTest.class.getResourceAsStream("g1_multiexp.csv"), + Objects.requireNonNull( + BLS12G1MultiExpPrecompiledContractTest.class.getResourceAsStream( + "g1_multiexp.csv")), UTF_8)) .stream() .map(line -> line.split(",", 4)) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContractTest.java index fca71f0c6f7..7db8ce7b5c1 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2AddPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2AddPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12G2AddPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G2AddPrecompiledContractTest { - public BLS12G2AddPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G2ADD); - } + BLS12G2AddPrecompiledContract contract = new BLS12G2AddPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G2AddPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G2AddPrecompiledContractTest.class.getResourceAsStream("g2_add.csv"), UTF_8)) + Objects.requireNonNull( + BLS12G2AddPrecompiledContractTest.class.getResourceAsStream("g2_add.csv")), + UTF_8)) .stream() .map(line -> line.split(",", 4)) .collect(Collectors.toList()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContractTest.java index 94219df0986..5dd7a08b0b6 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MulPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MulPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12G2MulPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G2MulPrecompiledContractTest { - public BLS12G2MulPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G2MUL); - } + BLS12G2MulPrecompiledContract contract = new BLS12G2MulPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G2MulPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G2MulPrecompiledContractTest.class.getResourceAsStream("g2_mul.csv"), UTF_8)) + Objects.requireNonNull( + BLS12G2MulPrecompiledContractTest.class.getResourceAsStream("g2_mul.csv")), + UTF_8)) .stream() .map(line -> line.split(",", 4)) .collect(Collectors.toList()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContractTest.java index e2fb819848f..5d08314868e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12G2MultiExpPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12G2MultiExpPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12G2MultiExpPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12G2MultiExpPrecompiledContractTest { - public BLS12G2MultiExpPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_G2MULTIEXP); - } + BLS12G2MultiExpPrecompiledContract contract = new BLS12G2MultiExpPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12G2MultiExpPrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12G2MultiExpPrecompiledContractTest.class.getResourceAsStream("g2_multiexp.csv"), + Objects.requireNonNull( + BLS12G2MultiExpPrecompiledContractTest.class.getResourceAsStream( + "g2_multiexp.csv")), UTF_8)) .stream() .map(line -> line.split(",", 4)) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContractTest.java index d04b8aff63f..2adead58c2d 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFp2ToG2PrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFp2ToG2PrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12MapFp2ToG2PrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12MapFp2ToG2PrecompiledContractTest { - public BLS12MapFp2ToG2PrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_MAP_FP2_TO_G2); - } + BLS12MapFp2ToG2PrecompiledContract contract = new BLS12MapFp2ToG2PrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12MapFp2ToG2PrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12MapFp2ToG2PrecompiledContractTest.class.getResourceAsStream("fp2_to_g2.csv"), + Objects.requireNonNull( + BLS12MapFp2ToG2PrecompiledContractTest.class.getResourceAsStream( + "fp2_to_g2.csv")), UTF_8)) .stream() .map(line -> line.split(",", 4)) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContractTest.java similarity index 81% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContractTest.java index 820980ae7cb..6025dcc06e1 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12MapFpToG1PrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12MapFpToG1PrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.io.CharStreams; @@ -37,11 +36,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12MapFpToG1PrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12MapFpToG1PrecompiledContractTest { - public BLS12MapFpToG1PrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_MAP_FP_TO_G1); - } + BLS12MapFpToG1PrecompiledContract contract = new BLS12MapFpToG1PrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -49,7 +46,9 @@ public BLS12MapFpToG1PrecompiledContractTest() { public static Iterable parameters() throws IOException { return CharStreams.readLines( new InputStreamReader( - BLS12MapFpToG1PrecompiledContractTest.class.getResourceAsStream("fp_to_g1.csv"), + Objects.requireNonNull( + BLS12MapFpToG1PrecompiledContractTest.class.getResourceAsStream( + "fp_to_g1.csv")), UTF_8)) .stream() .map(line -> line.split(",", 4)) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContractTest.java similarity index 79% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContractTest.java index dd69e76fc4c..d5462064d3b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/BLS12PairingPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/BLS12PairingPrecompiledContractTest.java @@ -13,20 +13,19 @@ * SPDX-License-Identifier: Apache-2.0 * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.MainnetPrecompiledContractRegistries; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Objects; import java.util.stream.Collectors; import com.google.common.collect.Streams; @@ -38,11 +37,9 @@ import org.mockito.ArgumentCaptor; @RunWith(Parameterized.class) -public class BLS12PairingPrecompiledContractTest extends AbstractPrecompiledContractTest { +public class BLS12PairingPrecompiledContractTest { - public BLS12PairingPrecompiledContractTest() { - super(MainnetPrecompiledContractRegistries::bls12, Address.BLS12_PAIRING); - } + BLS12PairingPrecompiledContract contract = new BLS12PairingPrecompiledContract(); private final MessageFrame messageFrame = mock(MessageFrame.class); @@ -51,13 +48,16 @@ public static Iterable parameters() throws IOException { return Streams.concat( CharStreams.readLines( new InputStreamReader( - BLS12PairingPrecompiledContractTest.class.getResourceAsStream("pairing.csv"), + Objects.requireNonNull( + BLS12PairingPrecompiledContractTest.class.getResourceAsStream( + "pairing.csv")), UTF_8)) .stream(), CharStreams.readLines( new InputStreamReader( - BLS12PairingPrecompiledContractTest.class.getResourceAsStream( - "invalid_subgroup_for_pairing.csv"), + Objects.requireNonNull( + BLS12PairingPrecompiledContractTest.class.getResourceAsStream( + "invalid_subgroup_for_pairing.csv")), UTF_8)) .stream()) .map(line -> line.split(",", 4)) diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/Benchmarks.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/Benchmarks.java similarity index 98% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/Benchmarks.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/Benchmarks.java index 36bd5ce2d4b..763611320f2 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/Benchmarks.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/Benchmarks.java @@ -14,7 +14,7 @@ * */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hyperledger.besu.crypto.Hash.keccak256; @@ -28,16 +28,13 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Wei; -import org.hyperledger.besu.ethereum.chain.Blockchain; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.core.ProcessableBlockHeader; -import org.hyperledger.besu.ethereum.core.WorldUpdater; -import org.hyperledger.besu.ethereum.mainnet.BerlinGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.IstanbulGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.PrecompiledContract; -import org.hyperledger.besu.ethereum.vm.BlockHashLookup; -import org.hyperledger.besu.ethereum.vm.Code; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Code; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.BlockValues; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator; +import org.hyperledger.besu.evm.worldstate.WorldUpdater; import java.math.BigInteger; import java.util.ArrayDeque; @@ -73,15 +70,14 @@ public class Benchmarks { .depth(1) .completer(__ -> {}) .address(Address.ZERO) - .blockHashLookup(mock(BlockHashLookup.class)) - .blockHeader(mock(ProcessableBlockHeader.class)) - .blockchain(mock(Blockchain.class)) + .blockHashLookup(n -> null) + .blockValues(mock(BlockValues.class)) .gasPrice(Wei.ZERO) .messageFrameStack(new ArrayDeque<>()) .miningBeneficiary(Address.ZERO) .originator(Address.ZERO) .initialGas(Gas.of(100000)) - .worldState(mock(WorldUpdater.class)) + .worldUpdater(mock(WorldUpdater.class)) .build(); public static void benchSecp256k1Recover() { diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContractTest.java similarity index 99% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContractTest.java index 5501087b314..12513689f71 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/ECRECPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/ECRECPrecompiledContractTest.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; -import org.hyperledger.besu.ethereum.mainnet.SpuriousDragonGasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/MODEXPPrecompiledContractTest.java b/evm/src/test/java/org/hyperledger/besu/evm/precompile/MODEXPPrecompiledContractTest.java similarity index 99% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/MODEXPPrecompiledContractTest.java rename to evm/src/test/java/org/hyperledger/besu/evm/precompile/MODEXPPrecompiledContractTest.java index 9f94b96c558..e59a0cec540 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/precompiles/MODEXPPrecompiledContractTest.java +++ b/evm/src/test/java/org/hyperledger/besu/evm/precompile/MODEXPPrecompiledContractTest.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.ethereum.mainnet.precompiles; +package org.hyperledger.besu.evm.precompile; import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.ethereum.core.Gas; -import org.hyperledger.besu.ethereum.mainnet.BerlinGasCalculator; -import org.hyperledger.besu.ethereum.mainnet.ByzantiumGasCalculator; -import org.hyperledger.besu.ethereum.vm.MessageFrame; +import org.hyperledger.besu.evm.Gas; +import org.hyperledger.besu.evm.frame.MessageFrame; +import org.hyperledger.besu.evm.gascalculator.BerlinGasCalculator; +import org.hyperledger.besu.evm.gascalculator.ByzantiumGasCalculator; import org.apache.tuweni.bytes.Bytes; import org.junit.Test; diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/fp2_to_g2.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/fp2_to_g2.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/fp2_to_g2.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/fp2_to_g2.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/fp_to_g1.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/fp_to_g1.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/fp_to_g1.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/fp_to_g1.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_add.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_add.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_add.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_add.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_mul.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_mul.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_mul.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_mul.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_multiexp.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_multiexp.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g1_multiexp.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g1_multiexp.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_add.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_add.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_add.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_add.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_mul.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_mul.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_mul.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_mul.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_multiexp.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_multiexp.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/g2_multiexp.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/g2_multiexp.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/invalid_subgroup_for_pairing.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/invalid_subgroup_for_pairing.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/invalid_subgroup_for_pairing.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/invalid_subgroup_for_pairing.csv diff --git a/ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/pairing.csv b/evm/src/test/resources/org/hyperledger/besu/evm/precompile/pairing.csv similarity index 100% rename from ethereum/core/src/test/resources/org/hyperledger/besu/ethereum/mainnet/precompiles/pairing.csv rename to evm/src/test/resources/org/hyperledger/besu/evm/precompile/pairing.csv diff --git a/settings.gradle b/settings.gradle index d015fa89f0a..161455f0b6c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -28,6 +28,7 @@ include 'container-tests:tests' include 'crypto' include 'datatypes' include 'enclave' +include 'evm' include 'errorprone-checks' include 'ethereum:api' include 'ethereum:blockcreation'