<p></p>
<blockquote>
<p><em>This is a Bisq Network project. Please familiarize yourself with the <a href="https://bisq.wiki/Project_management" rel="nofollow">project management process</a>.</em></p>
</blockquote>
<h2>Description</h2>

<p>The business logic of sending messages needs some love. During <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="579242410" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4047" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/4047/hovercard" href="https://github.com/bisq-network/bisq/pull/4047">bisq-network/bisq#4047</a>, it became apparent, that the logic might miss sending messages entirely. Main takeaways from the project:</p>
<ul>
<li>long term: ground work that improves reliability.</li>
<li>short term: maybe get rid of spurious message loss</li>
</ul>
<h2>Rationale</h2>

<h3>Why is it important?</h3>
<ul>
<li>Messages are submitted to the connection asynchronously, thus, chances are that messages do not get sent because threads are abandoned, killed, time out, or a connection is closed before all message in queue are sent</li>
<li>definitely explains why we see nasty walls of exceptions on app shutdown quite frequently</li>
<li>concrete example: removeOfferMessages on shutdown may or may not be sent, depending on the timeouts and therefore on the performance of the host, network load, message load of the bisq app, seed node load, ...</li>
<li>it can happen for more crucial messages (messages are messages are messages, there are no priorities built into them)</li>
<li>might explain why we see messages getting lost</li>
</ul>
<p>IMO:</p>
<ul>
<li>I consider this a high priority task</li>
<li>given my >1,5 years experience with the p2p part of Bisq</li>
<li>the p2p message handling needs cleanup and refactoring, technology is outdated, changing stuff is a minefield, there is synchronization everywhere which immediately causes deadlocks on the slightest change, attack counter measures are scattered throughout the code to make it almost impossible to understand how/if they work, yet alone understand, control and tweak them, copy-and-pasted spagetti code provides plenty of places for bugs to hide in</li>
<li>however, I cannot provide a concrete issue # that will be fixed by working on this</li>
</ul>
<h3>Why should it be done now? What will happen if we don't do it or delay doing it?</h3>
<ul>
<li>consider it as basic maintenance</li>
<li>thus, no, it does not have to be done now</li>
<li>delaying it will work as well</li>
</ul>
<p>however,</p>
<ul>
<li>we might just see a more robust network</li>
<li>less lost messages</li>
<li>eliminate unforeseen deadlock situations</li>
<li>confine timing issues to the Connection, where they can be (at least) handled somehow</li>
<li>track messages and see if they are actually sent</li>
</ul>
<h2>Criteria for delivery</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> have a test suit for message sending BL</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> more robust code</li>
</ul>
<h2>Measures of success</h2>

<ul>
<li>cleaner code</li>
<li>maybe catch a few bugs we are not aware of yet</li>
</ul>
<h2>Risks</h2>

<ul>
<li>as always, changing the P2P part of Bisq is highestest risk</li>
<li>this one only touches the message sending business logic, so the risk is somewhat confined. Yet, if nobody can send messages, the network is going to die as well.</li>
</ul>
<h2>Tasks</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> create test suit for message sending business logic (ie. on Connection level)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> implement a proper message queue for messages to be sent</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> implement a proper connection shutdown process, move away from dropping anything instantly</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> gradually remove "external" message scheduling mechanics</li>
</ul>
<h2>Estimates</h2>

<p>hard to say, as the project will only show its true face once we are knee-deep into it.</p>
<table>
<thead>
<tr>
<th>Task</th>
<th align="right">Amount [USD]</th>
</tr>
</thead>
<tbody>
<tr>
<td>create test suit</td>
<td align="right">1800,00</td>
</tr>
<tr>
<td>message queue</td>
<td align="right">900,00</td>
</tr>
<tr>
<td>remove "external" scheduling</td>
<td align="right">1200,00</td>
</tr>
<tr>
<td>testing</td>
<td align="right">700,00</td>
</tr>
<tr>
<td>other</td>
<td align="right">500,00</td>
</tr>
<tr>
<td><strong>total</strong></td>
<td align="right"><strong>5100,00</strong></td>
</tr>
</tbody>
</table>
<h2>Notes</h2>

<ul>
<li>supersedes <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="591001578" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4105" data-hovercard-type="issue" data-hovercard-url="/bisq-network/bisq/issues/4105/hovercard" href="https://github.com/bisq-network/bisq/issues/4105">bisq-network/bisq#4105</a></li>
<li>followup to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="579242410" data-permission-text="Title is private" data-url="https://github.com/bisq-network/bisq/issues/4047" data-hovercard-type="pull_request" data-hovercard-url="/bisq-network/bisq/pull/4047/hovercard" href="https://github.com/bisq-network/bisq/pull/4047">bisq-network/bisq#4047</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/projects/issues/28">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNUUJF2JATBIG3FDAX3RLGYE5ANCNFSM4MCFKKWA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNR3ZI7F6G3OTP6LXUTRLGYE5A5CNFSM4MCFKKWKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4I3XFERA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/projects/issues/28",
"url": "https://github.com/bisq-network/projects/issues/28",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>