Skip to content
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

Conversation

DoTheBestToGetTheBest
Copy link
Contributor

related : #40

src/opcode.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mattsse mattsse left a 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);
Copy link
Contributor

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();
Copy link
Contributor

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

Copy link
Contributor Author

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

@mattsse mattsse force-pushed the Track-dynamic-gas-with-gasinspector branch from a71a3e0 to 2198d4a Compare March 5, 2024 10:58
Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this!

@mattsse mattsse merged commit 5d560be into paradigmxyz:main Mar 5, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants