Skip to content

Commit

Permalink
EVMTool Docker Support (#7430)
Browse files Browse the repository at this point in the history
A few fixes that re-enable docker support for evm tool
* evmtool is the entrypoint
* turn off some noisy logging
* ensure EOF respects the create flag

Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon authored Aug 7, 2024
1 parent 7433c8c commit a92fdbb
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)

### Bug fixes
- Correct entrypoint in Docker evmtool [#7430](https://github.com/hyperledger/besu/pull/7430)

## 24.7.1

Expand Down
2 changes: 1 addition & 1 deletion ethereum/evmtool/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WORKDIR /opt/besu-evmtool
COPY --chown=besu:besu besu-evmtool /opt/besu-evmtool/

ENV PATH="/opt/besu-evmtool/bin:${PATH}"
ENTRYPOINT ["evm"]
ENTRYPOINT ["evmtool"]

# Build-time metadata as defined at http://label-schema.org
ARG BUILD_DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public EvmTool() {}
* @param args The command line arguments.
*/
public static void main(final String... args) {
LogConfigurator.setLevel("", "DEBUG");
LogConfigurator.setLevel("", "OFF");
final EvmToolCommand evmToolCommand = new EvmToolCommand();

evmToolCommand.execute(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.evmtool;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hyperledger.besu.evm.code.EOFLayout.EOFContainerMode.INITCODE;
import static picocli.CommandLine.ScopeType.INHERIT;

import org.hyperledger.besu.cli.config.NetworkName;
Expand All @@ -34,6 +35,7 @@
import org.hyperledger.besu.evm.EVM;
import org.hyperledger.besu.evm.EvmSpecVersion;
import org.hyperledger.besu.evm.code.CodeInvalid;
import org.hyperledger.besu.evm.code.CodeV1;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.log.LogsBloomFilter;
import org.hyperledger.besu.evm.tracing.OperationTracer;
Expand Down Expand Up @@ -418,11 +420,21 @@ public void run() {
if (codeBytes.isEmpty() && !createTransaction) {
codeBytes = component.getWorldState().get(receiver).getCode();
}
Code code = evm.getCodeForCreation(codeBytes);
Code code =
createTransaction ? evm.getCodeForCreation(codeBytes) : evm.getCodeUncached(codeBytes);
if (!code.isValid()) {
out.println(((CodeInvalid) code).getInvalidReason());
return;
} else if (code.getEofVersion() == 1
&& createTransaction
!= INITCODE.equals(((CodeV1) code).getEofLayout().containerMode().get())) {
out.println(
createTransaction
? "--create requires EOF in INITCODE mode"
: "To evaluate INITCODE mode EOF code use the --create flag");
return;
}

final Stopwatch stopwatch = Stopwatch.createUnstarted();
long lastTime = 0;
do {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"cli": [
"--notime",
"--json",
"--create",
"--code",
"ef00010100040200010001040000000080000000c0de471fe5",
"--coinbase",
"4444588443C3A91288C5002483449ABA1054192B",
"--fork",
"CancunEOF"
],
"stdin": "",
"stdout": "EOF Code Invalid : STOP is only a valid opcode in containers used for runtime operations.\n"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"cli": [
"--notime",
"--json",
"--code",
"ef00010100040200010001040000000080000000",
"--coinbase",
"4444588443C3A91288C5002483449ABA1054192B",
"--fork",
"CancunEOF"
],
"stdin": "",
"stdout": [
{"pc":0,"section":0,"op":0,"gas":"0x2540be400","gasCost":"0x0","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"STOP"},
{"gasUser":"0x0","gasTotal":"0x0","output":"0x"}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cli": [
"--notime",
"--json",
"--code",
"ef00010100040200010009030001001404000000008000035f355f5fa15f5fee00ef00010100040200010001040000000080000000",
"--coinbase",
"4444588443C3A91288C5002483449ABA1054192B",
"--fork",
"CancunEOF"
],
"stdin": "",
"stdout": "To evaluate INITCODE mode EOF code use the --create flag\n"
}

0 comments on commit a92fdbb

Please sign in to comment.