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

Add debug_with_gas functionality #1643

Closed
wants to merge 1 commit into from
Closed

Conversation

maurolacy
Copy link
Contributor

@maurolacy maurolacy commented Mar 21, 2023

Maybe closes #746.

Similar to #1642, prints a debug message but with remaining gas information, for benchmarking / optimisation / regression.

Instead of returning the gas to the contract, this just prints the amount of remaining gas; which is probably less problematic, and still pretty useful.

@maurolacy
Copy link
Contributor Author

Any plans on merging this? Can rebase and solve conflicts if that is the case.

let message_data = read_region(&env.memory(), message_ptr, MAX_LENGTH_DEBUG)?;
let msg = String::from_utf8_lossy(&message_data);
let gas_remaining = env.get_gas_left();
println!("{}, gas_left: {}", msg, gas_remaining);
Copy link
Member

Choose a reason for hiding this comment

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

This is something we can also easily add to the output of the current debug implementation (for the same reasons I mentioned in the trace PR)

@maurolacy
Copy link
Contributor Author

Closing in favour of #1667.

@maurolacy maurolacy closed this Apr 28, 2023
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.

Allow printing gas reports from contracts (debug mode)
2 participants