Skip to content

Commit

Permalink
Merge pull request #2546 from ManfredKarrer/add-dao-betatest-network
Browse files Browse the repository at this point in the history
Add dao betatest network
  • Loading branch information
ManfredKarrer authored Mar 17, 2019
2 parents 545eb8c + 765bf54 commit ad3647d
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 24 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/bisq/core/app/BisqEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static boolean isDaoActivated(Environment environment) {
rpcPort, rpcBlockNotificationPort, dumpBlockchainData, fullDaoNode,
banList, dumpStatistics, maxMemory, socks5ProxyBtcAddress,
torRcFile, torRcOptions, externalTorControlPort, externalTorPassword, externalTorCookieFile,
socks5ProxyHttpAddress, useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight,
socks5ProxyHttpAddress, useAllProvidedNodes, numConnectionForBtc, genesisTxId, genesisBlockHeight, genesisTotalSupply,
referralId, daoActivated, msgThrottlePerSec, msgThrottlePer10Sec, sendMsgThrottleTrigger, sendMsgThrottleSleep;

protected final boolean externalTorUseSafeCookieAuthentication, torStreamIsolation;
Expand Down Expand Up @@ -323,6 +323,9 @@ public BisqEnvironment(PropertySource commandLineProperties) {
genesisBlockHeight = commandLineProperties.containsProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT) ?
(String) commandLineProperties.getProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT) :
"-1";
genesisTotalSupply = commandLineProperties.containsProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY) ?
(String) commandLineProperties.getProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY) :
"-1";
daoActivated = commandLineProperties.containsProperty(DaoOptionKeys.DAO_ACTIVATED) ?
(String) commandLineProperties.getProperty(DaoOptionKeys.DAO_ACTIVATED) :
"";
Expand Down Expand Up @@ -499,6 +502,7 @@ private PropertySource<?> defaultProperties() {
setProperty(DaoOptionKeys.FULL_DAO_NODE, fullDaoNode);
setProperty(DaoOptionKeys.GENESIS_TX_ID, genesisTxId);
setProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT, genesisBlockHeight);
setProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, genesisTotalSupply);
setProperty(DaoOptionKeys.DAO_ACTIVATED, daoActivated);

setProperty(BtcOptionKeys.BTC_NODES, btcNodes);
Expand Down
11 changes: 6 additions & 5 deletions core/src/main/java/bisq/core/app/BisqExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@

import static bisq.core.app.BisqEnvironment.DEFAULT_APP_NAME;
import static bisq.core.app.BisqEnvironment.DEFAULT_USER_DATA_DIR;
import static bisq.core.btc.BaseCurrencyNetwork.BTC_DAO_TESTNET;
import static bisq.core.btc.BaseCurrencyNetwork.BTC_MAINNET;
import static bisq.core.btc.BaseCurrencyNetwork.BTC_REGTEST;
import static bisq.core.btc.BaseCurrencyNetwork.BTC_TESTNET;
import static bisq.core.btc.BaseCurrencyNetwork.*;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;

Expand Down Expand Up @@ -497,7 +494,7 @@ protected void customizeOptionParsing(OptionParser parser) {
format("Base currency network (default: %s)", BisqEnvironment.getDefaultBaseCurrencyNetwork().name()))
.withRequiredArg()
.ofType(String.class)
.describedAs(format("%s|%s|%s|%s", BTC_MAINNET, BTC_TESTNET, BTC_REGTEST, BTC_DAO_TESTNET));
.describedAs(format("%s|%s|%s|%s", BTC_MAINNET, BTC_TESTNET, BTC_REGTEST, BTC_DAO_TESTNET, BTC_DAO_BETANET));

parser.accepts(BtcOptionKeys.REG_TEST_HOST,
format("Bitcoin regtest host when using BTC_REGTEST network (default: %s)", RegTestHost.DEFAULT_HOST))
Expand Down Expand Up @@ -568,6 +565,10 @@ protected void customizeOptionParsing(OptionParser parser) {
format("Genesis transaction block height when not using the hard coded one (default: %s)", "-1"))
.withRequiredArg();

