openethereum/evmbin/src/display/simple.rs

61 lines
1.7 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/>.
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
//! Log EVM instruction output data traces from a simple formatting informant.
Move more code into state-account (#10840) * WIP move errors, pod_account and state account to own crates * Sort out dependencies, fix broken code and tests Remove botched ethcore-error crate * remove template line * fix review feedback * Remove test-only AccountDBMut::new * Extract AccountDB to account-db * Move Substate to state-account – wip * Add lib.rs * cleanup * test failure * test failure 2 * third time's the charm * Add factories crate * Use new factories crate * Use factories crate * Extract trace * Fix tests * Sort out parity-util-mem and parking_lot * cleanup * WIP port over the rest of state from ethcore * Collect all impls for Machine * some notes * Rename pod-account to pod * Move PodState to pod crate * Use PodState from pod crate * Fix use clause for json tests * Sort out evmbin * Add missing code and use PodState * Move code that depends on Machine and Executive to own module * Sort out cloning errors, fix ethcore to use new state crate * Do without funky From impls * Fix ethcore tests * Fixes around the project to use new state crate * Add back the more specific impls of StateOrBlock From conversions * Move execute to freestanding function and remove it from trait Sort out the error handling in executive_state by moving the result types from state to ethcore Undo the verbose code added to work around the StateOrBlock From conversions * cleanup * Fix "error: enum variants on type aliases are experimental" * Bring back the state tests Fix whitespace * remove ethcore/state/mod.rs * cleanup * cleanup * Cleanup state-account errors * Fix more todos Add module docs * Add error.rs * Fixup Cargo.lock * Smaller ethcore API is fine * Add `to-pod-full` feature to state-account Fix evmbin * Fix a few more test failures * Fix RPC test build * Baptize the new trait * Remove resolved TODOs * Rename state-account to account-state * Do not re-export the trace crate * Don't export state_db from ethcore * Let private-tx use StateDB. :( * Remove ethcore/src/pod_state.rs * Inner type does not need to be pub/pub(crate) * optimise imports * Revert "Inner type does not need to be pub/pub(crate)" This reverts commit 2f839f8a0f72f71334da64620f57e6dd6039f06b. * Move DatabaseExtras to ethcore-blockchain * Add database_extra module to ethcore-blockchain * Remove to-pod-full feature * Sort out the merge * sort imports * address grumbles * rename crate * address more grumbles
2019-07-08 18:17:48 +02:00
use trace;
use bytes::ToPretty;
use display;
2017-08-01 16:41:33 +02:00
use info as vm;
/// Simple formatting informant.
#[derive(Default)]
pub struct Informant;
impl vm::Informant for Informant {
type Sink = ();
fn before_test(&mut self, name: &str, action: &str) {
println!("Test: {} ({})", name, action);
}
fn clone_sink(&self) -> Self::Sink { () }
fn finish(result: vm::RunResult<Self::Output>, _sink: &mut Self::Sink) {
match result {
Ok(success) => {
println!("Output: 0x{}", success.output.to_hex());
println!("Gas used: {:x}", success.gas_used);
println!("Time: {}", display::format_time(&success.time));
},
Err(failure) => {
println!("Error: {}", failure.error);
println!("Time: {}", display::format_time(&failure.time));
},
}
}
}
impl trace::VMTracer for Informant {
2017-10-20 15:40:25 +02:00
type Output = ();
2018-10-02 16:33:19 +02:00
fn prepare_subtrace(&mut self, _code: &[u8]) { Default::default() }
fn done_subtrace(&mut self) {}
2017-10-20 15:40:25 +02:00
fn drain(self) -> Option<()> { None }
}