diff --git a/core/src/main/java/io/bisq/core/offer/Offer.java b/core/src/main/java/io/bisq/core/offer/Offer.java index 825654393d..542b9e018e 100644 --- a/core/src/main/java/io/bisq/core/offer/Offer.java +++ b/core/src/main/java/io/bisq/core/offer/Offer.java @@ -41,6 +41,12 @@ import static com.google.common.base.Preconditions.checkNotNull; @Slf4j public class Offer implements NetworkPayload, PersistablePayload { + // We allow max. 2 % difference between own offerPayload price calculation and takers calculation. + // Market price might be different at maker's and takers side so we need a bit of tolerance. + // The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations + // from one provider. + final static double PRICE_TOLERANCE = 0.02; + /////////////////////////////////////////////////////////////////////////////////////////// // Enums /////////////////////////////////////////////////////////////////////////////////////////// @@ -173,11 +179,11 @@ public class Offer implements NetworkPayload, PersistablePayload { checkArgument(takersTradePrice > 0, "takersTradePrice must be positive"); double factor = (double) takersTradePrice / (double) offerPrice.getValue(); - // We allow max. 1 % difference between own offerPayload price calculation and takers calculation. + // We allow max. 2 % difference between own offerPayload price calculation and takers calculation. // Market price might be different at maker's and takers side so we need a bit of tolerance. // The tolerance will get smaller once we have multiple price feeds avoiding fast price fluctuations // from one provider. - if (Math.abs(1 - factor) > 0.01) { + if (Math.abs(1 - factor) > PRICE_TOLERANCE) { String msg = "Taker's trade price is too far away from our calculated price based on the market price.\n" + "tradePrice=" + tradePrice.getValue() + "\n" + "offerPrice=" + offerPrice.getValue(); diff --git a/core/src/main/java/io/bisq/core/offer/availability/OfferAvailabilityProtocol.java b/core/src/main/java/io/bisq/core/offer/availability/OfferAvailabilityProtocol.java index 38aec4b4a7..1396f019a6 100644 --- a/core/src/main/java/io/bisq/core/offer/availability/OfferAvailabilityProtocol.java +++ b/core/src/main/java/io/bisq/core/offer/availability/OfferAvailabilityProtocol.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; public class OfferAvailabilityProtocol { private static final Logger log = LoggerFactory.getLogger(OfferAvailabilityProtocol.class); - private static final long TIMEOUT_SEC = 60; + private static final long TIMEOUT_SEC = 90; private final OfferAvailabilityModel model; private final ResultHandler resultHandler; diff --git a/core/src/main/java/io/bisq/core/offer/placeoffer/tasks/BroadcastMakerFeeTx.java b/core/src/main/java/io/bisq/core/offer/placeoffer/tasks/BroadcastMakerFeeTx.java index a653deefd8..3f491ba9bd 100644 --- a/core/src/main/java/io/bisq/core/offer/placeoffer/tasks/BroadcastMakerFeeTx.java +++ b/core/src/main/java/io/bisq/core/offer/placeoffer/tasks/BroadcastMakerFeeTx.java @@ -45,18 +45,20 @@ public class BroadcastMakerFeeTx extends Task { try { runInterceptHook(); final Transaction transaction = model.getTransaction(); + + // TODO Try to republish tx? Timer timeoutTimer = UserThread.runAfter(() -> { log.warn("Broadcast not completed after 5 sec. We go on with the trade protocol."); model.getOffer().setState(Offer.State.OFFER_FEE_PAID); complete(); - }, 5); + }, 20); model.getTradeWalletService().broadcastTx(model.getTransaction(), new FutureCallback() { @Override public void onSuccess(Transaction tx) { + timeoutTimer.stop(); if (!completed) { - timeoutTimer.stop(); log.debug("Broadcast of offer fee payment succeeded: transaction = " + tx.toString()); if (transaction.getHashAsString().equals(tx.getHashAsString())) { diff --git a/core/src/main/java/io/bisq/core/provider/fee/FeeService.java b/core/src/main/java/io/bisq/core/provider/fee/FeeService.java index ef2c5e0df0..72c08cfbc9 100644 --- a/core/src/main/java/io/bisq/core/provider/fee/FeeService.java +++ b/core/src/main/java/io/bisq/core/provider/fee/FeeService.java @@ -55,7 +55,7 @@ public class FeeService { // DEFAULT_TX_FEE used in FeeRequestService for non-BTC currencies and for BTC only if we cannot access fee service // fees are per byte - public static final long BTC_DEFAULT_TX_FEE = 100; // fees are between 50-400 sat/byte so we try to stay in average + public static final long BTC_DEFAULT_TX_FEE = 100; // fees are between 20-400 sat/byte so we try to stay in average public static final long LTC_DEFAULT_TX_FEE = LTC_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200; public static final long DOGE_DEFAULT_TX_FEE = DOGE_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200; // 200 bytes tx -> 200*5_000_000L=1_000_000_000 (1 DOGE) public static final long DASH_DEFAULT_TX_FEE = DASH_REFERENCE_DEFAULT_MIN_TX_FEE.value / 200; // 200 bytes tx -> 200*50=10000 @@ -67,8 +67,8 @@ public class FeeService { private static final long MIN_MAKER_FEE_IN_MBSQ = 50; // about 0.05 EUR if 1 BSQ = 1 EUR private static final long MIN_TAKER_FEE_IN_MBSQ = 50; - private static final long DEFAULT_MAKER_FEE_IN_MBSQ = 2000; // about 2 USD at BTC price 10000 USD for 1 BTC if 1 BSQ = 1 USD -> 10% of BTC fee - private static final long DEFAULT_TAKER_FEE_IN_MBSQ = 2000; + private static final long DEFAULT_MAKER_FEE_IN_MBSQ = 500; // about 0.5 EUR if 1 BSQ = 1 EUR + private static final long DEFAULT_TAKER_FEE_IN_MBSQ = 750; // 0.00216 btc is for 3 x tx fee for taker -> about 2 EUR! @@ -101,10 +101,10 @@ public class FeeService { */ switch (baseCurrencyCode) { case "BTC": - MIN_MAKER_FEE_IN_BASE_CUR = 20_000; // 2 USD at BTC price 10000 USD + MIN_MAKER_FEE_IN_BASE_CUR = 20_000; // 3 USD at BTC price 15000 USD MIN_TAKER_FEE_IN_BASE_CUR = 20_000; - DEFAULT_MAKER_FEE_IN_BASE_CUR = 200_000; // 20 USD at BTC price 10000 USD for 1 BTC (maxTradeAmount) - DEFAULT_TAKER_FEE_IN_BASE_CUR = 200_000; // 20 USD at BTC price 10000 USD + DEFAULT_MAKER_FEE_IN_BASE_CUR = 200_000; // 7.5 USD at BTC price 15000 USD for 0.25 BTC (maxTradeAmount for most fiat trades) + DEFAULT_TAKER_FEE_IN_BASE_CUR = 200_000; txFeePerByte = BTC_DEFAULT_TX_FEE; break; case "LTC": diff --git a/gui/src/main/java/io/bisq/gui/main/MainView.java b/gui/src/main/java/io/bisq/gui/main/MainView.java index 1f4f29acbd..90b02ad351 100644 --- a/gui/src/main/java/io/bisq/gui/main/MainView.java +++ b/gui/src/main/java/io/bisq/gui/main/MainView.java @@ -54,8 +54,7 @@ import javafx.scene.input.KeyEvent; import javafx.scene.layout.*; import javafx.scene.paint.Color; import javafx.scene.text.TextAlignment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import javax.inject.Inject; import java.util.List; @@ -63,8 +62,10 @@ import java.util.List; import static javafx.scene.layout.AnchorPane.*; @FxmlView +@Slf4j public class MainView extends InitializableView { - private static final Logger log = LoggerFactory.getLogger(MainView.class); + // If after 20 sec we have not got connected we show "open network settings" button + private final static int SHOW_TOR_SETTINGS_DELAY_SEC = 30; public static StackPane getRootContainer() { return MainView.rootContainer; @@ -485,11 +486,10 @@ public class MainView extends InitializableView { splashP2PNetworkIcon.setManaged(false); HBox.setMargin(splashP2PNetworkIcon, new Insets(0, 0, 5, 0)); - // If after 20 sec we have not got connected we show "open network settings" button Timer showTorNetworkSettingsTimer = UserThread.runAfter(() -> { showTorNetworkSettingsButton.setVisible(true); showTorNetworkSettingsButton.setManaged(true); - }, 20); + }, SHOW_TOR_SETTINGS_DELAY_SEC); splashP2PNetworkIconIdListener = (ov, oldValue, newValue) -> { splashP2PNetworkIcon.setId(newValue); diff --git a/gui/src/main/java/io/bisq/gui/main/dao/DaoView.java b/gui/src/main/java/io/bisq/gui/main/dao/DaoView.java index 88fc044007..ced09e2657 100644 --- a/gui/src/main/java/io/bisq/gui/main/dao/DaoView.java +++ b/gui/src/main/java/io/bisq/gui/main/dao/DaoView.java @@ -19,6 +19,7 @@ package io.bisq.gui.main.dao; import io.bisq.common.app.DevEnv; import io.bisq.common.locale.Res; +import io.bisq.core.app.BisqEnvironment; import io.bisq.gui.Navigation; import io.bisq.gui.common.model.Activatable; import io.bisq.gui.common.view.*; @@ -63,7 +64,7 @@ public class DaoView extends ActivatableViewAndModel { votingTab.setClosable(false); root.getTabs().addAll(compensationTab, votingTab); - if (!DevEnv.DAO_PHASE2_ACTIVATED) { + if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq() || !DevEnv.DAO_PHASE2_ACTIVATED) { votingTab.setDisable(true); compensationTab.setDisable(true); } diff --git a/gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferDataModel.java b/gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferDataModel.java index 1031dfb1cc..d91fbebd11 100644 --- a/gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferDataModel.java +++ b/gui/src/main/java/io/bisq/gui/main/offer/createoffer/CreateOfferDataModel.java @@ -721,7 +721,6 @@ class CreateOfferDataModel extends ActivatableDataModel { } public void swapTradeToSavings() { - log.error("swapTradeToSavings, offerId={}", offerId); btcWalletService.resetAddressEntriesForOpenOffer(offerId); } diff --git a/network/pom.xml b/network/pom.xml index 824a80dcce..f851005fa0 100644 --- a/network/pom.xml +++ b/network/pom.xml @@ -20,7 +20,7 @@ com.github.JesusMcCloud.netlayer tor.native - e7195748 + 1c9d80e org.slf4j diff --git a/network/src/main/java/io/bisq/network/p2p/network/Connection.java b/network/src/main/java/io/bisq/network/p2p/network/Connection.java index 0761248cb2..b6e79101ee 100644 --- a/network/src/main/java/io/bisq/network/p2p/network/Connection.java +++ b/network/src/main/java/io/bisq/network/p2p/network/Connection.java @@ -636,7 +636,7 @@ public class Connection implements MessageListener { closeConnectionReason = CloseConnectionReason.RESET; } else if (e instanceof SocketTimeoutException || e instanceof TimeoutException) { closeConnectionReason = CloseConnectionReason.SOCKET_TIMEOUT; - log.warn("Shut down caused by exception {} on connection={}", e.toString(), connection); + log.info("Shut down caused by exception {} on connection={}", e.toString(), connection); } else if (e instanceof EOFException) { closeConnectionReason = CloseConnectionReason.TERMINATED; log.warn("Shut down caused by exception {} on connection={}", e.toString(), connection); diff --git a/provider/src/main/java/io/bisq/provider/ProviderVersion.java b/provider/src/main/java/io/bisq/provider/ProviderVersion.java index 8c574234d3..d98901329f 100644 --- a/provider/src/main/java/io/bisq/provider/ProviderVersion.java +++ b/provider/src/main/java/io/bisq/provider/ProviderVersion.java @@ -18,6 +18,5 @@ package io.bisq.provider; public class ProviderVersion { - // Bisq v0.6.1 did not change anything relevant for that project so we stick with 0.6.0 - public static final String VERSION = "0.6.0"; + public static final String VERSION = "0.6.1"; } diff --git a/provider/src/main/java/io/bisq/provider/fee/providers/BtcFeesProvider.java b/provider/src/main/java/io/bisq/provider/fee/providers/BtcFeesProvider.java index 5fbe5a42e1..82580a25f9 100644 --- a/provider/src/main/java/io/bisq/provider/fee/providers/BtcFeesProvider.java +++ b/provider/src/main/java/io/bisq/provider/fee/providers/BtcFeesProvider.java @@ -14,8 +14,8 @@ import java.util.LinkedList; //TODO consider alternative https://www.bitgo.com/api/v1/tx/fee?numBlocks=3 @Slf4j public class BtcFeesProvider { - static int CAPACITY = 12; // we request each 5 min. so we take average of last hour - static int MAX_BLOCKS = 20; + static int CAPACITY = 6; // we request each 5 min. so we take average of last 30 min. + static int MAX_BLOCKS = 15; private final HttpClient httpClient; LinkedList fees = new LinkedList<>(); diff --git a/provider/src/main/java/io/bisq/provider/price/PriceRequestService.java b/provider/src/main/java/io/bisq/provider/price/PriceRequestService.java index ef4539212f..77f8a054fb 100644 --- a/provider/src/main/java/io/bisq/provider/price/PriceRequestService.java +++ b/provider/src/main/java/io/bisq/provider/price/PriceRequestService.java @@ -39,12 +39,12 @@ public class PriceRequestService { private static final Logger log = LoggerFactory.getLogger(PriceRequestService.class); // We adjust request time to fit into BitcoinAverage developer plan (45k request per month). - // We get 42514 request be below numbers. - private static final long INTERVAL_BTC_AV_LOCAL_MS = 90_000; // 90 sec - private static final long INTERVAL_BTC_AV_GLOBAL_MS = 210_000; // 3.5 min + // We get 42514 (29760+12754) request with below numbers. + private static final long INTERVAL_BTC_AV_LOCAL_MS = 90_000; // 90 sec; 29760 requests for 31 days + private static final long INTERVAL_BTC_AV_GLOBAL_MS = 210_000; // 3.5 min; 12754 requests for 31 days private static final long INTERVAL_POLONIEX_MS = 60_000; // 1 min - private static final long INTERVAL_COIN_MARKET_CAP_MS = 300_000; // 5 min + private static final long INTERVAL_COIN_MARKET_CAP_MS = 300_000; // 5 min that data structure is quite heavy so we don't request too often. private static final long MARKET_PRICE_TTL_SEC = 1800; // 30 min private final Timer timerBtcAverageLocal = new Timer(); diff --git a/seednode/src/main/java/io/bisq/seednode/SeedNodeMain.java b/seednode/src/main/java/io/bisq/seednode/SeedNodeMain.java index 04665dde60..56b1b7abdd 100644 --- a/seednode/src/main/java/io/bisq/seednode/SeedNodeMain.java +++ b/seednode/src/main/java/io/bisq/seednode/SeedNodeMain.java @@ -138,23 +138,21 @@ public class SeedNodeMain extends BisqExecutable { UserThread.runPeriodically(() -> { Profiler.printSystemLoad(log); - long usedMemoryInMB = Profiler.getUsedMemoryInMB(); if (!stopped) { - if (usedMemoryInMB > (maxMemory - 100)) { + long usedMemoryInMB = Profiler.getUsedMemoryInMB(); + if (usedMemoryInMB > (maxMemory * 0.8)) { log.warn("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" + "We are over our memory warn limit and call the GC. usedMemoryInMB: {}" + "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n", usedMemoryInMB); System.gc(); - usedMemoryInMB = Profiler.getUsedMemoryInMB(); Profiler.printSystemLoad(log); } - final long finalUsedMemoryInMB = usedMemoryInMB; UserThread.runAfter(() -> { - if (finalUsedMemoryInMB > maxMemory) + if (Profiler.getUsedMemoryInMB() > maxMemory) restart(bisqEnvironment); - }, 1); + }, 5); } }, CHECK_MEMORY_PERIOD_SEC); diff --git a/statistics/src/main/java/io/bisq/statistics/StatisticsMain.java b/statistics/src/main/java/io/bisq/statistics/StatisticsMain.java index b7df1d2248..459b8cef46 100644 --- a/statistics/src/main/java/io/bisq/statistics/StatisticsMain.java +++ b/statistics/src/main/java/io/bisq/statistics/StatisticsMain.java @@ -133,20 +133,19 @@ public class StatisticsMain extends BisqExecutable { UserThread.runPeriodically(() -> { Profiler.printSystemLoad(log); - long usedMemoryInMB = Profiler.getUsedMemoryInMB(); if (!stopped) { - if (usedMemoryInMB > (maxMemory - 100)) { + long usedMemoryInMB = Profiler.getUsedMemoryInMB(); + if (usedMemoryInMB > (maxMemory * 0.8)) { log.warn("\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" + "We are over our memory warn limit and call the GC. usedMemoryInMB: {}" + "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n", usedMemoryInMB); System.gc(); - usedMemoryInMB = Profiler.getUsedMemoryInMB(); Profiler.printSystemLoad(log); } - final long finalUsedMemoryInMB = usedMemoryInMB; UserThread.runAfter(() -> { + final long finalUsedMemoryInMB = Profiler.getUsedMemoryInMB(); if (finalUsedMemoryInMB > maxMemory) { log.error("\n\n############################################################\n" + "We shut down as we are over our memory limit. usedMemoryInMB: {}" + @@ -154,7 +153,7 @@ public class StatisticsMain extends BisqExecutable { finalUsedMemoryInMB); System.exit(EXIT_FAILURE); } - }, 1); + }, 5); } }, CHECK_MEMORY_PERIOD_SEC);