parser.accepts(DaoOptionKeys.GENESIS_TOTAL_SUPPLY,
format("Genesis total supply when not using the hard coded one (default: %s)", "-1"))
.withRequiredArg();

parser.accepts(DaoOptionKeys.DAO_ACTIVATED,
format("Developer flag. If true it enables dao phase 2 features. (default: %s)", "false"))
.withRequiredArg()
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/bisq/core/btc/BaseCurrencyNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public enum BaseCurrencyNetwork {
BTC_MAINNET(MainNetParams.get(), "BTC", "MAINNET", "Bitcoin"),
BTC_TESTNET(TestNet3Params.get(), "BTC", "TESTNET", "Bitcoin"),
BTC_REGTEST(RegTestParams.get(), "BTC", "REGTEST", "Bitcoin"),
BTC_DAO_TESTNET(RegTestParams.get(), "BTC", "REGTEST", "Bitcoin"); // server side regtest
BTC_DAO_TESTNET(RegTestParams.get(), "BTC", "REGTEST", "Bitcoin"), // server side regtest
BTC_DAO_BETANET(MainNetParams.get(), "BTC", "MAINNET", "Bitcoin"); // mainnet test genesis

@Getter
private final NetworkParameters parameters;
Expand Down Expand Up @@ -58,6 +59,10 @@ public boolean isDaoTestNet() {
return "BTC_DAO_TESTNET".equals(name());
}

public boolean isDaoBetaNet() {
return "BTC_DAO_BETANET".equals(name());
}

public boolean isRegtest() {
return "BTC_REGTEST".equals(name());
}
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/dao/DaoModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ protected void configure() {
Integer genesisBlockHeight = environment.getProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT, Integer.class, -1);
bind(Integer.class).annotatedWith(Names.named(DaoOptionKeys.GENESIS_BLOCK_HEIGHT)).toInstance(genesisBlockHeight);

Long genesisTotalSupply = environment.getProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, Long.class, -1L);
bind(Long.class).annotatedWith(Names.named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY)).toInstance(genesisTotalSupply);

