Skip to content

Commit f163419

Browse files
committed
Rename var
1 parent ba1215c commit f163419

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

crates/cheatcodes/src/inspector.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ pub struct Cheatcodes {
499499
pub wallets: Option<Wallets>,
500500
/// Signatures identifier for decoding events and functions
501501
pub signatures_identifier: Option<SignaturesIdentifier>,
502-
/// Whether the broadcasted call has fixed gas limit (if no GAS opcode seen before
503-
/// CALL opcode). Set to (true, true) when GAS is followed by a CALL opcode or if CREATE2
504-
/// opcode.
505-
pub is_fixed_gas_limit: Option<(bool, bool)>,
502+
/// Used to determine whether the broadcasted call has non-fixed gas limit.
503+
/// Holds values for (seen opcode GAS, seen opcode CALL) pair.
504+
/// If GAS opcode is followed by CALL opcode then both flags are marked true and call
505+
/// has non-fixed gas limit, otherwise the call is considered to have fixed gas limit.
506+
pub dynamic_gas_limit_sequence: Option<(bool, bool)>,
506507
}
507508

508509
// This is not derived because calling this in `fn new` with `..Default::default()` creates a second
@@ -558,7 +559,7 @@ impl Cheatcodes {
558559
deprecated: Default::default(),
559560
wallets: Default::default(),
560561
signatures_identifier: SignaturesIdentifier::new(true).ok(),
561-
is_fixed_gas_limit: Default::default(),
562+
dynamic_gas_limit_sequence: Default::default(),
562563
}
563564
}
564565

@@ -857,7 +858,8 @@ impl Cheatcodes {
857858
});
858859
}
859860

860-
let (gas_seen, call_seen) = self.is_fixed_gas_limit.take().unwrap_or_default();
861+
let (gas_seen, call_seen) =
862+
self.dynamic_gas_limit_sequence.take().unwrap_or_default();
861863
// Transaction has fixed gas limit if no GAS opcode seen before CALL opcode.
862864
let mut is_fixed_gas_limit = !(gas_seen && call_seen);
863865
// Additional check as transfers in forge scripts seem to be estimated at 2300
@@ -2313,11 +2315,11 @@ impl Cheatcodes {
23132315
fn record_gas_limit_opcode(&mut self, interpreter: &mut Interpreter) {
23142316
match interpreter.bytecode.opcode() {
23152317
// If current opcode is CREATE2 then set non-fixed gas limit.
2316-
op::CREATE2 => self.is_fixed_gas_limit = Some((true, true)),
2318+
op::CREATE2 => self.dynamic_gas_limit_sequence = Some((true, true)),
23172319
op::GAS => {
2318-
if self.is_fixed_gas_limit.is_none() {
2320+
if self.dynamic_gas_limit_sequence.is_none() {
23192321
// If current opcode is GAS then mark as seen.
2320-
self.is_fixed_gas_limit = Some((true, false));
2322+
self.dynamic_gas_limit_sequence = Some((true, false));
23212323
}
23222324
}
23232325
_ => {}
@@ -2327,20 +2329,20 @@ impl Cheatcodes {
23272329
#[cold]
23282330
fn set_gas_limit_type(&mut self, interpreter: &mut Interpreter) {
23292331
// Early exit in case we already determined is non-fixed gas limit.
2330-
if matches!(self.is_fixed_gas_limit, Some((true, true))) {
2332+
if matches!(self.dynamic_gas_limit_sequence, Some((true, true))) {
23312333
return;
23322334
}
23332335

23342336
// Record CALL opcode if GAS opcode was seen.
2335-
if matches!(self.is_fixed_gas_limit, Some((true, false)))
2337+
if matches!(self.dynamic_gas_limit_sequence, Some((true, false)))
23362338
&& interpreter.bytecode.opcode() == op::CALL
23372339
{
2338-
self.is_fixed_gas_limit = Some((true, true));
2340+
self.dynamic_gas_limit_sequence = Some((true, true));
23392341
return;
23402342
}
23412343

2342-
// Reset gas record if GAS opcode was not followed by a CALL opcode.
2343-
self.is_fixed_gas_limit = None;
2344+
// Reset dynamic gas limit sequence if GAS opcode was not followed by a CALL opcode.
2345+
self.dynamic_gas_limit_sequence = None;
23442346
}
23452347
}
23462348

0 commit comments

Comments
 (0)