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

Gas accounting for fee unshielding #2619

Merged
merged 13 commits into from
Apr 27, 2024
Merged

Conversation

grarco
Copy link
Collaborator

@grarco grarco commented Feb 15, 2024

Describe your changes

Closes #2592.

Modifies the protocol logic to charge the gas consumed by the fee unshielding operation, which therefore will pay fees. The gas is charged to the GasLimit declared by the transaction.

Adds an integration test to verify that a fee unshielding operation can run out of gas.

Indicate on which release or other PRs this topic is based on

v0.33.0

Checklist before merging to draft

  • I have added a changelog
  • Git history is in acceptable state

grarco added a commit that referenced this pull request Feb 15, 2024
vp_wasm_cache,
tx_wasm_cache,
),
if namada::ledger::protocol::run_fee_unshielding(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm now using for mempool_validate, prepare_proposal and process_proposal the same function used in finalize_block. The logic though is a bit different: in the first three cases, if the fee unshielding operation fails, for any reason, the transaction is deemed invalid (won't make it into the block). In finalize_block, instead, if the fee unshielding fails we still try to get the fee payment from the transparent address of the fee payer: if the funds are not enough we take what we can and reject the tx (won't get executed) otherwise, at least for now, the transaction can go ahead.

It has to be noted that this scenario in finalize_block should never happen, the check in process_proposal should prevent such a transaction from being included into the block. We still need to handle this case in case there was a bug and a transaction of this kind could indeed be included. We could also choose, for this case, to still try to get the payment from the transparent address but reject the transaction even if the payment was successful.

@grarco grarco marked this pull request as ready for review February 15, 2024 13:58
@grarco grarco requested a review from murisi February 15, 2024 13:58
@grarco grarco force-pushed the grarco/gas-for-fee-unshielding branch from aeae08f to 6936090 Compare February 23, 2024 10:48
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 19.81132% with 170 lines in your changes are missing coverage. Please review.

Project coverage is 59.37%. Comparing base (97ec5b4) to head (b57ec8b).
Report is 4 commits behind head on main.

Files Patch % Lines
crates/namada/src/ledger/protocol/mod.rs 10.00% 90 Missing ⚠️
crates/apps/src/lib/node/ledger/shell/mod.rs 15.18% 67 Missing ⚠️
crates/gas/src/lib.rs 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2619      +/-   ##
==========================================
- Coverage   59.39%   59.37%   -0.02%     
==========================================
  Files         298      298              
  Lines       92771    92785      +14     
==========================================
- Hits        55104    55095       -9     
- Misses      37667    37690      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

murisi
murisi previously approved these changes Mar 1, 2024
Copy link
Collaborator

@murisi murisi left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks!

@grarco grarco mentioned this pull request Apr 16, 2024
brentstone added a commit that referenced this pull request Apr 16, 2024
* grarco/gas-for-fee-unshielding:
  Propagates gas error in fee unshielding. Updates integration test
  Updates gas meter method to account for the overflow flag
  Fixes out of gas masp integration test
  Clippy + fmt
  Changelog #2619
  Share more code for fee unshielding validation
  Minor refactor
  Updates gas meter when verifying fee unshielding
  Adds integration test for fee unshielding gas
  Fee unshielding gas check in validation
  Charges gas for fee unshielding in `finalize_block`
brentstone added a commit that referenced this pull request Apr 16, 2024
* grarco/gas-for-fee-unshielding:
  Propagates gas error in fee unshielding. Updates integration test
  Updates gas meter method to account for the overflow flag
  Fixes out of gas masp integration test
  Clippy + fmt
  Changelog #2619
  Share more code for fee unshielding validation
  Minor refactor
  Updates gas meter when verifying fee unshielding
  Adds integration test for fee unshielding gas
  Fee unshielding gas check in validation
  Charges gas for fee unshielding in `finalize_block`
@brentstone brentstone merged commit da6d8d1 into main Apr 27, 2024
16 of 19 checks passed
@brentstone brentstone deleted the grarco/gas-for-fee-unshielding branch April 27, 2024 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charge gas for masp fee payment
3 participants