// Bonds
bind(LockupTxService.class).in(Singleton.class);
bind(UnlockTxService.class).in(Singleton.class);
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/bisq/core/dao/DaoOptionKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ public class DaoOptionKeys {
public static final String FULL_DAO_NODE = "fullDaoNode";
public static final String GENESIS_TX_ID = "genesisTxId";
public static final String GENESIS_BLOCK_HEIGHT = "genesisBlockHeight";
public static final String GENESIS_TOTAL_SUPPLY = "genesisTotalSupply";
public static final String DAO_ACTIVATED = "daoActivated";
}
28 changes: 21 additions & 7 deletions core/src/main/java/bisq/core/dao/governance/param/Param.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,43 +128,57 @@ public enum Param {
"3601" : // mainnet; 24 days
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"4" : // regtest
"380", // testnet or dao testnet (server side regtest); 2.6 days
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"144" : // daoBetaNet; 1 day
"380", // testnet or dao testnet (server side regtest); 2.6 days
ParamType.BLOCK, 3, 3),
PHASE_BREAK1(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"149" : // mainnet; 1 day
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"1" : // regtest
"10", // testnet or dao testnet (server side regtest)
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"10" : // daoBetaNet
"10", // testnet or dao testnet (server side regtest)
ParamType.BLOCK, 3, 3),
PHASE_BLIND_VOTE(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"601" : // mainnet; 4 days
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"2" : // regtest
"300", // testnet or dao testnet (server side regtest); 2 days
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"144" : // daoBetaNet; 1 day
"300", // testnet or dao testnet (server side regtest); 2 days
ParamType.BLOCK, 3, 3),
PHASE_BREAK2(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"9" : // mainnet
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"1" : // regtest
"10", // testnet or dao testnet (server side regtest)
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"10" : // daoBetaNet
"10", // testnet or dao testnet (server side regtest)
ParamType.BLOCK, 3, 23),
PHASE_VOTE_REVEAL(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"301" : // mainnet; 2 days
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"2" : // regtest
"300", // testnet or dao testnet (server side regtest); 2 days
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"144" : // daoBetaNet; 1 day
"300", // testnet or dao testnet (server side regtest); 2 days
ParamType.BLOCK, 3, 3),
PHASE_BREAK3(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"9" : // mainnet
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"1" : // regtest
"10", // testnet or dao testnet (server side regtest)
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"10" : // daoBetaNet
"10", // testnet or dao testnet (server side regtest)
ParamType.BLOCK, 3, 3),
PHASE_RESULT(BisqEnvironment.getBaseCurrencyNetwork().isMainnet() ?
"10" : // mainnet
BisqEnvironment.getBaseCurrencyNetwork().isRegtest() ?
"2" : // regtest
"2", // testnet or dao testnet (server side regtest)
BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet() ?
"10" : // daoBetaNet
"2", // testnet or dao testnet (server side regtest)
ParamType.BLOCK, 3, 3);

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ public void onDaoStateChanged(Block block) {
for (int i = genesisBlockHeight; i < blockHeight; i++) {
maybeUpdateHashChain(i);
}
log.info("updateHashChain for {} items took {} ms",
blockHeight - genesisBlockHeight,
System.currentTimeMillis() - ts);
if (!blindVoteStateBlockChain.isEmpty()) {
log.info("updateHashChain for {} items took {} ms",
blockHeight - genesisBlockHeight,
System.currentTimeMillis() - ts);
}
}
maybeUpdateHashChain(blockHeight);
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/bisq/core/dao/node/full/RpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ public RpcService(Preferences preferences,
boolean isMainnet = BisqEnvironment.getBaseCurrencyNetwork().isMainnet();
boolean isTestnet = BisqEnvironment.getBaseCurrencyNetwork().isTestnet();
boolean isDaoTestNet = BisqEnvironment.getBaseCurrencyNetwork().isDaoTestNet();
boolean isDaoBetaNet = BisqEnvironment.getBaseCurrencyNetwork().isDaoBetaNet();
this.rpcPort = isPortSet ? rpcPort :
isMainnet ? "8332" :
isMainnet || isDaoBetaNet ? "8332" :
isTestnet ? "18332" :
isDaoTestNet ? "18443" :
"18443"; // regtest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public int getGenesisBlockHeight() {
}

public Coin getGenesisTotalSupply() {
return GenesisTxInfo.GENESIS_TOTAL_SUPPLY;
return Coin.valueOf(genesisTxInfo.getGenesisTotalSupply());
}

