diff --git a/crates/inspector/src/gas.rs b/crates/inspector/src/gas.rs index 86c2e6f313..5913f2251d 100644 --- a/crates/inspector/src/gas.rs +++ b/crates/inspector/src/gas.rs @@ -1,13 +1,14 @@ //! GasIspector. Helper Inspector to calculate gas for others. - use revm::interpreter::{CallOutcome, CreateOutcome, Gas}; -/// Helper [Inspector] that keeps track of gas. +/// Helper that keeps track of gas. #[allow(dead_code)] #[derive(Clone, Copy, Debug)] pub struct GasInspector { gas_remaining: u64, last_gas_cost: u64, + /// depth + depth: usize, } impl Default for GasInspector { @@ -29,11 +30,10 @@ impl GasInspector { Self { gas_remaining: 0, last_gas_cost: 0, + depth: 0, } } -} -impl GasInspector { #[inline] pub fn initialize_interp(&mut self, gas: &Gas) { self.gas_remaining = gas.limit(); @@ -66,6 +66,24 @@ impl GasInspector { self.gas_remaining = 0; } } + + /// Returns depth + #[inline] + pub fn depth(&self) -> usize { + self.depth + } + + /// Increment depth + #[inline] + pub fn incr_depth(&mut self) { + self.depth += 1; + } + + /// Decrement depth + #[inline] + pub fn decr_depth(&mut self) { + self.depth -= 1; + } } // #[cfg(test)]