<p>New commits start at <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/bisq-network/bisq/commit/849155a92af779842c3bda8e5160effe3646a622/hovercard" href="https://github.com/bisq-network/bisq/commit/849155a92af779842c3bda8e5160effe3646a622"><tt>849155a</tt></a></p>
<p><span class="issue-keyword tooltipped tooltipped-se" aria-label="This pull request closes issue #3629.">fixes</span> <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="524700180" data-permission-text="Issue title is private" data-url="https://github.com/bisq-network/bisq/issues/3629" data-hovercard-type="issue" data-hovercard-url="/bisq-network/bisq/issues/3629/hovercard" href="https://github.com/bisq-network/bisq/issues/3629">#3629</a></p>
<p>Hotfix Needed: No</p>
<p>There was a bug when reconstructing the in-memory HashMap for <code>ProtectedStoragePayload</code> objects implementing the <code>PersistablePayload</code> object. This had two related bugs:</p>
<ol>
<li>
<p>The in-memory map would end up with duplicate Payloads if a node rebuilt a ProtectedStorageEntry from the 20-byte key, then received the 32-byte key from the seednode during initialization or from an update on the P2P network.</p>
</li>
<li>
<p>An initializing node would resync known payloads from the seednode since the <code>Payload</code> existed with both the 20-byte and 32-byte key.</p>
</li>
</ol>
<p>This PR cleans up the usages so that all outward users see the 32-byte key and all internal users can use the existing 20-byte key for persistence. This design is much safer than transitioning all persistent users to 32-byte keys and writing on-disk upgrade code.</p>
<p>All external listeners of Payloads don't look at the key. So, although they will receive 2 onAdded() calls instead of 1, they do the right thing by excluding the second payload since it is identical. I don't think there is any reason to publish a hotfix for this.</p>
<h2>Upgrade behavior</h2>
<p><strong>New Seednode <--> Old Client</strong><br>
The seednode will only have 1 32-byte key for each unique payload, but the client node may still have a 20-byte key that it will send as a known key. The seednode will ignore this known key, send back the 32-byte key <code>Payload</code> and the client node will update its map with the 32-byte key. This mimics existing behavior.</p>
<p><strong>Old Seednode <--> New Client</strong><br>
The seednode will have 1 20-byte key and 1 32-byte key for the same unique payload. The client will only have the 32-byte key and will send it is a known key. The seednode will transmit the 20-byte payload back to the client who will ignore it.</p>
<p><strong>New Seednode <--> New Client</strong><br>
Both the seednode and the client will only have 1 32-byte key for each unique payload. The client will include its 32-byte key as a known key which will match the key in the seednode map. No duplicate <code>Payload</code> objects will be transmitted.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/bisq-network/bisq/pull/3636'>https://github.com/bisq-network/bisq/pull/3636</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>[PR COMMENTS] Make maxSequenceNumberBeforePurge final</li>
  <li>[TESTS] Clean up 'Analyze Code' warnings</li>
  <li>[REFACTOR] HashMapListener::onAdded/onRemoved</li>
  <li>[REFACTOR] removeFromMapAndDataStore can operate on Collections</li>
  <li>Change removeFromMapAndDataStore to signal listeners at the end in a batch</li>
  <li>Update removeExpiredEntries to remove all items in a batch</li>
  <li>ProposalService::onProtectedDataRemoved signals listeners once on batch removes</li>
  <li>Remove HashmapChangedListener::onBatch operations</li>
  <li>[TESTS] Regression test for #3629</li>
  <li>[BUGFIX] Reconstruct HashMap using 32-byte key</li>
  <li>[BUGFIX] Use 32-byte key in requestData path</li>
  <li>[DEAD CODE] Remove getProtectedDataStoreMap</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-0">core/src/main/java/bisq/core/alert/AlertManager.java</a>
    (32)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-1">core/src/main/java/bisq/core/dao/governance/proposal/ProposalListPresentation.java</a>
    (49)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-2">core/src/main/java/bisq/core/dao/governance/proposal/ProposalService.java</a>
    (65)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-3">core/src/main/java/bisq/core/filter/FilterManager.java</a>
    (31)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-4">core/src/main/java/bisq/core/offer/OfferBookService.java</a>
    (37)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-5">core/src/main/java/bisq/core/support/dispute/agent/DisputeAgentManager.java</a>
    (23)
  </li>
  <li>
    <strong>A</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-6">core/src/test/java/bisq/core/dao/governance/proposal/ProposalServiceP2PDataStorageListenerTest.java</a>
    (127)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-7">p2p/src/main/java/bisq/network/p2p/P2PModule.java</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-8">p2p/src/main/java/bisq/network/p2p/P2PService.java</a>
    (13)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-9">p2p/src/main/java/bisq/network/p2p/peers/getdata/RequestDataHandler.java</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-10">p2p/src/main/java/bisq/network/p2p/storage/HashMapChangedListener.java</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-11">p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java</a>
    (89)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-12">p2p/src/test/java/bisq/network/p2p/storage/P2PDataStoragePersistableNetworkPayloadTest.java</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-13">p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageProtectedStorageEntryTest.java</a>
    (17)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-14">p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageRemoveExpiredTest.java</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-15">p2p/src/test/java/bisq/network/p2p/storage/P2PDataStoreDisconnectTest.java</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-16">p2p/src/test/java/bisq/network/p2p/storage/TestState.java</a>
    (184)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/bisq-network/bisq/pull/3636/files#diff-17">p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedStoragePayloadStub.java</a>
    (2)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/bisq-network/bisq/pull/3636.patch'>https://github.com/bisq-network/bisq/pull/3636.patch</a></li>
  <li><a href='https://github.com/bisq-network/bisq/pull/3636.diff'>https://github.com/bisq-network/bisq/pull/3636.diff</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/bisq/pull/3636?email_source=notifications&email_token=AJFFTNR736L6KBLTDHV4QWTQURIOZA5CNFSM4JPJMSH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H2O6NRQ">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNRHSUKKARL4PEYSFVTQURIOZANCNFSM4JPJMSHQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNRSDUVQ6LY4HLMYEJLQURIOZA5CNFSM4JPJMSH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H2O6NRQ.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/bisq/pull/3636?email_source=notifications\u0026email_token=AJFFTNR736L6KBLTDHV4QWTQURIOZA5CNFSM4JPJMSH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H2O6NRQ",
"url": "https://github.com/bisq-network/bisq/pull/3636?email_source=notifications\u0026email_token=AJFFTNR736L6KBLTDHV4QWTQURIOZA5CNFSM4JPJMSH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H2O6NRQ",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>