public Optional<Tx> getGenesisTx() {
Expand Down
36 changes: 33 additions & 3 deletions core/src/main/java/bisq/core/dao/state/GenesisTxInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,25 @@ public class GenesisTxInfo {
// Static
///////////////////////////////////////////////////////////////////////////////////////////

public static final Coin GENESIS_TOTAL_SUPPLY = Coin.valueOf(250_000_000); // 2.5M BSQ

private static final String MAINNET_GENESIS_TX_ID = "81855816eca165f17f0668898faa8724a105196e90ffc4993f4cac980176674e";
private static final int MAINNET_GENESIS_BLOCK_HEIGHT = 524717; // 2018-05-27
private static final Coin MAINNET_GENESIS_TOTAL_SUPPLY = Coin.parseCoin("2.5"); // 2.5M BSQ / 2.50000000 BTC

private static final String TESTNET_GENESIS_TX_ID = "09e70ce0ab7a962a82a2ca84c9ae8a89140bf1c3fb6f7efad6162e39e4b362ae";
private static final int TESTNET_GENESIS_BLOCK_HEIGHT = 1446300; // 2018-12-02
private static final Coin TESTNET_GENESIS_TOTAL_SUPPLY = Coin.parseCoin("2.5"); // 2.5M BSQ / 2.50000000 BTC

private static final String DAO_TESTNET_GENESIS_TX_ID = "cb316a186b9e88d1b8e1ce8dc79cc6a2080cc7bbc6df94f2be325d8253417af1";
private static final int DAO_TESTNET_GENESIS_BLOCK_HEIGHT = 104; // 2019-02-19
private static final Coin DAO_TESTNET_GENESIS_TOTAL_SUPPLY = Coin.parseCoin("2.5"); // 2.5M BSQ / 2.50000000 BTC

private static final String DAO_BETANET_GENESIS_TX_ID = "0bd66d8ff26476b55dfaf2a5db0c659a5d8635566488244df25606db63a08bd9";
private static final int DAO_BETANET_GENESIS_BLOCK_HEIGHT = 567405; // 2019-03-16
private static final Coin DAO_BETANET_GENESIS_TOTAL_SUPPLY = Coin.parseCoin("0.49998644"); // 1000 BSQ / 0.49998644 BTC

private static final String REGTEST_GENESIS_TX_ID = "30af0050040befd8af25068cc697e418e09c2d8ebd8d411d2240591b9ec203cf";
private static final int REGTEST_GENESIS_BLOCK_HEIGHT = 111;
private static final Coin REGTEST_GENESIS_TOTAL_SUPPLY = Coin.parseCoin("2.5"); // 2.5M BSQ / 2.50000000 BTC


///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -68,6 +74,8 @@ public class GenesisTxInfo {
private final String genesisTxId;
@Getter
private final int genesisBlockHeight;
@Getter
private final long genesisTotalSupply;

// mainnet
// this tx has a lot of outputs
Expand All @@ -92,11 +100,13 @@ public class GenesisTxInfo {

@Inject
public GenesisTxInfo(@Named(DaoOptionKeys.GENESIS_TX_ID) String genesisTxId,
@Named(DaoOptionKeys.GENESIS_BLOCK_HEIGHT) Integer genesisBlockHeight) {
@Named(DaoOptionKeys.GENESIS_BLOCK_HEIGHT) Integer genesisBlockHeight,
@Named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY) Long genesisTotalSupply) {
BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
boolean isMainnet = baseCurrencyNetwork.isMainnet();
boolean isTestnet = baseCurrencyNetwork.isTestnet();
boolean isDaoTestNet = baseCurrencyNetwork.isDaoTestNet();
boolean isDaoBetaNet = baseCurrencyNetwork.isDaoBetaNet();
boolean isRegtest = baseCurrencyNetwork.isRegtest();
if (!genesisTxId.isEmpty()) {
this.genesisTxId = genesisTxId;
Expand All @@ -106,6 +116,8 @@ public GenesisTxInfo(@Named(DaoOptionKeys.GENESIS_TX_ID) String genesisTxId,
this.genesisTxId = TESTNET_GENESIS_TX_ID;
} else if (isDaoTestNet) {
this.genesisTxId = DAO_TESTNET_GENESIS_TX_ID;
} else if (isDaoBetaNet) {
this.genesisTxId = DAO_BETANET_GENESIS_TX_ID;
} else if (isRegtest) {
this.genesisTxId = REGTEST_GENESIS_TX_ID;
} else {
Expand All @@ -120,10 +132,28 @@ public GenesisTxInfo(@Named(DaoOptionKeys.GENESIS_TX_ID) String genesisTxId,
this.genesisBlockHeight = TESTNET_GENESIS_BLOCK_HEIGHT;
} else if (isDaoTestNet) {
this.genesisBlockHeight = DAO_TESTNET_GENESIS_BLOCK_HEIGHT;
} else if (isDaoBetaNet) {
this.genesisBlockHeight = DAO_BETANET_GENESIS_BLOCK_HEIGHT;
} else if (isRegtest) {
this.genesisBlockHeight = REGTEST_GENESIS_BLOCK_HEIGHT;
} else {
this.genesisBlockHeight = 0;
}

if (genesisTotalSupply > -1) {
this.genesisTotalSupply = genesisTotalSupply;
} else if (isMainnet) {
this.genesisTotalSupply = MAINNET_GENESIS_TOTAL_SUPPLY.value;
} else if (isTestnet) {
this.genesisTotalSupply = TESTNET_GENESIS_TOTAL_SUPPLY.value;
} else if (isDaoTestNet) {
this.genesisTotalSupply = DAO_TESTNET_GENESIS_TOTAL_SUPPLY.value;
} else if (isDaoBetaNet) {
this.genesisTotalSupply = DAO_BETANET_GENESIS_TOTAL_SUPPLY.value;
} else if (isRegtest) {
this.genesisTotalSupply = REGTEST_GENESIS_TOTAL_SUPPLY.value;
} else {
this.genesisTotalSupply = 0;
}
}
}
4 changes: 4 additions & 0 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ public BlockChainExplorer getBlockChainExplorer() {
return prefPayload.getBlockChainExplorerTestNet();
case BTC_DAO_TESTNET:
return BTC_DAO_TEST_NET_EXPLORERS.get(0);
case BTC_DAO_BETANET:
return prefPayload.getBlockChainExplorerMainNet();
default:
throw new RuntimeException("BaseCurrencyNetwork not defined. BaseCurrencyNetwork=" + baseCurrencyNetwork);
}
Expand All @@ -664,6 +666,8 @@ public ArrayList<BlockChainExplorer> getBlockChainExplorers() {
return BTC_TEST_NET_EXPLORERS;
case BTC_DAO_TESTNET:
return BTC_DAO_TEST_NET_EXPLORERS;
case BTC_DAO_BETANET:
return BTC_MAIN_NET_EXPLORERS;
default:
throw new RuntimeException("BaseCurrencyNetwork not defined. BaseCurrencyNetwork=" + baseCurrencyNetwork);
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/resources/btc_dao_betanet.seednodes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# nodeaddress.onion:port [(@owner)]
csmijmjs7ftqfw6v.onion:8004
2 changes: 2 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,8 @@ BTC_TESTNET=Bitcoin Testnet
BTC_REGTEST=Bitcoin Regtest
# suppress inspection "UnusedProperty"
BTC_DAO_TESTNET=Bitcoin DAO Testnet
# suppress inspection "UnusedProperty"
BTC_DAO_BETANET=Bitcoin DAO Betanet (Bitcoin Mainnet)

time.year=Year
time.month=Month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import bisq.core.dao.state.model.blockchain.Block;
import bisq.core.util.BsqFormatter;

import org.bitcoinj.core.Coin;

import org.junit.Assert;
import org.junit.Test;

Expand All @@ -29,7 +31,7 @@ public class DaoStateServiceTest {
public void testIsBlockHashKnown() {
DaoStateService stateService = new DaoStateService(
new DaoState(),
new GenesisTxInfo("fakegenesistxid", 100),
new GenesisTxInfo("fakegenesistxid", 100, Coin.parseCoin("2.5").value),
new BsqFormatter());
Assert.assertEquals(
"Unknown block should not exist.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private void activateGeneralOptions() {
// We only show mainnet and dao testnet. Testnet is rather un-usable for application testing when asics
// create 10000s of blocks per day.
baseCurrencyNetworks = baseCurrencyNetworks.stream()
.filter(e -> e.isMainnet() || e.isDaoTestNet())
.filter(e -> e.isMainnet() || e.isDaoTestNet() || e.isDaoBetaNet())
.collect(Collectors.toList());
selectBaseCurrencyNetworkComboBox.setItems(FXCollections.observableArrayList(baseCurrencyNetworks));
selectBaseCurrencyNetworkComboBox.setOnAction(e -> onSelectNetwork());
Expand Down

0 comments on commit ad3647d

Please sign in to comment.