@@ -499,10 +499,11 @@ pub struct Cheatcodes {
499
499
pub wallets : Option < Wallets > ,
500
500
/// Signatures identifier for decoding events and functions
501
501
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 ) > ,
506
507
}
507
508
508
509
// This is not derived because calling this in `fn new` with `..Default::default()` creates a second
@@ -558,7 +559,7 @@ impl Cheatcodes {
558
559
deprecated : Default :: default ( ) ,
559
560
wallets : Default :: default ( ) ,
560
561
signatures_identifier : SignaturesIdentifier :: new ( true ) . ok ( ) ,
561
- is_fixed_gas_limit : Default :: default ( ) ,
562
+ dynamic_gas_limit_sequence : Default :: default ( ) ,
562
563
}
563
564
}
564
565
@@ -857,7 +858,8 @@ impl Cheatcodes {
857
858
} ) ;
858
859
}
859
860
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 ( ) ;
861
863
// Transaction has fixed gas limit if no GAS opcode seen before CALL opcode.
862
864
let mut is_fixed_gas_limit = !( gas_seen && call_seen) ;
863
865
// Additional check as transfers in forge scripts seem to be estimated at 2300
@@ -2313,11 +2315,11 @@ impl Cheatcodes {
2313
2315
fn record_gas_limit_opcode ( & mut self , interpreter : & mut Interpreter ) {
2314
2316
match interpreter. bytecode . opcode ( ) {
2315
2317
// 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 ) ) ,
2317
2319
op:: GAS => {
2318
- if self . is_fixed_gas_limit . is_none ( ) {
2320
+ if self . dynamic_gas_limit_sequence . is_none ( ) {
2319
2321
// 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 ) ) ;
2321
2323
}
2322
2324
}
2323
2325
_ => { }
@@ -2327,20 +2329,20 @@ impl Cheatcodes {
2327
2329
#[ cold]
2328
2330
fn set_gas_limit_type ( & mut self , interpreter : & mut Interpreter ) {
2329
2331
// 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 ) ) ) {
2331
2333
return ;
2332
2334
}
2333
2335
2334
2336
// 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 ) ) )
2336
2338
&& interpreter. bytecode . opcode ( ) == op:: CALL
2337
2339
{
2338
- self . is_fixed_gas_limit = Some ( ( true , true ) ) ;
2340
+ self . dynamic_gas_limit_sequence = Some ( ( true , true ) ) ;
2339
2341
return ;
2340
2342
}
2341
2343
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 ;
2344
2346
}
2345
2347
}
2346
2348
0 commit comments