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 <danno.ferrin@swirldslabs.com>
pull/5770/head
Danno Ferrin 1 year ago committed by GitHub
parent fb3b262f1b
commit ae335a1bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  3. 9
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/EvmToolCommand.java

@ -11,6 +11,7 @@
### Bug Fixes ### Bug Fixes
- Make smart contract permissioning features work with london fork [#5727](https://github.com/hyperledger/besu/pull/5727) - 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) - 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 ### Download Links

@ -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()); final AbstractMessageProcessor executor = getMessageProcessor(frame.getType());
executor.process(frame, operationTracer); executor.process(frame, operationTracer);
} }
private AbstractMessageProcessor getMessageProcessor(final MessageFrame.Type type) { private AbstractMessageProcessor getMessageProcessor(final MessageFrame.Type type) {
switch (type) { return switch (type) {
case MESSAGE_CALL: case MESSAGE_CALL -> messageCallProcessor;
return messageCallProcessor; case CONTRACT_CREATION -> contractCreationProcessor;
case CONTRACT_CREATION: };
return contractCreationProcessor;
default:
throw new IllegalStateException("Request for unsupported message processor type " + type);
}
} }
protected long refunded( protected long refunded(

@ -36,8 +36,6 @@ import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.code.CodeInvalid; import org.hyperledger.besu.evm.code.CodeInvalid;
import org.hyperledger.besu.evm.frame.MessageFrame; import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.log.LogsBloomFilter; 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.OperationTracer;
import org.hyperledger.besu.evm.tracing.StandardJsonTracer; import org.hyperledger.besu.evm.tracing.StandardJsonTracer;
import org.hyperledger.besu.evm.worldstate.WorldState; import org.hyperledger.besu.evm.worldstate.WorldState;
@ -344,8 +342,6 @@ public class EvmToolCommand implements Runnable {
.orElse(0L); .orElse(0L);
long txGas = gas - intrinsicGasCost - accessListCost; long txGas = gas - intrinsicGasCost - accessListCost;
final PrecompileContractRegistry precompileContractRegistry =
protocolSpec.getPrecompileContractRegistry();
final EVM evm = protocolSpec.getEvm(); final EVM evm = protocolSpec.getEvm();
Code code = evm.getCode(Hash.hash(codeBytes), codeBytes); Code code = evm.getCode(Hash.hash(codeBytes), codeBytes);
if (!code.isValid()) { if (!code.isValid()) {
@ -385,13 +381,12 @@ public class EvmToolCommand implements Runnable {
.miningBeneficiary(blockHeader.getCoinbase()) .miningBeneficiary(blockHeader.getCoinbase())
.blockHashLookup(new CachingBlockHashLookup(blockHeader, component.getBlockchain())) .blockHashLookup(new CachingBlockHashLookup(blockHeader, component.getBlockchain()))
.build(); .build();
Deque<MessageFrame> messageFrameStack = initialMessageFrame.getMessageFrameStack();
final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry);
final Deque<MessageFrame> messageFrameStack = initialMessageFrame.getMessageFrameStack();
stopwatch.start(); stopwatch.start();
while (!messageFrameStack.isEmpty()) { while (!messageFrameStack.isEmpty()) {
final MessageFrame messageFrame = messageFrameStack.peek(); final MessageFrame messageFrame = messageFrameStack.peek();
mcp.process(messageFrame, tracer); protocolSpec.getTransactionProcessor().process(messageFrame, tracer);
if (messageFrameStack.isEmpty()) { if (messageFrameStack.isEmpty()) {
stopwatch.stop(); stopwatch.stop();
if (lastTime == 0) { if (lastTime == 0) {

Loading…
Cancel
Save