From 105dda4bae24f1a6f7cc4c9ee5249e5d567277e2 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Wed, 21 Dec 2022 11:12:51 -0500 Subject: [PATCH 1/5] Fix headline height --- .../primary/main/content/academy/AcademyOverviewView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/primary/main/content/academy/AcademyOverviewView.java b/desktop/src/main/java/bisq/desktop/primary/main/content/academy/AcademyOverviewView.java index f667705416..5d68fa1a54 100644 --- a/desktop/src/main/java/bisq/desktop/primary/main/content/academy/AcademyOverviewView.java +++ b/desktop/src/main/java/bisq/desktop/primary/main/content/academy/AcademyOverviewView.java @@ -74,7 +74,7 @@ protected void onViewDetached() { private void addHeaderBox() { Label headlineLabel = new MultiLineLabel(Res.get("academy.overview.headline")); headlineLabel.getStyleClass().add("bisq-text-headline-4"); - headlineLabel.setMinHeight(35); + headlineLabel.setMinHeight(55); Label contentLabel = new MultiLineLabel(Res.get("academy.overview.content")); contentLabel.getStyleClass().add("bisq-text-16"); From 7700b65d2663442abcb98ee1f2f9219fc43c5aa9 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Wed, 21 Dec 2022 11:16:42 -0500 Subject: [PATCH 2/5] Add delayed call to adjustMinHeight at init to trigger height adjustment --- .../java/bisq/desktop/components/controls/MultiLineLabel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/components/controls/MultiLineLabel.java b/desktop/src/main/java/bisq/desktop/components/controls/MultiLineLabel.java index 3a93305dac..7280d12acd 100644 --- a/desktop/src/main/java/bisq/desktop/components/controls/MultiLineLabel.java +++ b/desktop/src/main/java/bisq/desktop/components/controls/MultiLineLabel.java @@ -87,8 +87,9 @@ private void initialize() { widthProperty().addListener(widthListener); heightProperty().addListener(heightListener); - } + UIThread.runOnNextRenderFrame(this::adjustMinHeight); + } private void adjustMinHeight() { if (getParent() instanceof Pane) { From cd69c4c2c199830c5aa70a894148c39a6374c38a Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Wed, 21 Dec 2022 12:21:29 -0500 Subject: [PATCH 3/5] Add more info to registration.info text --- i18n/src/main/resources/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/src/main/resources/default.properties b/i18n/src/main/resources/default.properties index dd0edc101d..c1e92f85ce 100644 --- a/i18n/src/main/resources/default.properties +++ b/i18n/src/main/resources/default.properties @@ -888,7 +888,7 @@ roles.type.ORACLE.inline=an oracle operator roles.registration.info=How to become {0}?\n\n\ 1. Copy the public key\n\ 2. Backup your data directory as your key pair is persisted in that directory.\n\ - 3. Make a proposal at https://github.com/bisq-network/proposals to become {1} and paste your public key in the proposal.\n\ + 3. Make a proposal at 'https://github.com/bisq-network/proposals' to become {1} and paste your public key, the user profile name, bot ID and profile ID in the proposal.\n\ 4. After your proposal got reviewed and got support from the community, make a DAO proposal for a bonded role.\n\ 5. After your DAO proposal got accepted in DAO voting lock up the required BSQ bond.\n\ 6. After your bond transaction is confirmed open a GitHub issue at Bisq 2 (https://github.com/bisq-network/bisq2/issues) with your public key, the link to the GitHub proposal and the lockup transaction.\n\ From de78308bd9686b51e6e2be8b9958034c64fdfa7f Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Wed, 21 Dec 2022 12:21:58 -0500 Subject: [PATCH 4/5] Reduce visibility --- .../auth/AddAuthenticatedDataRequest.java | 16 ++++---- .../auth/RefreshAuthenticatedDataRequest.java | 24 +++++------ .../auth/RemoveAuthenticatedDataRequest.java | 40 +++++++++---------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/AddAuthenticatedDataRequest.java b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/AddAuthenticatedDataRequest.java index 8ec517fbfd..cd0ae65714 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/AddAuthenticatedDataRequest.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/AddAuthenticatedDataRequest.java @@ -63,13 +63,13 @@ public static AddAuthenticatedDataRequest from(AuthenticatedDataStorageService s } @Getter - protected final AuthenticatedSequentialData authenticatedSequentialData; + private final AuthenticatedSequentialData authenticatedSequentialData; @Getter - protected final byte[] signature; // 256 bytes + private final byte[] signature; // 256 bytes @Getter - protected final byte[] ownerPublicKeyBytes; // 294 bytes + private final byte[] ownerPublicKeyBytes; // 294 bytes @Nullable - transient protected PublicKey ownerPublicKey; + transient private PublicKey ownerPublicKey; public AddAuthenticatedDataRequest(AuthenticatedSequentialData authenticatedSequentialData, byte[] signature, PublicKey ownerPublicKey) { this(authenticatedSequentialData, @@ -78,10 +78,10 @@ public AddAuthenticatedDataRequest(AuthenticatedSequentialData authenticatedSequ ownerPublicKey); } - protected AddAuthenticatedDataRequest(AuthenticatedSequentialData authenticatedSequentialData, - byte[] signature, - byte[] ownerPublicKeyBytes, - PublicKey ownerPublicKey) { + private AddAuthenticatedDataRequest(AuthenticatedSequentialData authenticatedSequentialData, + byte[] signature, + byte[] ownerPublicKeyBytes, + PublicKey ownerPublicKey) { this.authenticatedSequentialData = authenticatedSequentialData; this.signature = signature; this.ownerPublicKeyBytes = ownerPublicKeyBytes; diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RefreshAuthenticatedDataRequest.java b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RefreshAuthenticatedDataRequest.java index 6db1efbeea..ee90937d1a 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RefreshAuthenticatedDataRequest.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RefreshAuthenticatedDataRequest.java @@ -52,12 +52,12 @@ public static RefreshAuthenticatedDataRequest from(AuthenticatedDataStorageServi signature); } - protected final MetaData metaData; - protected final byte[] hash; - protected final byte[] ownerPublicKeyBytes; // 442 bytes - transient protected final PublicKey ownerPublicKey; - protected final int sequenceNumber; - protected final byte[] signature; // 47 bytes + private final MetaData metaData; + private final byte[] hash; + private final byte[] ownerPublicKeyBytes; // 442 bytes + transient private final PublicKey ownerPublicKey; + private final int sequenceNumber; + private final byte[] signature; // 47 bytes public RefreshAuthenticatedDataRequest(MetaData metaData, byte[] hash, @@ -72,12 +72,12 @@ public RefreshAuthenticatedDataRequest(MetaData metaData, signature); } - protected RefreshAuthenticatedDataRequest(MetaData metaData, - byte[] hash, - byte[] ownerPublicKeyBytes, - PublicKey ownerPublicKey, - int sequenceNumber, - byte[] signature) { + private RefreshAuthenticatedDataRequest(MetaData metaData, + byte[] hash, + byte[] ownerPublicKeyBytes, + PublicKey ownerPublicKey, + int sequenceNumber, + byte[] signature) { this.metaData = metaData; this.hash = hash; this.ownerPublicKeyBytes = ownerPublicKeyBytes; diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RemoveAuthenticatedDataRequest.java b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RemoveAuthenticatedDataRequest.java index b0f8d9369b..3ac2622bad 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RemoveAuthenticatedDataRequest.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/storage/auth/RemoveAuthenticatedDataRequest.java @@ -51,14 +51,14 @@ public static RemoveAuthenticatedDataRequest from(AuthenticatedDataStorageServic signature); } - protected final MetaData metaData; - protected final byte[] hash; - protected final byte[] ownerPublicKeyBytes; // 442 bytes + private final MetaData metaData; + private final byte[] hash; + private final byte[] ownerPublicKeyBytes; // 442 bytes @Nullable - transient protected PublicKey ownerPublicKey; - protected final int sequenceNumber; - protected final byte[] signature; // 47 bytes - protected final long created; + transient private PublicKey ownerPublicKey; + private final int sequenceNumber; + private final byte[] signature; // 47 bytes + private final long created; public RemoveAuthenticatedDataRequest(MetaData metaData, byte[] hash, @@ -73,12 +73,12 @@ public RemoveAuthenticatedDataRequest(MetaData metaData, signature); } - protected RemoveAuthenticatedDataRequest(MetaData metaData, - byte[] hash, - byte[] ownerPublicKeyBytes, - PublicKey ownerPublicKey, - int sequenceNumber, - byte[] signature) { + private RemoveAuthenticatedDataRequest(MetaData metaData, + byte[] hash, + byte[] ownerPublicKeyBytes, + PublicKey ownerPublicKey, + int sequenceNumber, + byte[] signature) { this(metaData, hash, ownerPublicKeyBytes, @@ -88,13 +88,13 @@ protected RemoveAuthenticatedDataRequest(MetaData metaData, System.currentTimeMillis()); } - protected RemoveAuthenticatedDataRequest(MetaData metaData, - byte[] hash, - byte[] ownerPublicKeyBytes, - PublicKey ownerPublicKey, - int sequenceNumber, - byte[] signature, - long created) { + private RemoveAuthenticatedDataRequest(MetaData metaData, + byte[] hash, + byte[] ownerPublicKeyBytes, + PublicKey ownerPublicKey, + int sequenceNumber, + byte[] signature, + long created) { this.metaData = metaData; this.hash = hash; this.ownerPublicKeyBytes = ownerPublicKeyBytes; From cda9954c27fcc94db52ab5581b627e0c2a285c9b Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Wed, 21 Dec 2022 12:31:41 -0500 Subject: [PATCH 5/5] Add deterministic sorting to Inventory as proof of work check compares byte arrays of payload and could fail otherwise --- .../main/java/bisq/common/data/ByteArray.java | 8 +++++++- .../p2p/services/data/inventory/Inventory.java | 18 ++++++++++++------ .../services/data/storage/StorageService.java | 4 ++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/bisq/common/data/ByteArray.java b/common/src/main/java/bisq/common/data/ByteArray.java index c515704e4b..e43443146e 100644 --- a/common/src/main/java/bisq/common/data/ByteArray.java +++ b/common/src/main/java/bisq/common/data/ByteArray.java @@ -22,10 +22,11 @@ import com.google.protobuf.ByteString; import lombok.Getter; +import java.math.BigInteger; import java.util.Arrays; @Getter -public final class ByteArray implements Proto { +public final class ByteArray implements Proto, Comparable { private final byte[] bytes; public ByteArray(byte[] bytes) { @@ -57,4 +58,9 @@ public int hashCode() { public String toString() { return Hex.encode(bytes); } + + @Override + public int compareTo(ByteArray o) { + return new BigInteger(this.getBytes()).compareTo(new BigInteger(o.getBytes())); + } } diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/inventory/Inventory.java b/network/network/src/main/java/bisq/network/p2p/services/data/inventory/Inventory.java index 0ed08e186f..33a2407cef 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/inventory/Inventory.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/inventory/Inventory.java @@ -17,6 +17,7 @@ package bisq.network.p2p.services.data.inventory; +import bisq.common.data.ByteArray; import bisq.common.proto.Proto; import bisq.network.p2p.services.data.DataRequest; import lombok.EqualsAndHashCode; @@ -24,8 +25,10 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; @Getter @@ -33,12 +36,15 @@ @EqualsAndHashCode @Slf4j public final class Inventory implements Proto { - private final Set entries; + private final List entries; private final int numDropped; - public Inventory(Set entries, int numDropped) { - this.entries = entries; + public Inventory(Collection entries, int numDropped) { + this.entries = new ArrayList<>(entries); this.numDropped = numDropped; + + // We need to sort deterministically as the data is used in the proof of work check + this.entries.sort(Comparator.comparing((DataRequest o) -> new ByteArray(o.serialize()))); } public bisq.network.protobuf.Inventory toProto() { @@ -50,9 +56,9 @@ public bisq.network.protobuf.Inventory toProto() { public static Inventory fromProto(bisq.network.protobuf.Inventory proto) { List entriesList = proto.getEntriesList(); - Set entries = entriesList.stream() + List entries = entriesList.stream() .map(DataRequest::fromProto) - .collect(Collectors.toSet()); + .collect(Collectors.toList()); return new Inventory(entries, proto.getNumDropped()); } } diff --git a/network/network/src/main/java/bisq/network/p2p/services/data/storage/StorageService.java b/network/network/src/main/java/bisq/network/p2p/services/data/storage/StorageService.java index 7f46bccc39..9613bc0dfb 100644 --- a/network/network/src/main/java/bisq/network/p2p/services/data/storage/StorageService.java +++ b/network/network/src/main/java/bisq/network/p2p/services/data/storage/StorageService.java @@ -312,10 +312,10 @@ public Inventory getInventoryFromStore(DataFilter dataFilter, DataStorageService private Inventory getInventory(DataFilter dataFilter, Set> entrySet) { - HashSet result = entrySet.stream() + Set result = entrySet.stream() .filter(mapEntry -> !dataFilter.getFilterEntries().contains(getFilterEntry(mapEntry))) .map(Map.Entry::getValue) - .collect(Collectors.toCollection(HashSet::new)); + .collect(Collectors.toSet()); return new Inventory(result, entrySet.size() - result.size()); }