revm_context_interface/
context.rs1pub use crate::journaled_state::StateLoad;
2use crate::{Block, Cfg, Database, JournalTr, Transaction};
3use auto_impl::auto_impl;
4use primitives::U256;
5
6#[auto_impl(&mut, Box)]
7pub trait ContextTr {
8 type Block: Block;
9 type Tx: Transaction;
10 type Cfg: Cfg;
11 type Db: Database;
12 type Journal: JournalTr<Database = Self::Db>;
13 type Chain;
14
15 fn tx(&self) -> &Self::Tx;
16 fn block(&self) -> &Self::Block;
17 fn cfg(&self) -> &Self::Cfg;
18 fn journal(&mut self) -> &mut Self::Journal;
19 fn journal_ref(&self) -> &Self::Journal;
20 fn db(&mut self) -> &mut Self::Db;
21 fn db_ref(&self) -> &Self::Db;
22 fn chain(&mut self) -> &mut Self::Chain;
23 fn error(&mut self) -> &mut Result<(), <Self::Db as Database>::Error>;
24 fn tx_journal(&mut self) -> (&mut Self::Tx, &mut Self::Journal);
25}
26
27#[derive(Clone, Debug, Default, PartialEq, Eq)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30pub struct SStoreResult {
31 pub original_value: U256,
33 pub present_value: U256,
35 pub new_value: U256,
37}
38
39impl SStoreResult {
40 #[inline]
42 pub fn is_new_eq_present(&self) -> bool {
43 self.new_value == self.present_value
44 }
45
46 #[inline]
48 pub fn is_original_eq_present(&self) -> bool {
49 self.original_value == self.present_value
50 }
51
52 #[inline]
54 pub fn is_original_eq_new(&self) -> bool {
55 self.original_value == self.new_value
56 }
57
58 #[inline]
60 pub fn is_original_zero(&self) -> bool {
61 self.original_value.is_zero()
62 }
63
64 #[inline]
66 pub fn is_present_zero(&self) -> bool {
67 self.present_value.is_zero()
68 }
69
70 #[inline]
72 pub fn is_new_zero(&self) -> bool {
73 self.new_value.is_zero()
74 }
75}
76
77#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
81#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
82pub struct SelfDestructResult {
83 pub had_value: bool,
84 pub target_exists: bool,
85 pub previously_destroyed: bool,
86}