[bisq-network/bisq] Fix failed trade / missing payment information (#5679)

jmacxx notifications at github.com
Mon Aug 30 17:04:23 CEST 2021


**Problem description:**
A trade will fail if the deposit transaction is received via the mempool before it is received via P2P messaging protocols.

During initial trade protocol messaging, the deposit transaction is received at the buyer via two possible paths: a P2P message `DepositTxAndDelayedPayoutTxMessage`, or received in the mempool.
Receiving via P2P message is much more likely, but in rare cases when received via the mempool first, we get the following error:

**Log of broken version:**

    Aug-30 07:52:20.383 [JavaFX Application Thread] INFO  b.c.btc.wallet.WalletService: depositTx received from network:
    Aug-30 07:52:36.318 [JavaFX Application Thread] INFO  b.c.t.p.FluentProtocol$Condition: We received a DepositTxAndDelayedPayoutTxMessage at phase DEPOSIT_PUBLISHED and state BUYER_SAW_DEPOSIT_TX_IN_NETWORK
    Aug-30 07:52:36.319 [JavaFX Application Thread] WARN  b.c.t.protocol.BuyerProtocol: We with a DepositTxAndDelayedPayoutTxMessage but we have already processed the deposit and delayed payout tx so we ignore the message. This can happen if the ACK message to the peer did not arrive and the peer repeats sending us the message. We send another ACK msg. 
    Aug-30 07:52:36.319 [JavaFX Application Thread] INFO  b.c.t.protocol.TradeProtocol: Send AckMessage for DepositTxAndDelayedPayoutTxMessage to peer 
    Aug-30 07:52:36.321 [JavaFX Application Thread] INFO  b.c.t.protocol.TradeProtocol: Remove DepositTxAndDelayedPayoutTxMessage from the P2P network. 
    Aug-30 07:52:36.321 [JavaFX Application Thread] WARN  b.c.t.protocol.TradeProtocol: PreConditions not met. preConditions=[false]
    Aug-30 07:52:36.321 [JavaFX Application Thread] ERROR b.c.t.protocol.TradeProtocol: Task runner failed with error PreConditions not met. preConditions=[false],
    ... followed by missing payment instructions and the trade cannot be completed.
    Aug-30 07:59:02.876 [JavaFX Application Thread] ERROR b.d.m.p.p.s.b.BuyerStep2View: Not supported PaymentMethod:


The handling of the P2P message is not carried out because it erroneously thinks it has been handled before.  The preconditions are incorrect.

Preconditions are changed via this PR, checking if the payment account payload has already been received.  If not, then the P2P message will be processed.

**Log of fixed version:**

    Aug-30 08:45:44.418 [JavaFX Application Thread] INFO  b.c.btc.wallet.WalletService: depositTx received from network:
    Aug-30 08:46:04.643 [JavaFX Application Thread] INFO  b.c.t.p.FluentProtocol$Condition: We received a DepositTxAndDelayedPayoutTxMessage at phase DEPOSIT_PUBLISHED and state BUYER_SAW_DEPOSIT_TX_IN_NETWORK
    Aug-30 08:46:04.643 [JavaFX Application Thread] INFO  b.c.btc.wallet.WalletService: depositTx received from peer:
    Aug-30 08:46:04.648 [JavaFX Application Thread] INFO  b.common.taskrunner.TaskRunner: Run task: ApplyFilter 
    Aug-30 08:46:04.648 [JavaFX Application Thread] INFO  b.common.taskrunner.TaskRunner: Run task: VerifyPeersAccountAgeWitness 
    Aug-30 08:46:04.649 [JavaFX Application Thread] INFO  b.common.taskrunner.TaskRunner: Run task: BuyerSendsShareBuyerPaymentAccountMessage 
    Aug-30 08:46:04.649 [JavaFX Application Thread] INFO  b.c.t.p.t.SendMailboxMessageTask: Send ShareBuyerPaymentAccountMessage to peer 




This PR was a collaboration between myself (analysis & test), and @chimp1984 (suggested code fix).
The problem has been replicated on mainnet, and the fix tested on mainnet.


You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/5679

-- Commit Summary --

  * Fix race between mempool notify / P2P notify causing failed trade

-- File Changes --

    M core/src/main/java/bisq/core/trade/protocol/BuyerProtocol.java (11)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/5679.patch
https://github.com/bisq-network/bisq/pull/5679.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5679
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210830/47506521/attachment.htm>


More information about the bisq-github mailing list