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

Validate BSQ fee payment using DAO tx info. #6425

Merged
merged 2 commits into from Dec 29, 2022
Merged

Validate BSQ fee payment using DAO tx info. #6425

merged 2 commits into from Dec 29, 2022

Conversation

ghost
Copy link

@ghost ghost commented Nov 22, 2022

Fixes an issue with BSQ fee validation which has been prompting users to open mediation tickets, as reported by @pazza83


Previously the BSQ fee payment was determined by parsing a raw tx without relying on the DAO. Unfortunately this turned out to be problematic, so with this change the BSQ fee paid is obtained from the DAO tx, as originally preferred by @chimp1984.

Unconfirmed transactions will not be able to have their BSQ fees checked so early requests for validation will skip the fee check. This is not a problem since maker fee validation is done by takers and in the majority of cases will be already confirmed; taker fee validation is done after the first confirm at trade step 2.

@HenrikJannsen
Copy link
Collaborator

Why do we need the explorer lookup then? We know if the fee payment was BTC or BSQ, at least for maker so we could use the exclusively the DAO data.
But would postpone that until the BM proposal is deployed as only then we can be sure that all traders have the DAO activated.

@ghost
Copy link
Author

ghost commented Nov 23, 2022

I went with the simplest minimal change. Yes, the fee validation could probably be refactored as you suggest.

@HenrikJannsen
Copy link
Collaborator

I went with the simplest minimal change. Yes, the fee validation could probably be refactored as you suggest.

I think it would be better to reduce the code to that whats needed now.

@ghost ghost marked this pull request as draft November 25, 2022 16:53
@ghost ghost closed this Nov 29, 2022
@ghost ghost reopened this Nov 30, 2022
Previously the BSQ fee payment was determined by parsing a raw tx
without relying on the DAO.  Unfortunately this turned out to be
problematic, so with this change the BSQ fee paid is obtained from
the DAO tx, as originally preferred by chimp1984.

Unconfirmed transactions will not be able to have their BSQ fees
checked so early requests for validation will skip the fee check.
This is not a problem since maker fee validation is done by the
taker and in the majority of cases will be already confirmed; taker
fee validation is done after the first confirm at trade step 2.
@ghost ghost changed the title Validate BSQ fee payment using DAO tx info. [DO NOT MERGE] Validate BSQ fee payment using DAO tx info. Nov 30, 2022
@ghost
Copy link
Author

ghost commented Nov 30, 2022

Refactored as suggested above. Rebased to latest master.

But would postpone that until the BM proposal is deployed as only then we can be sure that all traders have the DAO activated.

Marked as [DO NOT MERGE] for now.

@ghost ghost marked this pull request as ready for review November 30, 2022 00:28
@ripcurlx ripcurlx added this to the v1.9.7 milestone Dec 1, 2022
@ripcurlx ripcurlx modified the milestones: v1.9.7, v1.9.8 Dec 12, 2022
@ghost ghost changed the title [DO NOT MERGE] Validate BSQ fee payment using DAO tx info. Validate BSQ fee payment using DAO tx info. Dec 22, 2022
@pazza83
Copy link

pazza83 commented Dec 29, 2022

Hi would be good to get this merged soon. I have a user in support with multiple offers that are going offline. Shared the logs with @jmacxx who informed me that this PR will fix their issue.

@alejandrogarcia83
Copy link
Contributor

@HenrikJannsen Could you ACK this?

Copy link
Collaborator

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

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

Beside small mentioned issues utACK

private final List<String> errorList;
private final String txId;
private Coin amount;
@Nullable
private Boolean isFeeCurrencyBtc = null;
private Boolean isFeeCurrencyBtc = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As isFeeCurrencyBtc is only used by one constructor and otherwise is not set (and not used) I think keeping it a nullable Boolean is better. In the use cases where its accessed the constructor is use with a non null value, so no need to initialize it with true.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is one unused constructor as well. Better to remove that.

@@ -85,13 +85,13 @@ public TxValidator(DaoStateService daoStateService,
String txId,
Coin amount,
@Nullable Boolean isFeeCurrencyBtc,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better remove the @nullable and use primitive boolean value as the callers always provide a non null value.

HenrikJannsen
HenrikJannsen previously approved these changes Dec 29, 2022
Copy link
Collaborator

@HenrikJannsen HenrikJannsen left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

@alejandrogarcia83 alejandrogarcia83 left a comment

Choose a reason for hiding this comment

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

utACK

validateOfferMakerTx(mempoolRequest, txValidator, resultHandler);
} else {
// using BSQ for fees
UserThread.runAfter(() -> resultHandler.accept(txValidator.validateBsqFeeTx(true)), 1);
Copy link
Author

Choose a reason for hiding this comment

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

This BSQ fee check should be gated by a call to isServiceSupported()

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need it there. The MempoolService is not used to validate the BSQ fee because txValidator.validateBsqFeeTx(true) gets the transaction from the DaoStateService.

Copy link
Author

Choose a reason for hiding this comment

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

With the change to have BSQ fees checked using the DAO database rather than with data obtained from mempool.space, MempoolService is incorrectly named. (In fact, it was unfortunate that it was named referring to an implementation feature rather than functionality).

It would be more appropriately called TradeFeeCheckingService. Fee checking should be gated by isServiceSupported(), so that the filter and config settings can do their job in enabling/disabling the fee checking feature.

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.

5 participants