revm_interpreter/
instruction_context.rs1use context_interface::{context::SStoreResult, Host};
2use primitives::Address;
3
4use crate::{
5 InstructionContext as Ictx, InstructionResult, Interpreter, InterpreterTypes as ITy,
6 InterpreterTypes,
7};
8
9pub struct InstructionContext<'a, H: ?Sized, ITy: InterpreterTypes> {
13 pub interpreter: &'a mut Interpreter<ITy>,
15 pub host: &'a mut H,
17}
18
19impl<H: ?Sized, IT: InterpreterTypes> std::fmt::Debug for InstructionContext<'_, H, IT> {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 f.debug_struct("InstructionContext")
22 .field("host", &"<host>")
23 .field("interpreter", &"<interpreter>")
24 .finish()
25 }
26}
27
28#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
33#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
34pub struct GasStateOutcome {
35 pub skip_refund: bool,
37 pub skip_gas: bool,
41}
42
43pub trait GasStateTr<IT: ITy, H: Host + ?Sized> {
48 fn sstore_gas_state(
50 context: &mut Ictx<'_, H, IT>,
51 owner: Address,
52 vals: &SStoreResult,
53 ) -> Result<GasStateOutcome, InstructionResult>;
54}
55
56#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
58pub struct NoGasState;
59
60impl<IT: ITy, H: Host + ?Sized> GasStateTr<IT, H> for NoGasState {
61 #[inline]
62 fn sstore_gas_state(
63 _context: &mut Ictx<'_, H, IT>,
64 _owner: Address,
65 _vals: &SStoreResult,
66 ) -> Result<GasStateOutcome, InstructionResult> {
67 Ok(GasStateOutcome::default())
68 }
69}