[bisq-network/bisq] Hash of ProtectedStoragePayload is non-deterministic (leading to duplication of elements in P2PDataStorage) (#3367)
chimp1984
notifications at github.com
Wed Oct 9 01:48:11 UTC 2019
I tested in OfferBookService if there are duplicates and I could not find any so far. I will leave it running with 2 apps over night to see if any appear.
I also checked DaoState hash in 1000 iterations and all hashes are the same.
I am aware that this is not guarantee and we should fix it, but at least we should know if it is an acute issue or not.
Here is the code I used for checking for duplicates in OfferBookService:
```
public void onAdded(ProtectedStorageEntry data) {
if (data.getProtectedStoragePayload() instanceof OfferPayload) {
OfferPayload offerPayload = (OfferPayload) data.getProtectedStoragePayload();
byte[] hashOfPayload = P2PDataStorage.get32ByteHash(offerPayload);
totalOffers = 0;
duplicates = 0;
p2PService.getDataMap().forEach((key, value) -> {
if (value.getProtectedStoragePayload() instanceof OfferPayload) {
totalOffers++;
OfferPayload offerPayload2 = (OfferPayload) value.getProtectedStoragePayload();
byte[] hashOfPayload2 = P2PDataStorage.get32ByteHash(offerPayload2);
checkArgument(Arrays.equals(key.bytes, hashOfPayload2), "bytes must be same");
if (offerPayload2.getId().equals(offerPayload.getId()) && !Arrays.equals(hashOfPayload, hashOfPayload2)) {
duplicates++;
log.info("Duplicate \nofferPayload1={}\nhashOfPayload1={}\n" +
"offerPayload2={}\nhashOfPayload2={}", offerPayload, Hex.encode(hashOfPayload),
offerPayload2, Hex.encode(hashOfPayload2));
}
}
});
log.info("totalOffers: {}, duplicates={} ", totalOffers, duplicates);
}
offerBookChangedListeners.stream().forEach(listener -> {
if (data.getProtectedStoragePayload() instanceof OfferPayload) {
OfferPayload offerPayload = (OfferPayload) data.getProtectedStoragePayload();
Offer offer = new Offer(offerPayload);
if (showOffer(offer)) {
offer.setPriceFeedService(priceFeedService);
listener.onAdded(offer);
}
}
});
}
```
--
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/issues/3367#issuecomment-539783042
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191008/b78028ed/attachment.html>
More information about the bisq-github
mailing list