Skip to content

Commit

Permalink
EVMTool contract create processing (hyperledger#5755)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
shemnon authored and elenduuche committed Aug 16, 2023
1 parent dc84b4f commit d30a800
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,21 +506,17 @@ public TransactionProcessingResult processTransaction(
}
}

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
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;
Expand Down Expand Up @@ -344,8 +342,6 @@ public void run() {
.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()) {
Expand Down Expand Up @@ -385,13 +381,12 @@ public void run() {
.miningBeneficiary(blockHeader.getCoinbase())
.blockHashLookup(new CachingBlockHashLookup(blockHeader, component.getBlockchain()))
.build();
Deque<MessageFrame> messageFrameStack = initialMessageFrame.getMessageFrameStack();

final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry);
final Deque<MessageFrame> 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) {
Expand Down

0 comments on commit d30a800

Please sign in to comment.