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

Apply refund to fee bump fee charged #4228

Merged
merged 7 commits into from Mar 15, 2024

Conversation

sisuresh
Copy link
Contributor

@sisuresh sisuresh commented Mar 4, 2024

Description

Resolves #4188

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@sisuresh sisuresh requested a review from dmkozh March 4, 2024 18:32
// Now set update feeCharged on the fee bump. We don't have access to
// the refund value here, but we can calculate it using the pre and post
// feeCharged of mInnerTx.
int64_t refund = preRefundFeeCharged - mInnerTx->getResult().feeCharged;
Copy link
Contributor Author

@sisuresh sisuresh Mar 4, 2024

Choose a reason for hiding this comment

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

This is a kinda hacky, but it does make sure that any adjustment done to the inner fee charged is also applied to the feeBump feeCharged. We could also just expose the refund from mSorobanExtension in TransactionFrame instead, which would be cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using mSorobanExtension isn't trivial though because there are some cases where the refund is skipped - account doesn't exist or liabilities are too high, so that will also need to be taken into account.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this looks pretty foot gunny:

  • inner tx's feeCharged should be 0 in this case (consistent with classic)
  • modifying inner tx from the outside like that is brittle

I would recommend refactoring code a bit (maybe add a new virtual function to deal with this)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we may be mixing up some terminology between mInnerTx's result vs the innerResultPair of the feeBump result here so just to clarify -

  1. Are you saying that mResult.result.innerResultPair().result.feeCharged is always 0 in classic? Because that's not true. Here is an example xdr for a payment fee bump where the inner feeCharged isn't 0. And if you're referring to mInnerTx->getResult().feeCharged this also isn't 0 in classic afaict.

  2. For your second point, we are not modifying the innerTx's result. We are only modifying the innerResultPair of the feeBump result.

src/test/TxTests.cpp Outdated Show resolved Hide resolved
@dmkozh
Copy link
Contributor

dmkozh commented Mar 15, 2024

r+ 8af4005

@latobarita latobarita merged commit eb6a853 into stellar:master Mar 15, 2024
15 checks passed
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.

FeeBumpTransactionFrame's feeCharged does not take refunds into account
4 participants