-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: track dynamic gas used in opcode tracking gas #45
Fix: track dynamic gas used in opcode tracking gas #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there
the gas inspector is a bit tricky to use for these things
src/opcode.rs
Outdated
@@ -42,20 +47,67 @@ impl<DB> Inspector<DB> for OpcodeCounterInspector | |||
where | |||
DB: Database, | |||
{ | |||
fn step(&mut self, interp: &mut Interpreter, _context: &mut EvmContext<DB>) { | |||
fn step(&mut self, interp: &mut Interpreter, context: &mut EvmContext<DB>) { | |||
self.initialize_interp(interp, context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we need to delegate to gas inspector
src/opcode.rs
Outdated
|
||
*self.opcode_gas.entry(opcode).or_insert(0) += opcode_gas_cost; | ||
if let Some(opcode) = OpCode::new(opcode_value) { | ||
let gas_used = self.gas_inspector.last_gas_cost(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit tricky because gas cost track cost of the entire call so far
we need to track gas at the beginning of the step and on step end we can get the diff by comparing .remaining
see also TracingInspector for reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit tricky because gas cost track cost of the entire call so far
we need to track gas at the beginning of the step and on step end we can get the diff by comparing
.remaining
see also TracingInspector for reference
hey thank you for the review, i'm not sure i understand this
a71a3e0
to
2198d4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this!
related : #40