Skip to content

Commit 7cb09e6

Browse files
cdetrioaxic
authored andcommitted
remove debug prints
1 parent 322a163 commit 7cb09e6

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

wasm-utils/src/gas.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl Counter {
5858
/// Begin a new block.
5959
fn begin(&mut self, cursor: usize, cost: u32, flow_up: bool) {
6060
let block_idx = self.blocks.len();
61-
println!("beginning new block at idx: {:?}", block_idx);
6261
self.blocks.push(BlockEntry {
6362
start_pos: cursor,
6463
cost: cost,
@@ -72,7 +71,6 @@ impl Counter {
7271
/// Finalized blocks have final cost which will not change later.
7372
fn finalize(&mut self) -> Result<(), ()> {
7473
self.stack.pop().ok_or_else(|| ())?;
75-
println!("stack size after finalizing: {:?}", self.stack.len());
7674
Ok(())
7775
}
7876

@@ -111,12 +109,10 @@ impl Counter {
111109
// find closest ancestor block (starting from top of stack and going down) with blocked flow and add 1
112110

113111
for (i, stack_i) in self.stack.iter().rev().enumerate() {
114-
println!("stack at position {}: {:?}", i, stack_i);
115112
let block_i = self.blocks.get_mut(*stack_i).ok_or_else(|| ())?;
116-
println!("block_{:?} has cost: {:?}", *stack_i, block_i.cost);
117113
if !block_i.flow_up || *stack_i == 0 {
118114
block_i.cost = block_i.cost.checked_add(val).ok_or_else(|| ())?;
119-
println!("found ancestor with blocked flow or no parent. incrementing to new cost: {:?} and returning...", block_i.cost);
115+
//println!("found ancestor with blocked flow or no parent. incrementing to new cost: {:?} and returning...", block_i.cost);
120116
break;
121117
}
122118
}
@@ -130,7 +126,6 @@ impl Counter {
130126
let top_block = self.blocks.get_mut(*stack_top).ok_or_else(|| ())?;
131127

132128
top_block.cost = top_block.cost.checked_add(val).ok_or_else(|| ())?;
133-
println!("instruction for current block. incrementing, new cost: {:?}", top_block.cost);
134129

135130
Ok(())
136131
}
@@ -205,7 +200,6 @@ pub fn inject_counter(
205200

206201
},
207202
If(_) => {
208-
println!("on if instruction. finalizing current block and beginning new...");
209203
// Increment previous block with the cost of the current opcode.
210204
let instruction_cost = rules.process(instruction)?;
211205
//counter.increment(instruction_cost)?;
@@ -215,7 +209,6 @@ pub fn inject_counter(
215209
counter.begin(cursor + 1, 0, false);
216210
},
217211
BrIf(_) => {
218-
println!("on br_if instruction. finalizing current block and beginning new...");
219212
// Increment previous block with the cost of the current opcode.
220213
let instruction_cost = rules.process(instruction)?;
221214
//counter.increment(instruction_cost)?;
@@ -276,7 +269,6 @@ pub fn inject_counter(
276269
},
277270
Unreachable => {
278271
// charge nothing, do nothing
279-
println!("skipping unreachable...");
280272
},
281273
_ => {
282274
// An ordinal non control flow instruction. Just increment the cost of the current block.
@@ -344,7 +336,6 @@ pub fn inject_gas_counter(module: elements::Module, rules: &rules::Set)
344336
match section {
345337
&mut elements::Section::Code(ref mut code_section) => {
346338
for ref mut func_body in code_section.bodies_mut() {
347-
println!("doing metering over new function...");
348339
update_call_index(func_body.code_mut(), gas_func);
349340
if let Err(_) = inject_counter(func_body.code_mut(), rules, gas_func) {
350341
error = true;

0 commit comments

Comments
 (0)