From ae335a1bc59e83019b1fab51e6ba7cf013c4ffad Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Wed, 9 Aug 2023 10:51:56 -0600 Subject: [PATCH] EVMTool contract create processing (#5755) The "code" mode of the EVMTool did not support the side effects of a contract create. Expose the TransactionProcessor method that handles that switching. Signed-off-by: Danno Ferrin --- CHANGELOG.md | 1 + .../mainnet/MainnetTransactionProcessor.java | 14 +++++--------- .../hyperledger/besu/evmtool/EvmToolCommand.java | 9 ++------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4986f1e594..55c539ed2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Bug Fixes - Make smart contract permissioning features work with london fork [#5727](https://github.com/hyperledger/besu/pull/5727) - Add type to PendingTransactionDetail, fix eth_subscribe [#5729](https://github.com/hyperledger/besu/pull/5729) +- EvmTool "run" mode did not reflect contracts created within the transaction. [#5755](https://github.com/hyperledger/besu/pull/5755) ### Download Links 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 a87a35d725..64a8450cd3 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 @@ -506,21 +506,17 @@ public class MainnetTransactionProcessor { } } - protected void process(final MessageFrame frame, final OperationTracer operationTracer) { + public void process(final MessageFrame frame, final OperationTracer operationTracer) { final AbstractMessageProcessor executor = getMessageProcessor(frame.getType()); executor.process(frame, operationTracer); } private AbstractMessageProcessor getMessageProcessor(final MessageFrame.Type type) { - switch (type) { - case MESSAGE_CALL: - return messageCallProcessor; - case CONTRACT_CREATION: - return contractCreationProcessor; - default: - throw new IllegalStateException("Request for unsupported message processor type " + type); - } + return switch (type) { + case MESSAGE_CALL -> messageCallProcessor; + case CONTRACT_CREATION -> contractCreationProcessor; + }; } protected long refunded( 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 269f4c2b7d..0bd393b4fa 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 @@ -36,8 +36,6 @@ import org.hyperledger.besu.evm.account.AccountStorageEntry; import org.hyperledger.besu.evm.code.CodeInvalid; 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 org.hyperledger.besu.evm.worldstate.WorldState; @@ -344,8 +342,6 @@ public class EvmToolCommand implements Runnable { .orElse(0L); long txGas = gas - intrinsicGasCost - accessListCost; - final PrecompileContractRegistry precompileContractRegistry = - protocolSpec.getPrecompileContractRegistry(); final EVM evm = protocolSpec.getEvm(); Code code = evm.getCode(Hash.hash(codeBytes), codeBytes); if (!code.isValid()) { @@ -385,13 +381,12 @@ public class EvmToolCommand implements Runnable { .miningBeneficiary(blockHeader.getCoinbase()) .blockHashLookup(new CachingBlockHashLookup(blockHeader, component.getBlockchain())) .build(); + Deque messageFrameStack = initialMessageFrame.getMessageFrameStack(); - final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry); - final Deque messageFrameStack = initialMessageFrame.getMessageFrameStack(); stopwatch.start(); while (!messageFrameStack.isEmpty()) { final MessageFrame messageFrame = messageFrameStack.peek(); - mcp.process(messageFrame, tracer); + protocolSpec.getTransactionProcessor().process(messageFrame, tracer); if (messageFrameStack.isEmpty()) { stopwatch.stop(); if (lastTime == 0) {