alloy_rpc_types_trace/opcode.rs
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
//! Types for opcode tracing.
use alloy_primitives::{BlockHash, TxHash};
use serde::{Deserialize, Serialize};
/// Opcode gas usage for a transaction.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockOpcodeGas {
/// The block hash
pub block_hash: BlockHash,
/// The block number
pub block_number: u64,
/// All executed transactions in the block in the order they were executed, with their opcode
/// gas usage.
pub transactions: Vec<TransactionOpcodeGas>,
}
/// Opcode gas usage for a transaction.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[doc(alias = "TxOpcodeGas")]
pub struct TransactionOpcodeGas {
/// The transaction hash
#[doc(alias = "tx_hash")]
pub transaction_hash: TxHash,
/// The gas used by each opcode in the transaction
pub opcode_gas: Vec<OpcodeGas>,
}
/// Gas information for a single opcode.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OpcodeGas {
/// The name of the opcode
pub opcode: String,
/// How many times the opcode was executed
pub count: u64,
/// Combined gas used by all instances of the opcode
///
/// For opcodes with constant gas costs, this is the constant opcode gas cost times the count.
pub gas_used: u64,
}