Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVMTool contract create processing #5755

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -510,21 +510,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;
daniellehrner marked this conversation as resolved.
Show resolved Hide resolved
};
}

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 @@ -345,8 +343,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 @@ -390,11 +386,10 @@ public void run() {
.blockHashLookup(new CachingBlockHashLookup(blockHeader, component.getBlockchain()))
.build());

final MessageCallProcessor mcp = new MessageCallProcessor(evm, precompileContractRegistry);
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 Expand Up @@ -448,7 +443,7 @@ public static void dumpWorldState(final WorldState worldState, final PrintWriter
account -> {
out.println(
" \"" + account.getAddress().map(Address::toHexString).orElse("-") + "\": {");
if (account.getCode() != null && account.getCode().size() > 0) {
if (account.getCode() != null && !account.getCode().isEmpty()) {
out.println(" \"code\": \"" + account.getCode().toHexString() + "\",");
}
NavigableMap<Bytes32, AccountStorageEntry> storageEntries =
Expand Down
Loading