Skip to content

Fix resync fee missing #15964

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix resync fee missing #15964

wants to merge 2 commits into from

Conversation

ytx1991
Copy link
Contributor

@ytx1991 ytx1991 commented Aug 8, 2023

Purpose:

Fix issue: https://github.com/Chia-Network/issue-tracker/issues/558

Current Behavior:

After resync, all transactions don't have a fee

New Behavior:

After resync, all outgoing transactions will have a fee.

Testing Notes:

Tested on testnet10, waiting for another PR merged to add unit test

@ytx1991 ytx1991 requested a review from a team as a code owner August 8, 2023 00:46
@wallentx wallentx added the Fixed Required label for PR that categorizes merge commit message as "Fixed" for changelog label Aug 8, 2023
@emlowe emlowe requested a review from Quexington August 8, 2023 16:56
@Quexington
Copy link
Contributor

Is this change for a functional reason or is it just for the sake of user display on resync? If the latter, I think that this is probably a bad change: 1) it adds calls to our full node peer (who's already gracious enough) 2) Introduces potentially more flakiness into syncing coin states 3) we already have a user expectation that txs during resync will lose some information. It's not great but without a more scalable system, it's what we're stuck with.

I don't mind the change at the bottom though that seems to just be an extra calculation.

@wallentx wallentx closed this Aug 9, 2023
@wallentx wallentx reopened this Aug 9, 2023
@ytx1991
Copy link
Contributor Author

ytx1991 commented Aug 16, 2023

Is this change for a functional reason or is it just for the sake of user display on resync? If the latter, I think that this is probably a bad change: 1) it adds calls to our full node peer (who's already gracious enough) 2) Introduces potentially more flakiness into syncing coin states 3) we already have a user expectation that txs during resync will lose some information. It's not great but without a more scalable system, it's what we're stuck with.

I don't mind the change at the bottom though that seems to just be an extra calculation.

We only do an extra call for Clawback txs. For others it just a calculation like you said. If missing fee is acceptable for Clawback then I can remove it @esaung

@arvidn
Copy link
Contributor

arvidn commented Aug 22, 2023

what does it mean to be "missing a fee"? my understanding is that "fee" refers to the payment left for the farmer. that fee is paid when the block is farmed. I don't see how the current behavior is that no transactions pay a fee.

@arvidn
Copy link
Contributor

arvidn commented Aug 22, 2023

as someone not very familiar with this code, would you mind explaining what problem this fixes and under what circumstances it happens?

It looks weird. The existing code also looks weird, but this doesn't seem to address it. We add a TransactionRecord with fee hardcoded to 0, if it's not considered change. Why is that? What if you make a transaction with no change, but you pay a fee? That's a possible transaction that seems to be handled wrong (at least at a first glance of this code).

Secondly, after you compute the fee (which looks like a reasonable way to compute it) it's only used if we add another TransactionRecord, but we don't always do that. Are we just not recording the fee in that case? Or is that the case I mentioned in the previous paragraph that we just don't handle right?

@ytx1991
Copy link
Contributor Author

ytx1991 commented Aug 22, 2023

For your questions,

  1. After users nuked their wallet or sync on a different machine, the TX fee is 0 for all TXs. We want to recover this information.
  2. The code section I changed is only for the resync case. It shouldn't be executed when users syncing normally.
  3. My understanding is this fee is not in use previously and seems someone try to fix this issue but it just finished half of the fix. The change I made will calculate the fee for outgoing TX and set it instead of using 0.

@arvidn
Copy link
Contributor

arvidn commented Aug 23, 2023

@ytx1991
Copy link
Contributor Author

ytx1991 commented Aug 28, 2023

For the first case, it is for reorg only. For a normal resync, there shouldn't be any existing TX. And for the reorg, we already saved the fee in the DB. It just needs to update the confirmation height.

For the second case, it is for the normal syncing, not the resync. In this case, TX record is already saved in the DB with the fee, we just need to mark it as spent.

@ytx1991 ytx1991 closed this Sep 6, 2023
@ytx1991 ytx1991 reopened this Sep 6, 2023
@arvidn
Copy link
Contributor

arvidn commented Oct 5, 2023

one more question:

After resync, all outgoing transactions will have a fee.

Did you confirm that the fee you compute is always correct?

You compute the fee per coin, afaict. This means if you spend two coins, but only one of them creates the output coins. That coin can end up with a negative fee, which would throw an exception since you cast it to uint64. While the other coin would end up being considered 100% fee. I'm not sure it's better to "guess" some values for these, instead of indicating to the user that we just don't know.

Copy link
Contributor

This PR has been flagged as stale due to no activity for over 60 days. It will not be automatically closed, but it has been given a stale-pr label and should be manually reviewed by the relevant parties.

@github-actions github-actions bot added the stale-pr Flagged as stale and in need of manual review label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Required label for PR that categorizes merge commit message as "Fixed" for changelog stale-pr Flagged as stale and in need of manual review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants