Skip to content

evmtool binary, extracted from hyperledger besu

Notifications You must be signed in to change notification settings

contractshark/evmtool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title version description
EVM Tool Reference
2020-10
ethereum virtual machine command line tool

EVM Tool Reference

Options for running:

Quick Overview

$ ethereum/evmtool/build/install/evmtool/bin/evm --help
Usage:

evm [OPTIONS] [COMMAND]

Description:

This command evaluates EVM transactions.

Options:
      --code=<code>          Byte stream of code to be executed.
      --gas=<int>            Amount of gas for this invocation.
      --price=<int>          Price of gas (in GWei) for this invocation
      --sender=<address>     Calling address for this invocation.
      --receiver=<address>   Receiving address for this invocation.
      --input=<code>         The CALLDATA for this invocation
      --value=<int>          The amount of ether attached to this invocation
      --json                 Trace each opcode as a json object.
      --nomemory             Disable showing the full memory output for each op.
      --genesis, --prestate=<genesisFile>
                             The genesis file containing account data for this
                               invocation.
      --chain=<network>      Name of a well known network that will be used for
                               this invocation.
      --repeat=<repeat>      Number of times to repeat for benchmarking.
  -h, --help                 Show this help message and exit.
  -V, --version              Print version information and exit.
      --revert-reason-enabled[=<Boolean>]
                             Should revert reasons be persisted. (default: true)
      --key-value-storage=<keyValueStorageName>
                             Identity for the key-value storage to be used
                               (default: 'memory' alternate: 'rocksdb')
      --data-path=<PATH>     If using RocksDB storage, the path to Besu data
                               directory (default:
                               /Users/sbacha/besu-tool/build/data)
      --block-number=<blockParameter>
                             Block number to evaluate against (default:
                               'PENDING', or 'EARLIEST', 'LATEST', or a number)
Commands:
  state-test  Execute an Ethereum State Test.

Hyperledger Besu is licensed under the Apache License 2.0

Run Options

The first mode of the EVM tool runs an arbitrary EVM and is invoked without an extra command. Command Line Options specify the code and other contextual information.

code

"Syntax"
--code=<code as hex string>
"Example"
--code=5B600080808060045AFA50600056

The code to be executed, in compiled hex code form. There is no default value and execution fails if this is not set.

gas

"Syntax"
--gas=<gas as a decimal integer>
"Example"
--gas=100000000

Amount of gas to make available to the EVM. The default value is 10 Billion, an incredibly large number unlikely to be seen in any production blockchain.

price

"Syntax"
--price=<gas price in GWei as a decimal integer>
"Example"
--price=10

Price of gas in GWei. The default is zero. If set to a non-zero value, the sender account must have enough value to cover the gas fees.

sender

"Syntax"
--sender=<address>
"Example"
--sender=0xfe3b557e8fb62b89f4916b721be55ceb828dbd73

The account the invocation is sent from. The specified account must exist in the world state, which unless specified by --genesis or --prestate is the set of accounts used for testing.

receiver

"Syntax"
--receiver=<address>
"Example"
--receiver=0x588108d3eab34e94484d7cda5a1d31804ca96fe7

The account the invocation is sent to. The specified account does not need to exist.

input

"Syntax"
--input=<hex binary>
"Example"
--input=9064129300000000000000000000000000000000000000000000000000000000

The data passed into the call. Corresponds to the data field of the transaction and is returned by the CALLDATA and related opcodes.

value

"Syntax"
--value=<Wei in decimal>
"Example"
--value=1000000000000000000

The value of Ether attached to this transaction. For operations that query the value or transfer it to other accounts this is the amount that is available. The amount is not reduced to cover intrinsic cost and gas fees.

json

"Syntax"
--json=<boolean>
"Example"
--json=true

Provide an operation-by-operation trace of the command in json when set to true.

nomemory

"Syntax"
--nomemory=<boolean>
"Example"
--nomemory=true

By default, when tracing operations the memory is traced for each operation. For memory heavy scripts, setting this option may reduce the volume of json output.

genesis

"Syntax"
--genesis=<path>
"Example"
--genesis=/opt/besu/genesis.json

The Besu Genesis file to use when evaluating the EVM. Most useful are the alloc items that set up accounts and their stored memory states. For a complete description of this file see Genesis File Items.

--prestate is a deprecated alternative option name.

chain

"Syntax"
--chain=<mainnet|ropsten|rinkeby|goerli|classic|mordor|kotti|dev>
"Example"
--chain=goerli

The well-known network genesis file to use when evaluating the EVM. These values are an alternative to the --genesis option for well known networks.

repeat

"Syntax"
--repeat=<integer>
"Example"
--repeat=1000

Number of times to repeat the contract before gathering timing information. This is useful when benchmarking EVM operations.

revert-reason-enabled

"Syntax"
--revert-reason-enabled=<boolean>
"Example"
--revert-reason-enabled=true

If enabled, the json tracing includes the reason included in REVERT operations.

key-value-storage

"Syntax"
--key-value-storage=<memory|rocksdb>
"Example"
--key-value-storage=rocksdb

Kind of key value storage to use.

Occasionally it may be useful to execute isolated EVM calls in context of an actual world state. The default is memory, which executes the call only in context of the world provided by --genesis or --network at block zero. When set to rocksdb and combined with --data-path, --block-number, and --genesis a Besu node that is not currently running can be used to provide the appropriate world state for a transaction. Useful when evaluating consensus failures.

data-path

"Syntax"
--data-path=<path>
"Example"
--data-path=/opt/besu/data

When using rocksdb for key-value-storage, specifies the location of the database on disk.

block-number

"Syntax"
--block-number=<integer>
"Example"
--block-number=10000000

The block number to evaluate the code against. Used to ensure that the EVM is evaluating the code against the correct fork, or to specify the specific world state when running with rocksdb for key-value-storage.

State Test Options

The state-test sub command allows the Ethereum State Tests to be evaluated. Most of the options from EVM execution do not apply.

Applicable Options

json

"Syntax"
--json=<boolean>
"Example"
--json=true

Provide an operation by operation trace of the command in json when set to true. Set to true for EVMLab Fuzzing. Whether or not json is set, a summary JSON object is printed to standard output for each state test executed.

Using command arguments

If you use command arguments, you can list one or more state tests. All of the state tests are evaluated in the order they are specified.

"Docker Example"
docker run --rm -v ${PWD}:/opt/referencetests hyperledger/besu-evmtool:develop --json state-test /opt/referencetests/GeneralStateTests/stExample/add11.json
"CLI Example"
evm --json state-test stExample/add11.json

Using Standard Input

If no reference tests are passed in using the command line, the EVM Tool loads one complete json object from standard input and executes that state test.

"Docker Example"
docker run --rm  -i hyperledger/besu-evmtool:develop --json state-test < stExample/add11.json
"CLI Example"
evm --json state-test < stExample/add11.json