Merge branch 'dev'
This commit is contained in:
1
COPYING
1
COPYING
@@ -3,7 +3,6 @@ Copyright (c) 2009-2018 Bitcoin Developers
|
||||
Copyright (c) 2016-2017 The Zcash developers
|
||||
Copyright (c) 2016-2019 The Komodo developers
|
||||
Copyright (c) 2018-2019 The Hush developers
|
||||
Copyright (c) 2018 The VerusCoin developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -29,6 +29,11 @@ When in doubt, if you run into a compile error, especially if it mentions
|
||||
`OCTET_STRING`, run `build.sh` again. Running `make clean` before switching
|
||||
branches can often prevent those problems.
|
||||
|
||||
```
|
||||
cryptoconditions/src/asn/SimpleSha256Condition.h:14:10: fatal error: OCTET_STRING.h: No such file or directory
|
||||
```
|
||||
|
||||
|
||||
## Partial compiles
|
||||
|
||||
At any point, you can modify hush source code and then use `make` or `build.sh`
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
|
||||
You will need Apple's Xcode (at least version 7, preferably 8.x) and the Xcode Command Line Tools:
|
||||
|
||||
https://itunes.apple.com/us/app/xcode/id497799835?mt=12
|
||||
|
||||
And Homebrew:
|
||||
|
||||
http://brew.sh/
|
||||
|
||||
Use the brewfile to install the necessary packages:
|
||||
|
||||
```shell
|
||||
brew bundle
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```shell
|
||||
brew tap discoteq/discoteq; brew install flock autoconf autogen automake gcc@6 binutils protobuf coreutils wget
|
||||
```
|
||||
|
||||
Get all that installed, then run:
|
||||
|
||||
```shell
|
||||
git clone https://github.com/MyHush/hush3
|
||||
cd hush3
|
||||
./zcutil/build-mac.sh
|
||||
```
|
||||
|
||||
To build a distributable version of Hush then run the makeReleaseMac.sh script after building. This will fix the dependency references and move the komodod and komodo-cli binaries to the kmd/mac/verus-cli directory along with the 6 libraries required for it to work properly.
|
||||
|
||||
When you are done building, you need to create `Komodo.conf` the Mac way.
|
||||
|
||||
```shell
|
||||
mkdir ~/Library/Application\ Support/Komodo
|
||||
touch ~/Library/Application\ Support/Komodo/Komodo.conf
|
||||
nano ~/Library/Application\ Support/Komodo/Komodo.conf
|
||||
```
|
||||
|
||||
Add the following lines to the Komodo.conf file:
|
||||
|
||||
```shell
|
||||
rpcuser=dontuseweakusernameoryougetrobbed
|
||||
rpcpassword=dontuseweakpasswordoryougetrobbed
|
||||
txindex=1
|
||||
addnode=5.9.102.210
|
||||
addnode=78.47.196.146
|
||||
addnode=178.63.69.164
|
||||
addnode=88.198.65.74
|
||||
addnode=5.9.122.241
|
||||
addnode=144.76.94.38
|
||||
addnode=89.248.166.91
|
||||
```
|
||||
|
||||
Happy Building
|
||||
56
contrib/checkpoints.pl
Executable file
56
contrib/checkpoints.pl
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright 2019 The Hush developers
|
||||
# Released under the GPLv3
|
||||
use warnings;
|
||||
use strict;
|
||||
# Generate checkpoint data for use in src/main.cpp
|
||||
|
||||
# TODO: update when blocktime changes to 75s
|
||||
my $perday = 576;
|
||||
my $hush = "./src/hush-cli";
|
||||
my $gethash = "$hush getblockhash";
|
||||
my $stride = shift || 1000;
|
||||
my $count = 0;
|
||||
my $blocks = qx{$hush getblockcount};
|
||||
my $prev = $blocks - $perday;
|
||||
my $last = 0;
|
||||
my $now = time();
|
||||
chomp($blocks);
|
||||
|
||||
print "// Generated at $now via hush3 contrib/checkpoints.pl by Duke Leto\n";
|
||||
|
||||
while (1) {
|
||||
$count++;
|
||||
my $block = $stride*$count;
|
||||
if ($block > $blocks) {
|
||||
$last = $stride*($count-1);
|
||||
#print "last checkpointed block=$last\n";
|
||||
last;
|
||||
}
|
||||
my $blockhash = qx{$gethash $block};
|
||||
chomp $blockhash;
|
||||
print qq{($block, uint256S("0x$blockhash"))\n};
|
||||
}
|
||||
my $time = qx{$hush getblock $last |grep time|cut -d: -f2| sed 's/,//g'};
|
||||
chomp($time);
|
||||
# TODO: This is Linux-only
|
||||
my $line1 = qx{grep --text height=$prev ~/.komodo/HUSH3/debug.log};
|
||||
my $line2 = qx{grep --text height=$blocks ~/.komodo/HUSH3/debug.log};
|
||||
my $txs_per_day = 2 * $perday; # default estimate is 2 txs per block, on average
|
||||
my $total_txs = 0;
|
||||
#print "line1: $line1\n";
|
||||
#print "line2: $line2\n";
|
||||
|
||||
# This will calculate the number of txs in the previous day to the last checkpointed block
|
||||
if ($line1 =~ m/tx=(\d+)/) {
|
||||
my $tx1 = $1; # number of txs in the block 1 day ago
|
||||
#print "prevblock has $tx1 txs\n";
|
||||
if ($line2 =~ m/tx=(\d+)/) {
|
||||
$total_txs = $1;
|
||||
# TODO: average of last N days might be better
|
||||
$txs_per_day = $total_txs - $tx1;
|
||||
}
|
||||
}
|
||||
print "(int64_t) $time, // time of last checkpointed block\n";
|
||||
print "(int64_t) $total_txs, // total txs\n";
|
||||
print "(double) $txs_per_day, // txs in the last day before block $blocks\n";
|
||||
@@ -1,9 +1,9 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
|
||||
.TH KOMODO-CLI "1" "November 2019" "komodo-cli v3.2.2" "User Commands"
|
||||
.TH KOMODO-CLI "1" "November 2019" "komodo-cli v3.2.1" "User Commands"
|
||||
.SH NAME
|
||||
komodo-cli \- manual page for komodo-cli v3.2.2
|
||||
.SH DESCRIPTION
|
||||
Komodo RPC client version v3.2.2\-d8caae05b\-dirty
|
||||
Komodo RPC client version v3.2.1\-7965ffc29\-dirty
|
||||
.PP
|
||||
In order to ensure you are adequately protecting your privacy when using Hush,
|
||||
please see <https://myhush.org/security/>.
|
||||
@@ -79,9 +79,8 @@ Copyright (C) 2009-2019 The Bitcoin Core Developers
|
||||
Copyright (C) 2015-2019 The Zcash Developers
|
||||
Copyright (C) 2015-2019 jl777 and SuperNET developers
|
||||
Copyright (C) 2018-2019 The Hush developers
|
||||
Copyright (C) 2018-2019 The Verus developers
|
||||
|
||||
This is experimental software.
|
||||
This is experimental software!!!
|
||||
|
||||
Distributed under the MIT software license, see the accompanying file COPYING
|
||||
or <http://www.opensource.org/licenses/mit-license.php>.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
|
||||
.TH KOMODO-TX "1" "November 2019" "komodo-tx v3.2.2" "User Commands"
|
||||
.TH KOMODO-TX "1" "November 2019" "komodo-tx v3.2.1" "User Commands"
|
||||
.SH NAME
|
||||
komodo-tx \- manual page for komodo-tx v3.2.2
|
||||
.SH DESCRIPTION
|
||||
Hush komodo\-tx utility version v3.2.2\-d8caae05b\-dirty
|
||||
Hush komodo\-tx utility version v3.2.1\-7965ffc29\-dirty
|
||||
.SS "Usage:"
|
||||
.TP
|
||||
komodo\-tx [options] <hex\-tx> [commands]
|
||||
@@ -92,9 +92,8 @@ Copyright (C) 2009-2019 The Bitcoin Core Developers
|
||||
Copyright (C) 2015-2019 The Zcash Developers
|
||||
Copyright (C) 2015-2019 jl777 and SuperNET developers
|
||||
Copyright (C) 2018-2019 The Hush developers
|
||||
Copyright (C) 2018-2019 The Verus developers
|
||||
|
||||
This is experimental software.
|
||||
This is experimental software!!!
|
||||
|
||||
Distributed under the MIT software license, see the accompanying file COPYING
|
||||
or <http://www.opensource.org/licenses/mit-license.php>.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
|
||||
.TH KOMODOD "1" "November 2019" "komodod v3.2.2" "User Commands"
|
||||
.TH KOMODOD "1" "November 2019" "komodod v3.2.1" "User Commands"
|
||||
.SH NAME
|
||||
komodod \- manual page for komodod v3.2.2
|
||||
.SH DESCRIPTION
|
||||
Hush Daemon version v3.2.2\-d8caae05b\-dirty
|
||||
Hush Daemon version v3.2.1\-7965ffc29\-dirty
|
||||
.PP
|
||||
In order to ensure you are adequately protecting your privacy when using Hush,
|
||||
please see <https://myhush.org/security/>.
|
||||
@@ -617,10 +617,6 @@ Timelocked coinbase stop height
|
||||
\fB\-ac_txpow\fR
|
||||
.IP
|
||||
Enforce transaction\-rate limit, default 0
|
||||
.HP
|
||||
\fB\-ac_veruspos\fR
|
||||
.IP
|
||||
Use Verus Proof\-Of\-Stake (\fB\-ac_veruspos\fR=\fI\,50\/\fR) default 0
|
||||
.SH COPYRIGHT
|
||||
|
||||
In order to ensure you are adequately protecting your privacy when using Hush,
|
||||
@@ -630,9 +626,8 @@ Copyright (C) 2009-2019 The Bitcoin Core Developers
|
||||
Copyright (C) 2015-2019 The Zcash Developers
|
||||
Copyright (C) 2015-2019 jl777 and SuperNET developers
|
||||
Copyright (C) 2018-2019 The Hush developers
|
||||
Copyright (C) 2018-2019 The Verus developers
|
||||
|
||||
This is experimental software.
|
||||
This is experimental software!!!
|
||||
|
||||
Distributed under the MIT software license, see the accompanying file COPYING
|
||||
or <http://www.opensource.org/licenses/mit-license.php>.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2019 The Hush developers
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
CURDIR=$(cd $(dirname "$0"); pwd)
|
||||
@@ -14,7 +16,6 @@ testScripts=(
|
||||
'dpow.py'
|
||||
'dpowconfs.py'
|
||||
'ac_private.py'
|
||||
'verushash.py'
|
||||
'paymentdisclosure.py'
|
||||
'prioritisetransaction.py'
|
||||
'wallet_treestate.py'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2019 The Hush developers
|
||||
# Copyright (c) 2018 SuperNET developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
@@ -28,7 +29,7 @@ def generate_random_string(length):
|
||||
class AssetChainPrivateTest (BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print("Initializing VerusHash test directory "+self.options.tmpdir)
|
||||
print("Initializing ac_private test directory "+self.options.tmpdir)
|
||||
self.num_nodes = 1
|
||||
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
|
||||
|
||||
|
||||
@@ -46,8 +46,6 @@ LIBBITCOIN_COMMON=libbitcoin_common.a
|
||||
LIBBITCOIN_CLI=libbitcoin_cli.a
|
||||
LIBBITCOIN_UTIL=libbitcoin_util.a
|
||||
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
|
||||
LIBVERUS_CRYPTO=crypto/libverus_crypto.a
|
||||
LIBVERUS_PORTABLE_CRYPTO=crypto/libverus_portable_crypto.a
|
||||
LIBSECP256K1=secp256k1/libsecp256k1.la
|
||||
LIBCRYPTOCONDITIONS=cryptoconditions/libcryptoconditions_core.la
|
||||
LIBSNARK=snark/libsnark.a
|
||||
@@ -95,8 +93,6 @@ $(LIBCRYPTOCONDITIONS): $(wildcard cryptoconditions/src/*) $(wildcard cryptocond
|
||||
# But to build the less dependent modules first, we manually select their order here:
|
||||
EXTRA_LIBRARIES += \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
$(LIBBITCOIN_SERVER) \
|
||||
@@ -183,9 +179,6 @@ BITCOIN_CORE_H = \
|
||||
consensus/validation.h \
|
||||
core_io.h \
|
||||
core_memusage.h \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
deprecation.h \
|
||||
hash.h \
|
||||
httprpc.h \
|
||||
@@ -316,8 +309,6 @@ libbitcoin_server_a_SOURCES = \
|
||||
crosschain_authority.cpp \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp \
|
||||
deprecation.cpp \
|
||||
httprpc.cpp \
|
||||
httpserver.cpp \
|
||||
@@ -420,11 +411,7 @@ crypto_libbitcoin_crypto_a_SOURCES = \
|
||||
crypto/sha256.cpp \
|
||||
crypto/sha256.h \
|
||||
crypto/sha512.cpp \
|
||||
crypto/sha512.h \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp
|
||||
crypto/sha512.h
|
||||
|
||||
if ENABLE_MINING
|
||||
EQUIHASH_TROMP_SOURCES = \
|
||||
@@ -438,20 +425,6 @@ crypto_libbitcoin_crypto_a_SOURCES += \
|
||||
${EQUIHASH_TROMP_SOURCES}
|
||||
endif
|
||||
|
||||
# Verus hash specific library - optimized
|
||||
crypto_libverus_crypto_a_CPPFLAGS = -O3 -Wint-conversion -march=x86-64 -msse4 -msse4.1 -msse4.2 -mssse3 -mavx -maes -g -funroll-loops -fomit-frame-pointer -fPIC $(AM_CPPFLAGS)
|
||||
crypto_libverus_crypto_a_CXXFLAGS = -O3 -Wint-conversion -march=x86-64 -msse4 -msse4.1 -msse4.2 -mssse3 -mavx -maes -g -funroll-loops -fomit-frame-pointer -fPIC $(AM_CXXFLAGS)
|
||||
crypto_libverus_crypto_a_SOURCES = \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka.c
|
||||
|
||||
# Verus hash specific library - portable
|
||||
crypto_libverus_portable_crypto_a_CPPFLAGS = -O3 -Wint-conversion -march=x86-64 -g -funroll-loops -fomit-frame-pointer -fPIC $(AM_CPPFLAGS)
|
||||
crypto_libverus_portable_crypto_a_CXXFLAGS = -O3 -Wint-conversion -march=x86-64 -g -funroll-loops -fomit-frame-pointer -fPIC $(AM_CXXFLAGS)
|
||||
crypto_libverus_portable_crypto_a_SOURCES = \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/haraka_portable.c
|
||||
|
||||
# common: shared between zcashd and non-server tools
|
||||
libbitcoin_common_a_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_common_a_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
@@ -468,8 +441,6 @@ libbitcoin_common_a_SOURCES = \
|
||||
core_write.cpp \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp \
|
||||
hash.cpp \
|
||||
importcoin.cpp \
|
||||
key.cpp \
|
||||
@@ -486,7 +457,6 @@ libbitcoin_common_a_SOURCES = \
|
||||
script/cc.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
script/script_ext.cpp \
|
||||
script/script_error.cpp \
|
||||
script/sign.cpp \
|
||||
script/standard.cpp \
|
||||
@@ -558,8 +528,6 @@ komodod_LDADD = \
|
||||
$(LIBBITCOIN_ZMQ) \
|
||||
$(LIBBITCOIN_PROTON) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBZCASH) \
|
||||
$(LIBSNARK) \
|
||||
$(LIBLEVELDB) \
|
||||
@@ -581,8 +549,6 @@ komodod_LDADD += \
|
||||
$(ZMQ_LIBS) \
|
||||
$(PROTON_LIBS) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBZCASH_LIBS)
|
||||
|
||||
if TARGET_DARWIN
|
||||
@@ -635,8 +601,6 @@ komodo_cli_LDADD = \
|
||||
$(EVENT_LIBS) \
|
||||
$(LIBZCASH) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBZCASH_LIBS)
|
||||
|
||||
if ENABLE_WALLET
|
||||
@@ -644,8 +608,6 @@ wallet_utility_LDADD = \
|
||||
libbitcoin_wallet.a \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBSECP256K1) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(BOOST_LIBS) \
|
||||
@@ -667,7 +629,7 @@ if TARGET_WINDOWS
|
||||
komodo_tx_SOURCES += bitcoin-tx-res.rc
|
||||
endif
|
||||
|
||||
# FIXME: Is libzcash needed for zcash_tx?
|
||||
# FIXME: Is libzcash needed for hush-tx ?
|
||||
komodo_tx_LDADD = \
|
||||
$(LIBUNIVALUE) \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
@@ -676,8 +638,6 @@ komodo_tx_LDADD = \
|
||||
$(LIBZCASH) \
|
||||
$(LIBSNARK) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBVERUS_PORTABLE_CRYPTO) \
|
||||
$(LIBZCASH_LIBS) \
|
||||
$(LIBCRYPTOCONDITIONS)
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ endif
|
||||
komodo_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DMULTICORE -fopenmp -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES)
|
||||
komodo_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
|
||||
komodo_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBVERUS_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
komodo_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1)
|
||||
if ENABLE_ZMQ
|
||||
zcash_gtest_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
|
||||
|
||||
@@ -361,7 +361,7 @@ qt_komodo_qt_LDADD = qt/libbitcoinqt.a $(LIBBITCOIN_SERVER)
|
||||
if ENABLE_WALLET
|
||||
qt_komodo_qt_LDADD += $(LIBBITCOIN_WALLET)
|
||||
endif
|
||||
qt_komodo_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBVERUS_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
qt_komodo_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(LIBZCASH_LIBS)
|
||||
qt_komodo_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
qt_komodo_qt_LIBTOOLFLAGS = --tag CXX
|
||||
|
||||
@@ -30,7 +30,7 @@ qt_test_test_komodo_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER)
|
||||
if ENABLE_WALLET
|
||||
qt_test_test_komodo_qt_LDADD += $(LIBBITCOIN_WALLET)
|
||||
endif
|
||||
qt_test_test_komodo_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBVERUS_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \
|
||||
qt_test_test_komodo_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \
|
||||
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
|
||||
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) $(LIBZCASH_LIBS)
|
||||
qt_test_test_komodo_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
|
||||
@@ -113,7 +113,7 @@ endif
|
||||
|
||||
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
|
||||
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) -fopenmp $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS)
|
||||
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBVERUS_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
if ENABLE_WALLET
|
||||
|
||||
@@ -24,7 +24,6 @@ zcash_CreateJoinSplit_LDADD = \
|
||||
$(LIBSNARK) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(BOOST_LIBS) \
|
||||
$(LIBZCASH_LIBS) \
|
||||
$(LIBCRYPTOCONDITIONS) \
|
||||
|
||||
@@ -35,7 +35,6 @@ echo $pubkey
|
||||
./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -ac_sapling=5000000 -addnode=51.68.215.104 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=95.213.238.98 &
|
||||
~/VerusCoin/src/komodod -pubkey=$pubkey -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.236 -addnode=185.64.105.111 &
|
||||
./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 &
|
||||
./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 &
|
||||
./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=178.63.77.56 &
|
||||
@@ -48,10 +47,7 @@ echo $pubkey
|
||||
./komodod -pubkey=$pubkey -ac_name=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 &
|
||||
./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 &
|
||||
<<<<<<< HEAD
|
||||
./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 &
|
||||
=======
|
||||
>>>>>>> beta
|
||||
./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZEXO -ac_supply=100000000 -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_ccenable=236 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc -ac_public=1 -addnode=80.240.17.222 &
|
||||
./komodod -pubkey=$pubkey -ac_name=K64 -ac_supply=64000777 -ac_reward=0 -ac_staked=10 -addnode=18.197.20.211 &
|
||||
|
||||
@@ -103,17 +103,6 @@ struct CC_utxo
|
||||
int32_t vout;
|
||||
};
|
||||
|
||||
// these are the parameters stored after Verus crypto-condition vouts. new versions may change
|
||||
// the format
|
||||
struct CC_meta
|
||||
{
|
||||
std::vector<unsigned char> version;
|
||||
uint8_t evalCode;
|
||||
bool is1of2;
|
||||
uint8_t numDestinations;
|
||||
// followed by address destinations
|
||||
};
|
||||
|
||||
struct CCcontract_info
|
||||
{
|
||||
// this is for spending from 'unspendable' CC address
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/*Descriptson and examples of COptCCParams class found in:
|
||||
script/standard.h/cpp
|
||||
class COptCCParams
|
||||
|
||||
structure of data in vData payload attached to end of CCvout:
|
||||
param
|
||||
OP_1
|
||||
param
|
||||
OP_2 ... etc until OP_16
|
||||
OP_PUSHDATA4 is the last OP code to tell things its at the end.
|
||||
|
||||
taken from standard.cpp line 22: COptCCParams::COptCCParams(std::vector<unsigned char> &vch)
|
||||
|
||||
EXAMPLE taken from Verus how to create scriptPubKey from COptCCParams class:
|
||||
EXAMPLE taken from Verus how to decode scriptPubKey from COptCCParams class:
|
||||
*/
|
||||
|
||||
bool MakeGuardedOutput(CAmount value, CPubKey &dest, CTransaction &stakeTx, CTxOut &vout)
|
||||
{
|
||||
CCcontract_info *cp, C;
|
||||
cp = CCinit(&C,EVAL_STAKEGUARD);
|
||||
|
||||
CPubKey ccAddress = CPubKey(ParseHex(cp->CChexstr));
|
||||
|
||||
// return an output that is bound to the stake transaction and can be spent by presenting either a signed condition by the original
|
||||
// destination address or a properly signed stake transaction of the same utxo on a fork
|
||||
vout = MakeCC1of2vout(EVAL_STAKEGUARD, value, dest, ccAddress);
|
||||
|
||||
std::vector<CPubKey> vPubKeys = std::vector<CPubKey>();
|
||||
vPubKeys.push_back(dest);
|
||||
vPubKeys.push_back(ccAddress);
|
||||
|
||||
std::vector<std::vector<unsigned char>> vData = std::vector<std::vector<unsigned char>>();
|
||||
|
||||
CVerusHashWriter hw = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
hw << stakeTx.vin[0].prevout.hash;
|
||||
hw << stakeTx.vin[0].prevout.n;
|
||||
|
||||
uint256 utxo = hw.GetHash();
|
||||
vData.push_back(std::vector<unsigned char>(utxo.begin(), utxo.end())); // Can we use any data here to construct vector?
|
||||
|
||||
CStakeParams p;
|
||||
if (GetStakeParams(stakeTx, p))
|
||||
{
|
||||
// prev block hash and height is here to make validation easy
|
||||
vData.push_back(std::vector<unsigned char>(p.prevHash.begin(), p.prevHash.end()));
|
||||
std::vector<unsigned char> height = std::vector<unsigned char>(4);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
height[i] = (p.blkHeight >> (8 * i)) & 0xff;
|
||||
}
|
||||
vData.push_back(height);
|
||||
|
||||
COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_STAKEGUARD, 1, 2, vPubKeys, vData);
|
||||
|
||||
vout.scriptPubKey << ccp.AsVector() << OP_DROP;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ValidateMatchingStake(const CTransaction &ccTx, uint32_t voutNum, const CTransaction &stakeTx, bool &cheating)
|
||||
{
|
||||
// an invalid or non-matching stake transaction cannot cheat
|
||||
cheating = false;
|
||||
|
||||
//printf("ValidateMatchingStake: ccTx.vin[0].prevout.hash: %s, ccTx.vin[0].prevout.n: %d\n", ccTx.vin[0].prevout.hash.GetHex().c_str(), ccTx.vin[0].prevout.n);
|
||||
|
||||
if (ccTx.IsCoinBase())
|
||||
{
|
||||
CStakeParams p;
|
||||
if (ValidateStakeTransaction(stakeTx, p))
|
||||
{
|
||||
std::vector<std::vector<unsigned char>> vParams = std::vector<std::vector<unsigned char>>();
|
||||
CScript dummy;
|
||||
|
||||
if (ccTx.vout[voutNum].scriptPubKey.IsPayToCryptoCondition(&dummy, vParams) && vParams.size() > 0)
|
||||
{
|
||||
COptCCParams ccp = COptCCParams(vParams[0]);
|
||||
if (ccp.IsValid() & ccp.vData.size() >= 3 && ccp.vData[2].size() <= 4)
|
||||
{
|
||||
CVerusHashWriter hw = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
hw << stakeTx.vin[0].prevout.hash;
|
||||
hw << stakeTx.vin[0].prevout.n;
|
||||
uint256 utxo = hw.GetHash();
|
||||
|
||||
uint32_t height = 0;
|
||||
int i, dataLen = ccp.vData[2].size();
|
||||
for (i = dataLen - 1; i >= 0; i--)
|
||||
{
|
||||
height = (height << 8) + ccp.vData[2][i];
|
||||
}
|
||||
// for debugging strange issue
|
||||
// printf("iterator: %d, height: %d, datalen: %d\n", i, height, dataLen);
|
||||
|
||||
if (utxo == uint256(ccp.vData[0]))
|
||||
{
|
||||
if (p.prevHash != uint256(ccp.vData[1]) && p.blkHeight >= height)
|
||||
{
|
||||
cheating = true;
|
||||
return true;
|
||||
}
|
||||
// if block height is equal and we are at the else, prevHash must have been equal
|
||||
else if (p.blkHeight == height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2019 The Hush developers
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -36,7 +37,6 @@
|
||||
* there should be a code identifying it. For example,
|
||||
* a possible code is EVAL_BITCOIN_SCRIPT, where the entire binary
|
||||
* after the code is interpreted as a bitcoin script.
|
||||
* Verus EVAL_STAKEGUARD is 0x01
|
||||
*/
|
||||
#define FOREACH_EVAL(EVAL) \
|
||||
EVAL(EVAL_IMPORTPAYOUT, 0xe1) \
|
||||
|
||||
11
src/chain.h
11
src/chain.h
@@ -470,17 +470,6 @@ public:
|
||||
CBlockIndex* GetAncestor(int height);
|
||||
const CBlockIndex* GetAncestor(int height) const;
|
||||
|
||||
int32_t GetVerusPOSTarget() const
|
||||
{
|
||||
return GetBlockHeader().GetVerusPOSTarget();
|
||||
}
|
||||
|
||||
bool IsVerusPOSBlock() const
|
||||
{
|
||||
if ( ASSETCHAINS_LWMAPOS != 0 )
|
||||
return GetBlockHeader().IsVerusPOSBlock();
|
||||
else return(0);
|
||||
}
|
||||
};
|
||||
|
||||
/** Used to marshal pointers into hashes for db storage. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -104,7 +105,7 @@ public:
|
||||
strNetworkID = "main";
|
||||
strCurrencyUnits = "KMD";
|
||||
bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800
|
||||
consensus.fCoinbaseMustBeProtected = false;
|
||||
consensus.nSubsidySlowStartInterval = 20000;
|
||||
consensus.nSubsidyHalvingInterval = 840000;
|
||||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||
@@ -581,22 +582,6 @@ void *chainparams_commandline()
|
||||
pCurrentParams->pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff;
|
||||
pCurrentParams->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);
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
|
||||
{
|
||||
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
|
||||
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
|
||||
pCurrentParams->consensus.nLwmaAjustedWeight = 1350;
|
||||
pCurrentParams->consensus.nPowAveragingWindow = 45;
|
||||
pCurrentParams->consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
}
|
||||
else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1)
|
||||
{
|
||||
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
|
||||
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
|
||||
pCurrentParams->consensus.nLwmaAjustedWeight = 1350;
|
||||
pCurrentParams->consensus.nPowAveragingWindow = 45;
|
||||
pCurrentParams->consensus.powAlternate = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
}
|
||||
|
||||
if (ASSETCHAINS_LWMAPOS != 0)
|
||||
{
|
||||
@@ -604,57 +589,160 @@ void *chainparams_commandline()
|
||||
pCurrentParams->consensus.nPOSAveragingWindow = 45;
|
||||
// spacing is 1000 units per block to get better resolution, POS is 50% hard coded for now, we can vary it later
|
||||
// when we get reliable integer math on nLwmaPOSAjustedWeight
|
||||
pCurrentParams->consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
|
||||
pCurrentParams->consensus.nPOSTargetSpacing = KOMODO_BLOCK_POSUNITS * 2;
|
||||
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
|
||||
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
|
||||
// this needs to be recalculated if KOMODO_BLOCK_POSUNITS is changed
|
||||
pCurrentParams->consensus.nLwmaPOSAjustedWeight = 46531;
|
||||
}
|
||||
|
||||
// only require coinbase protection on Verus from the Komodo family of coins
|
||||
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
|
||||
{
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = 227520;
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = 227520;
|
||||
pCurrentParams->consensus.fCoinbaseMustBeProtected = true;
|
||||
checkpointData = //(Checkpoints::CCheckpointData)
|
||||
{
|
||||
boost::assign::map_list_of
|
||||
(0, pCurrentParams->consensus.hashGenesisBlock)
|
||||
(10000, uint256S("0xac2cd7d37177140ea4991cf630c0b9c7f94d707b84fb0351bf3a44856d2ae5dc"))
|
||||
(20000, uint256S("0xb0e8cb9f77aaa7ff5bd90d6c08d06f4c4bf03e00c2b8a35a042e760845590c8a"))
|
||||
(30000, uint256S("0xf2112ca577338ad7104bf905fa6a63d36b17a86f914c97b73cd31d43fcd7557c"))
|
||||
(40000, uint256S("0x00000000008f83378dab727864b763ce91a4ea5f75d55939c0c1390cfb8c38f1"))
|
||||
(49170, uint256S("0x2add646c0089871ec2379f02f7cd60b3af6efd9c152a6f16fc10925458c270cc")),
|
||||
(int64_t)1529910234, // * UNIX timestamp of last checkpoint block
|
||||
(int64_t)63661, // * total number of transactions between genesis and last checkpoint
|
||||
// (the tx=... number in the SetBestChain debug.log lines)
|
||||
(double)2777 // * estimated number of transactions per day after checkpoint
|
||||
// total number of tx / (checkpoint block height / (24 * 24))
|
||||
};
|
||||
|
||||
pCurrentParams->consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000001a8f4f23f8b2d1f7e");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(ASSETCHAINS_SYMBOL,"VRSCTEST") == 0 || strcmp(ASSETCHAINS_SYMBOL,"VERUSTEST") == 0)
|
||||
{
|
||||
pCurrentParams->consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000001f7e");
|
||||
}
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = ASSETCHAINS_SAPLING;
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER;
|
||||
checkpointData = //(Checkpoints::CCheckpointData)
|
||||
{
|
||||
boost::assign::map_list_of
|
||||
(0, pCurrentParams->consensus.hashGenesisBlock),
|
||||
(int64_t)1231006505,
|
||||
(int64_t)1,
|
||||
(double)2777 // * estimated number of transactions per day after checkpoint
|
||||
// total number of tx / (checkpoint block height / (24 * 24))
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = ASSETCHAINS_SAPLING;
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER;
|
||||
// Generated at 1575831755 via hush3 contrib/checkpoints.pl by Duke Leto
|
||||
checkpointData = //(Checkpoints::CCheckpointData)
|
||||
{
|
||||
boost::assign::map_list_of
|
||||
(0, pCurrentParams->consensus.hashGenesisBlock)
|
||||
(1000, uint256S("0x0000001893130f005d2e90fcdf40057ae06390bd0490740aae2843e62aeb7bc2"))
|
||||
(2000, uint256S("0x00000003003e6c8fa176ef293d1322514778343601fa21dfdb0c9aacef189576"))
|
||||
(3000, uint256S("0x00000005c1419d252bc59d77c06e07aad61702c8b3e76d2070577a18159ab59d"))
|
||||
(4000, uint256S("0x00000008bc4094ea475a871302361ffdc6bfd63ded049d172c8dad01ed67fd3c"))
|
||||
(5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60"))
|
||||
(6000, uint256S("0x0000000567191591911b33b852e4b87de119df2c773bc800b5a3655be18eb98e"))
|
||||
(7000, uint256S("0x000000082e7b000480d0317d9115f0d0737e78fa2381a2d6456f598bf83fe2f0"))
|
||||
(8000, uint256S("0x0000000415226fff123cd868e255a23d72e204d61bb405fb9dde0810e7721ebf"))
|
||||
(9000, uint256S("0x00000000bd26f7b8d6d80230aad06c0cd590758176b8558da7dfc14161a23ab7"))
|
||||
(10000, uint256S("0x00000002d177d1cbfeaf7c27a2a32766ea9063d222cbcc7623dc08355b07a3ad"))
|
||||
(11000, uint256S("0x0000000284bcffa3bef4097178a94b6b9a788261981253cb8cd6db6b47634732"))
|
||||
(12000, uint256S("0x000000006cf15fdb94253a9389d95ef607c3484c635fe0c8a1f1ec1e5a1c6865"))
|
||||
(13000, uint256S("0x00000001cdc66e08f7f13c775aa1220a801a33df90edba7bbcffac8d06181207"))
|
||||
(14000, uint256S("0x0000000443e432c7dbf0707a12c5671dd1ca606f962368a847bbcff2f5fc2135"))
|
||||
(15000, uint256S("0x000000008dbfbd5d5e27d819bf2989c5658c3494608bfa1320ad0b090660cd44"))
|
||||
(16000, uint256S("0x00000003c6a59e5b10e1a1c6bef08dee4d33d1841156bf97e26c3e4df789b128"))
|
||||
(17000, uint256S("0x00000001debe3734ef4b6aacedde4a6b04cd1c60d4cf37b9f4689f2225ff7c24"))
|
||||
(18000, uint256S("0x00000002e37eccfa7bacd9c201468c754cbef50be9411e3f907891755eef4c6d"))
|
||||
(19000, uint256S("0x000000044636331c0277abb5592529cae1303d2bd43981a8382b4cc152a8d024"))
|
||||
(20000, uint256S("0x00000000a7840e1fccedb13672804e94fcaa87c0360ee4f7353a6b93e5a59da8"))
|
||||
(21000, uint256S("0x00000003a89b17d0cd489045ad62531c4211ee17c3609ed3e4291a067636d526"))
|
||||
(22000, uint256S("0x0000000352a7a25b3fe5f1a32a2c42260d32345487b92b6e520eecec0ee6aca4"))
|
||||
(23000, uint256S("0x00000002c1fdc5cc1211b7adff3b7e755059638fd98bd9da1cdd86bd9a0af1fd"))
|
||||
(24000, uint256S("0x0000000603a6190bbfdcdc5da9645d069aebd7a0b29607077470089c7b4a1188"))
|
||||
(25000, uint256S("0x0000000519d6ab6ca9c705ebafa9946bce34934709621bc22227567e90608667"))
|
||||
(26000, uint256S("0x0000000146e7314e2ebb2bfc10b9fe0fdd744734910a3971bbc4e970fe2c4cb9"))
|
||||
(27000, uint256S("0x000000047060e4173b4edd6374c3580580981dea20d0b49ea15c9fdfa97ba104"))
|
||||
(28000, uint256S("0x000000065eea521cccf6b1f99e1a77683717d02ddaed654a4c85d717e1e8c957"))
|
||||
(29000, uint256S("0x00000001ecdbcd195e04f792721262dc79bb070e73b6606b389825b5ae8e4791"))
|
||||
(30000, uint256S("0x0000000240de901e9e70d2db5badf62886ab0e8c442107d571bc04b3bdd43052"))
|
||||
(31000, uint256S("0x00000002d39f4f3504660e13e956c12aa3411a0ba392b3797d95f15e8fbd1958"))
|
||||
(32000, uint256S("0x0000000130cd781ed559d553f35a6bc99ed252aadd92b2a461bd332ca2d69a96"))
|
||||
(33000, uint256S("0x000000035ad950b0e78bbaf19f7a97865f29edd600e7aee4a3fce2e42db29d38"))
|
||||
(34000, uint256S("0x00000004f33b5ff97c128bfbef656aa10341e2606f54e198d5280016d2578eca"))
|
||||
(35000, uint256S("0x00000000ad1ef91eb70011a94646c148f1b8949b464a0de82adf1ba1ce6175a5"))
|
||||
(36000, uint256S("0x00000003b1450e1cf9f4e5f53534777b24039fcde81ec7ac1c2ea754a26fcd78"))
|
||||
(37000, uint256S("0x0000000337c4407954be01dcaf75a660e4b5b69e9e923bd62e74b0e44f01d9df"))
|
||||
(38000, uint256S("0x00000002b5d6f83f8d2ef7d88c3cdff1e444882819a70a7c7281d1d92f81bc9a"))
|
||||
(39000, uint256S("0x00000001a1eb6a530b065c873f65219de3282c4f386ba68bc2a0b88dc2b4c5cd"))
|
||||
(40000, uint256S("0x000000013b65e22d0bb6a9103dc71da5a1b7fa2acbc1c7d7a4d8f7730c37d4ab"))
|
||||
(41000, uint256S("0x000000027dbc2315769690cf93c79c54e0591c808d83decb66302492f0f79f1c"))
|
||||
(42000, uint256S("0x00000000ca09a12162a92b9ecbf6bf00a2bb822a77dd142df26d81db95c21bed"))
|
||||
(43000, uint256S("0x000000050c4c80b9e53b960a638bd231c193a383f0df162c720e4594ba427a4b"))
|
||||
(44000, uint256S("0x00000000f42d6c43703dbb47847298cedcbef8a27018baed8f4a217e7d5d823c"))
|
||||
(45000, uint256S("0x00000004da449923c218bd3e69745ebafca41c32e0c81ab6b485ae6c4c80df18"))
|
||||
(46000, uint256S("0x00000006e4bdf2707158e266d2d54294b20063c0f1723abed97fafe7ecf4b2de"))
|
||||
(47000, uint256S("0x0000000015d099357b0c8cbc24d8e2bd18e5e47eabe6ff89c09c9837bb071cd8"))
|
||||
(48000, uint256S("0x00000009c9ddaffefc5d5c78a6f89b872fdd732c16a5311debed6b92255f340b"))
|
||||
(49000, uint256S("0x00000008447d907ddc1d87df0ea235636baaaf34bc1000620e8173f1d8f7758c"))
|
||||
(50000, uint256S("0x000000027470e84cd195242f199b90fde40b70f80fac7a7080b1517c95cf56c6"))
|
||||
(51000, uint256S("0x000000015190913dec8a508bc219b0a0a1587b50acb23b48343010015cb5ec69"))
|
||||
(52000, uint256S("0x000000071608ad395dc31dc3011d5cad7f7a7296e34490a1e9e2dcf060bcc649"))
|
||||
(53000, uint256S("0x0000000608fa8a454c3c0e5e06bf091c4cfa131e7b91eb6622087cfc3fa4c149"))
|
||||
(54000, uint256S("0x0000000455eac130c205512cc0bffaa3ecb2d393cbf0d9e943c3d5911ea06a4b"))
|
||||
(55000, uint256S("0x00000000a20b276ed95b261a51681fb2d0d58e528cc8cd2e5fb7fdeb732b1861"))
|
||||
(56000, uint256S("0x000000016057dfbf2fc59650b63b7c2dc2379af75cf00c0ee3f3835e992ec11e"))
|
||||
(57000, uint256S("0x00000003a1eff8b5160655111ff1c0f1426b2b879c1f6fd761332b82c8640c67"))
|
||||
(58000, uint256S("0x00000001b0ac789061a277b553de1aae373533f5b6b1330326744ac7087c87c9"))
|
||||
(59000, uint256S("0x0000000a0dee07bdf593a68e5463cb5553f9bce3367a39d88f07ea43709eba87"))
|
||||
(60000, uint256S("0x000000060382850eadef184b67f38c0b2de27157296f3d9d8e2b7b70b1f76127"))
|
||||
(61000, uint256S("0x0000000492a93fd6c9eb080f3398517b39c8eaf835440d2571e515f76a931bf2"))
|
||||
(62000, uint256S("0x00000005ee0b8f7fcae8e6b17b12ab66f17cf34697182afc29d863d9844a84a9"))
|
||||
(63000, uint256S("0x000000045842b1c05c7e9a1a887e9a6ecdcaea2f4e03b9476031ed609ace91d2"))
|
||||
(64000, uint256S("0x00000004259921159c0714b90b1950fbae7eee2a14687dcfc57ab22b39c8123c"))
|
||||
(65000, uint256S("0x0000000618eb1c909301585f6b8f17ee6d09da97c580fe70d59babcd7864b556"))
|
||||
(66000, uint256S("0x000000049c85139efb1694525b5cf864a6021e49a412aaea9ff2b2b6ee04e1ca"))
|
||||
(67000, uint256S("0x0000000141358b3ae2c4ab2a384f963f4fdc925060c42de5578aec82c1de3189"))
|
||||
(68000, uint256S("0x0000000405b0273ba96d1e83e27e50ecf5f123c2e3e05b56524cc2cd79ea18e7"))
|
||||
(69000, uint256S("0x0000000764c8a434a1583b2578155a18720bbad67cc2c06e2fb013e872b1b10e"))
|
||||
(70000, uint256S("0x00000006d11cf168399c719b2bb036eadd09e740c98764d82adf75f5a800e90d"))
|
||||
(71000, uint256S("0x00000002339c3cf62fc4716899a0e341969d85146dcb98854607332f81e5f258"))
|
||||
(72000, uint256S("0x000000055e39f9cd963bac08c9c10ab982491d50b66486099675b015016dad7a"))
|
||||
(73000, uint256S("0x0000000766261dbd9e48a0d544d012f57ab7890a761d893851b63e0e5b5e47dc"))
|
||||
(74000, uint256S("0x000000058bd8080674ffb086704fbfde45e91172d0784416ed5356d20bd60fd7"))
|
||||
(75000, uint256S("0x00000007abb9cb521244c988f0ace53bf230bdf9c9db75d0102472a721c6b038"))
|
||||
(76000, uint256S("0x000000071789d7ecf5e8c7e1a982e119d0b9d6748cb01426a5b8fff77a54f76b"))
|
||||
(77000, uint256S("0x00000007364be847b08481f87bbe4db69a79f5c4388e3c898ea140011a121ca7"))
|
||||
(78000, uint256S("0x000000031b7afd1aa244d78056606bf718cb96cb1fe1656070d37ed9d4031ebf"))
|
||||
(79000, uint256S("0x00000003125d8e62fa215c1797229d271db705299f43e1db85edb7ac68349127"))
|
||||
(80000, uint256S("0x000000031c23c3a1828b3a432ab27c6b34a93741f5711507abeb34a822ba5311"))
|
||||
(81000, uint256S("0x0000000212aab2361322e29a1037b82624fc2acdb61dd457ae25e4dffca14b42"))
|
||||
(82000, uint256S("0x00000003140442a0d3b5ba57d2e51ed4a2ec39fb6ee8c9e2d70d530f46843f57"))
|
||||
(83000, uint256S("0x0000000404e963d87db2ccd709377d5fd8b28c67c51ffcace62290844b895ba0"))
|
||||
(84000, uint256S("0x00000003076c29391d9a5910e287d5319f4bf29f92eb309a8dd72cbf98847102"))
|
||||
(85000, uint256S("0x00000006fc5823857bdd44f89f4a97838a9f735c7bdf81bd89f50110dc16fbab"))
|
||||
(86000, uint256S("0x00000002247705c4f02ab4a672686dadba9de55fcf71433388a4250af6d1154d"))
|
||||
(87000, uint256S("0x00000000302718129c873c0ba6e571512ab5c4216e0d978ed3ef1d4dccddbb26"))
|
||||
(88000, uint256S("0x00000002129732e7d8d99d78eef4ed3318cdbd73883d88e7c2b9534d11284486"))
|
||||
(89000, uint256S("0x00000001513759a2e2b6e6c30ee8db631957511adcefa518ad31e0b1ec4e789d"))
|
||||
(90000, uint256S("0x00000003e62dcb81fe33178e2dc45c70ca04733542179ac5d93bceb7c456f365"))
|
||||
(91000, uint256S("0x00000000674963dd8d6d7dab67d1df8c6e9455cef55014aa15082722f9d7f115"))
|
||||
(92000, uint256S("0x00000004f4e1151df0905baf82bd29ece0fc7db8d96a2ae6c0efad0e0e68e55e"))
|
||||
(93000, uint256S("0x00000002876b9eb7b41e025d55d7dd740b5dc811eae0909169081e705c61b6b5"))
|
||||
(94000, uint256S("0x00000001efdcd19bf060a424cd0cef2d04f0d206fae21a72a57b4cc8d1019421"))
|
||||
(95000, uint256S("0x00000002a22cae35b32e31ffbe55d2d56ef04f010aebd19f1536b7582c1ea4d9"))
|
||||
(96000, uint256S("0x0000000433d2385e8260c26dabec1c5f7376ed63b478c5d94bc15ee521a86ee3"))
|
||||
(97000, uint256S("0x00000003112c73fd4cf10604e1a44b7acd698e196cbe16e63abdcd34008f4b36"))
|
||||
(98000, uint256S("0x0000000179fb7ea8e68c54de5d09e531b5cbbfe7f5d128f3f93f55576673ddc7"))
|
||||
(99000, uint256S("0x00000002e8e3a9f26154b941837d42ad62ea153d75be61a13c04e2249a781243"))
|
||||
(100000, uint256S("0x00000001bc1c40d120bf2df1654f3fb5e4d28d4ff292d05667cf5610042c794a"))
|
||||
(101000, uint256S("0x00000003a52ec72d58bdb88096334a29eddb17fd454a7c15aba815358f3b4285"))
|
||||
(102000, uint256S("0x00000002a602644eb8765aab158112307f25bc6e8f82c1220be08642be6d12ca"))
|
||||
(103000, uint256S("0x000000044a6a0aca758af879fee5bbbfc4ac75287f63cc91ad26bc921d3c44ac"))
|
||||
(104000, uint256S("0x000000013fe4abb66862573821938d8e203da577e8c15055249a5fc4d6ca28f6"))
|
||||
(105000, uint256S("0x0000000175182a7f9c46aaae8723a664168af4be37c5d73e8f773df6b67a458b"))
|
||||
(106000, uint256S("0x000000005426bdc52efa996e5bd44f0d5f075fdd865063a1c5c341f4b37aa8d7"))
|
||||
(107000, uint256S("0x000000026ce5ee0c6f81786838f502ab3ac4b52371716b3956bb58f91fe2a79e"))
|
||||
(108000, uint256S("0x000000042a0f660df6ef24e237b4010749b7cc7ba402fe7f6af98643df62cb0b"))
|
||||
(109000, uint256S("0x000000020debe96d90bc1d317036404c4518309e93c45303f86bdef7fac213df"))
|
||||
(110000, uint256S("0x000000030ba3cdbb85d5028379dfe50fbf28c04f8add3300814c2f649ec53594"))
|
||||
(111000, uint256S("0x000000030d9aa7e30990157616d54e5c32a26a0fbb5db1a7fde7e192bb2bd992"))
|
||||
(112000, uint256S("0x00000003885472c246e7f5cc5c9982ce0d1ed292ff0b09451c272f201ff1bd3a"))
|
||||
(113000, uint256S("0x000000027d6d7f782a510fa9b2a41f8f1a713fa4ff12906e453ba59af911cbfc"))
|
||||
(114000, uint256S("0x000000046020cd15a3803db747ec6811bee5703c9b67b54185d8fae23f7617cf"))
|
||||
(115000, uint256S("0x000000019fd1a317c649c83c6b2a3f6bca7e82fac2fc89ce69de4b6d5715050b"))
|
||||
(116000, uint256S("0x00000002cad5e312f8553c3ca053f3588d53561722ce3bf20d55eb4654707668"))
|
||||
(117000, uint256S("0x0000000339f55a289fabf4881ab5d89739779bc0e1ab5650830b4fec8870d183"))
|
||||
(118000, uint256S("0x000000027bc70600ad7355ee66e6ca0b9d2fd24b7778014bb464a7bbc37627de"))
|
||||
(119000, uint256S("0x00000001ddca829e3480f45ec3f7291fe9d611dd4600c047516729052a881058"))
|
||||
(120000, uint256S("0x0000000217decb42c4ea26cbee700e728a558ae648393b8014f035566ef2a456"))
|
||||
(121000, uint256S("0x00000000f2798338531f5a39201960a80ec28203cdd5dcd27718f6a7fd6723bf"))
|
||||
(122000, uint256S("0x00000001204dfcde9f95ef04a25f54553329a48fe34078e213d93199dfe0c26b"))
|
||||
(123000, uint256S("0x0000000220091729c30ec5a296a5218e0500bff2dfe10a5d9e5ceca2ea39482b"))
|
||||
(124000, uint256S("0x00000002415360bf949d8e96362ce7b0aada6adbcfb73aba536fa7a329fec49f"))
|
||||
(125000, uint256S("0x000000002aeab45f5e399d027976c49f4c7732ddbb78d7dc729fb226346ea3f1"))
|
||||
(126000, uint256S("0x0000000067f239b6b78180145dc4ccbda1c71d506201f807912ddc170683808d"))
|
||||
(127000, uint256S("0x00000001962a64e4e5a9e9c6cc286e2bcf155734c24f2c9481128e37ac6d9712"))
|
||||
(128000, uint256S("0x000000011dfac6f7447ae6de5002dd3bf5ddc94faadb706f45e0b4724257dfe5"))
|
||||
(129000, uint256S("0x0000000014f4aa454784a182645fa425834f8f9464abea319ea0afe5d3ccd91a"))
|
||||
(130000, uint256S("0x000000001c4a5aa11e6c142931463fcf7a9f5b9fb41061d26c18ff1860431881"))
|
||||
(131000, uint256S("0x000000003c44e490a60f7aa1941835277230706cfbf58dc8113610cc9c3582eb"))
|
||||
(132000, uint256S("0x0000000041bef6adaff29263986224bd5a2999e2aec38aa07b52fa67eed1402f"))
|
||||
(133000, uint256S("0x0000000162eb0ea1633481197a8ddc3743ff32ce2e8ecc249f9a8e9912459e05"))
|
||||
(134000, uint256S("0x00000002a34611317b4b1d8bc8640282ffb7d7c86fc858af7e0abb0bca6b720d"))
|
||||
(135000, uint256S("0x000000025f9502fc7474d62a0a23417cc5b77f3a049260e65b5b810d71074743"))
|
||||
(136000, uint256S("0x00000000af2a19997fde28b70235070f627f3b5900a9ee13c927529a11110bc6")),
|
||||
(int64_t) 1575741799, // time of last checkpointed block
|
||||
(int64_t) 274689, // total txs
|
||||
(double) 1065 // txs in the last day before block 136590
|
||||
};
|
||||
} else {
|
||||
checkpointData = //(Checkpoints::CCheckpointData)
|
||||
{
|
||||
boost::assign::map_list_of
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#define DO_STRINGIZE(X) #X
|
||||
|
||||
//! Copyright string used in Windows .rc files
|
||||
#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, The Zcash developers, Komodo developers, Hush developers and Verus developers"
|
||||
#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, The Zcash developers, Komodo developers, Hush developers"
|
||||
|
||||
/**
|
||||
* bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -39,7 +40,6 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include "zcash/IncrementalMerkleTree.hpp"
|
||||
//#include "veruslaunch.h"
|
||||
|
||||
/**
|
||||
* Pruned version of CTransaction: only retains metadata and unspent transaction outputs
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
// (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.
|
||||
|
||||
/*
|
||||
This provides the PoW hash function for Verus, a CPU-optimized hash
|
||||
function with a Haraka V2 core. Unlike Haraka, which is made for short
|
||||
inputs only, Verus Hash takes any length of input and produces a 256
|
||||
bit output.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "crypto/common.h"
|
||||
#include "crypto/verus_hash.h"
|
||||
|
||||
void (*CVerusHash::haraka512Function)(unsigned char *out, const unsigned char *in);
|
||||
|
||||
void CVerusHash::Hash(void *result, const void *data, size_t _len)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
unsigned char *bufPtr = buf;
|
||||
int nextOffset = 64;
|
||||
uint32_t pos = 0, len = _len;
|
||||
unsigned char *bufPtr2 = bufPtr + nextOffset;
|
||||
unsigned char *ptr = (unsigned char *)data;
|
||||
|
||||
// put our last result or zero at beginning of buffer each time
|
||||
memset(bufPtr, 0, 32);
|
||||
|
||||
// digest up to 32 bytes at a time
|
||||
for ( ; pos < len; pos += 32)
|
||||
{
|
||||
if (len - pos >= 32)
|
||||
{
|
||||
memcpy(bufPtr + 32, ptr + pos, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = (int)(len - pos);
|
||||
memcpy(bufPtr + 32, ptr + pos, i);
|
||||
memset(bufPtr + 32 + i, 0, 32 - i);
|
||||
}
|
||||
(*haraka512Function)(bufPtr2, bufPtr);
|
||||
bufPtr2 = bufPtr;
|
||||
bufPtr += nextOffset;
|
||||
nextOffset *= -1;
|
||||
}
|
||||
memcpy(result, bufPtr, 32);
|
||||
};
|
||||
|
||||
void CVerusHash::init()
|
||||
{
|
||||
if (IsCPUVerusOptimized())
|
||||
{
|
||||
haraka512Function = &haraka512_zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
haraka512Function = &haraka512_port_zero;
|
||||
}
|
||||
}
|
||||
|
||||
CVerusHash &CVerusHash::Write(const unsigned char *data, size_t _len)
|
||||
{
|
||||
unsigned char *tmp;
|
||||
uint32_t pos, len = _len;
|
||||
|
||||
// digest up to 32 bytes at a time
|
||||
for ( pos = 0; pos < len; )
|
||||
{
|
||||
uint32_t room = 32 - curPos;
|
||||
|
||||
if (len - pos >= room)
|
||||
{
|
||||
memcpy(curBuf + 32 + curPos, data + pos, room);
|
||||
(*haraka512Function)(result, curBuf);
|
||||
tmp = curBuf;
|
||||
curBuf = result;
|
||||
result = tmp;
|
||||
pos += room;
|
||||
curPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(curBuf + 32 + curPos, data + pos, len - pos);
|
||||
curPos += len - pos;
|
||||
pos = 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);
|
||||
}
|
||||
|
||||
void (*CVerusHashV2::haraka512Function)(unsigned char *out, const unsigned char *in);
|
||||
|
||||
void CVerusHashV2::init()
|
||||
{
|
||||
if (IsCPUVerusOptimized())
|
||||
{
|
||||
load_constants();
|
||||
haraka512Function = &haraka512;
|
||||
}
|
||||
else
|
||||
{
|
||||
// load and tweak the haraka constants
|
||||
load_constants_port();
|
||||
haraka512Function = &haraka512_port;
|
||||
}
|
||||
}
|
||||
|
||||
void CVerusHashV2::Hash(void *result, const void *data, size_t len)
|
||||
{
|
||||
unsigned char buf[128];
|
||||
unsigned char *bufPtr = buf;
|
||||
int pos = 0, nextOffset = 64;
|
||||
unsigned char *bufPtr2 = bufPtr + nextOffset;
|
||||
unsigned char *ptr = (unsigned char *)data;
|
||||
|
||||
// put our last result or zero at beginning of buffer each time
|
||||
memset(bufPtr, 0, 32);
|
||||
|
||||
// digest up to 32 bytes at a time
|
||||
for ( ; pos < len; pos += 32)
|
||||
{
|
||||
if (len - pos >= 32)
|
||||
{
|
||||
memcpy(bufPtr + 32, ptr + pos, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = (int)(len - pos);
|
||||
memcpy(bufPtr + 32, ptr + pos, i);
|
||||
memset(bufPtr + 32 + i, 0, 32 - i);
|
||||
}
|
||||
(*haraka512Function)(bufPtr2, bufPtr);
|
||||
bufPtr2 = bufPtr;
|
||||
bufPtr += nextOffset;
|
||||
nextOffset *= -1;
|
||||
}
|
||||
memcpy(result, bufPtr, 32);
|
||||
};
|
||||
|
||||
CVerusHashV2 &CVerusHashV2::Write(const unsigned char *data, size_t len)
|
||||
{
|
||||
unsigned char *tmp;
|
||||
|
||||
// digest up to 32 bytes at a time
|
||||
for ( int pos = 0; pos < len; )
|
||||
{
|
||||
int room = 32 - curPos;
|
||||
|
||||
if (len - pos >= room)
|
||||
{
|
||||
memcpy(curBuf + 32 + curPos, data + pos, room);
|
||||
(*haraka512Function)(result, curBuf);
|
||||
tmp = curBuf;
|
||||
curBuf = result;
|
||||
result = tmp;
|
||||
pos += room;
|
||||
curPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(curBuf + 32 + curPos, data + pos, len - pos);
|
||||
curPos += len - pos;
|
||||
pos = len;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// to be declared and accessed from C
|
||||
void verus_hash_v2(void *result, const void *data, size_t len)
|
||||
{
|
||||
return CVerusHashV2::Hash(result, data, len);
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
// (C) 2018 Michael Toutonghi
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
/*
|
||||
This provides the PoW hash function for Verus, enabling CPU mining.
|
||||
*/
|
||||
#ifndef VERUS_HASH_H_
|
||||
#define VERUS_HASH_H_
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <cpuid.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "crypto/haraka.h"
|
||||
#include "crypto/haraka_portable.h"
|
||||
}
|
||||
|
||||
class CVerusHash
|
||||
{
|
||||
public:
|
||||
static void Hash(void *result, const void *data, size_t len);
|
||||
static void (*haraka512Function)(unsigned char *out, const unsigned char *in);
|
||||
|
||||
static void init();
|
||||
|
||||
CVerusHash() { }
|
||||
|
||||
CVerusHash &Write(const unsigned char *data, size_t len);
|
||||
|
||||
CVerusHash &Reset()
|
||||
{
|
||||
curBuf = buf1;
|
||||
result = buf2;
|
||||
curPos = 0;
|
||||
std::fill(buf1, buf1 + sizeof(buf1), 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int64_t *ExtraI64Ptr() { return (int64_t *)(curBuf + 32); }
|
||||
void ClearExtra()
|
||||
{
|
||||
if (curPos)
|
||||
{
|
||||
std::fill(curBuf + 32 + curPos, curBuf + 64, 0);
|
||||
}
|
||||
}
|
||||
void ExtraHash(unsigned char hash[32]) { (*haraka512Function)(hash, curBuf); }
|
||||
|
||||
void Finalize(unsigned char hash[32])
|
||||
{
|
||||
if (curPos)
|
||||
{
|
||||
std::fill(curBuf + 32 + curPos, curBuf + 64, 0);
|
||||
(*haraka512Function)(hash, curBuf);
|
||||
}
|
||||
else
|
||||
std::memcpy(hash, curBuf, 32);
|
||||
}
|
||||
|
||||
private:
|
||||
// only buf1, the first source, needs to be zero initialized
|
||||
unsigned char buf1[64] = {0}, buf2[64];
|
||||
unsigned char *curBuf = buf1, *result = buf2;
|
||||
size_t curPos = 0;
|
||||
};
|
||||
|
||||
class CVerusHashV2
|
||||
{
|
||||
public:
|
||||
static void Hash(void *result, const void *data, size_t len);
|
||||
static void (*haraka512Function)(unsigned char *out, const unsigned char *in);
|
||||
|
||||
static void init();
|
||||
|
||||
CVerusHashV2() {}
|
||||
|
||||
CVerusHashV2 &Write(const unsigned char *data, size_t len);
|
||||
|
||||
CVerusHashV2 &Reset()
|
||||
{
|
||||
curBuf = buf1;
|
||||
result = buf2;
|
||||
curPos = 0;
|
||||
std::fill(buf1, buf1 + sizeof(buf1), 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int64_t *ExtraI64Ptr() { return (int64_t *)(curBuf + 32); }
|
||||
void ClearExtra()
|
||||
{
|
||||
if (curPos)
|
||||
{
|
||||
std::fill(curBuf + 32 + curPos, curBuf + 64, 0);
|
||||
}
|
||||
}
|
||||
void ExtraHash(unsigned char hash[32]) { (*haraka512Function)(hash, curBuf); }
|
||||
|
||||
void Finalize(unsigned char hash[32])
|
||||
{
|
||||
if (curPos)
|
||||
{
|
||||
std::fill(curBuf + 32 + curPos, curBuf + 64, 0);
|
||||
(*haraka512Function)(hash, curBuf);
|
||||
}
|
||||
else
|
||||
std::memcpy(hash, curBuf, 32);
|
||||
}
|
||||
|
||||
private:
|
||||
// only buf1, the first source, needs to be zero initialized
|
||||
unsigned char buf1[64] = {0}, buf2[64];
|
||||
unsigned char *curBuf = buf1, *result = buf2;
|
||||
size_t curPos = 0;
|
||||
};
|
||||
|
||||
extern void verus_hash(void *result, const void *data, size_t len);
|
||||
extern void verus_hash_v2(void *result, const void *data, size_t len);
|
||||
|
||||
inline bool IsCPUVerusOptimized()
|
||||
{
|
||||
unsigned int eax,ebx,ecx,edx;
|
||||
|
||||
if (!__get_cpuid(1,&eax,&ebx,&ecx,&edx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((ecx & (bit_AVX | bit_AES)) == (bit_AVX | bit_AES));
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=VRSC $1 $2 $3 $4 $5 $6
|
||||
92
src/hash.h
92
src/hash.h
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -23,7 +24,6 @@
|
||||
|
||||
#include "crypto/ripemd160.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "crypto/verus_hash.h"
|
||||
#include "prevector.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
@@ -221,78 +221,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** A writer stream (for serialization) that computes a 256-bit Verus hash. */
|
||||
class CVerusHashWriter
|
||||
{
|
||||
private:
|
||||
CVerusHash state;
|
||||
|
||||
public:
|
||||
int nType;
|
||||
int nVersion;
|
||||
|
||||
CVerusHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), state() { }
|
||||
void Reset() { state.Reset(); }
|
||||
|
||||
CVerusHashWriter& write(const char *pch, size_t size) {
|
||||
state.Write((const unsigned char*)pch, size);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
// invalidates the object for further writing
|
||||
uint256 GetHash() {
|
||||
uint256 result;
|
||||
state.Finalize((unsigned char*)&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t *xI64p() { return state.ExtraI64Ptr(); }
|
||||
CVerusHash &GetState() { return state; }
|
||||
|
||||
template<typename T>
|
||||
CVerusHashWriter& operator<<(const T& obj) {
|
||||
// Serialize to this stream
|
||||
::Serialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
};
|
||||
|
||||
/** A writer stream (for serialization) that computes a 256-bit Verus hash with key initialized to Haraka standard. */
|
||||
class CVerusHashV2Writer
|
||||
{
|
||||
private:
|
||||
CVerusHashV2 state;
|
||||
|
||||
public:
|
||||
int nType;
|
||||
int nVersion;
|
||||
|
||||
CVerusHashV2Writer(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), state() {}
|
||||
void Reset() { state.Reset(); }
|
||||
|
||||
CVerusHashV2Writer& write(const char *pch, size_t size) {
|
||||
state.Write((const unsigned char*)pch, size);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
// invalidates the object for further writing
|
||||
uint256 GetHash() {
|
||||
uint256 result;
|
||||
state.Finalize((unsigned char*)&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t *xI64p() { return state.ExtraI64Ptr(); }
|
||||
CVerusHashV2 &GetState() { return state; }
|
||||
|
||||
template<typename T>
|
||||
CVerusHashV2Writer& operator<<(const T& obj) {
|
||||
// Serialize to this stream
|
||||
::Serialize(*this, obj);
|
||||
return (*this);
|
||||
}
|
||||
};
|
||||
|
||||
/** Compute the 256-bit hash of an object's serialization. */
|
||||
template<typename T>
|
||||
uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
|
||||
@@ -302,24 +230,6 @@ uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL
|
||||
return ss.GetHash();
|
||||
}
|
||||
|
||||
/** Compute the 256-bit Verus hash of an object's serialization. */
|
||||
template<typename T>
|
||||
uint256 SerializeVerusHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
CVerusHashWriter ss(nType, nVersion);
|
||||
ss << obj;
|
||||
return ss.GetHash();
|
||||
}
|
||||
|
||||
/** Compute the 256-bit Verus hash of an object's serialization. */
|
||||
template<typename T>
|
||||
uint256 SerializeVerusHashV2(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
CVerusHashV2Writer ss(nType, nVersion);
|
||||
ss << obj;
|
||||
return ss.GetHash();
|
||||
}
|
||||
|
||||
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash);
|
||||
|
||||
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
|
||||
|
||||
40
src/init.cpp
40
src/init.cpp
@@ -608,7 +608,6 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-ac_timelockgte", _("Timelocked coinbase minimum amount to be locked"));
|
||||
strUsage += HelpMessageOpt("-ac_timelockto", _("Timelocked coinbase stop height"));
|
||||
strUsage += HelpMessageOpt("-ac_txpow", _("Enforce transaction-rate limit, default 0"));
|
||||
strUsage += HelpMessageOpt("-ac_veruspos", _("Use Verus Proof-Of-Stake (-ac_veruspos=50) default 0"));
|
||||
|
||||
return strUsage;
|
||||
}
|
||||
@@ -1379,24 +1378,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
ECC_Start();
|
||||
globalVerifyHandle.reset(new ECCVerifyHandle());
|
||||
|
||||
/*
|
||||
// set the hash algorithm to use for this chain
|
||||
// Again likely better solution here, than using long IF ELSE.
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1;
|
||||
CVerusHash::init();
|
||||
CVerusHashV2::init();
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
|
||||
{
|
||||
// initialize VerusHash
|
||||
CBlockHeader::SetVerusHash();
|
||||
}
|
||||
else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1)
|
||||
{
|
||||
// initialize VerusHashV2
|
||||
CBlockHeader::SetVerusHashV2();
|
||||
}
|
||||
*/
|
||||
|
||||
//fprintf(stderr,"%s tik10\n", __FUNCTION__);
|
||||
// Sanity check
|
||||
if (!InitSanityCheck())
|
||||
@@ -1685,31 +1666,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
fReindex = GetBoolArg("-reindex", false);
|
||||
|
||||
// Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/
|
||||
boost::filesystem::path blocksDir = GetDataDir() / "blocks";
|
||||
if (!boost::filesystem::exists(blocksDir))
|
||||
{
|
||||
boost::filesystem::create_directories(blocksDir);
|
||||
bool linked = false;
|
||||
for (unsigned int i = 1; i < 10000; i++) {
|
||||
boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i);
|
||||
if (!boost::filesystem::exists(source)) break;
|
||||
boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
|
||||
try {
|
||||
boost::filesystem::create_hard_link(source, dest);
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
|
||||
linked = true;
|
||||
} catch (const boost::filesystem::filesystem_error& e) {
|
||||
// Note: hardlink creation failing is not a disaster, it just means
|
||||
// blocks will get re-downloaded from peers.
|
||||
LogPrintf("Error hardlinking blk%04u.dat: %s\n", i, e.what());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (linked)
|
||||
{
|
||||
fReindex = true;
|
||||
}
|
||||
}
|
||||
|
||||
// block tree db settings
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "pubkey.h"
|
||||
#include "script/script.h"
|
||||
#include "script/standard.h"
|
||||
#include "script/script_ext.h"
|
||||
#include "sync.h"
|
||||
#include "zcash/Address.hpp"
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Copyright 2019 The Hush Developers
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -17,8 +19,8 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/easy.h>
|
||||
#include "primitives/nonce.h"
|
||||
#include "consensus/params.h"
|
||||
#include "primitives/nonce.h"
|
||||
#include "komodo_defs.h"
|
||||
#include "script/standard.h"
|
||||
#include "cc/CCinclude.h"
|
||||
@@ -1481,11 +1483,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
|
||||
}
|
||||
if ( m+n < 100 )
|
||||
{
|
||||
// We do actual PoS % at the start. Requires coin distribution in first 10 blocks!
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 )
|
||||
percPoS = (percPoS*100) / (m+n);
|
||||
else
|
||||
percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100;
|
||||
percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100;
|
||||
}
|
||||
if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 )
|
||||
fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height);
|
||||
@@ -1583,24 +1581,6 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh
|
||||
if ( blocktime+iter+segid*2 < txtime+minage )
|
||||
continue;
|
||||
diff = (iter + blocktime - txtime - minage);
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 )
|
||||
{
|
||||
/*if ( PoSperc < ASSETCHAINS_STAKED )
|
||||
{
|
||||
// Under PoS % target and we need to increase diff.
|
||||
//fprintf(stderr, "PoS too low diff.%i changed to.",diff);
|
||||
diff = diff * ( (ASSETCHAINS_STAKED - PoSperc + 1) * (ASSETCHAINS_STAKED - PoSperc + 1) * ( nHeight < 50 ? 1000 : 1));
|
||||
//fprintf(stderr, "%i \n",diff);
|
||||
}
|
||||
else */
|
||||
if ( PoSperc > ASSETCHAINS_STAKED )
|
||||
{
|
||||
// Over PoS target need to lower diff.
|
||||
//fprintf(stderr, "PoS too high diff.%i changed to.",diff);
|
||||
diff = diff / ( (PoSperc - ASSETCHAINS_STAKED + 1) * (PoSperc - ASSETCHAINS_STAKED + 1) );
|
||||
//fprintf(stderr, "%i \n",diff);
|
||||
}
|
||||
}
|
||||
if ( diff < 0 )
|
||||
diff = 60;
|
||||
else if ( diff > 3600*24*30 )
|
||||
@@ -1611,17 +1591,6 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh
|
||||
if ( iter > 0 )
|
||||
diff += segid*2;
|
||||
coinage = (value * diff);
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 )
|
||||
{
|
||||
if ( PoSperc < ASSETCHAINS_STAKED )
|
||||
{
|
||||
// Under PoS % target and we need to increase diff.
|
||||
//fprintf(stderr, "PoS too low diff.%i changed to.",diff);
|
||||
if ( blocktime+iter+segid*2 > prevtime+128 )
|
||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+102));
|
||||
//fprintf(stderr, "%i \n",diff);
|
||||
}
|
||||
}
|
||||
if ( blocktime+iter+segid*2 > prevtime+480 )
|
||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
|
||||
coinage256 = arith_uint256(coinage+1);
|
||||
@@ -1752,181 +1721,6 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
||||
bool GetStakeParams(const CTransaction &stakeTx, CStakeParams &stakeParams);
|
||||
bool ValidateMatchingStake(const CTransaction &ccTx, uint32_t voutNum, const CTransaction &stakeTx, bool &cheating);
|
||||
|
||||
// for now, we will ignore slowFlag in the interest of keeping success/fail simpler for security purposes
|
||||
bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
||||
{
|
||||
CBlockIndex *pastBlockIndex;
|
||||
uint256 txid, blkHash;
|
||||
int32_t txn_count;
|
||||
uint32_t voutNum;
|
||||
CAmount value;
|
||||
bool isPOS = false;
|
||||
CTxDestination voutaddress, destaddress, cbaddress;
|
||||
arith_uint256 target, hash;
|
||||
CTransaction tx;
|
||||
|
||||
if (!pblock->IsVerusPOSBlock())
|
||||
{
|
||||
printf("%s, height %d not POS block\n", pblock->nNonce.GetHex().c_str(), height);
|
||||
//pblock->nNonce.SetPOSTarget(pblock->nNonce.GetPOSTarget());
|
||||
//printf("%s after setting POS target\n", pblock->nNonce.GetHex().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
char voutaddr[64], destaddr[64], cbaddr[64];
|
||||
|
||||
txn_count = pblock->vtx.size();
|
||||
|
||||
if ( txn_count > 1 )
|
||||
{
|
||||
target.SetCompact(pblock->GetVerusPOSTarget());
|
||||
txid = pblock->vtx[txn_count-1].vin[0].prevout.hash;
|
||||
voutNum = pblock->vtx[txn_count-1].vin[0].prevout.n;
|
||||
value = pblock->vtx[txn_count-1].vout[0].nValue;
|
||||
|
||||
{
|
||||
bool validHash = (value != 0);
|
||||
bool enablePOSNonce = CPOSNonce::NewPOSActive(height);
|
||||
uint256 rawHash;
|
||||
arith_uint256 posHash;
|
||||
|
||||
if (validHash && enablePOSNonce)
|
||||
{
|
||||
validHash = pblock->GetRawVerusPOSHash(rawHash, height);
|
||||
posHash = UintToArith256(rawHash) / value;
|
||||
if (!validHash || posHash > target)
|
||||
{
|
||||
validHash = false;
|
||||
printf("ERROR: invalid nonce value for PoS block\nnNonce: %s\nrawHash: %s\nposHash: %s\nvalue: %lu\n",
|
||||
pblock->nNonce.GetHex().c_str(), rawHash.GetHex().c_str(), posHash.GetHex().c_str(), value);
|
||||
}
|
||||
}
|
||||
if (validHash)
|
||||
{
|
||||
if (slowflag == 0)
|
||||
{
|
||||
isPOS = true;
|
||||
}
|
||||
else if (!(pastBlockIndex = komodo_chainactive(height - 100)))
|
||||
{
|
||||
fprintf(stderr,"ERROR: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else
|
||||
#ifndef KOMODO_ZCASH
|
||||
if (!GetTransaction(txid, tx, Params().GetConsensus(), blkHash, true))
|
||||
#else
|
||||
if (!GetTransaction(txid, tx, blkHash, true))
|
||||
#endif
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - no source transaction\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CBlockHeader bh = pastBlockIndex->GetBlockHeader();
|
||||
uint256 pastHash = bh.GetVerusEntropyHash(height - 100);
|
||||
|
||||
// if height is over when Nonce is required to be the new format, we check that the new format is correct
|
||||
// if over when we have the new POS hash function, we validate that as well
|
||||
// they are 100 blocks apart
|
||||
CPOSNonce nonce = pblock->nNonce;
|
||||
|
||||
//printf("before nNonce: %s, height: %d\n", pblock->nNonce.GetHex().c_str(), height);
|
||||
//validHash = pblock->GetRawVerusPOSHash(rawHash, height);
|
||||
//hash = UintToArith256(rawHash) / tx.vout[voutNum].nValue;
|
||||
//printf("Raw POShash: %s\n", hash.GetHex().c_str());
|
||||
|
||||
hash = UintToArith256(tx.GetVerusPOSHash(&nonce, voutNum, height, pastHash));
|
||||
|
||||
//printf("after nNonce: %s, height: %d\n", nonce.GetHex().c_str(), height);
|
||||
//printf("POShash: %s\n\n", hash.GetHex().c_str());
|
||||
|
||||
if (posHash == hash && hash <= target)
|
||||
{
|
||||
BlockMap::const_iterator it = mapBlockIndex.find(blkHash);
|
||||
if ((it == mapBlockIndex.end()) ||
|
||||
!(pastBlockIndex = it->second) ||
|
||||
(height - pastBlockIndex->GetHeight()) < VERUS_MIN_STAKEAGE)
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - stake source too new or not found\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure we have the right target
|
||||
CBlockIndex *previndex;
|
||||
it = mapBlockIndex.find(pblock->hashPrevBlock);
|
||||
if (it == mapBlockIndex.end() || !(previndex = it->second))
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - no prev block found\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
arith_uint256 cTarget;
|
||||
uint32_t nBits = lwmaGetNextPOSRequired(previndex, Params().GetConsensus());
|
||||
cTarget.SetCompact(nBits);
|
||||
bool nonceOK = true;
|
||||
|
||||
// check to see how many fail
|
||||
//if (nonce != pblock->nNonce)
|
||||
// printf("Mismatched nNonce: %s\nblkHash: %s, height: %d\n", nonce.GetHex().c_str(), pblock->GetHash().GetHex().c_str(), height);
|
||||
|
||||
if (CPOSNonce::NewNonceActive(height) && !nonce.CheckPOSEntropy(pastHash, txid, voutNum))
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - nonce entropy corrupted or forged\n",blkHash.ToString().c_str());
|
||||
nonceOK = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cTarget != target)
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid diff target\n",blkHash.ToString().c_str());
|
||||
nonceOK = false;
|
||||
}
|
||||
}
|
||||
if ( nonceOK && ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey, voutaddress) &&
|
||||
ExtractDestination(tx.vout[voutNum].scriptPubKey, destaddress) )
|
||||
{
|
||||
strcpy(voutaddr, CBitcoinAddress(voutaddress).ToString().c_str());
|
||||
strcpy(destaddr, CBitcoinAddress(destaddress).ToString().c_str());
|
||||
if ( !strcmp(destaddr,voutaddr) )
|
||||
{
|
||||
isPOS = true;
|
||||
CTransaction &cbtx = pblock->vtx[0];
|
||||
for (int i = 0; i < cbtx.vout.size(); i++)
|
||||
{
|
||||
if (CScriptExt::ExtractVoutDestination(cbtx, i, cbaddress))
|
||||
{
|
||||
strcpy(cbaddr, CBitcoinAddress(cbaddress).ToString().c_str());
|
||||
if (!strcmp(destaddr,cbaddr))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cbtx.vout[i].scriptPubKey.IsOpReturn())
|
||||
continue;
|
||||
isPOS = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid stake or coinbase destination\n",blkHash.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ERROR: malformed nonce value for PoS block\nnNonce: %s\nrawHash: %s\nposHash: %s\nvalue: %lu\n",
|
||||
pblock->nNonce.GetHex().c_str(), rawHash.GetHex().c_str(), posHash.GetHex().c_str(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(isPOS);
|
||||
}
|
||||
|
||||
uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount)
|
||||
{
|
||||
@@ -2290,11 +2084,6 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
// bnTarget = komodo_adaptivepow_target(height,bnTarget,pblock->nTime);
|
||||
if ( ASSETCHAINS_LWMAPOS != 0 && bhash > bnTarget )
|
||||
{
|
||||
// if proof of stake is active, check if this is a valid PoS block before we fail
|
||||
if (verusCheckPOSBlock(slowflag, pblock, height))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if ( (ASSETCHAINS_SYMBOL[0] != 0 || height > 792000) && bhash > bnTarget )
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright © 2019 The Hush developers
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -270,24 +271,23 @@ int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC;
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
|
||||
extern int32_t ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER,ASSETCHAINS_BLOCKTIME;
|
||||
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD;
|
||||
|
||||
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH,KOMODO_INITDONE;
|
||||
|
||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE,ASSETCHAINS_STAKED,KOMODO_NSPV;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_LASTERA,ASSETCHAINS_CBOPRET;
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_NOTARY_PAY[ASSETCHAINS_MAX_ERAS+1], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[],ASSETCHAINS_NK[2];
|
||||
extern const char *ASSETCHAINS_ALGORITHMS[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern uint32_t ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB;
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
|
||||
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
|
||||
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD;
|
||||
extern int32_t KOMODO_BLOCK_POSUNITS, KOMODO_CONSECUTIVE_POS_THRESHOLD, KOMODO_NOPOS_THRESHHOLD;
|
||||
|
||||
extern uint256 KOMODO_EARLYTXID;
|
||||
|
||||
extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
||||
@@ -298,7 +298,6 @@ extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern int32_t KOMODO_EXCHANGEWALLET;
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
extern std::string DONATION_PUBKEY;
|
||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2019 The Hush developers
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -727,7 +728,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
// we don't want these checks in VRSC, leave it at the Sapling upgrade
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 ||
|
||||
((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) ||
|
||||
NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) )
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Copyright 2019 The Hush Developers
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -46,13 +48,17 @@ struct komodo_state KOMODO_STATES[34];
|
||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
|
||||
uint256 KOMODO_EARLYTXID;
|
||||
int32_t KOMODO_BLOCK_POSUNITS = 1024; // one block is 1024 units
|
||||
int32_t KOMODO_MIN_STAKEAGE = 150; // 1/2 this should also be a cap on the POS averaging window, or startup could be too easy
|
||||
int32_t KOMODO_CONSECUTIVE_POS_THRESHOLD = 7;
|
||||
int32_t KOMODO_NOPOS_THRESHHOLD = 150; // if we have no POS blocks in this many blocks, set to default difficulty
|
||||
|
||||
|
||||
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV;
|
||||
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
|
||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
|
||||
int8_t ASSETCHAINS_ADAPTIVEPOW;
|
||||
bool VERUS_MINTBLOCKS;
|
||||
std::vector<uint8_t> Mineropret;
|
||||
std::vector<std::string> vWhiteListAddress;
|
||||
char NOTARYADDRS[64][64];
|
||||
@@ -83,23 +89,14 @@ std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
|
||||
#define _ASSETCHAINS_EQUIHASH 0
|
||||
uint32_t ASSETCHAINS_NUMALGOS = 3;
|
||||
uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH;
|
||||
uint32_t ASSETCHAINS_VERUSHASH = 1;
|
||||
uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2;
|
||||
const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash", "verushash11"};
|
||||
uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff,0xfffffff};
|
||||
uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16,16};
|
||||
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096,4096};
|
||||
const char *ASSETCHAINS_ALGORITHMS[] = {"equihash"};
|
||||
uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff};
|
||||
uint32_t ASSETCHAINS_NONCESHIFT[] = {32};
|
||||
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1};
|
||||
uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH;
|
||||
// min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked.
|
||||
uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375,487526159};
|
||||
// ^ wrong!
|
||||
// Verus proof of stake controls
|
||||
uint32_t ASSETCHAINS_MINDIFF[] = {537857807};
|
||||
int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS
|
||||
int32_t VERUS_BLOCK_POSUNITS = 1024; // one block is 1000 units
|
||||
int32_t VERUS_MIN_STAKEAGE = 150; // 1/2 this should also be a cap on the POS averaging window, or startup could be too easy
|
||||
int32_t VERUS_CONSECUTIVE_POS_THRESHOLD = 7;
|
||||
int32_t VERUS_NOPOS_THRESHHOLD = 150; // if we have no POS blocks in this many blocks, set to default difficulty
|
||||
|
||||
int32_t ASSETCHAINS_SAPLING = -1;
|
||||
int32_t ASSETCHAINS_OVERWINTER = -1;
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#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; };
|
||||
|
||||
@@ -1026,45 +1024,24 @@ 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)
|
||||
{
|
||||
if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800)
|
||||
int i;
|
||||
uint8_t hashSrc[8];
|
||||
uint64_t result=0, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
|
||||
bits256 hashResult;
|
||||
|
||||
for ( i = 0; i < sizeof(hashSrc); i++ )
|
||||
{
|
||||
uint64_t i, result = 0, hashSrc64 = ((uint64_t)ASSETCHAINS_MAGIC << 32) | (uint64_t)nHeight;
|
||||
uint8_t hashSrc[8];
|
||||
bits256 hashResult;
|
||||
|
||||
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;
|
||||
hashSrc[i] = hashSrc64 & 0xff;
|
||||
hashSrc64 >>= 8;
|
||||
int8_t b = hashSrc[i];
|
||||
}
|
||||
else
|
||||
|
||||
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
|
||||
for ( i = 0; i < 8; i++ )
|
||||
{
|
||||
int i;
|
||||
uint8_t hashSrc[8];
|
||||
uint64_t result=0, 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;
|
||||
result = (result << 8) + hashResult.bytes[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// given a block height, this returns the unlock time for that block height, derived from
|
||||
@@ -1078,19 +1055,11 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
|
||||
unlocktime = ASSETCHAINS_TIMEUNLOCKTO;
|
||||
else
|
||||
{
|
||||
if (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nHeight >= 12800)
|
||||
{
|
||||
unlocktime = komodo_block_prg(nHeight) % (ASSETCHAINS_TIMEUNLOCKTO - ASSETCHAINS_TIMEUNLOCKFROM);
|
||||
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--;
|
||||
}
|
||||
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);
|
||||
}
|
||||
@@ -2000,7 +1969,7 @@ void komodo_args(char *argv0)
|
||||
|
||||
// for now, we only support 50% PoS due to other parts of the algorithm needing adjustment for
|
||||
// other values
|
||||
if ( (ASSETCHAINS_LWMAPOS = GetArg("-ac_veruspos",0)) != 0 )
|
||||
if ( (ASSETCHAINS_LWMAPOS = GetArg("-ac_lwmapos",0)) != 0 )
|
||||
{
|
||||
ASSETCHAINS_LWMAPOS = 50;
|
||||
}
|
||||
@@ -2362,8 +2331,6 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
|
||||
ASSETCHAINS_HALVING[0] *= 5;
|
||||
fprintf(stderr,"PIRATE halving changed to %d %.1f days ASSETCHAINS_LASTERA.%llu\n",(int32_t)ASSETCHAINS_HALVING[0],(double)ASSETCHAINS_HALVING[0]/1440,(long long)ASSETCHAINS_LASTERA);
|
||||
}
|
||||
else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 )
|
||||
dpowconfs = 0;
|
||||
else if ( ASSETCHAINS_PRIVATE != 0 )
|
||||
{
|
||||
fprintf(stderr,"-ac_private for a non-PIRATE chain is not supported. The only reason to have an -ac_private chain is for total privacy and that is best achieved with the largest anon set. PIRATE has that and it is recommended to just use PIRATE\n");
|
||||
|
||||
50
src/main.cpp
50
src/main.cpp
@@ -1110,42 +1110,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
*/
|
||||
bool ContextualCheckCoinbaseTransaction(int32_t slowflag,const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight,int32_t validateprices)
|
||||
{
|
||||
// if time locks are on, ensure that this coin base is time locked exactly as it should be
|
||||
if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) ||
|
||||
(((nHeight >= 31680) || strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0) && komodo_ac_block_subsidy(nHeight) >= ASSETCHAINS_TIMELOCKGTE))
|
||||
{
|
||||
CScriptID scriptHash;
|
||||
|
||||
// to be valid, it must be a P2SH transaction and have an op_return in vout[1] that
|
||||
// holds the full output script, which may include multisig, etc., but starts with
|
||||
// the time lock verify of the correct time lock for this block height
|
||||
if (tx.vout.size() == 2 &&
|
||||
CScriptExt(tx.vout[0].scriptPubKey).IsPayToScriptHash(&scriptHash) &&
|
||||
tx.vout[1].scriptPubKey.size() >= 7 && // minimum for any possible future to prevent out of bounds
|
||||
tx.vout[1].scriptPubKey[0] == OP_RETURN)
|
||||
{
|
||||
opcodetype op;
|
||||
std::vector<uint8_t> opretData = std::vector<uint8_t>();
|
||||
CScript::const_iterator it = tx.vout[1].scriptPubKey.begin() + 1;
|
||||
if (tx.vout[1].scriptPubKey.GetOp2(it, op, &opretData))
|
||||
{
|
||||
if (opretData.size() > 0 && opretData.data()[0] == OPRETTYPE_TIMELOCK)
|
||||
{
|
||||
int64_t unlocktime;
|
||||
CScriptExt opretScript = CScriptExt(&opretData[1], &opretData[opretData.size()]);
|
||||
|
||||
if (CScriptID(opretScript) == scriptHash &&
|
||||
opretScript.IsCheckLockTimeVerify(&unlocktime) &&
|
||||
komodo_block_unlocktime(nHeight) == unlocktime)
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
else if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 )
|
||||
if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -2842,16 +2807,6 @@ namespace Consensus {
|
||||
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
|
||||
}
|
||||
|
||||
// Ensure that coinbases cannot be spent to transparent outputs
|
||||
// Disabled on regtest
|
||||
if (fCoinbaseEnforcedProtectionEnabled &&
|
||||
consensusParams.fCoinbaseMustBeProtected &&
|
||||
!(tx.vout.size() == 0 || (tx.vout.size() == 1 && tx.vout[0].nValue == 0)) &&
|
||||
(strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || (nSpendHeight >= 12800 && coins->nHeight >= 12800))) {
|
||||
return state.DoS(100,
|
||||
error("CheckInputs(): tried to spend coinbase with transparent outputs"),
|
||||
REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for negative or overflow input values
|
||||
@@ -4172,7 +4127,6 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
for (int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
CTransaction &tx = block.vtx[i];
|
||||
//if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))))
|
||||
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0)))
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -5234,7 +5188,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
||||
//LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str());
|
||||
// take advantage of other checks, but if we were only rejected because it is a valid staking
|
||||
// transaction, sync with wallets and don't mark as a reject
|
||||
if (i == (block.vtx.size() - 1) && ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock() && state.GetRejectReason() == "staking")
|
||||
if (i == (block.vtx.size() - 1) && ASSETCHAINS_LWMAPOS && state.GetRejectReason() == "staking")
|
||||
{
|
||||
sTx = Tx;
|
||||
ptx = &sTx;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "script/script.h"
|
||||
#include "script/serverchecker.h"
|
||||
#include "script/standard.h"
|
||||
#include "script/script_ext.h"
|
||||
#include "spentindex.h"
|
||||
#include "sync.h"
|
||||
#include "tinyformat.h"
|
||||
|
||||
@@ -137,12 +137,7 @@ int64_t GetUptime()
|
||||
|
||||
double GetLocalSolPS()
|
||||
{
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH || ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1)
|
||||
{
|
||||
return miningTimer.rate(nHashCount);
|
||||
}
|
||||
else
|
||||
return miningTimer.rate(solutionTargetChecks);
|
||||
return miningTimer.rate(solutionTargetChecks);
|
||||
}
|
||||
|
||||
int EstimateNetHeightInner(int height, int64_t tipmediantime,
|
||||
|
||||
545
src/miner.cpp
545
src/miner.cpp
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -32,7 +33,6 @@
|
||||
#include "consensus/validation.h"
|
||||
#ifdef ENABLE_MINING
|
||||
#include "crypto/equihash.h"
|
||||
#include "crypto/verus_hash.h"
|
||||
#endif
|
||||
#include "hash.h"
|
||||
#include "key_io.h"
|
||||
@@ -149,7 +149,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
|
||||
int64_t komodo_block_unlocktime(uint32_t nHeight);
|
||||
uint64_t komodo_commission(const CBlock *block,int32_t height);
|
||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
||||
int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk);
|
||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||
int32_t komodo_is_notarytx(const CTransaction& tx);
|
||||
@@ -588,22 +587,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
if (ASSETCHAINS_LWMAPOS != 0)
|
||||
{
|
||||
uint32_t nBitsPOS;
|
||||
arith_uint256 posHash;
|
||||
|
||||
siglen = verus_staked(pblock, txStaked, nBitsPOS, posHash, utxosig, pk);
|
||||
blocktime = GetAdjustedTime();
|
||||
|
||||
// change the scriptPubKeyIn to the same output script exactly as the staking transaction
|
||||
if (siglen > 0)
|
||||
scriptPubKeyIn = CScript(txStaked.vout[0].scriptPubKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
blocktime = GetAdjustedTime();
|
||||
siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig);
|
||||
// if you skip this check it will create a block too far into the future and not pass ProcessBlock or AcceptBlock.
|
||||
// This has been moved from the mining loop to save CPU, and to also make ac_staked work with the verus miner.
|
||||
// This has been moved from the mining loop to save CPU, and to also make ac_staked work
|
||||
while ( blocktime-57 > GetAdjustedTime() )
|
||||
{
|
||||
sleep(1);
|
||||
@@ -701,31 +691,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
}
|
||||
else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE)
|
||||
{
|
||||
int32_t opretlen, p2shlen, scriptlen;
|
||||
CScriptExt opretScript = CScriptExt();
|
||||
|
||||
txNew.vout.resize(2);
|
||||
|
||||
// prepend time lock to original script unless original script is P2SH, in which case, we will leave the coins
|
||||
// protected only by the time lock rather than 100% inaccessible
|
||||
opretScript.AddCheckLockTimeVerify(komodo_block_unlocktime(nHeight));
|
||||
if (scriptPubKeyIn.IsPayToScriptHash() || scriptPubKeyIn.IsPayToCryptoCondition())
|
||||
{
|
||||
fprintf(stderr,"CreateNewBlock: attempt to add timelock to pay2sh or pay2cc\n");
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
opretScript += scriptPubKeyIn;
|
||||
|
||||
txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript));
|
||||
txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK);
|
||||
txNew.vout[1].nValue = 0;
|
||||
// timelocks and commissions are currently incompatible due to validation complexity of the combination
|
||||
fprintf(stderr,"timelocked chains not supported in this code!\n");
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
return(0);
|
||||
}
|
||||
else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 )
|
||||
{
|
||||
@@ -759,7 +728,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
pblock->vtx[0] = txNew;
|
||||
pblocktemplate->vTxFees[0] = -nFees;
|
||||
|
||||
// if not Verus stake, setup nonce, otherwise, leave it alone
|
||||
// if not staking, setup nonce, otherwise, leave it alone
|
||||
if (!isStake || ASSETCHAINS_LWMAPOS == 0)
|
||||
{
|
||||
// Randomise nonce
|
||||
@@ -775,7 +744,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
pblock->hashFinalSaplingRoot = sapling_tree.root();
|
||||
|
||||
// all Verus PoS chains need this data in the block at all times
|
||||
// all PoS chains need this data in the block at all times
|
||||
if ( ASSETCHAINS_LWMAPOS || ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || KOMODO_MININGTHREADS > 0 )
|
||||
{
|
||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
@@ -1135,477 +1104,8 @@ CBlockIndex *get_chainactive(int32_t height)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* A separate thread to stake, while the miner threads mine.
|
||||
*/
|
||||
void static VerusStaker(CWallet *pwallet)
|
||||
{
|
||||
LogPrintf("Verus staker thread started\n");
|
||||
RenameThread("verus-staker");
|
||||
|
||||
const CChainParams& chainparams = Params();
|
||||
auto consensusParams = chainparams.GetConsensus();
|
||||
|
||||
// Each thread has its own key
|
||||
CReserveKey reservekey(pwallet);
|
||||
|
||||
// Each thread has its own counter
|
||||
unsigned int nExtraNonce = 0;
|
||||
std::vector<unsigned char> solnPlaceholder = std::vector<unsigned char>();
|
||||
solnPlaceholder.resize(Eh200_9.SolutionWidth);
|
||||
uint8_t *script; uint64_t total,checktoshis; int32_t i,j;
|
||||
|
||||
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->GetHeight() != 235300 &&
|
||||
{
|
||||
sleep(1);
|
||||
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
CBlockIndex *pindexPrev, *pindexCur;
|
||||
do {
|
||||
pindexPrev = chainActive.LastTip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
waitForPeers(chainparams);
|
||||
pindexCur = chainActive.LastTip();
|
||||
} while (pindexPrev != pindexCur);
|
||||
|
||||
try {
|
||||
while (true)
|
||||
{
|
||||
waitForPeers(chainparams);
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||
printf("Staking height %d for %s\n", pindexPrev->GetHeight() + 1, ASSETCHAINS_SYMBOL);
|
||||
|
||||
// Create new block
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->GetHeight()+1;
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
}
|
||||
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
// try to stake a block
|
||||
CBlockTemplate *ptr = NULL;
|
||||
if (Mining_height > VERUS_MIN_STAKEAGE)
|
||||
ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0, true);
|
||||
|
||||
if ( ptr == 0 )
|
||||
{
|
||||
// wait to try another staking block until after the tip moves again
|
||||
while ( chainActive.LastTip() == pindexPrev )
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||
if (!pblocktemplate.get())
|
||||
{
|
||||
if (GetArg("-mineraddress", "").empty()) {
|
||||
LogPrintf("Error in %s staker: Keypool ran out, please call keypoolrefill before restarting the mining thread\n",
|
||||
ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
} else {
|
||||
// Should never reach here, because -mineraddress validity is checked in init.cpp
|
||||
LogPrintf("Error in %s staker: Invalid %s -mineraddress\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO], ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
LogPrintf("Staking with %u transactions in block (%u bytes)\n", pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
//
|
||||
// Search
|
||||
//
|
||||
int64_t nStart = GetTime();
|
||||
|
||||
// take up the necessary space for alignment
|
||||
pblock->nSolution = solnPlaceholder;
|
||||
|
||||
// we don't use this, but IncrementExtraNonce is the function that builds the merkle tree
|
||||
unsigned int nExtraNonce = 0;
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
fprintf(stderr,"no nodes, attempting reconnect\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
{
|
||||
fprintf(stderr,"timeout, retrying\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
printf("Block %d added to chain\n", chainActive.LastTip()->GetHeight());
|
||||
MilliSleep(250);
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t unlockTime = komodo_block_unlocktime(Mining_height);
|
||||
int64_t subsidy = (int64_t)(pblock->vtx[0].vout[0].nValue);
|
||||
|
||||
uint256 hashTarget = ArithToUint256(arith_uint256().SetCompact(pblock->nBits));
|
||||
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
|
||||
|
||||
UpdateTime(pblock, consensusParams, pindexPrev);
|
||||
|
||||
ProcessBlockFound(pblock, *pwallet, reservekey);
|
||||
|
||||
LogPrintf("Using %s algorithm:\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
LogPrintf("Staked block found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex());
|
||||
printf("Found block %d \n", Mining_height );
|
||||
printf("staking reward %.8f %s!\n", (double)subsidy / (double)COIN, ASSETCHAINS_SYMBOL);
|
||||
arith_uint256 post;
|
||||
post.SetCompact(pblock->GetVerusPOSTarget());
|
||||
pindexPrev = get_chainactive(Mining_height - 100);
|
||||
CTransaction &sTx = pblock->vtx[pblock->vtx.size()-1];
|
||||
printf("POS hash: %s \ntarget: %s\n",
|
||||
CTransaction::_GetVerusPOSHash(&(pblock->nNonce), sTx.vin[0].prevout.hash, sTx.vin[0].prevout.n, Mining_height, pindexPrev->GetBlockHeader().GetVerusEntropyHash(Mining_height - 100), sTx.vout[0].nValue).GetHex().c_str(), ArithToUint256(post).GetHex().c_str());
|
||||
if (unlockTime > Mining_height && subsidy >= ASSETCHAINS_TIMELOCKGTE)
|
||||
printf("- timelocked until block %i\n", unlockTime);
|
||||
else
|
||||
printf("\n");
|
||||
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
sleep(3);
|
||||
|
||||
// In regression test mode, stop mining after a block is found.
|
||||
if (chainparams.MineBlocksOnDemand()) {
|
||||
throw boost::thread_interrupted();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const boost::thread_interrupted&)
|
||||
{
|
||||
LogPrintf("VerusStaker terminated\n");
|
||||
throw;
|
||||
}
|
||||
catch (const std::runtime_error &e)
|
||||
{
|
||||
LogPrintf("VerusStaker runtime error: %s\n", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void static BitcoinMiner_noeq(CWallet *pwallet)
|
||||
#else
|
||||
void static BitcoinMiner_noeq()
|
||||
#endif
|
||||
{
|
||||
LogPrintf("%s miner started\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
RenameThread("verushash-miner");
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
// Each thread has its own key
|
||||
CReserveKey reservekey(pwallet);
|
||||
#endif
|
||||
|
||||
const CChainParams& chainparams = Params();
|
||||
// Each thread has its own counter
|
||||
unsigned int nExtraNonce = 0;
|
||||
std::vector<unsigned char> solnPlaceholder = std::vector<unsigned char>();
|
||||
solnPlaceholder.resize(Eh200_9.SolutionWidth);
|
||||
uint8_t *script; uint64_t total,checktoshis; int32_t i,j;
|
||||
|
||||
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->GetHeight() != 235300 &&
|
||||
{
|
||||
sleep(1);
|
||||
if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
CBlockIndex *pindexPrev, *pindexCur;
|
||||
do {
|
||||
pindexPrev = chainActive.LastTip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
waitForPeers(chainparams);
|
||||
pindexCur = chainActive.LastTip();
|
||||
} while (pindexPrev != pindexCur);
|
||||
|
||||
// this will not stop printing more than once in all cases, but it will allow us to print in all cases
|
||||
// and print duplicates rarely without having to synchronize
|
||||
static CBlockIndex *lastChainTipPrinted;
|
||||
|
||||
miningTimer.start();
|
||||
|
||||
try {
|
||||
printf("Mining %s with %s\n", ASSETCHAINS_SYMBOL, ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
while (true)
|
||||
{
|
||||
miningTimer.stop();
|
||||
waitForPeers(chainparams);
|
||||
|
||||
pindexPrev = chainActive.LastTip();
|
||||
sleep(1);
|
||||
|
||||
// prevent forking on startup before the diff algorithm kicks in
|
||||
if (pindexPrev->GetHeight() < 50 || pindexPrev != chainActive.LastTip())
|
||||
{
|
||||
do {
|
||||
pindexPrev = chainActive.LastTip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (pindexPrev != chainActive.LastTip());
|
||||
}
|
||||
|
||||
// Create new block
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
if ( Mining_height != pindexPrev->GetHeight()+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->GetHeight()+1;
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
}
|
||||
|
||||
if (lastChainTipPrinted != pindexPrev)
|
||||
{
|
||||
printf("Mining height %d\n", Mining_height);
|
||||
lastChainTipPrinted = pindexPrev;
|
||||
}
|
||||
|
||||
miningTimer.start();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, Mining_height, 0, ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0);
|
||||
#else
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
||||
#endif
|
||||
if ( ptr == 0 )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( ASSETCHAINS_STAKED == 0 && counter++ < 10 )
|
||||
fprintf(stderr,"created illegal block, retry\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||
if (!pblocktemplate.get())
|
||||
{
|
||||
if (GetArg("-mineraddress", "").empty()) {
|
||||
LogPrintf("Error in %s miner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n",
|
||||
ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
} else {
|
||||
// Should never reach here, because -mineraddress validity is checked in init.cpp
|
||||
LogPrintf("Error in %s miner: Invalid %s -mineraddress\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO], ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
{
|
||||
if ( ASSETCHAINS_REWARD[0] == 0 && !ASSETCHAINS_LASTERA )
|
||||
{
|
||||
if ( pblock->vtx.size() == 1 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 10 )
|
||||
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL);
|
||||
sleep(10);
|
||||
continue;
|
||||
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
|
||||
}
|
||||
}
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
LogPrintf("Running %s miner with %u transactions in block (%u bytes)\n",ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO],
|
||||
pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
//
|
||||
// Search
|
||||
//
|
||||
uint32_t savebits; int64_t nStart = GetTime();
|
||||
|
||||
pblock->nSolution = solnPlaceholder;
|
||||
savebits = pblock->nBits;
|
||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
HASHTarget = arith_uint256().SetCompact(savebits);
|
||||
arith_uint256 mask(ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]);
|
||||
|
||||
Mining_start = 0;
|
||||
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
if (lastChainTipPrinted != chainActive.LastTip())
|
||||
{
|
||||
lastChainTipPrinted = chainActive.LastTip();
|
||||
printf("Block %d added to chain\n", lastChainTipPrinted->GetHeight());
|
||||
}
|
||||
MilliSleep(250);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
{
|
||||
int32_t percPoS,z; bool fNegative,fOverflow;
|
||||
HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED);
|
||||
HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED);
|
||||
}
|
||||
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
|
||||
// HASHTarget_POW = komodo_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
|
||||
|
||||
while (true)
|
||||
{
|
||||
arith_uint256 arNonce = UintToArith256(pblock->nNonce);
|
||||
int64_t *extraPtr;
|
||||
|
||||
// This seems to be a really bad way to do this, but its better than copy pasting the entire miner function at this stage.
|
||||
CVerusHashWriter ss = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
ss << *((CBlockHeader *)pblock);
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH )
|
||||
extraPtr = ss.xI64p();
|
||||
CVerusHash &vh = ss.GetState();
|
||||
uint256 hashResult = uint256();
|
||||
vh.ClearExtra();
|
||||
|
||||
CVerusHashV2Writer ss2 = CVerusHashV2Writer(SER_GETHASH, PROTOCOL_VERSION);
|
||||
ss2 << *((CBlockHeader *)pblock);
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 )
|
||||
extraPtr = ss2.xI64p();
|
||||
CVerusHashV2 &vh2 = ss2.GetState();
|
||||
vh2.ClearExtra();
|
||||
|
||||
int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1;
|
||||
int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO];
|
||||
if ( ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 )
|
||||
{
|
||||
if ( KOMODO_MININGTHREADS > 0 )
|
||||
hashTarget = HASHTarget_POW;
|
||||
else
|
||||
hashTarget = HASHTarget;
|
||||
}
|
||||
else if ( ASSETCHAINS_STAKED == 100 && Mining_height > 100 )
|
||||
hashTarget = HASHTarget;
|
||||
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
|
||||
// hashTarget = HASHTarget_POW;
|
||||
|
||||
// for speed check NONCEMASK at a time
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
*extraPtr = i;
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH )
|
||||
vh.ExtraHash((unsigned char *)&hashResult);
|
||||
else if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1 )
|
||||
vh2.ExtraHash((unsigned char *)&hashResult);
|
||||
|
||||
if ( UintToArith256(hashResult) <= hashTarget )
|
||||
{
|
||||
if (pblock->nSolution.size() != 1344)
|
||||
{
|
||||
LogPrintf("ERROR: Block solution is not 1344 bytes as it should be");
|
||||
sleep(5);
|
||||
break;
|
||||
}
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
|
||||
*((int64_t *)&(pblock->nSolution.data()[pblock->nSolution.size() - 15])) = i;
|
||||
|
||||
int32_t unlockTime = komodo_block_unlocktime(Mining_height);
|
||||
int64_t subsidy = (int64_t)(pblock->vtx[0].vout[0].nValue);
|
||||
|
||||
LogPrintf("Using %s algorithm:\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex());
|
||||
printf("Found block %d \n", Mining_height );
|
||||
printf("mining reward %.8f %s!\n", (double)subsidy / (double)COIN, ASSETCHAINS_SYMBOL);
|
||||
printf(" hash: %s \ntarget: %s\n", pblock->GetHash().GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
if (unlockTime > Mining_height && subsidy >= ASSETCHAINS_TIMELOCKGTE)
|
||||
printf("- timelocked until block %i\n", unlockTime);
|
||||
else
|
||||
printf("\n");
|
||||
#ifdef ENABLE_WALLET
|
||||
ProcessBlockFound(pblock, *pwallet, reservekey);
|
||||
#else
|
||||
ProcessBlockFound(pblock));
|
||||
#endif
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
break;
|
||||
}
|
||||
// check periodically if we're stale
|
||||
if (!--hashesToGo)
|
||||
{
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
if (lastChainTipPrinted != chainActive.LastTip())
|
||||
{
|
||||
lastChainTipPrinted = chainActive.LastTip();
|
||||
printf("Block %d added to chain\n", lastChainTipPrinted->GetHeight());
|
||||
}
|
||||
break;
|
||||
}
|
||||
hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(cs_metrics);
|
||||
nHashCount += i;
|
||||
}
|
||||
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
boost::this_thread::interruption_point();
|
||||
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
fprintf(stderr,"no nodes, attempting reconnect\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
{
|
||||
fprintf(stderr,"timeout, retrying\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
if (lastChainTipPrinted != chainActive.LastTip())
|
||||
{
|
||||
lastChainTipPrinted = chainActive.LastTip();
|
||||
printf("Block %d added to chain\n", lastChainTipPrinted->GetHeight());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
printf("%llu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576);
|
||||
#else
|
||||
printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576);
|
||||
#endif
|
||||
pblock->nBits = savebits;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const boost::thread_interrupted&)
|
||||
{
|
||||
miningTimer.stop();
|
||||
LogPrintf("%s miner terminated\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
throw;
|
||||
}
|
||||
catch (const std::runtime_error &e)
|
||||
{
|
||||
miningTimer.stop();
|
||||
LogPrintf("%s miner runtime error: %s\n", ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO], e.what());
|
||||
return;
|
||||
}
|
||||
miningTimer.stop();
|
||||
}
|
||||
|
||||
int32_t gotinvalid;
|
||||
|
||||
@@ -1617,7 +1117,7 @@ void static BitcoinMiner()
|
||||
{
|
||||
LogPrintf("HushMiner started\n");
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
RenameThread("komodo-miner");
|
||||
RenameThread("hush-miner");
|
||||
const CChainParams& chainparams = Params();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -2104,39 +1604,24 @@ void static BitcoinMiner()
|
||||
minerThreads = NULL;
|
||||
}
|
||||
|
||||
//fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate);
|
||||
if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 && fGenerate )
|
||||
{
|
||||
if ( pwallet != NULL )
|
||||
nThreads = 1;
|
||||
else
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,"%s: nThreads.%d fGenerate.%d\n",__FUNCTION__, (int32_t)nThreads,fGenerate);
|
||||
|
||||
if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL))
|
||||
if (nThreads == 0)
|
||||
return;
|
||||
if (!fGenerate)
|
||||
return;
|
||||
if (pwallet == NULL)
|
||||
return;
|
||||
|
||||
minerThreads = new boost::thread_group();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if (ASSETCHAINS_LWMAPOS != 0 && VERUS_MINTBLOCKS)
|
||||
{
|
||||
minerThreads->create_thread(boost::bind(&VerusStaker, pwallet));
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < nThreads; i++) {
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH )
|
||||
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
|
||||
else
|
||||
minerThreads->create_thread(boost::bind(&BitcoinMiner_noeq, pwallet));
|
||||
#else
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH )
|
||||
minerThreads->create_thread(&BitcoinMiner);
|
||||
else
|
||||
minerThreads->create_thread(&BitcoinMiner_noeq);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
32
src/pow.cpp
32
src/pow.cpp
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -643,18 +644,13 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
||||
// if we have had no POS block in the threshold number of blocks, we must return the default, otherwise, we'll now have
|
||||
// a starting point
|
||||
uint32_t nBits = nProofOfStakeLimit;
|
||||
for (int64_t i = 0; i < VERUS_NOPOS_THRESHHOLD; i++)
|
||||
for (int64_t i = 0; i < KOMODO_NOPOS_THRESHHOLD; i++)
|
||||
{
|
||||
if (!pindexFirst)
|
||||
return nProofOfStakeLimit;
|
||||
|
||||
CBlockHeader hdr = pindexFirst->GetBlockHeader();
|
||||
|
||||
if (hdr.IsVerusPOSBlock())
|
||||
{
|
||||
nBits = hdr.GetVerusPOSTarget();
|
||||
break;
|
||||
}
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
}
|
||||
|
||||
@@ -664,10 +660,10 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
||||
|
||||
for (int64_t i = N - 1; i >= 0; i--)
|
||||
{
|
||||
// we measure our solve time in passing of blocks, where one bock == VERUS_BLOCK_POSUNITS units
|
||||
// we measure our solve time in passing of blocks, where one bock == KOMODO_BLOCK_POSUNITS units
|
||||
// consecutive blocks in either direction have their solve times exponentially multiplied or divided by power of 2
|
||||
int x;
|
||||
for (x = 0; x < VERUS_CONSECUTIVE_POS_THRESHOLD; x++)
|
||||
for (x = 0; x < KOMODO_CONSECUTIVE_POS_THRESHOLD; x++)
|
||||
{
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
|
||||
@@ -675,27 +671,17 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
||||
return nProofOfStakeLimit;
|
||||
|
||||
CBlockHeader hdr = pindexFirst->GetBlockHeader();
|
||||
if (hdr.IsVerusPOSBlock())
|
||||
{
|
||||
nBits = hdr.GetVerusPOSTarget();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x)
|
||||
{
|
||||
idx[i].consecutive = false;
|
||||
if (!memcmp(ASSETCHAINS_SYMBOL, "VRSC", 4) && pindexLast->GetHeight() < 67680)
|
||||
{
|
||||
idx[i].solveTime = VERUS_BLOCK_POSUNITS * (x + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t lastSolveTime = 0;
|
||||
idx[i].solveTime = VERUS_BLOCK_POSUNITS;
|
||||
idx[i].solveTime = KOMODO_BLOCK_POSUNITS;
|
||||
for (int64_t j = 0; j < x; j++)
|
||||
{
|
||||
lastSolveTime = VERUS_BLOCK_POSUNITS + (lastSolveTime >> 1);
|
||||
lastSolveTime = KOMODO_BLOCK_POSUNITS + (lastSolveTime >> 1);
|
||||
idx[i].solveTime += lastSolveTime;
|
||||
}
|
||||
}
|
||||
@@ -707,13 +693,13 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
||||
idx[i].nBits = nBits;
|
||||
// go forward and halve the minimum solve time for all consecutive blocks in this run, to get here, our last block is POS,
|
||||
// and if there is no POS block in front of it, it gets the normal solve time of one block
|
||||
uint32_t st = VERUS_BLOCK_POSUNITS;
|
||||
uint32_t st = KOMODO_BLOCK_POSUNITS;
|
||||
for (int64_t j = i; j < N; j++)
|
||||
{
|
||||
if (idx[j].consecutive == true)
|
||||
{
|
||||
idx[j].solveTime = st;
|
||||
if ((j - i) >= VERUS_CONSECUTIVE_POS_THRESHOLD)
|
||||
if ((j - i) >= KOMODO_CONSECUTIVE_POS_THRESHOLD)
|
||||
{
|
||||
// if this is real time, return zero
|
||||
if (j == (N - 1))
|
||||
@@ -870,7 +856,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 && ASSETCHAINS_STAKED == 0 )
|
||||
// bnTarget = komodo_adaptivepow_target(height,bnTarget,blkHeader.nTime);
|
||||
// Check proof of work matches claimed amount
|
||||
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )
|
||||
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget )
|
||||
{
|
||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
||||
return true;
|
||||
|
||||
@@ -35,96 +35,12 @@ uint256 CBlockHeader::GetSHA256DHash() const
|
||||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusHash() const
|
||||
{
|
||||
if (hashPrevBlock.IsNull())
|
||||
// always use SHA256D for genesis block
|
||||
return SerializeHash(*this);
|
||||
else
|
||||
return SerializeVerusHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusV2Hash() const
|
||||
{
|
||||
if (hashPrevBlock.IsNull())
|
||||
// always use SHA256D for genesis block
|
||||
return SerializeHash(*this);
|
||||
else
|
||||
return SerializeVerusHashV2(*this);
|
||||
}
|
||||
|
||||
void CBlockHeader::SetSHA256DHash()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetSHA256DHash;
|
||||
}
|
||||
|
||||
void CBlockHeader::SetVerusHash()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash;
|
||||
}
|
||||
|
||||
void CBlockHeader::SetVerusHashV2()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusV2Hash;
|
||||
}
|
||||
|
||||
// returns false if unable to fast calculate the VerusPOSHash from the header.
|
||||
// if it returns false, value is set to 0, but it can still be calculated from the full block
|
||||
// in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out
|
||||
// this is used as a source of entropy
|
||||
bool CBlockHeader::GetRawVerusPOSHash(uint256 &ret, int32_t nHeight) const
|
||||
{
|
||||
// if below the required height or no storage space in the solution, we can't get
|
||||
// a cached txid value to calculate the POSHash from the header
|
||||
if (!(CPOSNonce::NewNonceActive(nHeight) && IsVerusPOSBlock()))
|
||||
{
|
||||
ret = uint256();
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we can calculate, this assumes the protocol that the POSHash calculation is:
|
||||
// hashWriter << ASSETCHAINS_MAGIC;
|
||||
// hashWriter << nNonce; (nNonce is:
|
||||
// (high 128 bits == low 128 bits of verus hash of low 128 bits of nonce)
|
||||
// (low 32 bits == compact PoS difficult)
|
||||
// (mid 96 bits == low 96 bits of HASH(pastHash, txid, voutnum)
|
||||
// pastHash is hash of height - 100, either PoW hash of block or PoS hash, if new PoS
|
||||
// )
|
||||
// hashWriter << height;
|
||||
// return hashWriter.GetHash();
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
hashWriter << ASSETCHAINS_MAGIC;
|
||||
hashWriter << nNonce;
|
||||
hashWriter << nHeight;
|
||||
ret = hashWriter.GetHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBlockHeader::GetVerusPOSHash(arith_uint256 &ret, int32_t nHeight, CAmount value) const
|
||||
{
|
||||
uint256 raw;
|
||||
if (GetRawVerusPOSHash(raw, nHeight))
|
||||
{
|
||||
ret = UintToArith256(raw) / value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// depending on the height of the block and its type, this returns the POS hash or the POW hash
|
||||
uint256 CBlockHeader::GetVerusEntropyHash(int32_t height) const
|
||||
{
|
||||
uint256 retVal;
|
||||
// if we qualify as PoW, use PoW hash, regardless of PoS state
|
||||
if (GetRawVerusPOSHash(retVal, height))
|
||||
{
|
||||
// POS hash
|
||||
return retVal;
|
||||
}
|
||||
return GetHash();
|
||||
}
|
||||
|
||||
uint256 BuildMerkleTree(bool* fMutated, const std::vector<uint256> leaves,
|
||||
std::vector<uint256> &vMerkleTree)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -51,7 +52,9 @@ public:
|
||||
uint256 hashFinalSaplingRoot;
|
||||
uint32_t nTime;
|
||||
uint32_t nBits;
|
||||
CPOSNonce nNonce;
|
||||
//CPOSNonce nNonce;
|
||||
uint256 nNonce;
|
||||
|
||||
std::vector<unsigned char> nSolution;
|
||||
|
||||
CBlockHeader()
|
||||
@@ -98,57 +101,14 @@ public:
|
||||
uint256 GetSHA256DHash() const;
|
||||
static void SetSHA256DHash();
|
||||
|
||||
uint256 GetVerusHash() const;
|
||||
static void SetVerusHash();
|
||||
|
||||
bool GetRawVerusPOSHash(uint256 &ret, int32_t nHeight) const;
|
||||
bool GetVerusPOSHash(arith_uint256 &ret, int32_t nHeight, CAmount value) const; // value is amount of stake tx
|
||||
uint256 GetVerusEntropyHash(int32_t nHeight) const;
|
||||
|
||||
uint256 GetVerusV2Hash() const;
|
||||
static void SetVerusHashV2();
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
return (int64_t)nTime;
|
||||
}
|
||||
|
||||
uint32_t GetVerusPOSTarget() const
|
||||
{
|
||||
uint32_t nBits = 0;
|
||||
|
||||
for (const unsigned char *p = nNonce.begin() + 3; p >= nNonce.begin(); p--)
|
||||
{
|
||||
nBits <<= 8;
|
||||
nBits += *p;
|
||||
}
|
||||
return nBits;
|
||||
}
|
||||
|
||||
bool IsVerusPOSBlock() const
|
||||
{
|
||||
if ( ASSETCHAINS_LWMAPOS != 0 )
|
||||
return nNonce.IsPOSNonce();
|
||||
else return(0);
|
||||
}
|
||||
|
||||
void SetVerusPOSTarget(uint32_t nBits)
|
||||
{
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
arith_uint256 arNonce = UintToArith256(nNonce);
|
||||
|
||||
// printf("before svpt: %s\n", ArithToUint256(arNonce).GetHex().c_str());
|
||||
|
||||
arNonce = (arNonce & CPOSNonce::entropyMask) | nBits;
|
||||
|
||||
// printf("after clear: %s\n", ArithToUint256(arNonce).GetHex().c_str());
|
||||
|
||||
hashWriter << ArithToUint256(arNonce);
|
||||
nNonce = CPOSNonce(ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | arNonce));
|
||||
|
||||
// printf(" after svpt: %s\n", nNonce.GetHex().c_str());
|
||||
}
|
||||
};
|
||||
|
||||
// this class is used to address the type mismatch that existed between nodes, where block headers
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright (c) 2019 The Hush Developers
|
||||
// Copyright (c) 2018 Michael Toutonghi
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
@@ -21,66 +22,3 @@
|
||||
#include "nonce.h"
|
||||
#include <cstring>
|
||||
|
||||
extern char ASSETCHAINS_SYMBOL[65];
|
||||
|
||||
arith_uint256 CPOSNonce::entropyMask = UintToArith256(uint256S("00000000000000000000000000000000ffffffffffffffffffffffff00000000"));
|
||||
arith_uint256 CPOSNonce::posDiffMask = UintToArith256(uint256S("00000000000000000000000000000000000000000000000000000000ffffffff"));
|
||||
|
||||
bool CPOSNonce::NewPOSActive(int32_t height)
|
||||
{
|
||||
if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < (96480 + 100)))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPOSNonce::NewNonceActive(int32_t height)
|
||||
{
|
||||
if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < 96480))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPOSNonce::SetPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t voutNum)
|
||||
{
|
||||
// get low 96 bits of past hash and put it in top 96 bits of low 128 bits of nonce
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
// first hash the pastHash, txid, and voutNum, to create a combined 96 bits, which will be used in the nonce
|
||||
hashWriter << pastHash;
|
||||
hashWriter << txid;
|
||||
hashWriter << voutNum;
|
||||
|
||||
arith_uint256 arNonce = (UintToArith256(*this) & posDiffMask) |
|
||||
(UintToArith256(hashWriter.GetHash()) & entropyMask);
|
||||
|
||||
// printf("before %s\n", ArithToUint256(arNonce).GetHex().c_str());
|
||||
|
||||
hashWriter.Reset();
|
||||
hashWriter << ArithToUint256(arNonce);
|
||||
|
||||
*this = CPOSNonce(ArithToUint256((UintToArith256(hashWriter.GetHash()) << 128) | arNonce));
|
||||
|
||||
// printf("after %s\n", this->GetHex().c_str());
|
||||
}
|
||||
|
||||
bool CPOSNonce::CheckPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t voutNum)
|
||||
{
|
||||
// get low 96 bits of past hash and put it in top 96 bits of low 128 bits of nonce
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
// first hash the pastHash, txid, and voutNum, to create a combined 96 bits, which will be used in the nonce
|
||||
hashWriter << pastHash;
|
||||
hashWriter << txid;
|
||||
hashWriter << voutNum;
|
||||
|
||||
arith_uint256 arNonce = (UintToArith256(*this) & posDiffMask) |
|
||||
(UintToArith256(hashWriter.GetHash()) & entropyMask);
|
||||
|
||||
hashWriter.Reset();
|
||||
hashWriter << ArithToUint256(arNonce);
|
||||
|
||||
return UintToArith256(*this) == (UintToArith256(hashWriter.GetHash()) << 128 | arNonce);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright (c) 2019 Hush Developers
|
||||
// Copyright (c) 2018 Michael Toutonghi
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
@@ -25,55 +26,4 @@
|
||||
#include "arith_uint256.h"
|
||||
|
||||
|
||||
/** For POS blocks, the nNonce of a block header holds the entropy source for the POS contest
|
||||
* in the latest VerusHash protocol
|
||||
* */
|
||||
class CPOSNonce : public uint256
|
||||
{
|
||||
public:
|
||||
static bool NewPOSActive(int32_t height);
|
||||
static bool NewNonceActive(int32_t height);
|
||||
|
||||
static arith_uint256 entropyMask;
|
||||
static arith_uint256 posDiffMask;
|
||||
|
||||
CPOSNonce() : uint256() { }
|
||||
CPOSNonce(const base_blob<256> &b) : uint256(b) { }
|
||||
CPOSNonce(const std::vector<unsigned char> &vch) : uint256(vch) { }
|
||||
|
||||
int32_t GetPOSTarget() const
|
||||
{
|
||||
uint32_t nBits = 0;
|
||||
|
||||
for (const unsigned char *p = begin() + 3; p >= begin(); p--)
|
||||
{
|
||||
nBits <<= 8;
|
||||
nBits += *p;
|
||||
}
|
||||
return nBits;
|
||||
}
|
||||
|
||||
bool IsPOSNonce() const
|
||||
{
|
||||
arith_uint256 arNonce = UintToArith256(*this);
|
||||
arith_uint256 tmpNonce = ((arNonce << 128) >> 128);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
hashWriter << ArithToUint256(tmpNonce);
|
||||
return (*this == ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | tmpNonce));
|
||||
}
|
||||
|
||||
void SetPOSTarget(uint32_t nBits)
|
||||
{
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
arith_uint256 arNonce = (UintToArith256(*this) & entropyMask) | nBits;
|
||||
hashWriter << ArithToUint256(arNonce);
|
||||
|
||||
(uint256 &)(*this) = ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | arNonce);
|
||||
}
|
||||
|
||||
void SetPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t voutNum);
|
||||
bool CheckPOSEntropy(const uint256 &pastHash, uint256 txid, int32_t voutNum);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_PRIMITIVES_NONCE_H
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "arith_uint256.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "hash.h"
|
||||
#include "nonce.h"
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <stdint.h>
|
||||
@@ -727,41 +726,6 @@ public:
|
||||
return a.hash != b.hash;
|
||||
}
|
||||
|
||||
// verus hash will be the same for a given txid, output number, block height, and blockhash of 100 blocks past
|
||||
static uint256 _GetVerusPOSHash(CPOSNonce *pNonce, const uint256 &txid, int32_t voutNum, int32_t height, const uint256 &pastHash, int64_t value)
|
||||
{
|
||||
pNonce->SetPOSEntropy(pastHash, txid, voutNum);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
|
||||
hashWriter << ASSETCHAINS_MAGIC;
|
||||
|
||||
// we only use the new style of POS hash after changeover and 100 blocks of enforced proper nonce updating
|
||||
if (CPOSNonce::NewPOSActive(height))
|
||||
{
|
||||
hashWriter << *pNonce;
|
||||
hashWriter << height;
|
||||
return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value);
|
||||
}
|
||||
else
|
||||
{
|
||||
hashWriter << pastHash;
|
||||
hashWriter << height;
|
||||
hashWriter << txid;
|
||||
hashWriter << voutNum;
|
||||
return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value);
|
||||
}
|
||||
}
|
||||
|
||||
// Nonce is modified to include the transaction information
|
||||
uint256 GetVerusPOSHash(CPOSNonce *pNonce, int32_t voutNum, int32_t height, const uint256 &pastHash) const
|
||||
{
|
||||
uint256 txid = GetHash();
|
||||
|
||||
if (voutNum >= vout.size())
|
||||
return uint256S("ff0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
|
||||
return _GetVerusPOSHash(pNonce, txid, voutNum, height, pastHash, (uint64_t)vout[voutNum].nValue);
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
@@ -326,7 +326,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||
result.push_back(Pair("chainwork", blockindex->chainPower.chainWork.GetHex()));
|
||||
result.push_back(Pair("anchor", blockindex->hashFinalSproutRoot.GetHex()));
|
||||
result.push_back(Pair("blocktype", block.IsVerusPOSBlock() ? "minted" : "mined"));
|
||||
result.push_back(Pair("blocktype", "mined"));
|
||||
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -162,7 +163,6 @@ UniValue getnetworkhashps(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
UniValue getgenerate(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 0)
|
||||
@@ -184,7 +184,7 @@ UniValue getgenerate(const UniValue& params, bool fHelp)
|
||||
|
||||
LOCK(cs_main);
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
bool staking = VERUS_MINTBLOCKS;
|
||||
bool staking = false;
|
||||
if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 )
|
||||
staking = true;
|
||||
obj.push_back(Pair("staking", staking));
|
||||
@@ -370,27 +370,11 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
|
||||
//if (nGenProcLimit == 0)
|
||||
// fGenerate = false;
|
||||
}
|
||||
if ( ASSETCHAINS_LWMAPOS != 0 )
|
||||
{
|
||||
if (fGenerate && !nGenProcLimit)
|
||||
{
|
||||
VERUS_MINTBLOCKS = 1;
|
||||
fGenerate = GetBoolArg("-gen", false);
|
||||
KOMODO_MININGTHREADS = nGenProcLimit;
|
||||
}
|
||||
else if (!fGenerate)
|
||||
{
|
||||
VERUS_MINTBLOCKS = 0;
|
||||
KOMODO_MININGTHREADS = 0;
|
||||
}
|
||||
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||
}
|
||||
else
|
||||
{
|
||||
KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||
}
|
||||
|
||||
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
||||
KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||
fprintf(stderr,"%s:KOMODO_MININGTHREADS=%d\n", __FUNCTION__, KOMODO_MININGTHREADS);
|
||||
|
||||
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
||||
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -499,9 +483,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
|
||||
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
|
||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||
#ifdef ENABLE_MINING
|
||||
bool staking = VERUS_MINTBLOCKS;
|
||||
if ( ASSETCHAINS_STAKED != 0 && GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) == 0 )
|
||||
staking = true;
|
||||
bool staking = false;
|
||||
obj.push_back(Pair("staking", staking));
|
||||
obj.push_back(Pair("generate", GetBoolArg("-gen", false) && GetBoolArg("-genproclimit", -1) != 0 ));
|
||||
obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS));
|
||||
|
||||
@@ -353,7 +353,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
obj.push_back(Pair("staked", ASSETCHAINS_STAKED));
|
||||
if ( ASSETCHAINS_LWMAPOS != 0 )
|
||||
obj.push_back(Pair("veruspos", ASSETCHAINS_LWMAPOS));
|
||||
obj.push_back(Pair("lwmapos", ASSETCHAINS_LWMAPOS));
|
||||
if ( ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH )
|
||||
obj.push_back(Pair("algo",ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]));
|
||||
}
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// 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.
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
||||
* the top-level directory of this distribution for the individual copyright *
|
||||
* holder information and the developer policies on copyright and licensing. *
|
||||
* *
|
||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
||||
* SuperNET software, including this file may be copied, modified, propagated *
|
||||
* or distributed except according to the terms contained in the LICENSE file *
|
||||
* *
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "script_ext.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool CScriptExt::IsPayToScriptHash(CScriptID *scriptID) const
|
||||
{
|
||||
if (((CScript *)this)->IsPayToScriptHash())
|
||||
{
|
||||
*scriptID = CScriptID(uint160(std::vector<unsigned char>(this->begin() + 2, this->end() - 1)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// P2PKH script, adds to whatever is already in the script (for example CLTV)
|
||||
const CScriptExt &CScriptExt::AddPayToPubKeyHash(const CKeyID &key) const
|
||||
{
|
||||
*((CScript *)this) << OP_DUP;
|
||||
*((CScript *)this) << OP_HASH160;
|
||||
*((CScript *)this) << ToByteVector(key);
|
||||
*((CScript *)this) << OP_EQUALVERIFY;
|
||||
*((CScript *)this) << OP_CHECKSIG;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// push data into an op_return script with an opret type indicator, fails if the op_return is too large
|
||||
const CScriptExt &CScriptExt::OpReturnScript(const vector<unsigned char> &data, unsigned char opretType) const
|
||||
{
|
||||
((CScript *)this)->clear();
|
||||
if (data.size() < MAX_SCRIPT_ELEMENT_SIZE)
|
||||
{
|
||||
vector<unsigned char> scratch = vector<unsigned char>(data);
|
||||
scratch.insert(scratch.begin(), opretType);
|
||||
*((CScript *)this) << OP_RETURN;
|
||||
*((CScript *)this) << scratch;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// push data into an op_return script with an opret type indicator, fails if the op_return is too large
|
||||
const CScriptExt &CScriptExt::OpReturnScript(const CScript &src, unsigned char opretType) const
|
||||
{
|
||||
vector<unsigned char> vch = vector<unsigned char>(src.begin(), src.end());
|
||||
return OpReturnScript(vch, opretType);
|
||||
}
|
||||
|
||||
// P2SH script, adds to whatever is already in the script (for example CLTV)
|
||||
const CScriptExt &CScriptExt::PayToScriptHash(const CScriptID &scriptID) const
|
||||
{
|
||||
((CScript *)this)->clear();
|
||||
*((CScript *)this) << OP_HASH160;
|
||||
*((CScript *)this) << ToByteVector(scriptID);
|
||||
*((CScript *)this) << OP_EQUAL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// P2SH script, adds to whatever is already in the script (for example CLTV)
|
||||
const CScriptExt &CScriptExt::AddCheckLockTimeVerify(int64_t unlocktime) const
|
||||
{
|
||||
if (unlocktime > 0)
|
||||
{
|
||||
*((CScript *)this) << CScriptNum::serialize(unlocktime);
|
||||
*((CScript *)this) << OP_CHECKLOCKTIMEVERIFY;
|
||||
*((CScript *)this) << OP_DROP;
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// combined CLTV script and P2PKH
|
||||
const CScriptExt &CScriptExt::TimeLockSpend(const CKeyID &key, int64_t unlocktime) const
|
||||
{
|
||||
((CScript *)this)->clear();
|
||||
this->AddCheckLockTimeVerify(unlocktime);
|
||||
this->AddPayToPubKeyHash(key);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* provide destination extraction for non-standard, timelocked coinbase transactions
|
||||
* as well as other transactions
|
||||
*/
|
||||
bool CScriptExt::ExtractVoutDestination(const CTransaction& tx, int32_t voutNum, CTxDestination& addressRet)
|
||||
{
|
||||
if (tx.vout.size() <= voutNum)
|
||||
return false;
|
||||
|
||||
CScriptID scriptHash;
|
||||
CScriptExt spk = tx.vout[voutNum].scriptPubKey;
|
||||
|
||||
// if this is a timelocked transaction, get the destination behind the time lock
|
||||
if (tx.IsCoinBase() && tx.vout.size() == 2 && voutNum == 0 &&
|
||||
spk.IsPayToScriptHash(&scriptHash) &&
|
||||
tx.vout[1].scriptPubKey.IsOpReturn())
|
||||
{
|
||||
opcodetype op;
|
||||
std::vector<uint8_t> opretData = std::vector<uint8_t>();
|
||||
CScript::const_iterator it = tx.vout[1].scriptPubKey.begin() + 1;
|
||||
if (tx.vout[1].scriptPubKey.GetOp2(it, op, &opretData))
|
||||
{
|
||||
if (opretData.size() > 0 && opretData[0] == OPRETTYPE_TIMELOCK)
|
||||
{
|
||||
int64_t unlocktime;
|
||||
CScriptExt se = CScriptExt(&opretData[1], &opretData[opretData.size()]);
|
||||
|
||||
if (CScriptID(se) == scriptHash &&
|
||||
se.IsCheckLockTimeVerify(&unlocktime))
|
||||
{
|
||||
spk = se;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ExtractDestination(spk, addressRet);
|
||||
}
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// 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.
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
||||
* the top-level directory of this distribution for the individual copyright *
|
||||
* holder information and the developer policies on copyright and licensing. *
|
||||
* *
|
||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
||||
* SuperNET software, including this file may be copied, modified, propagated *
|
||||
* or distributed except according to the terms contained in the LICENSE file *
|
||||
* *
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BITCOIN_SCRIPT_SCRIPT_EXT_H
|
||||
#define BITCOIN_SCRIPT_SCRIPT_EXT_H
|
||||
|
||||
#include "script.h"
|
||||
#include "standard.h"
|
||||
#include "pubkey.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class CScriptExt : public CScript
|
||||
{
|
||||
public:
|
||||
CScriptExt() { }
|
||||
CScriptExt(const CScript& b) : CScript(b) { }
|
||||
CScriptExt(const_iterator pbegin, const_iterator pend) : CScript(pbegin, pend) { }
|
||||
CScriptExt(const unsigned char* pbegin, const unsigned char* pend) : CScript(pbegin, pend) { }
|
||||
|
||||
// overload to return the hash of the referenced script
|
||||
bool IsPayToScriptHash(CScriptID *scriptID) const;
|
||||
|
||||
// P2PKH script, adds to whatever is already in the script (for example CLTV)
|
||||
const CScriptExt &AddPayToPubKeyHash(const CKeyID &key) const;
|
||||
|
||||
// push data into an op_return script with an opret type indicator, fails if the op_return is too large
|
||||
const CScriptExt &OpReturnScript(const std::vector<unsigned char> &data, unsigned char opretType) const;
|
||||
|
||||
// push data into an op_return script with an opret type indicator, fails if the op_return is too large
|
||||
const CScriptExt &OpReturnScript(const CScript &src, unsigned char opretType) const;
|
||||
|
||||
// P2SH script
|
||||
const CScriptExt &PayToScriptHash(const CScriptID &scriptID) const;
|
||||
|
||||
// P2SH script, adds to whatever is already in the script (for example CLTV)
|
||||
const CScriptExt &AddCheckLockTimeVerify(int64_t unlocktime) const;
|
||||
|
||||
// combined CLTV script and P2PKH
|
||||
const CScriptExt &TimeLockSpend(const CKeyID &key, int64_t unlocktime) const;
|
||||
|
||||
// lookup for destinations that includes non-standard destinations for time locked coinbases
|
||||
static bool ExtractVoutDestination(const CTransaction& tx, int32_t voutNum, CTxDestination& addressRet);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1031,9 +1031,8 @@ std::string LicenseInfo()
|
||||
FormatParagraph(strprintf(_("Copyright (C) 2015-%i The Zcash Developers"), COPYRIGHT_YEAR)) + "\n" +
|
||||
FormatParagraph(strprintf(_("Copyright (C) 2015-%i jl777 and SuperNET developers"), COPYRIGHT_YEAR)) + "\n" +
|
||||
FormatParagraph(strprintf(_("Copyright (C) 2018-%i The Hush developers"), COPYRIGHT_YEAR)) + "\n" +
|
||||
FormatParagraph(strprintf(_("Copyright (C) 2018-%i The Verus developers"), COPYRIGHT_YEAR)) + "\n" +
|
||||
"\n" +
|
||||
FormatParagraph(_("This is experimental software.")) + "\n" +
|
||||
FormatParagraph(_("This is experimental software!!!")) + "\n" +
|
||||
"\n" +
|
||||
FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or <http://www.opensource.org/licenses/mit-license.php>.")) + "\n" +
|
||||
"\n" +
|
||||
|
||||
@@ -17,14 +17,12 @@ uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
|
||||
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
||||
uint32_t ASSETCHAINS_EQUIHASH = 0;
|
||||
uint32_t ASSETCHAINS_VERUSHASH = 1;
|
||||
uint32_t ASSETCHAINS_VERUSHASHV1_1 = 2;
|
||||
uint32_t ASSETCHAINS_ALGO = 0;
|
||||
int32_t ASSETCHAINS_LWMAPOS = 0;
|
||||
int32_t VERUS_BLOCK_POSUNITS = 1000;
|
||||
int32_t ASSETCHAINS_OVERWINTER = 227520;
|
||||
int32_t ASSETCHAINS_SAPLING = 227520;
|
||||
int32_t KOMODO_TESTNODE = 0;
|
||||
int32_t KOMODO_BLOCK_POSUNITS = 1000;
|
||||
|
||||
unsigned int MAX_BLOCK_SIGOPS = 20000;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -1858,11 +1859,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||
entry.push_back(Pair("involvesWatchonly", true));
|
||||
entry.push_back(Pair("account", account));
|
||||
|
||||
CTxDestination dest;
|
||||
if (CScriptExt::ExtractVoutDestination(wtx, r.vout, dest))
|
||||
MaybePushAddress(entry, dest);
|
||||
else
|
||||
MaybePushAddress(entry, r.destination);
|
||||
MaybePushAddress(entry, r.destination);
|
||||
|
||||
if (bIsCoinbase)
|
||||
{
|
||||
@@ -5464,12 +5461,6 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33)
|
||||
return(siglen);
|
||||
}
|
||||
|
||||
int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk)
|
||||
{
|
||||
return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk);
|
||||
}
|
||||
|
||||
|
||||
#include "../cc/CCfaucet.h"
|
||||
#include "../cc/CCassets.h"
|
||||
#include "../cc/CCrewards.h"
|
||||
@@ -7968,7 +7959,6 @@ UniValue heirfund(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
uint256 tokenid = zeroid;
|
||||
int64_t txfee;
|
||||
int64_t amount;
|
||||
int64_t inactivitytime;
|
||||
std::string hex;
|
||||
@@ -7978,51 +7968,47 @@ UniValue heirfund(const UniValue& params, bool fHelp)
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() != 6 && params.size() != 7)
|
||||
throw runtime_error("heirfund txfee funds heirname heirpubkey inactivitytime memo [tokenid]\n");
|
||||
if (fHelp || params.size() != 5 && params.size() != 6)
|
||||
throw runtime_error("heirfund funds heirname heirpubkey inactivitytime memo [tokenid]\n");
|
||||
if (ensure_CCrequirements(EVAL_HEIR) < 0)
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
|
||||
if(params.size() == 7) // tokens in satoshis:
|
||||
amount = atoll(params[1].get_str().c_str());
|
||||
else // coins:
|
||||
amount = atof(params[1].get_str().c_str()) * COIN;
|
||||
if (params.size() == 6) // tokens in satoshis:
|
||||
amount = atoll(params[0].get_str().c_str());
|
||||
else { // coins:
|
||||
amount = 0;
|
||||
if (!ParseFixedPoint(params[0].get_str(), 8, &amount)) // using ParseFixedPoint instead atof to avoid small round errors
|
||||
amount = -1; // set error
|
||||
}
|
||||
if (amount <= 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect amount"));
|
||||
return result;
|
||||
}
|
||||
|
||||
name = params[2].get_str();
|
||||
name = params[1].get_str();
|
||||
|
||||
pubkey = ParseHex(params[3].get_str().c_str());
|
||||
pubkey = ParseHex(params[2].get_str().c_str());
|
||||
if (!pubkey2pk(pubkey).IsValid()) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect pubkey"));
|
||||
return result;
|
||||
}
|
||||
|
||||
inactivitytime = atoll(params[4].get_str().c_str());
|
||||
inactivitytime = atoll(params[3].get_str().c_str());
|
||||
if (inactivitytime <= 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect inactivity time"));
|
||||
return result;
|
||||
}
|
||||
|
||||
memo = params[5].get_str();
|
||||
memo = params[4].get_str();
|
||||
|
||||
if (params.size() == 7) {
|
||||
tokenid = Parseuint256((char*)params[6].get_str().c_str());
|
||||
if (params.size() == 6) {
|
||||
tokenid = Parseuint256((char*)params[5].get_str().c_str());
|
||||
if (tokenid == zeroid) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect tokenid"));
|
||||
@@ -8031,9 +8017,9 @@ UniValue heirfund(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
if( tokenid == zeroid )
|
||||
result = HeirFundCoinCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo);
|
||||
result = HeirFundCoinCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo);
|
||||
else
|
||||
result = HeirFundTokenCaller(txfee, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid);
|
||||
result = HeirFundTokenCaller(0, amount, name, pubkey2pk(pubkey), inactivitytime, memo, tokenid);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -8042,7 +8028,6 @@ UniValue heiradd(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result;
|
||||
uint256 fundingtxid;
|
||||
int64_t txfee;
|
||||
int64_t amount;
|
||||
int64_t inactivitytime;
|
||||
std::string hex;
|
||||
@@ -8052,24 +8037,18 @@ UniValue heiradd(const UniValue& params, bool fHelp)
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() != 3)
|
||||
throw runtime_error("heiradd txfee funds fundingtxid\n");
|
||||
if (fHelp || params.size() != 2)
|
||||
throw runtime_error("heiradd funds fundingtxid\n");
|
||||
if (ensure_CCrequirements(EVAL_HEIR) < 0)
|
||||
throw runtime_error(CC_REQUIREMENTS_MSG);
|
||||
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
std::string strAmount = params[0].get_str();
|
||||
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
|
||||
|
||||
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
|
||||
|
||||
result = HeirAddCaller(fundingtxid, txfee, params[1].get_str());
|
||||
result = HeirAddCaller(fundingtxid, 0, strAmount);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -8094,16 +8073,9 @@ UniValue heirclaim(const UniValue& params, bool fHelp)
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
txfee = atoll(params[0].get_str().c_str());
|
||||
if (txfee < 0) {
|
||||
result.push_back(Pair("result", "error"));
|
||||
result.push_back(Pair("error", "incorrect txfee"));
|
||||
return result;
|
||||
}
|
||||
|
||||
fundingtxid = Parseuint256((char*)params[2].get_str().c_str());
|
||||
|
||||
result = HeirClaimCaller(fundingtxid, txfee, params[1].get_str());
|
||||
std::string strAmount = params[0].get_str();
|
||||
fundingtxid = Parseuint256((char*)params[1].get_str().c_str());
|
||||
result = HeirClaimCaller(fundingtxid, 0, strAmount);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -1338,120 +1339,6 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
|
||||
return txOrdered;
|
||||
}
|
||||
|
||||
// looks through all wallet UTXOs and checks to see if any qualify to stake the block at the current height. it always returns the qualified
|
||||
// UTXO with the smallest coin age if there is more than one, as larger coin age will win more often and is worth saving
|
||||
// each attempt consists of taking a VerusHash of the following values:
|
||||
// ASSETCHAINS_MAGIC, nHeight, txid, voutNum
|
||||
bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, uint32_t &bnTarget) const
|
||||
{
|
||||
arith_uint256 target;
|
||||
arith_uint256 curHash;
|
||||
vector<COutput> vecOutputs;
|
||||
COutput *pwinner = NULL;
|
||||
CBlockIndex *pastBlockIndex;
|
||||
txnouttype whichType;
|
||||
std:vector<std::vector<unsigned char>> vSolutions;
|
||||
|
||||
pBlock->nNonce.SetPOSTarget(bnTarget);
|
||||
target.SetCompact(bnTarget);
|
||||
|
||||
pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false);
|
||||
|
||||
if (pastBlockIndex = komodo_chainactive(nHeight - 100))
|
||||
{
|
||||
CBlockHeader bh = pastBlockIndex->GetBlockHeader();
|
||||
uint256 pastHash = bh.GetVerusEntropyHash(nHeight - 100);
|
||||
CPOSNonce curNonce;
|
||||
|
||||
BOOST_FOREACH(COutput &txout, vecOutputs)
|
||||
{
|
||||
if (txout.fSpendable && (UintToArith256(txout.tx->GetVerusPOSHash(&(pBlock->nNonce), txout.i, nHeight, pastHash)) <= target) && (txout.nDepth >= VERUS_MIN_STAKEAGE))
|
||||
{
|
||||
if ((!pwinner || UintToArith256(curNonce) > UintToArith256(pBlock->nNonce)) &&
|
||||
(Solver(txout.tx->vout[txout.i].scriptPubKey, whichType, vSolutions) && (whichType == TX_PUBKEY || whichType == TX_PUBKEYHASH)))
|
||||
{
|
||||
//printf("Found PoS block\nnNonce: %s\n", pBlock->nNonce.GetHex().c_str());
|
||||
pwinner = &txout;
|
||||
curNonce = pBlock->nNonce;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pwinner)
|
||||
{
|
||||
stakeSource = *(pwinner->tx);
|
||||
voutNum = pwinner->i;
|
||||
pBlock->nNonce = curNonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey pk) const
|
||||
{
|
||||
CTransaction stakeSource;
|
||||
int32_t voutNum, siglen = 0;
|
||||
int64_t nValue;
|
||||
txnouttype whichType;
|
||||
std::vector<std::vector<unsigned char>> vSolutions;
|
||||
|
||||
CBlockIndex *tipindex = chainActive.LastTip();
|
||||
uint32_t stakeHeight = tipindex->GetHeight() + 1;
|
||||
|
||||
pk = CPubKey();
|
||||
|
||||
bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());
|
||||
|
||||
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->GetHeight() + 1, bnTarget) ||
|
||||
!Solver(stakeSource.vout[voutNum].scriptPubKey, whichType, vSolutions))
|
||||
{
|
||||
LogPrintf("Searched for eligible staking transactions, no winners found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool signSuccess;
|
||||
SignatureData sigdata;
|
||||
uint64_t txfee;
|
||||
auto consensusBranchId = CurrentEpochBranchId(stakeHeight, Params().GetConsensus());
|
||||
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
txNew.vin.resize(1);
|
||||
txNew.vout.resize(1);
|
||||
txfee = 0;
|
||||
txNew.vin[0].prevout.hash = stakeSource.GetHash();
|
||||
txNew.vin[0].prevout.n = voutNum;
|
||||
|
||||
if (whichType == TX_PUBKEY)
|
||||
{
|
||||
txNew.vout[0].scriptPubKey << ToByteVector(vSolutions[0]) << OP_CHECKSIG;
|
||||
if (!pk.IsValid())
|
||||
pk = CPubKey(vSolutions[0]);
|
||||
}
|
||||
else if (whichType == TX_PUBKEYHASH)
|
||||
{
|
||||
txNew.vout[0].scriptPubKey << OP_DUP << OP_HASH160 << ToByteVector(vSolutions[0]) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
|
||||
|
||||
txNew.nLockTime = 0;
|
||||
CTransaction txNewConst(txNew);
|
||||
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, nValue, SIGHASH_ALL), stakeSource.vout[voutNum].scriptPubKey, sigdata, consensusBranchId);
|
||||
if (!signSuccess)
|
||||
fprintf(stderr,"failed to create signature\n");
|
||||
else
|
||||
{
|
||||
uint8_t *ptr;
|
||||
UpdateTransaction(txNew,0,sigdata);
|
||||
ptr = (uint8_t *)&sigdata.scriptSig[0];
|
||||
siglen = sigdata.scriptSig.size();
|
||||
for (int i=0; i<siglen; i++)
|
||||
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
|
||||
}
|
||||
return(siglen);
|
||||
}
|
||||
|
||||
void CWallet::MarkDirty()
|
||||
{
|
||||
@@ -2198,13 +2085,13 @@ bool CWallet::IsMine(const CTransaction& tx)
|
||||
return false;
|
||||
}
|
||||
|
||||
// special case handling for non-standard/Verus OP_RETURN script outputs, which need the transaction
|
||||
// special case handling for non-standard OP_RETURN script outputs, which need the transaction
|
||||
// to determine ownership
|
||||
isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
{
|
||||
vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
const CScriptExt scriptPubKey = CScriptExt(tx.vout[voutNum].scriptPubKey);
|
||||
const CScript scriptPubKey = CScript(tx.vout[voutNum].scriptPubKey);
|
||||
|
||||
if (!Solver(scriptPubKey, whichType, vSolutions)) {
|
||||
if (this->HaveWatchOnly(scriptPubKey))
|
||||
@@ -2214,7 +2101,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
|
||||
CKeyID keyID;
|
||||
CScriptID scriptID;
|
||||
CScriptExt subscript;
|
||||
CScript subscript;
|
||||
int voutNext = voutNum + 1;
|
||||
|
||||
switch (whichType)
|
||||
@@ -2248,6 +2135,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
|
||||
case TX_SCRIPTHASH:
|
||||
scriptID = CScriptID(uint160(vSolutions[0]));
|
||||
//TODO: remove CLTV stuff not relevant to Hush
|
||||
if (this->GetCScript(scriptID, subscript))
|
||||
{
|
||||
// if this is a CLTV, handle it differently
|
||||
|
||||
@@ -1330,9 +1330,6 @@ public:
|
||||
bool requireSpendingKey=true,
|
||||
bool ignoreLocked=true);
|
||||
|
||||
// staking functions
|
||||
bool VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, uint32_t &bnTarget) const;
|
||||
int32_t VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey pk) const;
|
||||
};
|
||||
|
||||
/** A key allocated from the key pool. */
|
||||
|
||||
19
zcutil/afl/afl-build.sh
Executable file
19
zcutil/afl/afl-build.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# A wrapper around ./zcutil/build.sh for instrumenting the build with AFL:
|
||||
# ./zcutil/afl/afl-build.sh <directory where AFL is installed> <fuzz case>
|
||||
# You may obtain a copy of AFL using ./zcutil/afl/afl-get.sh.
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
export AFL_INSTALL_DIR=$(realpath "$1")
|
||||
FUZZ_CASE="$2"
|
||||
shift 2
|
||||
export AFL_LOG_DIR="$(pwd)"
|
||||
export ZCUTIL=$(realpath "./zcutil")
|
||||
|
||||
cp "./src/fuzzing/$FUZZ_CASE/fuzz.cpp" src/fuzz.cpp
|
||||
|
||||
CONFIGURE_FLAGS="--enable-tests=no --enable-fuzz-main" "$ZCUTIL/build.sh" "CC=$ZCUTIL/afl/zcash-wrapper-gcc" "CXX=$ZCUTIL/afl/zcash-wrapper-g++" AFL_HARDEN=1 "$@"
|
||||
|
||||
echo "You can now run AFL as follows:"
|
||||
echo "$ ./zcutil/afl/afl-run.sh '$AFL_INSTALL_DIR' '$FUZZ_CASE'"
|
||||
33
zcutil/afl/afl-get.sh
Executable file
33
zcutil/afl/afl-get.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Obtains and builds a copy of AFL from source.
|
||||
# ./zcutil/afl/afl-get.sh <directory to build and install AFL in>
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
mkdir -p "$1"
|
||||
cd "$1"
|
||||
|
||||
if [ ! -z "$(ls -A .)" ]; then
|
||||
echo "$1 is not empty. This script will only attempt to build AFL in an empty directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the AFL source
|
||||
rm -f afl-latest.tgz
|
||||
wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
|
||||
sha256sum afl-latest.tgz | grep '43614b4b91c014d39ef086c5cc84ff5f068010c264c2c05bf199df60898ce045'
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
echo "Wrong SHA256 hash for afl"
|
||||
exit
|
||||
fi
|
||||
tar xvf afl-latest.tgz
|
||||
mv afl-*/* .
|
||||
|
||||
# Build AFL
|
||||
make
|
||||
|
||||
echo "You can now build zcashd with AFL instrumentation as follows:"
|
||||
echo "$ make clean # if you've already built zcashd without AFL instrumentation"
|
||||
echo "$ ./zcutil/afl/afl-build.sh '$(pwd)' <fuzz case> -j\$(nproc)"
|
||||
echo "...where <fuzz case> is the name of a directory in src/fuzzing."
|
||||
20
zcutil/afl/afl-getbuildrun.sh
Executable file
20
zcutil/afl/afl-getbuildrun.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds AFL and an instrumented zcashd, then begins fuzzing.
|
||||
# This script must be run from within the top level directory of a zcash clone.
|
||||
# Pass it the name of a directory in ./src/fuzzing.
|
||||
# Additional arguments are passed-through to AFL.
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
FUZZ_CASE="$1"
|
||||
shift 1
|
||||
|
||||
export AFL_INSTALL_DIR=$(realpath "./afl-temp")
|
||||
|
||||
if [ ! -d "$AFL_INSTALL_DIR" ]; then
|
||||
mkdir "$AFL_INSTALL_DIR"
|
||||
./zcutil/afl/afl-get.sh "$AFL_INSTALL_DIR"
|
||||
fi
|
||||
|
||||
./zcutil/afl/afl-build.sh "$AFL_INSTALL_DIR" "$FUZZ_CASE" -j$(nproc)
|
||||
./zcutil/afl/afl-run.sh "$AFL_INSTALL_DIR" "$FUZZ_CASE" "$@"
|
||||
9
zcutil/afl/afl-run.sh
Executable file
9
zcutil/afl/afl-run.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
AFL_INSTALL_DIR="$1"
|
||||
FUZZ_CASE="$2"
|
||||
shift 2
|
||||
|
||||
"$AFL_INSTALL_DIR/afl-fuzz" -i "./src/fuzzing/$FUZZ_CASE/input" -o "./src/fuzzing/$FUZZ_CASE/output" "$@" ./src/zcashd @@
|
||||
48
zcutil/afl/hush-wrapper
Executable file
48
zcutil/afl/hush-wrapper
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex -o pipefail
|
||||
|
||||
export ARGS=$@
|
||||
|
||||
instrument=(
|
||||
"\/src$"
|
||||
|
||||
)
|
||||
|
||||
if [ "$override_instrument" != "" ]
|
||||
then
|
||||
instrument = $override_instrument
|
||||
fi
|
||||
|
||||
# Store the command line we were given to a file
|
||||
|
||||
(echo "$ARGS" ; pwd) >> "$AFL_LOG_DIR/hush-build-wrapper.log"
|
||||
|
||||
# Work out which compiler we were called as
|
||||
|
||||
case $0 in
|
||||
*hush-wrapper-g++)
|
||||
COMPILER="g++"
|
||||
;;
|
||||
*hush-wrapper-gcc)
|
||||
COMPILER="gcc"
|
||||
;;
|
||||
*hush-wrapper)
|
||||
echo "Call this script instead of your regular compiler, and if the absolute path of the CWD the wrapper was called from matches a regex in the array 'instrument', it will call AFL to instrument the resulting binary. Otherwise it will call either g++ or gcc depending on how it was invoked. \$AFL_INSTALL_DIR must be set to the path where AFL is installed."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# Check if we should instrument
|
||||
|
||||
for i in "${instrument[@]}"
|
||||
do
|
||||
if echo -- "`pwd`" | grep "$i"; then
|
||||
# We found a match, let's instrument this one.
|
||||
echo "Matched directory `pwd` to instrument element $i. Instrumenting this call." >> "$AFL_LOG_DIR/hush-build-wrapper.log"
|
||||
exec -- "$AFL_INSTALL_DIR/afl-$COMPILER" "$@"
|
||||
fi
|
||||
done
|
||||
|
||||
# No match, just pass-through.
|
||||
exec -- "$COMPILER" "$@"
|
||||
1
zcutil/afl/hush-wrapper-g++
Symbolic link
1
zcutil/afl/hush-wrapper-g++
Symbolic link
@@ -0,0 +1 @@
|
||||
hush-wrapper
|
||||
1
zcutil/afl/hush-wrapper-gcc
Symbolic link
1
zcutil/afl/hush-wrapper-gcc
Symbolic link
@@ -0,0 +1 @@
|
||||
hush-wrapper
|
||||
Reference in New Issue
Block a user