-
Notifications
You must be signed in to change notification settings - Fork 305
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 fees in WASM planner #3693
Merged
Merged
Fix fees in WASM planner #3693
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jessepinho
had a problem deploying
to
smoke-test
January 29, 2024 18:01 — with
GitHub Actions
Failure
jessepinho
force-pushed
the
jessepinho/web-362-wasm-planner-fixes
branch
from
January 29, 2024 19:01
e0c2ab4
to
a782508
Compare
jessepinho
had a problem deploying
to
smoke-test
January 29, 2024 19:01 — with
GitHub Actions
Failure
jessepinho
force-pushed
the
jessepinho/web-362-wasm-planner-fixes
branch
from
January 29, 2024 23:04
a782508
to
9dcaa94
Compare
jessepinho
commented
Jan 29, 2024
@@ -161,15 +161,23 @@ impl<R: RngCore + CryptoRng> Planner<R> { | |||
/// | |||
/// This function should be called once. | |||
pub fn add_gas_fees(&mut self) -> &mut Self { |
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.
Changes copied from
penumbra/crates/view/src/planner.rs
Lines 172 to 192 in 1d368d4
pub fn add_gas_fees(&mut self) -> &mut Self { | |
// Add a single Spend + Output to the minimum fee to cover paying the fee | |
let minimum_fee = self | |
.gas_prices | |
.fee(&(self.plan.gas_cost() + gas::output_gas_cost() + gas::spend_gas_cost())); | |
// Since paying the fee possibly requires adding additional Spends and Outputs | |
// to the transaction, which would then change the fee calculation, we multiply | |
// the fee here by a factor of 128 and then recalculate and capture the excess as | |
// change outputs. | |
// | |
// TODO: this is gross and depending on gas costs could make the gas overpayment | |
// ridiculously large (so large that the account may not have notes available to cover it) | |
// or too small. We may need a cyclical calculation of fees on the transaction plan, | |
// or a "simulated" transaction plan with infinite assets to calculate fees on before | |
// copying the exact fees to the real transaction. | |
let fee = Fee::from_staking_token_amount(minimum_fee * Amount::from(128u32)); | |
self.balance -= fee.0; | |
self.plan.transaction_parameters.fee = fee.clone(); | |
self | |
} |
zbuc
approved these changes
Jan 30, 2024
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.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After some recent changes to the non-WASM/"regular" planner, the WASM planner was out of sync as regards fee handling. This PR gets it back in sync.
Manual testing (optional reading, but here for posterity)
This was hard to test because of some issues in Penumbra core. Steps I took to test it:
main
branchcrates/core/component/fee/src/genesis.rs
:cd crates/wasm/publish && pnpm install && pnpm run compile-wasm
)pnpm install ../penumbra-core/crate/wasm/publish/bundler
; note that you first have to uninstall @penumbra-zone/wasm-bundler from both the root of the web monorepo and thepackages/wasm
directory)packages/constants/config.ts
to set thegrpcEndpoint
tohttp:/localhost:8080