diff --git a/.travis.yml b/.travis.yml index aba91579a..bb92777d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,36 +22,27 @@ cache: matrix: fast_finish: true include: - - compiler: ": Linux" - env: 'HOST=x86_64-unknown-linux-gnu TARGET_PLATFORM=Linux64 BUILD_SCRIPT=build.sh - TRAVIS_OS_NAME=linux PACKAGES="build-essential pkg-config libc6-dev m4 g++-multilib - autoconf libtool ncurses-dev unzip python zlib1g-dev wget bsdmainutils automake - libssl-dev libprotobuf-dev protobuf-compiler libqrencode-dev libdb++-dev software-properties-common - libcurl4-openssl-dev curl" PPA="ppa:chris-lea/zeromq" KOMODO_EXEC_SET=src/komodod\ - src/komodo-cli COMPRESSED_BUILD=Komodo-build.tar.gz -' - - compiler: ": Windows" - env: 'HOST=x86_64-w64-mingw32 TARGET_PLATFORM=Win64 RUST_TARGET=x86_64-pc-windows-gnu - BUILD_SCRIPT=build-win.sh PACKAGES="build-essential pkg-config libcurl3-gnutls-dev - libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git - python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler - libdb++-dev ntp ntpdate mingw-w64 wine bc" KOMODO_EXEC_SET=src/komodod.exe\ - src/komodo-cli.exe\ src/komodo-tx.exe KOMODO_BUILD_DIR=Komodo-build COMPRESSED_BUILD=Komodo-build.tar.gz - -' + - compiler: ": Mac" + os: osx + osx_image: xcode9.2 + env: 'HOST=x86_64-apple-darwin11 TARGET=x86_64-apple-darwin BUILD_SCRIPT=build-mac.sh + TRAVIS_OS_NAME=osx PACKAGES="binutils protobuf autogen" OSX_SDK=10.9 exclude: - compiler: gcc install: -- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export - CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi -- source /home/travis/google-cloud-sdk/path.bash.inc -- sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list -- travis_retry sudo apt-get -y update && sudo apt-get -y install -qq $PACKAGES - if [ $TARGET_PLATFORM = Win64 ]; then curl -sSf https://build.travis-ci.org/files/rustup-init.sh | sh -s -- --default-toolchain stable -y && export PATH=$PATH:$HOME/.cargo/bin:$PATH; fi - if [ $TARGET_PLATFORM = Win64 ]; then rustup target add $RUST_TARGET; fi +- if [ $TRAVIS_OS_NAME = osx ]; then brew upgrade python coreutils automake; fi +- if [ $TRAVIS_OS_NAME = osx ]; then travis_retry brew tap discoteq/discoteq && brew + install flock; fi +- if [ $TRAVIS_OS_NAME = osx ]; then rm '/usr/local/include/c++' && travis_retry brew + tap homebrew/homebrew-core && brew install homebrew/homebrew-core/gcc@5 --overwrite + gcc@5; fi +- if [ $TRAVIS_OS_NAME = osx ]; then travis_retry brew update && brew install $PACKAGES; + fi before_script: - unset CC; unset CXX - mkdir -p depends/SDKs depends/sdk-sources @@ -61,13 +52,10 @@ script: after_script: - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gcloud auth activate-service-account --key-file AUTH_KEY.json; fi -- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then mkdir -p src/$KOMODO_BUILD_DIR && cp $KOMODO_EXEC_SET - src/$KOMODO_BUILD_DIR && cd src && tar -czvf $COMPRESSED_BUILD $KOMODO_BUILD_DIR; fi -- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gsutil cp $COMPRESSED_BUILD gs://$BUCKET/$PROJECT/$TRAVIS_BRANCH/$TARGET_PLATFORM/; - fi -notifications: - slack: - secure: A7JtO9RXl0Tgx09IWwUKbCuZ0oTC4wM4jthsV2CW3AS7r5Iz1qMFBnb7sb8744f40vi/QYjbr1KHkdOEbSJqWzOJS7oelSM9kyck808un7zZ8OwweXdGqdirNmIR3x+IQAYZw2lvYZcUBX/5h8eXK2LU67Rsve5I1WRGPtz0rmctFeRG6Xe0yGpMDYYxt4Ce/L7N5h3cC2eak8pQU6mSyQog0yvbiM73CFzz//bWughamOHKLx6o8BDgklwuCuh4rHQe/0kwVq1AoPQMqxuKQTsGAmub4mrDcsde39h3uo4GjAqAgfmL2e4hyp8fumdd7BtrQaFF4UBqyR8Xo/Ao97Ca7Dbeii5Eq7sl5/sTxZRdjy+MFD7z+jFpLkXfivBradyu0jABT5YYYMzZOCkpOGl5l3YymT86HKO5RBHyZLNL06jxHLti3NYBvFC6C+0yZrJOo7KN9DMqHHLZ5Y3ASZqbARWlVDE4oQmauyn4X2d6EOoE7ohwHwpY/LbVNFmrGvD+jAf4dOttwCMoWnT2pLWzs8Tl4FrvDGR3tbmZSCR/0NfbbeGrv9YNJtUghjubp1OikaZ3/Hs0+yJVsKo3kVd+dZvT/5u9MD6bu/cSdBRnoG0orca9QB8obaTEQ+71XC63D0hwDoZ9IgX6qVv+3KFErHZdZGiQBZI2yXSckvI= -before_install: -- openssl aes-256-cbc -K $encrypted_11153c0bb86c_key -iv $encrypted_11153c0bb86c_iv - -in AUTH_KEY.json.enc -out AUTH_KEY.json -d +- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gsutil cp gs://$BUCKET/CI-TESTS/$PROJECT/$TRAVIS_BRANCH/$TARGET_PLATFORM.tar.gz + . && tar -xzvf $TARGET_PLATFORM.tar.gz && ls && rm $TARGET_PLATFORM.tar.gz; fi +- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cp -rv $KOMODO_EXEC_SET $TARGET_PLATFORM + && cd src && tar -czvf $TARGET_PLATFORM.tar.gz $TARGET_PLATFORM; fi +- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gsutil cp -rv $TARGET_PLATFORM.tar.gz + gs://$BUCKET/CI-TESTS/$PROJECT/$TRAVIS_BRANCH/; fi + diff --git a/AUTH_KEY.json.enc b/AUTH_KEY.json.enc index ff2e4ce96..6d9d8225a 100644 Binary files a/AUTH_KEY.json.enc and b/AUTH_KEY.json.enc differ diff --git a/README.md b/README.md index d01e90e7c..656e4525c 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,26 @@ Building for Windows: ./zcutil/build-win.sh ``` +Building +-------- + +First time you'll need to get assorted startup values downloaded. This takes a moderate amount of time once but then does niot need to be repeated unless you bring a new system up. The command is: +``` +./zcutil/fetch-params.sh +``` +Building for Ubunutu/Mint: +``` +./zcutil/build.sh +``` +Building for Mac OS/X: +``` +./zcutil/build-mac.sh +``` +Building for Windows: +``` +./zcutil/build-win.sh +``` + Komodo ------ We have a release process that goes through several stages before it reaches master. This allows the most conservative users just use the master branch, which is only updated after the other branches have signed off on a release. diff --git a/src/base58.cpp b/src/base58.cpp index c086cc854..b85803569 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -302,6 +302,14 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const return true; } +bool CBitcoinAddress::GetKeyID_NoCheck(CKeyID& keyID) const +{ + uint160 id; + memcpy(&id, &vchData[0], 20); + keyID = CKeyID(id); + return true; +} + bool CBitcoinAddress::IsScript() const { return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS); diff --git a/src/base58.h b/src/base58.h index 73e1c4d94..4e8b2c3ce 100644 --- a/src/base58.h +++ b/src/base58.h @@ -163,6 +163,7 @@ public: CTxDestination Get() const; bool GetKeyID(CKeyID &keyID) const; + bool GetKeyID_NoCheck(CKeyID& keyID) const; bool GetIndexKey(uint160& hashBytes, int& type) const; bool IsScript() const; }; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7f9ef7549..c58380e2f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,7 +92,7 @@ public: { strNetworkID = "main"; strCurrencyUnits = "KMD"; - consensus.fCoinbaseMustBeProtected = false;//true; + consensus.fCoinbaseMustBeProtected = true; // this is only enforced after block 12800 on Verus consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; consensus.nMajorityEnforceBlockUpgrade = 750; diff --git a/src/coins.cpp b/src/coins.cpp index 42939ccac..9ce8607fd 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -379,17 +379,30 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const return coins->vout[input.prevout.n]; } -const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const -{ - const CCoins* coins = AccessCoins(input.prevout.hash); - assert(coins); - return coins->vout[input.prevout.n].scriptPubKey; -} - //uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& input) +{ + assert(coins); + if (coins->nHeight < 6400 && !strcmp(ASSETCHAINS_SYMBOL, "VRSC")) + { + std::string hc = input.prevout.hash.ToString(); + if (LaunchMap().lmap.count(hc)) + { + return LaunchMap().lmap[hc]; + } + } + return coins->vout[input.prevout.n].scriptPubKey; +} + +const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const +{ + const CCoins* coins = AccessCoins(input.prevout.hash); + return GetSpendFor(coins, input); +} + CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const { if ( interestp != 0 ) diff --git a/src/coins.h b/src/coins.h index 85cb69d5c..14cfbfee8 100644 --- a/src/coins.h +++ b/src/coins.h @@ -13,13 +13,18 @@ #include "memusage.h" #include "serialize.h" #include "uint256.h" +#include "base58.h" +#include "pubkey.h" #include #include +#include +#include #include #include #include "zcash/IncrementalMerkleTree.hpp" +#include "veruslaunch.h" /** * Pruned version of CTransaction: only retains metadata and unspent transaction outputs @@ -436,6 +441,29 @@ public: friend class CCoinsViewCache; }; +class CLaunchMap +{ + public: + std::unordered_map lmap; + CLaunchMap() : lmap() + { + for (int i = 0; i < WHITELIST_COUNT; i++) + { + printf("txid: %s -> addr: %s", whitelist_ids[i], whitelist_addrs[i]); + CBitcoinAddress address(whitelist_addrs[i]); + CKeyID key; + if (address.GetKeyID_NoCheck(key)) + { + std::vector adr = std::vector(key.begin(), key.end()); + std::string hash = uint256S(whitelist_ids[i]).ToString(); + lmap[hash] = CScript(); + lmap[hash] << OP_DUP << OP_HASH160 << adr << OP_EQUALVERIFY << OP_CHECKSIG; + } + } + } +}; +static CLaunchMap launchMap = CLaunchMap(); + /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked { @@ -443,7 +471,6 @@ protected: /* Whether this cache has an active modifier. */ bool hasModifier; - /** * Make mutable so that we can "fill the cache" even from Get-methods * declared as "const". @@ -462,6 +489,7 @@ public: ~CCoinsViewCache(); // Standard CCoinsView methods + static CLaunchMap &LaunchMap() { return launchMap; } bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; @@ -535,6 +563,7 @@ public: const CTxOut &GetOutputFor(const CTxIn& input) const; const CScript &GetSpendFor(const CTxIn& input) const; + static const CScript &GetSpendFor(const CCoins *coins, const CTxIn& input); friend class CCoinsModifier; diff --git a/src/fiat/verus b/src/fiat/verus old mode 100644 new mode 100755 index 0bcc79fd2..956ac71c4 --- a/src/fiat/verus +++ b/src/fiat/verus @@ -4,4 +4,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR -../komodo-cli -ac_name=VERUSTEST "$@" +../komodo-cli -ac_name=VRSC "$@" diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3bff063ad..e87bf3727 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1330,7 +1330,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height) strcpy(voutaddr, CBitcoinAddress(voutaddress).ToString().c_str()); strcpy(destaddr, CBitcoinAddress(destaddress).ToString().c_str()); strcpy(cbaddr, CBitcoinAddress(cbaddress).ToString().c_str()); - if ( !strcmp(destaddr,voutaddr) && ( !strcmp(destaddr,cbaddr) || (height < 10080)) ) + if ( !strcmp(destaddr,voutaddr) && ( !strcmp(destaddr,cbaddr) || (height < 12800)) ) { isPOS = true; } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2fa46819a..62f178bf1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1052,11 +1052,20 @@ int64_t komodo_block_unlocktime(uint32_t nHeight) unlocktime = ASSETCHAINS_TIMEUNLOCKTO; else { - unlocktime = komodo_block_prg(nHeight) / (0xffffffffffffffff / ((ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM) + 1)); - // boundary and power of 2 can make it exceed to time by 1 - unlocktime = unlocktime + ASSETCHAINS_TIMEUNLOCKFROM; - if (unlocktime > ASSETCHAINS_TIMEUNLOCKTO) - unlocktime--; + if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800) + { + unlocktime = komodo_block_prg(nHeight) % (ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM); + // boundary and power of 2 can make it exceed to time by 1 + unlocktime = unlocktime + ASSETCHAINS_TIMEUNLOCKFROM; + } + else + { + unlocktime = komodo_block_prg(nHeight) / (0xffffffffffffffff / ((ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM) + 1)); + // boundary and power of 2 can make it exceed to time by 1 + unlocktime = unlocktime + ASSETCHAINS_TIMEUNLOCKFROM; + if (unlocktime > ASSETCHAINS_TIMEUNLOCKTO) + unlocktime--; + } } return ((int64_t)unlocktime); } diff --git a/src/main.cpp b/src/main.cpp index 0569d6c84..1ec144326 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,9 @@ #include "wallet/asyncrpcoperation_sendmany.h" #include "wallet/asyncrpcoperation_shieldcoinbase.h" +#include #include +#include #include #include @@ -2045,7 +2047,7 @@ namespace Consensus { const COutPoint &prevout = tx.vin[i].prevout; const CCoins *coins = inputs.AccessCoins(prevout.hash); assert(coins); - + if (coins->IsCoinBase()) { // Ensure that coinbases are matured if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { @@ -2066,7 +2068,8 @@ namespace Consensus { // Disabled on regtest if (fCoinbaseEnforcedProtectionEnabled && consensusParams.fCoinbaseMustBeProtected && - !tx.vout.empty()) { + !tx.vout.empty() && + (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || (nSpendHeight >= 12800 && coins->nHeight >= 12800))) { return state.Invalid( error("CheckInputs(): tried to spend coinbase with transparent outputs"), REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs"); diff --git a/src/main.h b/src/main.h index 3a43b5fba..99babb874 100644 --- a/src/main.h +++ b/src/main.h @@ -751,7 +751,7 @@ private: public: CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), consensusBranchId(0), error(SCRIPT_ERR_UNKNOWN_ERROR) {} CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, uint32_t consensusBranchIdIn, PrecomputedTransactionData* txdataIn) : - scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), + scriptPubKey(CCoinsViewCache::GetSpendFor(&txFromIn, txToIn.vin[nInIn])), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), consensusBranchId(consensusBranchIdIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { } bool operator()(); diff --git a/src/pow/tromp/equi_miner.h b/src/pow/tromp/equi_miner.h index ae527827a..d53d0d8aa 100644 --- a/src/pow/tromp/equi_miner.h +++ b/src/pow/tromp/equi_miner.h @@ -25,7 +25,13 @@ #include typedef uint16_t u16; +#ifdef _WIN32 +typedef unsigned long long u64; +#elif __linux__ typedef uint64_t u64; +#else +typedef unsigned long u64; +#endif #ifdef EQUIHASH_TROMP_ATOMIC #include diff --git a/src/verusd b/src/verusd new file mode 100755 index 000000000..7ec4f6246 --- /dev/null +++ b/src/verusd @@ -0,0 +1,2 @@ +./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.72 -addnode=185.25.48.236 -addnode=185.64.105.111 "$@" + diff --git a/src/veruslaunch.cpp b/src/veruslaunch.cpp new file mode 100644 index 000000000..e7e1838ae --- /dev/null +++ b/src/veruslaunch.cpp @@ -0,0 +1,12 @@ +// Copyright (c) 2018 The Verus developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include "veruslaunch.h" + + +const char *whitelist_ids[WHITELIST_COUNT] = {}; + +const char *whitelist_addrs[WHITELIST_COUNT] = {}; diff --git a/src/veruslaunch.h b/src/veruslaunch.h new file mode 100644 index 000000000..16e81312d --- /dev/null +++ b/src/veruslaunch.h @@ -0,0 +1,16 @@ + +// Copyright (c) 2018 The Verus developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef VERUS_LAUNCH_H +#define VERUS_LAUNCH_H + +#include + +#define WHITELIST_COUNT 0 + +extern const char *whitelist_ids[WHITELIST_COUNT]; +extern const char *whitelist_addrs[WHITELIST_COUNT]; + +#endif