@@ -108,7 +108,7 @@ impl Counter {
108108
109109 // find closest ancestor block (starting from top of stack and going down) with blocked flow and add 1
110110
111- for ( i , stack_i) in self . stack . iter ( ) . rev ( ) . enumerate ( ) {
111+ for ( _i , stack_i) in self . stack . iter ( ) . rev ( ) . enumerate ( ) {
112112 let block_i = self . blocks . get_mut ( * stack_i) . ok_or_else ( || ( ) ) ?;
113113 if !block_i. flow_up || * stack_i == 0 {
114114 block_i. cost = block_i. cost . checked_add ( val) . ok_or_else ( || ( ) ) ?;
@@ -120,15 +120,6 @@ impl Counter {
120120
121121 }
122122
123- /// Increment the cost of the current block by the specified value.
124- fn increment ( & mut self , val : u32 ) -> Result < ( ) , ( ) > {
125- let stack_top = self . stack . last_mut ( ) . ok_or_else ( || ( ) ) ?;
126- let top_block = self . blocks . get_mut ( * stack_top) . ok_or_else ( || ( ) ) ?;
127-
128- top_block. cost = top_block. cost . checked_add ( val) . ok_or_else ( || ( ) ) ?;
129-
130- Ok ( ( ) )
131- }
132123}
133124
134125fn inject_grow_counter ( instructions : & mut elements:: Instructions , grow_counter_func : u32 ) -> usize {
@@ -154,10 +145,8 @@ fn add_grow_counter(module: elements::Module, rules: &rules::Set, gas_func: u32)
154145 . with_instructions ( elements:: Instructions :: new ( vec ! [
155146 GetLocal ( 0 ) ,
156147 GetLocal ( 0 ) ,
157- // I64Const(rules.grow_cost() as i64),
158- // I64Mul,
159- I32Const ( rules. grow_cost( ) as i32 ) ,
160- I32Mul ,
148+ I64Const ( rules. grow_cost( ) as i64 ) ,
149+ I64Mul ,
161150 // todo: there should be strong guarantee that it does not return anything on stack?
162151 Call ( gas_func) ,
163152 GrowMemory ( 0 ) ,
@@ -285,8 +274,7 @@ pub fn inject_counter(
285274 if block. cost > 0 {
286275 let effective_pos = block. start_pos + cumulative_offset;
287276
288- //instructions.elements_mut().insert(effective_pos, I64Const(block.cost as i64));
289- instructions. elements_mut ( ) . insert ( effective_pos, I32Const ( block. cost as i32 ) ) ;
277+ instructions. elements_mut ( ) . insert ( effective_pos, I64Const ( block. cost as i64 ) ) ;
290278 instructions. elements_mut ( ) . insert ( effective_pos+1 , Call ( gas_func) ) ;
291279
292280 // Take into account these two inserted instructions.
@@ -308,7 +296,7 @@ pub fn inject_gas_counter(module: elements::Module, rules: &rules::Set)
308296 let mut mbuilder = builder:: from_module ( module) ;
309297 let import_sig = mbuilder. push_signature (
310298 builder:: signature ( )
311- . param ( ) . i32 ( )
299+ . param ( ) . i64 ( )
312300 . build_sig ( )
313301 ) ;
314302
0 commit comments