Merge pull request #34 from VerusCoin/dev

Dev
This commit is contained in:
miketout
2018-05-27 20:20:00 -07:00
committed by GitHub
17 changed files with 1527 additions and 44 deletions

1
.gitignore vendored
View File

@@ -47,6 +47,7 @@ src/univalue/gen
.deps
.dirstamp
.idea
.libs
.*.swp
*.*~*

View File

@@ -23,19 +23,19 @@ matrix:
fast_finish: true
include:
- compiler: ": Linux"
env: HOST=x86_64-unknown-linux-gnu TARGET_PLATFORM=Linux64 BUILD_SCRIPT=build.sh
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="komodod
komodo-cli" COMPRESSED_BUILD=Komodo-build.tar.gz
komodo-cli"
- compiler: ": Windows"
env: HOST=x86_64-w64-mingw32 TARGET_PLATFORM=Win64 RUST_TARGET=x86_64-pc-windows-gnu
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="komodod.exe komodo-cli.exe komodo-tx.exe" COMPRESSED_BUILD=Komodo-build.tar.gz
libdb++-dev ntp ntpdate mingw-w64 wine bc" KOMODO_EXEC_SET="komodod.exe komodo-cli.exe
komodo-tx.exe"
exclude:
- compiler: gcc
install:
@@ -44,10 +44,10 @@ install:
- 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
- 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 [ $TARGET_PLATFORM = win64 ]; then rustup target add $RUST_TARGET; fi
before_script:
- unset CC; unset CXX
- mkdir -p depends/SDKs depends/sdk-sources
@@ -57,13 +57,14 @@ 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 cd src && gsutil cp gs://$BUCKET/$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 ls && cp -rv $KOMODO_EXEC_SET $TARGET_PLATFORM && tar -czvf $TARGET_PLATFORM.tar.gz $TARGET_PLATFORM; fi
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gsutil cp -rv $TARGET_PLATFORM.tar.gz gs://$BUCKET/$PROJECT/$TRAVIS_BRANCH/;
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd src && mkdir $TARGET_PLATFORM &&
cp -r $KOMODO_EXEC_SET $TARGET_PLATFORM && tar -czvf $TARGET_PLATFORM.tar.gz $TARGET_PLATFORM;
fi
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gsutil cp $TARGET_PLATFORM.tar.gz
gs://$BUCKET/$PROJECT/$TRAVIS_BRANCH/; fi
notifications:
slack:
secure: A7JtO9RXl0Tgx09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Nz0+uukuJinAdazGaNmmfesv1wg9p3jGa/TLsfHLMcUti875DzkUHnenivP5cXrc6/uuZyyQNq5+Gn/3DA8k0y7d1e23nm3nDjCNfATAn3yu1jieYY2yYI6CYGEXcD+UbP61uG6no+mm/lkQbQosyDfE0sADqGryqXswRste+R0sSVMBQtTipAZOUoYNbEmhN4+L78SSp3zpmgkrIxAw7le8oj6Evp2ofvE2Kvh+Z0MVoEJx6mtZI6hheIFSS38NeUZr/HBfRSpaElOYTN/ZNf8QwThCWo=
before_install:
- openssl aes-256-cbc -K $encrypted_11153c0bb86c_key -iv $encrypted_11153c0bb86c_iv
-in AUTH_KEY.json.enc -out AUTH_KEY.json -d

Binary file not shown.

4
kmd/assemble Executable file
View File

@@ -0,0 +1,4 @@
cp ../src/komodod .
cp ../src/komodo-cli .
tar -czf kmd.tar.gz komodod komodo-cli verus verusd

7
kmd/verus Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
#set working directory to the location of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
../komodo-cli -ac_name=VRSC "$@"

2
kmd/verusd Executable file
View File

@@ -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 "$@"

View File

@@ -92,7 +92,7 @@ public:
{
strNetworkID = "main";
strCurrencyUnits = "KMD";
consensus.fCoinbaseMustBeProtected = true; // this is only enforced after block 12800 on Verus
consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800
consensus.nSubsidySlowStartInterval = 20000;
consensus.nSubsidyHalvingInterval = 840000;
consensus.nMajorityEnforceBlockUpgrade = 750;
@@ -232,6 +232,12 @@ void *chainparams_commandline(void *ptr)
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
mainParams.consensus.fCoinbaseMustBeProtected = true;
}
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:

View File

@@ -391,7 +391,11 @@ const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& in
std::string hc = input.prevout.hash.ToString();
if (LaunchMap().lmap.count(hc))
{
return LaunchMap().lmap[hc];
CTransactionExceptionData &txData = LaunchMap().lmap[hc];
if ((txData.voutMask & (((uint64_t)1) << (uint64_t)input.prevout.n)) != 0)
{
return txData.scriptPubKey;
}
}
}
return coins->vout[input.prevout.n].scriptPubKey;

View File

