1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
// Copyright 2015-2020 Parity Technologies (UK) Ltd. // This file is part of Tetsy Vapory. // Tetsy Vapory 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. // Tetsy Vapory 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 Tetsy Vapory. If not, see <http://www.gnu.org/licenses/>. //! State machine types use vapory_types::{Address, U256}; use bytes::Bytes; use crate::{ log_entry::LogEntry, receipt, state_diff::StateDiff, }; /// Type alias for a function we can make calls through synchronously. /// Returns the call result and state proof for each call. pub type Call<'a> = dyn Fn(Address, Vec<u8>) -> Result<(Vec<u8>, Vec<Vec<u8>>), String> + 'a; /// Request for auxiliary data of a block. #[derive(Debug, Clone, Copy, PartialEq)] pub enum AuxiliaryRequest { /// Needs the body. Body, /// Needs the receipts. Receipts, /// Needs both body and receipts. Both, } /// Auxiliary data fetcher for an Vapory machine. In Vapory-like machines /// there are two kinds of auxiliary data: bodies and receipts. #[derive(Default, Clone)] pub struct AuxiliaryData<'a> { /// The full block bytes, including the header. pub bytes: Option<&'a [u8]>, /// The block receipts. pub receipts: Option<&'a [receipt::Receipt]>, } /// Transaction execution receipt. #[derive(Debug, PartialEq, Clone)] pub struct Executed<T, V> { /// True if the outer call/create resulted in an exceptional exit. pub exception: Option<tetsy_vm::Error>, /// Gas paid up front for execution of transaction. pub gas: U256, /// Gas used during execution of transaction. pub gas_used: U256, /// Gas refunded after the execution of transaction. /// To get gas that was required up front, add `refunded` and `gas_used`. pub refunded: U256, /// Cumulative gas used in current block so far. /// /// `cumulative_gas_used = gas_used(t0) + gas_used(t1) + ... gas_used(tn)` /// /// where `tn` is current transaction. pub cumulative_gas_used: U256, /// Vector of logs generated by transaction. pub logs: Vec<LogEntry>, /// Addresses of contracts created during execution of transaction. /// Ordered from earliest creation. /// /// eg. sender creates contract A and A in constructor creates contract B /// /// B creation ends first, and it will be the first element of the vector. pub contracts_created: Vec<Address>, /// Transaction output. pub output: Bytes, /// The trace of this transaction. pub trace: Vec<T>, /// The VM trace of this transaction. pub vm_trace: Option<V>, /// The state diff, if we traced it. pub state_diff: Option<StateDiff>, }