-
Notifications
You must be signed in to change notification settings - Fork 18
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
runtime-sdk: Mask gas limit/wanted in case EMIT_GAS_USED_EVENTS is false #1021
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1021 +/- ##
==========================================
- Coverage 68.37% 68.37% -0.01%
==========================================
Files 126 126
Lines 10670 10677 +7
==========================================
+ Hits 7296 7300 +4
- Misses 3349 3352 +3
Partials 25 25
Continue to review full report at Codecov.
|
@@ -158,7 +154,11 @@ impl<Cfg: Config> OasisV1<Cfg> { | |||
// Compute how much gas was wanted. | |||
let final_gas = gas::get_remaining_gas(instance); | |||
let wanted_gas = initial_gas + exhausted_gas.saturating_sub(final_gas); | |||
core::Error::OutOfGas(initial_gas, wanted_gas).into() | |||
core::Error::out_of_gas::<<<C::Runtime as Runtime>::Core as core::API>::Config>( |
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.
😵
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.
Yeah unfortunately the Rust compiler wants explicit casts here :(
/// Generate a proper OutOfGas error, depending on whether the module is configured to emit gas | ||
/// use information or not. | ||
pub fn out_of_gas<Cfg: Config>(limit: u64, wanted: u64) -> Self { | ||
if Cfg::EMIT_GAS_USED_EVENTS { |
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 already existed? what did it do before?
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.
It suppresses emission of gas used events (which are by default emitted for every transaction). With this PR the same flag is also used for masking exact amounts in out of gas errors.
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.
👍
f2eb52d
to
33fe84d
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.
ok that's a reasonable extension of the flag's meaning
No description provided.