@@ -441,23 +441,31 @@ public:
friend class CCoinsViewCache;
};
class CTransactionExceptionData
{
public:
CScript scriptPubKey;
uint64_t voutMask;
CTransactionExceptionData() : scriptPubKey(), voutMask() {}
};
class CLaunchMap
{
public:
std::unordered_map<std::string, CScript> lmap;
std::unordered_map<std::string, CTransactionExceptionData> lmap;
CLaunchMap() : lmap()
{
for (int i = 0; i < WHITELIST_COUNT; i++)
//printf("txid: %s -> addr: %s\n", whitelist_ids[i], whitelist_addrs[i]);
CBitcoinAddress bcaddr(whitelist_address);
CKeyID key;
if (bcaddr.GetKeyID_NoCheck(key))
{
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<unsigned char> address = std::vector<unsigned char>(key.begin(), key.end());
for (int i = 0; i < WHITELIST_COUNT; i++)
{
std::vector<unsigned char> adr = std::vector<unsigned char>(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;
lmap[hash].scriptPubKey << OP_DUP << OP_HASH160 << address << OP_EQUALVERIFY << OP_CHECKSIG;
lmap[hash].voutMask = whitelist_masks[i];
}
}
}

View File

@@ -73,3 +73,8 @@ CVerusHash &CVerusHash::Write(const unsigned char *data, size_t len)
return *this;
}
// to be declared and accessed from C
void verus_hash(void *result, const void *data, size_t len)
{
return CVerusHash::Hash(result, data, len);
}

View File

@@ -51,4 +51,6 @@ class CVerusHash
size_t curPos = 0;
};
extern void verus_hash(void *result, const void *data, size_t len);
#endif

View File

@@ -28,6 +28,8 @@
#define portable_mutex_lock pthread_mutex_lock
#define portable_mutex_unlock pthread_mutex_unlock
extern void verus_hash(void *result, const void *data, size_t len);
struct allocitem { uint32_t allocsize,type; };
struct queueitem { struct queueitem *next,*prev; uint32_t allocsize,type; };
@@ -1022,23 +1024,45 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
// from all other blocks. the sequence is extremely likely, but not guaranteed to be unique for each block chain
uint64_t komodo_block_prg(uint32_t nHeight)
{
int i;
uint8_t hashSrc[8];
uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
bits256 hashResult;
for ( i = 0; i < sizeof(hashSrc); i++ )
if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800)
{
hashSrc[i] = hashSrc64 & 0xff;
hashSrc64 >>= 8;
}
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
uint64_t i, result = 0, hashSrc64 = ((uint64_t)ASSETCHAINS_MAGIC << 32) | (uint64_t)nHeight;
uint8_t hashSrc[8];
bits256 hashResult;
for ( i = 0; i < 8; i++ )
{
result = (result << 8) + hashResult.bytes[i];
for ( i = 0; i < sizeof(hashSrc); i++ )
{
uint64_t x = hashSrc64 >> (i * 8);
hashSrc[i] = (uint8_t)(x & 0xff);
}
verus_hash(hashResult.bytes, hashSrc, sizeof(hashSrc));
for ( i = 0; i < 8; i++ )
{
result = (result << 8) | hashResult.bytes[i];
}
return result;
}
else
{
int i;
uint8_t hashSrc[8];
uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
bits256 hashResult;
for ( i = 0; i < sizeof(hashSrc); i++ )
{
hashSrc[i] = hashSrc64 & 0xff;
hashSrc64 >>= 8;
int8_t b = hashSrc[i];
}
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
for ( i = 0; i < 8; i++ )
{
result = (result << 8) + hashResult.bytes[i];
}
return result;
}
return(result);
}
// given a block height, this returns the unlock time for that block height, derived from
@@ -1055,8 +1079,7 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
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;
unlocktime += ASSETCHAINS_TIMEUNLOCKFROM;
}
else
{

View File

@@ -25,7 +25,13 @@
#include <assert.h>
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 <atomic>

View File

@@ -1041,7 +1041,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
TxInErrorToJSON(txin, vErrors, "Input not found or already spent");
continue;
}
const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
const CScript& prevPubKey = CCoinsViewCache::GetSpendFor(coins, txin);
const CAmount& amount = coins->vout[txin.prevout.n].nValue;
SignatureData sigdata;

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,10 @@
#include <string>
#define WHITELIST_COUNT 0
#define WHITELIST_COUNT 704
extern const char *whitelist_ids[WHITELIST_COUNT];
extern const char *whitelist_addrs[WHITELIST_COUNT];
extern const char *whitelist_address;
extern uint64_t whitelist_masks[WHITELIST_COUNT];
#endif

View File

@@ -9,7 +9,8 @@ set -eu -o pipefail
set -x
cd "$(dirname "$(readlink -f "$0")")/.."
cd depends/ && make HOST=$HOST V=1 NO_QT=1 && cd ../
cd depends/ && make HOST=$HOST V=1 NO_QT=1
cd ..
./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared
sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure