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

runtime-sdk: Mask gas limit/wanted in case EMIT_GAS_USED_EVENTS is false #1021

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

kostko
Copy link
Member

@kostko kostko commented Jun 24, 2022

No description provided.

@kostko kostko requested review from pro-wh and ptrus as code owners June 24, 2022 08:16
@codecov
Copy link

codecov bot commented Jun 24, 2022

Codecov Report

Merging #1021 (33fe84d) into main (524d088) will decrease coverage by 0.00%.
The diff coverage is 66.66%.

@@            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              
Impacted Files Coverage Δ
runtime-sdk/modules/contracts/src/abi/oasis/mod.rs 67.46% <50.00%> (-0.84%) ⬇️
runtime-sdk/src/modules/core/mod.rs 73.01% <80.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 524d088...33fe84d. Read the comment docs.

@kostko kostko enabled auto-merge June 24, 2022 08:52
@@ -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>(
Copy link
Contributor

Choose a reason for hiding this comment

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

😵

Copy link
Member Author

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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@kostko kostko force-pushed the kostko/feature/mask-gas-errors branch from f2eb52d to 33fe84d Compare June 27, 2022 17:13
Copy link
Contributor

@pro-wh pro-wh left a 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

@kostko kostko merged commit 9a51be8 into main Jun 27, 2022
@kostko kostko deleted the kostko/feature/mask-gas-errors branch June 27, 2022 17:37
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.

None yet

2 participants