Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
refactor: Refactor evmbin CLI (#10742)
Browse files Browse the repository at this point in the history
* docs: Add comments to run_transaction arguments

* docs: Add general state test example from github.com/ethereum/test

* docs: Add state test file used in ethjson

* refactor: Reorder CLI options. Modify CLI descriptions. See commit comments

* Reorder parity-evm CLI options
* Update descriptions for CLI options
* Change to `--chain PATH` (general) and `--chain CHAIN` (state test)
* Remove unncessary 'Display result state dump in standardized JSON format.

* refactor: Move  function to be ordered after

* refactor: Refactor run_state_test

* refactor: Modify run_stats_jsontests_vm comment to be more specific

* refactor: Refactor run_call

* refactor: Update Args struct including rustdocs

* refactor: Reorder functions in Args struct to match other orders

* tests: Update tests for evmbin

* revert unintentional changes

* comply with style guide

* docs: Info and Display Modules made public so appear in rustdocs

* docs: Rename VM to EVM

* docs: Update rustdocs

* docs: Update state-test cli command comments

Co-Authored-By: David <dvdplm@gmail.com>

* docs: Update chain path cli command description

Co-Authored-By: David <dvdplm@gmail.com>

* docs: Prefix to specify only one chain type to be provided

Co-Authored-By: David <dvdplm@gmail.com>

* docs: Update to be lowercase fat

Co-Authored-By: David <dvdplm@gmail.com>

* rename err to stderr, out to stdout

* revert to wei for gas price

* review-fix: Do not expose private modules but still show docs

View docs with:
```
cargo doc -p evmbin --document-private-items --open
```

* test: Read from file. Add initial tests for state-test CLI command

* review-fix: Change to single TODO that links to new issue to create integration tests

* refactor: Move run_transaction params into fields of a TxInput struct and make doc comments of its fields (#10769)

* Question

* refactor: Further changes for doc comments to be part of public struct

* refactor: Rename InputData to TxInput for clarity in docs

* docs: Change String to fixed length str

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* refactor: Update evmbin/src/info.rs moving mut into fn declaration

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* refactor: Update evmbin/src/info.rs moving mut into fn declaration part 2

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* review-fix: Add missing docs to TxInput transaction and trie_spec

* docs: Improve grammar

* review-fix: Destructure tx_input

* WIP

* review-fix: Rename variables of InputTx

* rename `spec_from_json` to `fork_spec_from_json`
* rename `name` to `state_test_name`
* rename `spec` to `fork_spec_name`
* rename `spec_checked` to `fork_spec`

* review-fix: Rename idx to tx_index

* fix indentation

* review-fix: Add missing part of tests. Yet to fix tests and add assertions

* [evmbin] remove state-db dependency

* [evmbin] run_transaction returns bool

* [evmbin] more cleanup
  • Loading branch information
ltfschoen authored and dvdplm committed Aug 7, 2019
1 parent 4695452 commit c689495
Show file tree
Hide file tree
Showing 15 changed files with 709 additions and 168 deletions.
2 changes: 1 addition & 1 deletion ethcore/src/client/evm_test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a> fmt::Debug for EvmTestClient<'a> {

impl<'a> EvmTestClient<'a> {
/// Converts a json spec definition into spec.
pub fn spec_from_json(spec: &ForkSpec) -> Option<spec::Spec> {
pub fn fork_spec_from_json(spec: &ForkSpec) -> Option<spec::Spec> {
match *spec {
ForkSpec::Frontier => Some(ethereum::new_frontier_test()),
ForkSpec::Homestead => Some(ethereum::new_homestead_test()),
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn json_chain_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_ho
flush!(" - {}...", name);

let spec = {
let mut spec = match EvmTestClient::spec_from_json(&blockchain.network) {
let mut spec = match EvmTestClient::fork_spec_from_json(&blockchain.network) {
Some(spec) => spec,
None => {
println!(" - {} | {:?} Ignoring tests because of missing spec", name, blockchain.network);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn json_chain_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_ho

for (spec_name, states) in test.post_states {
let total = states.len();
let spec = match EvmTestClient::spec_from_json(&spec_name) {
let spec = match EvmTestClient::fork_spec_from_json(&spec_name) {
Some(spec) => spec,
None => {
println!(" - {} | {:?} Ignoring tests because of missing spec", name, spec_name);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/json_tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu
start_stop_hook(&name, HookType::OnStart);

for (spec_name, result) in test.post_state {
let spec = match EvmTestClient::spec_from_json(&spec_name) {
let spec = match EvmTestClient::fork_spec_from_json(&spec_name) {
Some(spec) => spec,
None => {
println!(" - {} | {:?} Ignoring tests because of missing spec", name, spec_name);
Expand Down
2 changes: 1 addition & 1 deletion ethcore/types/src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl UnverifiedTransaction {
self
}

/// Checks is signature is empty.
/// Checks if the signature is empty.
pub fn is_unsigned(&self) -> bool {
self.r.is_zero() && self.s.is_zero()
}
Expand Down
2 changes: 1 addition & 1 deletion evmbin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ name = "parity-evm"
path = "./src/main.rs"

[dependencies]
account-state = { path = "../ethcore/account-state" }
common-types = { path = "../ethcore/types" }
docopt = "1.0"
env_logger = "0.5"
Expand All @@ -23,7 +24,6 @@ rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
account-state = { path = "../ethcore/account-state" }
trace = { path = "../ethcore/trace" }
vm = { path = "../ethcore/vm" }

Expand Down
2 changes: 1 addition & 1 deletion evmbin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Transaction options:
--gas-price WEI Supplied gas price as hex (without 0x).
State test options:
--only NAME Runs only a single test matching the name.
--only NAME Runs only a single state test matching the name.
--chain CHAIN Run only tests from specific chain.
General options:
Expand Down
140 changes: 140 additions & 0 deletions evmbin/res/create2callPrecompiles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"create2callPrecompiles": {
"_info": {
"comment": "CALL precompiles during init code of CREATE2 contract ",
"filledwith": "testeth 1.5.0.dev2-73+commit.1bcd29e5",
"lllcversion": "Version: 0.4.26-develop.2018.9.19+commit.785cbf40.Linux.g++",
"source": "src/GeneralStateTestsFiller/stCreate2/create2callPrecompilesFiller.json",
"sourceHash": "0dcd6d7b5819f61399ecfba9a67b7518c92c426866bd5b599516c184d194e51c"
},
"env": {
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty": "0x20000",
"currentGasLimit": "0xe8d4a51000",
"currentNumber": "0x01",
"currentTimestamp": "0x03e8",
"previousHash": "0x5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"post": {
"Constantinople": [
{
"hash": "0x3dfdcd1d19badbbba8b0c953504e8b4685270ee5b86e155350b6ef1042c9ce43",
"indexes": {
"data": 0,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0x88803085d3420aec76078e215f67fc5f7b6f297fbe19d85c2236ad685d0fc7fc",
"indexes": {
"data": 1,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0x57181dda5c067cb31f084c4118791b40d5028c39071e83e60e7f7403d683527e",
"indexes": {
"data": 2,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0xf04c1039893eb6959354c3c16e9fe025d4b9dc3981362f79c56cc427dca0d544",
"indexes": {
"data": 3,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0x5d5db3d6c4377b34b74ecf8638f684acb220cc7ce286ae5f000ffa74faf38bae",
"indexes": {
"data": 4,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0xf8343b2e05ae120bf25947de840cedf1ca2c1bcda1cdb89d218427d8a84d4798",
"indexes": {
"data": 5,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0x305a8a8a7d9da97d14ed2259503d9373d803ea4b7fbf8c360f50b1b30a3d04ed",
"indexes": {
"data": 6,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
{
"hash": "0xde1d3953b508913c6e3e9bd412cd50daf60bb177517e5d1e8ccb0dab193aed03",
"indexes": {
"data": 7,
"gas": 0,
"value": 0
},
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}
]
},
"pre": {
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x0de0b6b3a7640000",
"code": "",
"nonce": "0x00",
"storage": {
}
},
"0xaddf5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x00",
"code": "0x600035600052602035602052604035604052606035606052604060c860806000600060066207a120f260005560c85160015560e851600255",
"nonce": "0x00",
"storage": {
}
},
"0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x00",
"code": "0x60003560005260203560205260403560405260603560605260803560805260a03560a05260c03560c052604061012c60806000600060066207a120f2600055604061019060606080600060076207a120f260015561012c51600a5561014c51600b55610190516014556101b051601555601454600a5414600255601554600b5414600355",
"nonce": "0x00",
"storage": {
}
}
},
"transaction": {
"data": [
"0x6000609a80601260003960006000f55000fe7f18c547e4f7b0f325ad1e56f57e26c745b09a3e503d86e00e5255ff7f715d3d1c600052601c6020527f73b1693892219d736caba55bdb67216e485557ea6b6af75f37096c9aa6a5a75f6040527feeb940b1d03b21e36b0e47e79769f095fe2ab855bd91e3a38756b7d75a9c4549606052602060806080600060006001620493e0f160025560a060020a60805106600055600054321460015500",
"0x6000602380601260003960006000f55000fe64f34578907f6005526020600060256000600060026101f4f160025560005160005500",
"0x6000601a80601260003960006000f55000fe602060006000600060006003610258f160025560005160005500",
"0x6000602380601260003960006000f55000fe64f34578907f6000526020600060256000600060046101f4f160025560005160005500",
"0x6000609580601260003960006000f55000fe6001600052602060205260206040527f03fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc6060527f2efffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc6080527f2f0000000000000000000000000000000000000000000000000000000000000060965260206103e860976000600060055af26001556103e85160025500",
"0x6000602180601260003960006000f55000fe600160005260206000610100600060006006620927c0f160025560005160005500",
"0x600060b680601260003960006000f55000fe7f0f25929bcb43d5a57391564615c9e70a992b10eafa4db109709649cf48c50dd26000527f16da2f5cb6be7a0aa72c440c53c9bbdfec6c36c7d515536431b3a865468acbba6020527f1de49a4b0233273bba8146af82042d004f2085ec982397db0d97da17204cc2866040527f0217327ffc463919bef80cc166d09c6172639d8589799928761bcd9f22c903d46060526000600060806000600073addf5374fce5edbc8e2a8697c15331677e6ebf0b6207a120f25000",
"0x600060c580601260003960006000f55000fe7f1de49a4b0233273bba8146af82042d004f2085ec982397db0d97da17204cc2866000527f0217327ffc463919bef80cc166d09c6172639d8589799928761bcd9f22c903d4602052600060405260006060527f1de49a4b0233273bba8146af82042d004f2085ec982397db0d97da17204cc2866080527f0217327ffc463919bef80cc166d09c6172639d8589799928761bcd9f22c903d460a052600160c0526000600060e06000600073b94f5374fce5edbc8e2a8697c15331677e6ebf0b6207a120f25000"
],
"gasLimit": [
"0xe4e1c0"
],
"gasPrice": "0x01",
"nonce": "0x00",
"secretKey": "0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to": "",
"value": [
"0x01"
]
}
}
}
144 changes: 144 additions & 0 deletions evmbin/res/teststate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"add11": {
"env": {
"currentCoinbase": "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty": "0x0100",
"currentGasLimit": "0x01c9c380",
"currentNumber": "0x00",
"currentTimestamp": "0x01",
"previousHash": "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"post": {
"EIP150": [
{
"hash": "3e6dacc1575c6a8c76422255eca03529bbf4c0dda75dfc110b22d6dc4152396f",
"indexes": { "data": 0, "gas": 0, "value": 0 }
},
{
"hash": "99a450d8ce5b987a71346d8a0a1203711f770745c7ef326912e46761f14cd764",
"indexes": { "data": 0, "gas": 0, "value": 1 }
}
],
"EIP158": [
{
"hash": "3e6dacc1575c6a8c76422255eca03529bbf4c0dda75dfc110b22d6dc4152396f",
"indexes": { "data": 0, "gas": 0, "value": 0 }
},
{
"hash": "99a450d8ce5b987a71346d8a0a1203711f770745c7ef326912e46761f14cd764",
"indexes": { "data": 0, "gas": 0, "value": 1 }
}
]
},
"pre": {
"1000000000000000000000000000000000000000": {
"balance": "0x0de0b6b3a7640000",
"code": "0x6040600060406000600173100000000000000000000000000000000000000162055730f1600055",
"nonce": "0x00",
"storage": {
}
},
"1000000000000000000000000000000000000001": {
"balance": "0x0de0b6b3a7640000",
"code": "0x604060006040600060027310000000000000000000000000000000000000026203d090f1600155",
"nonce": "0x00",
"storage": {
}
},
"1000000000000000000000000000000000000002": {
"balance": "0x00",
"code": "0x600160025533600455346007553060e6553260e8553660ec553860ee553a60f055",
"nonce": "0x00",
"storage": {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x0de0b6b3a7640000",
"code": "0x",
"nonce": "0x00",
"storage": {
}
}
},
"transaction": {
"data": [ "" ],
"gasLimit": [ "285000", "100000", "6000" ],
"gasPrice": "0x01",
"nonce": "0x00",
"secretKey": "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to": "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value": [ "10", "0" ]
}
},
"add12": {
"env": {
"currentCoinbase": "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty": "0x0100",
"currentGasLimit": "0x01c9c380",
"currentNumber": "0x00",
"currentTimestamp": "0x01",
"previousHash": "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"post": {
"EIP150": [
{
"hash": "3e6dacc1575c6a8c76422255eca03529bbf4c0dda75dfc110b22d6dc4152396f",
"indexes": { "data": 0, "gas": 0, "value": 0 }
},
{
"hash": "99a450d8ce5b987a71346d8a0a1203711f770745c7ef326912e46761f14cd764",
"indexes": { "data": 0, "gas": 0, "value": 1 }
}
],
"EIP158": [
{
"hash": "3e6dacc1575c6a8c76422255eca03529bbf4c0dda75dfc110b22d6dc4152396f",
"indexes": { "data": 0, "gas": 0, "value": 0 }
},
{
"hash": "99a450d8ce5b987a71346d8a0a1203711f770745c7ef326912e46761f14cd764",
"indexes": { "data": 0, "gas": 0, "value": 1 }
}
]
},
"pre": {
"1000000000000000000000000000000000000000": {
"balance": "0x0de0b6b3a7640000",
"code": "0x6040600060406000600173100000000000000000000000000000000000000162055730f1600055",
"nonce": "0x00",
"storage": {
}
},
"1000000000000000000000000000000000000001": {
"balance": "0x0de0b6b3a7640000",
"code": "0x604060006040600060027310000000000000000000000000000000000000026203d090f1600155",
"nonce": "0x00",
"storage": {
}
},
"1000000000000000000000000000000000000002": {
"balance": "0x00",
"code": "0x600160025533600455346007553060e6553260e8553660ec553860ee553a60f055",
"nonce": "0x00",
"storage": {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0x0de0b6b3a7640000",
"code": "0x",
"nonce": "0x00",
"storage": {
}
}
},
"transaction": {
"data": [ "" ],
"gasLimit": [ "285000", "100000", "6000" ],
"gasPrice": "0x01",
"nonce": "0x00",
"secretKey": "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to": "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value": [ "10", "0" ]
}
}
}
2 changes: 1 addition & 1 deletion evmbin/src/display/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

//! JSON VM output.
//! Log EVM instruction output data traces from a JSON formatting informant.

use std::collections::HashMap;
use std::mem;
Expand Down
2 changes: 1 addition & 1 deletion evmbin/src/display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

//! VM Output display utils.
//! EVM output display utils.

use std::time::Duration;

Expand Down
2 changes: 1 addition & 1 deletion evmbin/src/display/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

//! Simple VM output.
//! Log EVM instruction output data traces from a simple formatting informant.

use trace;
use bytes::ToPretty;
Expand Down
Loading

0 comments on commit c689495

Please sign in to comment.