openethereum/evmbin/src/main.rs

675 lines
21 KiB
Rust
Raw Normal View History

// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Parity EVM Interpreter Binary.
//!
//! ## Overview
//!
//! The Parity EVM interpreter binary is a tool in the Parity
//! Ethereum toolchain. It is an EVM implementation for Parity Ethereum that
//! is used to run a standalone version of the EVM interpreter.
//!
//! ## Usage
//!
//! The evmbin tool is not distributed with regular Parity Ethereum releases
//! so you need to build it from source and run it like so:
//!
//! ```bash
//! cargo build -p evmbin --release
//! ./target/release/parity-evm --help
//! ```
#![warn(missing_docs)]
2016-10-17 11:55:47 +02:00
use std::sync::Arc;
use std::{fmt, fs};
use std::path::PathBuf;
use parity_bytes::Bytes;
use docopt::Docopt;
2017-07-06 11:36:15 +02:00
use rustc_hex::FromHex;
use ethereum_types::{U256, Address};
Extract spec to own crate (#10978) * Add client-traits crate Move the BlockInfo trait to new crate * New crate `machine` Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code. * Use new machine and client-traits crates in ethcore * Use new crates machine and client-traits instead of ethcore where appropriate * Fix tests * Don't re-export so many types from ethcore::client * Fixing more fallout from removing re-export * fix test * More fallout from not re-exporting types * Add some docs * cleanup * import the macro edition style * Tweak docs * Add missing import * remove unused ethabi_derive imports * Use latest ethabi-contract * Move many traits from ethcore/client/traits to client-traits crate Initial version of extracted Engine trait * Move snapshot related traits to the engine crate (eew) * Move a few snapshot related types to common_types Cleanup Executed as exported from machine crate * fix warning * Gradually introduce new engine crate: snapshot * ethcore typechecks with new engine crate * Sort out types outside ethcore * Add an EpochVerifier to ethash and use that in Engine.epoch_verifier() Cleanup * Document pub members * Sort out tests Sort out default impls for EpochVerifier * Add test-helpers feature and move EngineSigner impl to the right place * Sort out tests * Sort out tests and refactor verification types * Fix missing traits * More missing traits Fix Histogram * Fix tests and cleanup * cleanup * Put back needed logger import * Don't rexport common_types from ethcore/src/client Don't export ethcore::client::* * Remove files no longer used Use types from the engine crate Explicit exports from engine::engine * Get rid of itertools * Move a few more traits from ethcore to client-traits: BlockChainReset, ScheduleInfo, StateClient * Move ProvingBlockChainClient to client-traits * Don't re-export ForkChoice and Transition from ethcore * Address grumbles: sort imports, remove commented out code * Fix merge resolution error * Extract the Clique engine to own crate * Extract NullEngine and the block_reward module from ethcore * Extract InstantSeal engine to own crate * Extract remaining engines * Extract executive_state to own crate so it can be used by engine crates * Remove snapshot stuff from the engine crate * Put snapshot traits back in ethcore * cleanup * Remove stuff from ethcore * Don't use itertools * itertools in aura is legit-ish * More post-merge fixes * Re-export less types in client * cleanup * Extract spec to own crate * Put back the test-helpers from basic-authority * Fix ethcore benchmarks * Reduce the public api of ethcore/verification * Update ethcore/block-reward/Cargo.toml Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update ethcore/engines/basic-authority/Cargo.toml Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update ethcore/engines/ethash/Cargo.toml Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update ethcore/engines/clique/src/lib.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * signers is already a ref * Add an EngineType enum to tighten up Engine.name() * Introduce Snapshotting enum to distinguish the type of snapshots a chain uses * Rename supports_warp to snapshot_mode * Missing import * Update ethcore/src/snapshot/consensus/mod.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * missing import * Fix import * double semi
2019-08-23 15:32:58 +02:00
use ethcore::{json_tests, TrieSpec};
use spec;
use serde::Deserialize;
2017-08-10 18:47:23 +02:00
use vm::{ActionParams, CallType};
2017-08-01 16:41:33 +02:00
mod info;
mod display;
use crate::info::{Informant, TxInput};
const USAGE: &'static str = r#"
EVM implementation for Parity.
Copyright 2015-2019 Parity Technologies (UK) Ltd.
Usage:
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
parity-evm state-test <file> [--chain CHAIN --only NAME --json --std-json --std-dump-json --std-out-only --std-err-only]
2017-08-18 17:44:40 +02:00
parity-evm stats [options]
parity-evm stats-jsontests-vm <file>
2017-08-18 17:44:40 +02:00
parity-evm [options]
parity-evm [-h | --help]
Commands:
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
state-test Run a state test on a provided state test JSON file.
stats Execute EVM runtime code and return the statistics.
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
stats-jsontests-vm Execute standard json-tests on a provided state test JSON
file path, format VMTests, and return timing statistics
in tsv format.
Transaction options:
--code CODE Contract code as hex (without 0x).
2017-08-10 18:47:23 +02:00
--to ADDRESS Recipient address (without 0x).
--from ADDRESS Sender address (without 0x).
--input DATA Input data as hex (without 0x).
--gas GAS Supplied gas as hex (without 0x).
2017-08-10 18:47:23 +02:00
--gas-price WEI Supplied gas price as hex (without 0x).
State test options:
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
--chain CHAIN Run only from specific chain name (i.e. one of EIP150, EIP158,
Frontier, Homestead, Byzantium, Constantinople,
ConstantinopleFix, Istanbul, EIP158ToByzantiumAt5, FrontierToHomesteadAt5,
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
HomesteadToDaoAt5, HomesteadToEIP150At5).
--only NAME Runs only a single test matching the name.
General options:
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
--chain PATH Path to chain spec file.
--json Display verbose results in JSON.
--std-json Display results in standardized JSON format.
--std-dump-json Display results in standardized JSON format
with additional state dump.
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
--std-err-only With --std-json redirect to err output only.
--std-out-only With --std-json redirect to out output only.
-h, --help Display this message and exit.
"#;
fn main() {
panic_hook::set_abort();
env_logger::init();
2017-07-06 11:36:15 +02:00
let args: Args = Docopt::new(USAGE).and_then(|d| d.deserialize()).unwrap_or_else(|e| e.exit());
if args.cmd_state_test {
run_state_test(args)
} else if args.cmd_stats_jsontests_vm {
run_stats_jsontests_vm(args)
} else if args.flag_json {
run_call(args, display::json::Informant::default())
} else if args.flag_std_dump_json || args.flag_std_json {
if args.flag_std_err_only {
run_call(args, display::std_json::Informant::err_only())
} else if args.flag_std_out_only {
run_call(args, display::std_json::Informant::out_only())
} else {
run_call(args, display::std_json::Informant::default())
};
} else {
run_call(args, display::simple::Informant::default())
}
}
fn run_state_test(args: Args) {
use ethjson::state::test::Test;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Parse the specified state test JSON file provided to the command `state-test <file>`.
let file = args.arg_file.expect("PATH to a state test JSON file is required");
let mut file = match fs::File::open(&file) {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
Err(err) => die(format!("Unable to open path: {:?}: {}", file, err)),
Ok(file) => file,
};
let state_test = match Test::load(&mut file) {
Err(err) => die(format!("Unable to load the test file: {}", err)),
Ok(test) => test,
};
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Parse the name CLI option `--only NAME`.
let only_test = args.flag_only.map(|s| s.to_lowercase());
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Parse the chain `--chain CHAIN`
let only_chain = args.flag_chain.map(|s| s.to_lowercase());
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Iterate over 1st level (outer) key-value pair of the state test JSON file.
// Skip to next iteration if CLI option `--only NAME` was parsed into `only_test` and does not match
// the current key `state_test_name` (i.e. add11, create2callPrecompiles).
for (state_test_name, test) in state_test {
if let Some(false) = only_test.as_ref().map(|only_test| {
&state_test_name.to_lowercase() == only_test
}) {
continue;
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Assign from 2nd level key-value pairs of the state test JSON file (i.e. env, post, pre, transaction).
let multitransaction = test.transaction;
let env_info = test.env.into();
let pre = test.pre_state.into();
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Iterate over remaining "post" key of the 2nd level key-value pairs in the state test JSON file.
// Skip to next iteration if CLI option `--chain CHAIN` was parsed into `only_chain` and does not match
// the current key `fork_spec_name` (i.e. Constantinople, EIP150, EIP158).
for (fork_spec_name, states) in test.post_states {
if let Some(false) = only_chain.as_ref().map(|only_chain| {
&format!("{:?}", fork_spec_name).to_lowercase() == only_chain
}) {
continue;
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Iterate over the 3rd level key-value pairs of the state test JSON file
// (i.e. list of transactions and associated state roots hashes corresponding each chain).
for (tx_index, state) in states.into_iter().enumerate() {
let post_root = state.hash.into();
let transaction = multitransaction.select(&state.indexes).into();
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Determine the type of trie with state root to create in the database.
// The database is a key-value datastore implemented as a database-backend
// modified Merkle tree.
// Use a secure trie database specification when CLI option `--std-dump-json`
// is specified, otherwise use secure trie with fat trie database.
let trie_spec = if args.flag_std_dump_json {
TrieSpec::Fat
} else {
TrieSpec::Secure
};
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Execute the given transaction and verify resulting state root
// for CLI option `--std-dump-json` or `--std-json`.
if args.flag_std_dump_json || args.flag_std_json {
if args.flag_std_err_only {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root,
env_info: &env_info,
transaction,
informant: display::std_json::Informant::err_only(),
trie_spec,
};
// Use Standard JSON informant with err only
info::run_transaction(tx_input);
} else if args.flag_std_out_only {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root,
env_info: &env_info,
transaction,
informant: display::std_json::Informant::out_only(),
trie_spec,
};
// Use Standard JSON informant with out only
info::run_transaction(tx_input);
} else {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root,
env_info: &env_info,
transaction,
informant: display::std_json::Informant::default(),
trie_spec,
};
// Use Standard JSON informant default
info::run_transaction(tx_input);
}
} else {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// Execute the given transaction and verify resulting state root
// for CLI option `--json`.
if args.flag_json {
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root,
env_info: &env_info,
transaction,
informant: display::json::Informant::default(),
trie_spec,
};
// Use JSON informant
info::run_transaction(tx_input);
} else {
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root,
env_info: &env_info,
transaction,
informant: display::simple::Informant::default(),
trie_spec,
};
// Use Simple informant
info::run_transaction(tx_input);
}
}
}
}
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
fn run_stats_jsontests_vm(args: Args) {
use crate::json_tests::HookType;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
use std::collections::HashMap;
use std::time::{Instant, Duration};
let file = args.arg_file.expect("PATH to a state test JSON file is required");
let mut timings: HashMap<String, (Instant, Option<Duration>)> = HashMap::new();
{
let mut record_time = |name: &str, typ: HookType| {
match typ {
HookType::OnStart => {
timings.insert(name.to_string(), (Instant::now(), None));
},
HookType::OnStop => {
timings.entry(name.to_string()).and_modify(|v| {
v.1 = Some(v.0.elapsed());
});
},
}
};
if !file.is_file() {
json_tests::run_executive_test_path(&file, &[], &mut record_time);
} else {
json_tests::run_executive_test_file(&file, &mut record_time);
}
}
for (name, v) in timings {
println!("{}\t{}", name, display::as_micros(&v.1.expect("All hooks are called with OnStop; qed")));
}
}
// CLI command `stats`
2017-10-20 15:40:25 +02:00
fn run_call<T: Informant>(args: Args, informant: T) {
let code = arg(args.code(), "--code");
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let to = arg(args.to(), "--to");
let from = arg(args.from(), "--from");
let data = arg(args.data(), "--input");
let gas = arg(args.gas(), "--gas");
let gas_price = arg(args.gas_price(), "--gas-price");
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let spec = arg(args.spec(), "--chain");
Upgrade ethereum types (#10670) * cargo upgrade "ethereum-types" --all --allow-prerelease * [ethash] fix compilation errors * [ethkey] fix compilation errors * [journaldb] fix compilation errors * [dir] fix compilation errors * [ethabi] update to 0.7 * wip * [eip-712] fix compilation errors * [ethjson] fix compilation errors * [Cargo.toml] add TODO to remove patches * [ethstore] fix compilation errors * use patched keccak-hash with new primitive-types * wip * [ethcore-network-devp2p] fix compilation errors * [vm] fix compilation errors * [common-types, evm, wasm] fix compilation errors * [ethcore-db] Require AsRef instead of Deref for keys * [ethcore-blockchain] fix some compilation errors * [blooms-db] fix compilation errors Thanks a lot @dvdplm :) * we don't need no rlp ethereum feature * [ethcore] fix some compilation errors * [parity-ipfs-api] fix compilation error * [ethcore-light] fix compilation errors * [Cargo.lock] update parity-common * [ethcore-private-tx] fix some compilation errors * wip * [ethcore-private-tx] fix compilation errors * [parity-updater] fix compilation errors * [parity-rpc] fix compilation errors * [parity-bin] fix other compilation errors * update to new ethereum-types * update keccak-hash * [fastmap] fix compilation in tests * [blooms-db] fix compilation in tests * [common-types] fix compilation in tests * [triehash-ethereum] fix compilation in tests * [ethkey] fix compilation in tests * [pwasm-run-test] fix compilation errors * [wasm] fix compilation errors * [ethjson] fix compilation in tests * [eip-712] fix compilation in tests * [ethcore-blockchain] fix compilation in tests * [ethstore] fix compilation in tests * [ethstore-accounts] fix compilation in tests * [parity-hash-fetch] fix compilation in tests * [parity-whisper] fix compilation in tests * [ethcore-miner] fix compilation in tests * [ethcore-network-devp2p] fix compilation in tests * [*] upgrade rand to 0.6 * [evm] get rid of num-bigint conversions * [ethcore] downgrade trie-standardmap and criterion * [ethcore] fix some warnings * [ethcore] fix compilation in tests * [evmbin] fix compilation in tests * [updater] fix compilation in tests * [ethash] fix compilation in tests * [ethcore-secretstore] fix compilation in tests * [ethcore-sync] fix compilation in tests * [parity-rpc] fix compilation in tests * [ethcore] finally fix compilation in tests FUCK YEAH!!! * [ethstore] lazy_static is unused * [ethcore] fix test * fix up bad merge * [Cargo.toml] remove unused patches * [*] replace some git dependencies with crates.io * [Cargo.toml] remove unused lazy_static * [*] clean up * [ethcore] fix transaction_filter_deprecated test * [private-tx] fix serialization tests * fix more serialization tests * [ethkey] fix smoky test * [rpc] fix tests, please? * [ethcore] remove commented out code * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * [ethstore] remove unused dev-dependency * [ethcore] remove resolved TODO * [*] resolve keccak-hash TODO * [*] s/Address::default()/Address::zero() * [rpc] remove Subscribers::new_test * [rpc] remove EthPubSubClient::new_test * [ethcore] use trie-standardmap from crates.io * [dir] fix db_root_path * [ethcore] simplify snapshot::tests::helpers::fill_storage * Apply suggestions from code review Co-Authored-By: David <dvdplm@gmail.com> * [ethcore-secretstore] resolve TODO in serialization * [ethcore-network-devp2p] resolve TODO in save_key * [Cargo.lock] update triehash * [*] use ethabi from crates.io * [ethkey] use secp256k1 from master branch * [Cargo.lock] update eth-secp256k1
2019-06-03 15:36:21 +02:00
if code.is_none() && to == Address::zero() {
2017-08-10 18:47:23 +02:00
die("Either --code or --to is required.");
}
let mut params = ActionParams::default();
2017-08-10 18:47:23 +02:00
params.call_type = if code.is_none() { CallType::Call } else { CallType::None };
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
params.code = code.map(Arc::new);
2017-08-10 18:47:23 +02:00
params.code_address = to;
params.address = to;
params.sender = from;
params.origin = from;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
params.data = data;
params.gas = gas;
2017-08-10 18:47:23 +02:00
params.gas_price = gas_price;
let mut sink = informant.clone_sink();
let result = if args.flag_std_dump_json {
info::run_action(&spec, params, informant, TrieSpec::Fat)
} else {
info::run_action(&spec, params, informant, TrieSpec::Secure)
};
T::finish(result, &mut sink);
}
2017-07-06 11:36:15 +02:00
#[derive(Debug, Deserialize)]
struct Args {
cmd_stats: bool,
cmd_state_test: bool,
cmd_stats_jsontests_vm: bool,
arg_file: Option<PathBuf>,
flag_code: Option<String>,
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
flag_to: Option<String>,
flag_from: Option<String>,
flag_input: Option<String>,
flag_gas: Option<String>,
2017-08-10 18:47:23 +02:00
flag_gas_price: Option<String>,
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
flag_only: Option<String>,
2017-08-18 17:44:40 +02:00
flag_chain: Option<String>,
flag_json: bool,
flag_std_json: bool,
flag_std_dump_json: bool,
flag_std_err_only: bool,
flag_std_out_only: bool,
}
impl Args {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--code CODE`
/// Set the contract code in hex. Only send to either a contract code or a recipient address.
pub fn code(&self) -> Result<Option<Bytes>, String> {
match self.flag_code {
Some(ref code) => code.from_hex().map(Some).map_err(to_string),
None => Ok(None),
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--to ADDRESS`
/// Set the recipient address in hex. Only send to either a contract code or a recipient address.
pub fn to(&self) -> Result<Address, String> {
match self.flag_to {
Some(ref to) => to.parse().map_err(to_string),
None => Ok(Address::zero()),
2017-08-10 18:47:23 +02:00
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--from ADDRESS`
/// Set the sender address.
pub fn from(&self) -> Result<Address, String> {
match self.flag_from {
Some(ref from) => from.parse().map_err(to_string),
Upgrade ethereum types (#10670) * cargo upgrade "ethereum-types" --all --allow-prerelease * [ethash] fix compilation errors * [ethkey] fix compilation errors * [journaldb] fix compilation errors * [dir] fix compilation errors * [ethabi] update to 0.7 * wip * [eip-712] fix compilation errors * [ethjson] fix compilation errors * [Cargo.toml] add TODO to remove patches * [ethstore] fix compilation errors * use patched keccak-hash with new primitive-types * wip * [ethcore-network-devp2p] fix compilation errors * [vm] fix compilation errors * [common-types, evm, wasm] fix compilation errors * [ethcore-db] Require AsRef instead of Deref for keys * [ethcore-blockchain] fix some compilation errors * [blooms-db] fix compilation errors Thanks a lot @dvdplm :) * we don't need no rlp ethereum feature * [ethcore] fix some compilation errors * [parity-ipfs-api] fix compilation error * [ethcore-light] fix compilation errors * [Cargo.lock] update parity-common * [ethcore-private-tx] fix some compilation errors * wip * [ethcore-private-tx] fix compilation errors * [parity-updater] fix compilation errors * [parity-rpc] fix compilation errors * [parity-bin] fix other compilation errors * update to new ethereum-types * update keccak-hash * [fastmap] fix compilation in tests * [blooms-db] fix compilation in tests * [common-types] fix compilation in tests * [triehash-ethereum] fix compilation in tests * [ethkey] fix compilation in tests * [pwasm-run-test] fix compilation errors * [wasm] fix compilation errors * [ethjson] fix compilation in tests * [eip-712] fix compilation in tests * [ethcore-blockchain] fix compilation in tests * [ethstore] fix compilation in tests * [ethstore-accounts] fix compilation in tests * [parity-hash-fetch] fix compilation in tests * [parity-whisper] fix compilation in tests * [ethcore-miner] fix compilation in tests * [ethcore-network-devp2p] fix compilation in tests * [*] upgrade rand to 0.6 * [evm] get rid of num-bigint conversions * [ethcore] downgrade trie-standardmap and criterion * [ethcore] fix some warnings * [ethcore] fix compilation in tests * [evmbin] fix compilation in tests * [updater] fix compilation in tests * [ethash] fix compilation in tests * [ethcore-secretstore] fix compilation in tests * [ethcore-sync] fix compilation in tests * [parity-rpc] fix compilation in tests * [ethcore] finally fix compilation in tests FUCK YEAH!!! * [ethstore] lazy_static is unused * [ethcore] fix test * fix up bad merge * [Cargo.toml] remove unused patches * [*] replace some git dependencies with crates.io * [Cargo.toml] remove unused lazy_static * [*] clean up * [ethcore] fix transaction_filter_deprecated test * [private-tx] fix serialization tests * fix more serialization tests * [ethkey] fix smoky test * [rpc] fix tests, please? * [ethcore] remove commented out code * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * [ethstore] remove unused dev-dependency * [ethcore] remove resolved TODO * [*] resolve keccak-hash TODO * [*] s/Address::default()/Address::zero() * [rpc] remove Subscribers::new_test * [rpc] remove EthPubSubClient::new_test * [ethcore] use trie-standardmap from crates.io * [dir] fix db_root_path * [ethcore] simplify snapshot::tests::helpers::fill_storage * Apply suggestions from code review Co-Authored-By: David <dvdplm@gmail.com> * [ethcore-secretstore] resolve TODO in serialization * [ethcore-network-devp2p] resolve TODO in save_key * [Cargo.lock] update triehash * [*] use ethabi from crates.io * [ethkey] use secp256k1 from master branch * [Cargo.lock] update eth-secp256k1
2019-06-03 15:36:21 +02:00
None => Ok(Address::zero()),
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--input DATA`
/// Set the input data in hex.
pub fn data(&self) -> Result<Option<Bytes>, String> {
match self.flag_input {
Some(ref input) => input.from_hex().map_err(to_string).map(Some),
None => Ok(None),
2017-08-10 18:47:23 +02:00
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--gas GAS`
/// Set the gas limit in units of gas. Defaults to max value to allow code to run for whatever time is required.
pub fn gas(&self) -> Result<U256, String> {
match self.flag_gas {
Some(ref gas) => gas.parse().map_err(to_string),
None => Ok(U256::from(u64::max_value())),
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--gas-price WEI`
/// Set the gas price. Defaults to zero to allow the code to run even if an account with no balance
/// is used, otherwise such accounts would not have sufficient funds to pay the transaction fee.
/// Defaulting to zero also makes testing easier since it is not necessary to specify a special configuration file.
pub fn gas_price(&self) -> Result<U256, String> {
match self.flag_gas_price {
Some(ref gas_price) => gas_price.parse().map_err(to_string),
None => Ok(U256::zero()),
}
}
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
// CLI option `--chain PATH`
/// Set the path of the chain specification JSON file.
pub fn spec(&self) -> Result<spec::Spec, String> {
2017-08-18 17:44:40 +02:00
Ok(match self.flag_chain {
Some(ref filename) => {
let file = fs::File::open(filename).map_err(|e| e.to_string())?;
spec::Spec::load(&::std::env::temp_dir(), file).map_err(|e| e.to_string())?
},
None => {
spec::new_foundation(&::std::env::temp_dir())
},
})
}
}
fn arg<T>(v: Result<T, String>, param: &str) -> T {
v.unwrap_or_else(|e| die(format!("Invalid {}: {}", param, e)))
}
fn to_string<T: fmt::Display>(msg: T) -> String {
format!("{}", msg)
}
fn die<T: fmt::Display>(msg: T) -> ! {
println!("{}", msg);
::std::process::exit(-1)
}
2017-08-18 17:44:40 +02:00
#[cfg(test)]
mod tests {
use common_types::transaction;
2017-08-18 17:44:40 +02:00
use docopt::Docopt;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
use ethcore::{TrieSpec};
use ethjson::state::test::{State};
use serde::Deserialize;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
use super::{Args, USAGE, Address, run_call};
use crate::{
display::std_json::tests::informant,
info::{self, TxInput}
};
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
#[derive(Debug, PartialEq, Deserialize)]
pub struct SampleStateTests {
pub add11: State,
pub add12: State,
}
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstantinopleStateTests {
pub create2call_precompiles: State,
}
2017-08-18 17:44:40 +02:00
fn run<T: AsRef<str>>(args: &[T]) -> Args {
Docopt::new(USAGE).and_then(|d| d.argv(args.into_iter()).deserialize()).unwrap()
}
#[test]
fn should_parse_all_the_options() {
let args = run(&[
"parity-evm",
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
"--code", "05",
"--to", "0000000000000000000000000000000000000004",
"--from", "0000000000000000000000000000000000000003",
"--input", "06",
"--gas", "1",
"--gas-price", "2",
"--chain", "./testfile.json",
2017-08-18 17:44:40 +02:00
"--json",
"--std-json",
"--std-dump-json",
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
"--std-err-only",
"--std-out-only",
2017-08-18 17:44:40 +02:00
]);
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
assert_eq!(args.code(), Ok(Some(vec![05])));
assert_eq!(args.to(), Ok(Address::from_low_u64_be(4)));
assert_eq!(args.from(), Ok(Address::from_low_u64_be(3)));
assert_eq!(args.data(), Ok(Some(vec![06]))); // input data
assert_eq!(args.gas(), Ok(1.into()));
assert_eq!(args.gas_price(), Ok(2.into()));
assert_eq!(args.flag_chain, Some("./testfile.json".to_owned()));
2017-08-18 17:44:40 +02:00
assert_eq!(args.flag_json, true);
assert_eq!(args.flag_std_json, true);
assert_eq!(args.flag_std_dump_json, true);
assert_eq!(args.flag_std_err_only, true);
assert_eq!(args.flag_std_out_only, true);
2017-08-18 17:44:40 +02:00
}
#[test]
fn should_parse_state_test_command() {
let args = run(&[
"parity-evm",
"state-test",
"./file.json",
"--chain", "homestead",
"--only=add11",
"--json",
"--std-json",
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
"--std-dump-json",
"--std-out-only",
"--std-err-only",
]);
assert_eq!(args.cmd_state_test, true);
assert!(args.arg_file.is_some());
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
assert_eq!(args.flag_chain, Some("homestead".to_owned()));
assert_eq!(args.flag_only, Some("add11".to_owned()));
assert_eq!(args.flag_json, true);
assert_eq!(args.flag_std_json, true);
assert_eq!(args.flag_std_dump_json, true);
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
assert_eq!(args.flag_std_out_only, true);
assert_eq!(args.flag_std_err_only, true);
}
#[test]
#[should_panic]
fn should_not_parse_only_flag_without_state_test() {
let _ = run(&[
"parity-evm",
"./file.json",
"--chain", "homestead",
"--only=add11",
"--json",
]);
}
#[test]
#[should_panic]
fn should_not_parse_only_flag_with_stats() {
let _ = run(&[
"parity-evm",
"stats",
"./file.json",
"--chain", "homestead",
"--only=add11",
"--json",
]);
}
#[test]
fn should_not_verify_state_root_using_sample_state_test_json_file() {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let state_tests = include_str!("../res/teststate.json");
// Parse the specified state test JSON file to simulate the CLI command `state-test <file>`.
let deserialized_state_tests: SampleStateTests = serde_json::from_str(state_tests)
.expect("Serialization cannot fail; qed");
// Simulate the name CLI option `--only NAME`
let state_test_name = "add11";
let pre = deserialized_state_tests.add11.pre_state.into();
let env_info = deserialized_state_tests.add11.env.into();
let multitransaction = deserialized_state_tests.add11.transaction;
for (fork_spec_name, tx_states) in deserialized_state_tests.add11.post_states.iter() {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
for (tx_index, tx_state) in tx_states.into_iter().enumerate() {
let (informant, _, res) = informant();
let trie_spec = TrieSpec::Secure;
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let transaction: transaction::SignedTransaction = multitransaction.select(&tx_state.indexes).into();
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root: tx_states[tx_index].hash.0,
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
env_info: &env_info,
transaction,
informant,
trie_spec,
};
assert!(!info::run_transaction(tx_input));
assert!(
&String::from_utf8_lossy(&**res.0.lock().unwrap()).contains("State root mismatch")
);
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
}
}
}
#[test]
fn should_verify_state_root_using_constantinople_state_test_json_file() {
let state_tests = include_str!("../res/create2callPrecompiles.json");
// Parse the specified state test JSON file to simulate the CLI command `state-test <file>`.
let deserialized_state_tests: ConstantinopleStateTests = serde_json::from_str(state_tests)
.expect("Serialization cannot fail; qed");
// Simulate the name CLI option `--only NAME`
let state_test_name = "create2callPrecompiles";
let pre = deserialized_state_tests.create2call_precompiles.pre_state.into();
let env_info = deserialized_state_tests.create2call_precompiles.env.into();
let multitransaction = deserialized_state_tests.create2call_precompiles.transaction;
for (fork_spec_name, tx_states) in deserialized_state_tests.create2call_precompiles.post_states.iter() {
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
for (tx_index, tx_state) in tx_states.into_iter().enumerate() {
let (informant, _, _) = informant();
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
let trie_spec = TrieSpec::Secure; // TrieSpec::Fat for --std_dump_json
let transaction: transaction::SignedTransaction = multitransaction.select(&tx_state.indexes).into();
let tx_input = TxInput {
state_test_name: &state_test_name,
tx_index,
fork_spec_name: &fork_spec_name,
pre_state: &pre,
post_root: tx_states[tx_index].hash.0,
refactor: Refactor evmbin CLI (#10742) * 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
2019-08-07 16:51:08 +02:00
env_info: &env_info,
transaction,
informant,
trie_spec,
};
assert!(info::run_transaction(tx_input));
}
}
}
#[test]
fn should_error_out_of_gas() {
let args = run(&[
"parity-evm",
"stats",
"--to", "0000000000000000000000000000000000000004",
"--from", "0000000000000000000000000000000000000003",
"--code", "05",
"--input", "06",
"--gas", "1",
"--gas-price", "2",
"--only=add11",
"--std-json",
"--std-out-only",
]);
let (inf, _, res) = informant();
run_call(args, inf);
assert!(
&String::from_utf8_lossy(&**res.0.lock().unwrap())
.starts_with(r#"{"error":"EVM: Out of gas","gasUsed":"0x1","#),
);
}
#[test]
fn should_not_error_out_of_gas() {
let args = run(&[
"parity-evm",
"stats",
"--to", "0000000000000000000000000000000000000004",
"--from", "0000000000000000000000000000000000000003",
"--code", "05",
"--input", "06",
"--gas", "21",
"--gas-price", "2",
"--only=add11",
"--std-json",
"--std-out-only",
]);
let (inf, _, res) = informant();
run_call(args, inf);
assert!(
&String::from_utf8_lossy(&**res.0.lock().unwrap())
.starts_with(r#"{"output":"0x06","gasUsed":"0x12","#),
);
}
2017-08-18 17:44:40 +02:00
}