Merge pull request #17 from VerusCoin/dev
Merge all VerusCoin changes for 0.3.11-beta
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
*.tar.gz
|
||||
*.deb
|
||||
*.exe
|
||||
src/bitcoin
|
||||
src/zcashd
|
||||
src/zcash-cli
|
||||
@@ -47,6 +46,7 @@ src/univalue/gen
|
||||
|
||||
.deps
|
||||
.dirstamp
|
||||
.idea
|
||||
.libs
|
||||
.*.swp
|
||||
*.*~*
|
||||
@@ -121,6 +121,9 @@ src/komodod
|
||||
src/komodo-tx
|
||||
src/komodo-test
|
||||
src/wallet-utility
|
||||
src/komodo-cli.exe
|
||||
src/komodod.exe
|
||||
src/komodo-tx.exe
|
||||
|
||||
#output during builds, symbol tables?
|
||||
*.dSYM
|
||||
|
||||
255
.gitlab-ci.yml
Normal file
255
.gitlab-ci.yml
Normal file
@@ -0,0 +1,255 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
VERSION: 0.3.10
|
||||
AGAMA_ARTIFACTS_LINUX: linux64.tar.gz
|
||||
AGAMA_ARTIFACTS_MACOS: osx.tar.gz
|
||||
AGAMA_ARTIFACTS_WINDOWS: win64.zip
|
||||
VERUS_CLI_DEBIAN: verus-cli-v${VERSION}-beta-amd64.deb
|
||||
VERUS_CLI_LINUX_PORTABLE: verus-cli-linux-v$VERSION-beta.tar.gz
|
||||
VERUS_CLI_WINDOWS_PORTABLE: verus-cli-windows-v$VERSION-beta.zip
|
||||
VERUS_CLI_MACOS_PORTABLE: verus-cli-mac-v$VERSION-beta.tar.gz
|
||||
|
||||
|
||||
build:linux:
|
||||
image: asherd/veruscoin-cross-compiler:linux
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
stage: build
|
||||
cache:
|
||||
key: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- depends/built
|
||||
- .ccache
|
||||
before_script: # Setup Cache
|
||||
- rm -rf /root/.ccache || true
|
||||
- mv .ccache /root/ || true
|
||||
script:
|
||||
- zcutil/build.sh -j4
|
||||
- ./makeReleaseLinux.sh
|
||||
- dos2unix kmd/linux/verus-cli/README.txt
|
||||
- tar -C kmd/linux/ -czvf $VERUS_CLI_LINUX_PORTABLE verus-cli ./
|
||||
- mv kmd/linux/verus-cli kmd/linux/linux64
|
||||
- tar -C kmd/linux/ -czvf $AGAMA_ARTIFACTS_LINUX linux64 ./
|
||||
after_script:
|
||||
- mv /root/.ccache ./ || true
|
||||
cache:
|
||||
key: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- depends/built
|
||||
- .ccache
|
||||
artifacts:
|
||||
paths:
|
||||
- $VERUS_CLI_LINUX_PORTABLE
|
||||
- $AGAMA_ARTIFACTS_LINUX
|
||||
expire_in: 1 week
|
||||
|
||||
|
||||
build:windows:
|
||||
image: asherd/veruscoin-cross-compiler:latest
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
stage: build
|
||||
cache:
|
||||
key: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- depends/built
|
||||
- .ccache
|
||||
- .cargo
|
||||
before_script:
|
||||
- mkdir .ccache || echo ccache exists
|
||||
- ln -s $PWD/.ccache /root/.ccache
|
||||
- mkdir .zcash-params || echo zcash-params exists
|
||||
- mkdir .cargo || echo .cargo exists
|
||||
- ln -s $PWD/.cargo /root/.cargo
|
||||
script:
|
||||
- zcutil/build-win.sh
|
||||
- ./makeReleaseWindows.sh
|
||||
- cd kmd/windows/
|
||||
- zip -r $VERUS_CLI_WINDOWS_PORTABLE verus-cli
|
||||
- mv $VERUS_CLI_WINDOWS_PORTABLE ../..
|
||||
- mv verus-cli win64
|
||||
- zip -r $AGAMA_ARTIFACTS_WINDOWS win64
|
||||
- mv $AGAMA_ARTIFACTS_WINDOWS ../..
|
||||
artifacts:
|
||||
paths:
|
||||
- $VERUS_CLI_WINDOWS_PORTABLE
|
||||
- $AGAMA_ARTIFACTS_WINDOWS
|
||||
expire_in: 1 week
|
||||
|
||||
|
||||
build:mac:
|
||||
stage: build
|
||||
tags: ["High Sierra"]
|
||||
cache:
|
||||
key: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- depends/built
|
||||
script:
|
||||
- zcutil/build-mac.sh | xcpretty
|
||||
- ./makeReleaseMac.sh
|
||||
- dos2unix kmd/mac/verus-cli/README.txt
|
||||
- tar -C kmd/mac/ -czvf $VERUS_CLI_MACOS_PORTABLE verus-cli ./
|
||||
- mv kmd/mac/verus-cli kmd/mac/osx
|
||||
- tar -C kmd/mac/ -czvf $AGAMA_ARTIFACTS_MACOS osx ./
|
||||
artifacts:
|
||||
paths:
|
||||
- $VERUS_CLI_MACOS_PORTABLE
|
||||
- $AGAMA_ARTIFACTS_MACOS
|
||||
expire_in: 1 week
|
||||
|
||||
|
||||
code_quality:
|
||||
image: docker:stable
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [gl-code-quality-report.json]
|
||||
|
||||
|
||||
sast:
|
||||
image: docker:stable
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
||||
--volume "$PWD:/code"
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
||||
artifacts:
|
||||
paths: [gl-sast-report.json]
|
||||
|
||||
|
||||
|
||||
license_management:
|
||||
image: docker:stable
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export LICENSE_MANAGEMENT_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--volume "$PWD:/code"
|
||||
"registry.gitlab.com/gitlab-org/security-products/license-management:$LICENSE_MANAGEMENT_VERSION" analyze /code
|
||||
artifacts:
|
||||
paths: [gl-license-management-report.json]
|
||||
|
||||
ubuntu:xenial:
|
||||
image: ubuntu:xenial
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
stage: test
|
||||
before_script:
|
||||
- apt update && apt install -y wget g++-multilib libcurl3 python
|
||||
script:
|
||||
- tar -xzvf $VERUS_CLI_LINUX_PORTABLE
|
||||
- export PATH=$PATH:$CI_PROJECT_DIR/verus-cli
|
||||
- python qa/verus-cli-tests/verus-cli-tester.py
|
||||
artifacts:
|
||||
paths: [log.txt]
|
||||
expire_in: 1 week
|
||||
dependencies:
|
||||
- build:linux
|
||||
|
||||
|
||||
ubuntu:bionic:
|
||||
image: ubuntu:bionic
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
stage: test
|
||||
before_script:
|
||||
- apt update && apt install -y wget g++-multilib libcurl3 python
|
||||
script:
|
||||
- tar -xzvf $VERUS_CLI_LINUX_PORTABLE
|
||||
- export PATH=$PATH:$CI_PROJECT_DIR/verus-cli
|
||||
- python qa/verus-cli-tests/verus-cli-tester.py
|
||||
artifacts:
|
||||
paths: [log.txt]
|
||||
expire_in: 1 week
|
||||
dependencies:
|
||||
- build:linux
|
||||
|
||||
|
||||
.osx:sierra: # fetch-params.sh needs to be fixed for MacOS
|
||||
stage: test
|
||||
tags: ["Sierra"]
|
||||
script:
|
||||
- tar -xzvf $VERUS_CLI_MACOS_PORTABLE
|
||||
- export PATH=$PATH:$CI_PROJECT_DIR/verus-cli
|
||||
- python qa/verus-cli-tests/verus-cli-tester.py
|
||||
artifacts:
|
||||
paths: [log.txt]
|
||||
expire_in: 1 week
|
||||
dependencies:
|
||||
- build:mac
|
||||
|
||||
|
||||
.osx:high-sierra: # fetch-params.sh needs to be fixed for MacOS
|
||||
stage: test
|
||||
tags: ["High Sierra"]
|
||||
script:
|
||||
- tar -xzvf $VERUS_CLI_MACOS_PORTABLE
|
||||
- export PATH=$PATH:$CI_PROJECT_DIR/verus-cli
|
||||
- python qa/verus-cli-tests/verus-cli-tester.py
|
||||
artifacts:
|
||||
paths: [log.txt]
|
||||
expire_in: 1 week
|
||||
dependencies:
|
||||
- build:mac
|
||||
|
||||
|
||||
windows:10:
|
||||
stage: test
|
||||
tags: ["Windows 10"]
|
||||
script:
|
||||
- PowerShell Expand-Archive -Path %VERUS_CLI_WINDOWS_PORTABLE% -DestinationPath %CI_PROJECT_DIR%
|
||||
- set PATH=%PATH%;%CI_PROJECT_DIR%\verus-cli
|
||||
- qa\verus-cli-tests\verus-cli-tester.py
|
||||
artifacts:
|
||||
paths: [log.txt]
|
||||
expire_in: 1 week
|
||||
dependencies:
|
||||
- build:windows
|
||||
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
image: google/cloud-sdk:alpine
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
dependencies:
|
||||
- build:linux
|
||||
- build:windows
|
||||
- build:mac
|
||||
script:
|
||||
- mkdir -p $CI_COMMIT_REF_NAME/Windows
|
||||
- mkdir -p $CI_COMMIT_REF_NAME/Linux
|
||||
- mkdir -p $CI_COMMIT_REF_NAME/MacOS
|
||||
- mv $VERUS_CLI_WINDOWS_PORTABLE $AGAMA_ARTIFACTS_WINDOWS $CI_COMMIT_REF_NAME/Windows
|
||||
- mv $VERUS_CLI_LINUX_PORTABLE $AGAMA_ARTIFACTS_LINUX $CI_COMMIT_REF_NAME/Linux
|
||||
- mv $VERUS_CLI_MACOS_PORTABLE $AGAMA_ARTIFACTS_MACOS $CI_COMMIT_REF_NAME/MacOS
|
||||
- echo "$AUTH_KEY" > AUTH_KEY.json
|
||||
- gcloud auth activate-service-account --key-file AUTH_KEY.json
|
||||
- gsutil rsync -r $CI_COMMIT_REF_NAME/ $STAGING/VerusCoin/$CI_COMMIT_REF_NAME/
|
||||
|
||||
|
||||
128
.travis.yml
128
.travis.yml
@@ -1,105 +1,67 @@
|
||||
<<<<<<< HEAD
|
||||
language: cpp
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler libdb++-dev ntp ntpdate
|
||||
#install:
|
||||
|
||||
script:
|
||||
- ./zcutil/build.sh -j 5
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "chat.freenode.net#komodoplatform"
|
||||
template:
|
||||
- "%{repository}/%{branch} (%{commit} - %{author}): %{message}"
|
||||
- "Alt Message : %{repository_slug} - (%{commit} - %{author}): %{message}, Build Time: %{duration}"
|
||||
- "Change view : %{compare_url}"
|
||||
- "Build details : %{build_url}"
|
||||
=======
|
||||
# errata:
|
||||
# - A travis bug causes caches to trample eachother when using the same
|
||||
# compiler key (which we don't use anyway). This is worked around for now by
|
||||
# replacing the "compilers" with a build name prefixed by the no-op ":"
|
||||
# command. See: https://github.com/travis-ci/travis-ci/issues/4393
|
||||
# - sudo/dist/group are set so as to get Blue Box VMs, necessary for [loopback]
|
||||
# IPv6 support
|
||||
|
||||
sudo: required
|
||||
dist: precise
|
||||
group: legacy
|
||||
|
||||
os: linux
|
||||
dist: xenial
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
compiler:
|
||||
- gcc
|
||||
env:
|
||||
global:
|
||||
- MAKEJOBS=-j3
|
||||
- RUN_TESTS=false
|
||||
- BOOST_TEST_RANDOM=1$TRAVIS_BUILD_ID
|
||||
- CCACHE_SIZE=100M
|
||||
- CCACHE_TEMPDIR=/tmp/.ccache-temp
|
||||
- CCACHE_COMPRESS=1
|
||||
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
|
||||
- SDK_URL=https://bitcoincore.org/depends-sources/sdks
|
||||
- PYTHON_DEBUG=1
|
||||
- WINEDEBUG=fixme-all
|
||||
- STORAGE_DEST=gs://$BUCKET/$PROJECT/$TRAVIS_BRANCH/
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- depends/built
|
||||
- depends/sdk-sources
|
||||
- $HOME/.ccache
|
||||
- "$HOME/google-cloud-sdk/"
|
||||
- "$HOME/.ccache"
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- compiler: ": ARM"
|
||||
env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="" GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
|
||||
- compiler: ": Win32"
|
||||
env: HOST=i686-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2"
|
||||
- compiler: ": 32-bit + dash"
|
||||
env: HOST=i686-pc-linux-gnu PACKAGES="g++-multilib bc python-zmq" PPA="ppa:chris-lea/zeromq" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" USE_SHELL="/bin/dash"
|
||||
- compiler: ": Win64"
|
||||
env: HOST=x86_64-w64-mingw32 PACKAGES="nsis gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-dev wine bc" RUN_TESTS=true GOAL="deploy" BITCOIN_CONFIG="--enable-reduce-exports" MAKEJOBS="-j2"
|
||||
- compiler: ": bitcoind"
|
||||
env: HOST=x86_64-unknown-linux-gnu PACKAGES="bc python-zmq" PPA="ppa:chris-lea/zeromq" DEP_OPTS="DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports CPPFLAGS=-DDEBUG_LOCKORDER"
|
||||
- compiler: ": No wallet"
|
||||
env: HOST=x86_64-unknown-linux-gnu DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
|
||||
- compiler: ": Cross-Mac"
|
||||
env: HOST=x86_64-apple-darwin11 PACKAGES="cmake libcap-dev libz-dev libbz2-dev" BITCOIN_CONFIG="--enable-reduce-exports" OSX_SDK=10.9 GOAL="deploy"
|
||||
- compiler: ": Linux"
|
||||
env: BUILD_SCRIPT=build.sh
|
||||
PACKAGES="build-essential pkg-config libc6-dev m4 g++-multilib
|
||||
autoconf libtool ncurses-dev unzip python zlib1g-dev wget bsdmainutils automake
|
||||
libssl-dev libprotobuf-dev protobuf-compiler libqrencode-dev libdb++-dev software-properties-common
|
||||
libcurl4-openssl-dev curl"
|
||||
PACKAGE_NAME=verus-cli-linux.tar.gz
|
||||
PACKAGING_MATRIX="cp src/komodod src/komodo-cli kmd/linux/verus-cli && chmod +x kmd/linux/verus-cli/komodod && chmod +x kmd/linux/verus-cli/komodo-cli && cd kmd/linux && tar -czf $PACKAGE_NAME verus-cli && ls"
|
||||
- compiler: ": Windows"
|
||||
env: RUST_TARGET=x86_64-pc-windows-gnu
|
||||
BUILD_SCRIPT=build-win.sh
|
||||
PACKAGES="build-essential pkg-config libcurl3-gnutls-dev
|
||||
libc6-dev libevent-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git
|
||||
python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev protobuf-compiler
|
||||
libdb++-dev ntp ntpdate mingw-w64 wine bc"
|
||||
PACKAGE_NAME=verus-cli-windows.zip
|
||||
PACKAGING_MATRIX="cp src/komodod.exe src/komodo-cli.exe src/komodo-tx.exe kmd/windows/verus-cli &&
|
||||
cd kmd/windows && zip -r9 $PACKAGE_NAME verus-cli && ls"
|
||||
exclude:
|
||||
- compiler: gcc
|
||||
install:
|
||||
- if [ -n "$PACKAGES" ]; then sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list; fi
|
||||
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
|
||||
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
|
||||
- sudo rm -f /etc/apt/sources.list.d/travis_ci_zeromq3-source.list
|
||||
- travis_retry sudo apt-get -y update && travis_retry sudo apt-get -y install -qq $PACKAGES
|
||||
- if [ -n "$RUST_TARGET" ]; then curl -sSf https://build.travis-ci.org/files/rustup-init.sh
|
||||
| sh -s -- --default-toolchain stable -y && export PATH=$PATH:$HOME/.cargo/bin:$PATH && rustup target add $RUST_TARGET; fi
|
||||
before_script:
|
||||
- unset CC; unset CXX
|
||||
- mkdir -p depends/SDKs depends/sdk-sources
|
||||
- if [ -n "$OSX_SDK" -a ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
|
||||
- if [ -n "$OSX_SDK" -a -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz; fi
|
||||
- make $MAKEJOBS -C depends HOST=$HOST $DEP_OPTS
|
||||
- unset CC; unset CXX
|
||||
script:
|
||||
- if [ -n "$USE_SHELL" ]; then export CONFIG_SHELL="$USE_SHELL"; fi
|
||||
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
|
||||
- BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib"
|
||||
- depends/$HOST/native/bin/ccache --max-size=$CCACHE_SIZE
|
||||
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then export CCACHE_READONLY=1; fi
|
||||
- test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh
|
||||
- ./configure --cache-file=config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
|
||||
- make distdir PACKAGE=bitcoin VERSION=$HOST
|
||||
- cd bitcoin-$HOST
|
||||
- ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG || ( cat config.log && false)
|
||||
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
|
||||
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
|
||||
- if [ "$RUN_TESTS" = "true" ]; then make check; fi
|
||||
- if [ "$RUN_TESTS" = "true" ]; then qa/pull-tester/rpc-tests.sh; fi
|
||||
- "./zcutil/fetch-params.sh"
|
||||
- "./zcutil/$BUILD_SCRIPT -j2"
|
||||
after_script:
|
||||
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then (echo "Upload goes here. Something like: scp -r $BASE_OUTDIR server" || echo "upload failed"); fi
|
||||
>>>>>>> zcash/master
|
||||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then eval "${PACKAGING_MATRIX}" &&
|
||||
gsutil cp $PACKAGE_NAME $STORAGE_DEST; fi
|
||||
notifications:
|
||||
slack:
|
||||
secure: FiVlFhSw5xnDu1Cx2yAo3J7miFCSRyuzR/2+8LKFjdWl5+fyIGvQ9x5vgUg6dWbv3UP9iIMqQuWfotsg8H+NE8pYRZQ0zDVxZ5h9+PA028qGb3OF4TMFNcltP5DGtAZ6AqrMNRZ4ltatPUm5H9ig1bhzjsx+3pqlqQuVXTXPjaUryB5s/fk2CjrsV6zTLfPHiI30jeMjmQrJJLik1vSWF70sB6HkQhvaT6jymkO4Vuh+cja418W1xIgkkoRsOXiZ/JK4hIypFo/sBkmIOprGqoFUahFqJlsBoSrp9iAzkwbDItIqqvNCHTEeN7lj6kK43ZK72E4etjjNc0CXWeleXBJBCj5Prq2lEkQ4NwuDTos3KLyyr2vI7f54xhb5+wjzY9dByHXGuG5UaNz0+uukuJinAdazGaNmmfesv1wg9p3jGa/TLsfHLMcUti875DzkUHnenivP5cXrc6/uuZyyQNq5+Gn/3DA8k0y7d1e23nm3nDjCNfATAn3yu1jieYY2yYI6CYGEXcD+UbP61uG6no+mm/lkQbQosyDfE0sADqGryqXswRste+R0sSVMBQtTipAZOUoYNbEmhN4+L78SSp3zpmgkrIxAw7le8oj6Evp2ofvE2Kvh+Z0MVoEJx6mtZI6hheIFSS38NeUZr/HBfRSpaElOYTN/ZNf8QwThCWo=
|
||||
before_install:
|
||||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_11153c0bb86c_key -iv $encrypted_11153c0bb86c_iv
|
||||
-in AUTH_KEY.json.enc -out AUTH_KEY.json -d; fi
|
||||
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export
|
||||
CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
|
||||
- source /home/travis/google-cloud-sdk/path.bash.inc
|
||||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then gcloud auth activate-service-account --key-file AUTH_KEY.json; fi
|
||||
- if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then rm AUTH_KEY.json; fi
|
||||
- rm AUTH_KEY.json.enc
|
||||
|
||||
BIN
AUTH_KEY.json.enc
Normal file
BIN
AUTH_KEY.json.enc
Normal file
Binary file not shown.
17
Brewfile
Normal file
17
Brewfile
Normal file
@@ -0,0 +1,17 @@
|
||||
tap "discoteq/discoteq"
|
||||
tap "homebrew/bundle"
|
||||
tap "homebrew/cask"
|
||||
tap "homebrew/cask-versions"
|
||||
tap "homebrew/core"
|
||||
brew "autoconf"
|
||||
brew "autogen"
|
||||
brew "automake"
|
||||
brew "binutils"
|
||||
brew "cmake"
|
||||
brew "coreutils"
|
||||
brew "gcc@5"
|
||||
brew "leveldb"
|
||||
brew "nanomsg"
|
||||
brew "protobuf"
|
||||
brew "wget"
|
||||
brew "discoteq/discoteq/flock"
|
||||
3
COPYING
3
COPYING
@@ -1,5 +1,6 @@
|
||||
Copyright (c) 2016-2017 The Zcash developers
|
||||
Copyright (c) 2009-2017 The Bitcoin Core 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
|
||||
@@ -31,7 +32,7 @@ OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic
|
||||
software written by Eric Young (eay@cryptsoft.com).
|
||||
|
||||
|
||||
Although almost all of the Zcash code is licensed under "permissive" open source
|
||||
Although almost all of the Zcash/Komodo/VerusCoin code is licensed under "permissive" open source
|
||||
licenses, users and distributors should note that when built using the default
|
||||
build options, Zcash depends on Oracle Berkeley DB 6.2.x, which is licensed
|
||||
under the GNU Affero General Public License.
|
||||
|
||||
@@ -13,14 +13,14 @@ pkgconfig_DATA = libzcashconsensus.pc
|
||||
endif
|
||||
|
||||
|
||||
BITCOIND_BIN=$(top_builddir)/src/zcashd$(EXEEXT)
|
||||
BITCOIN_CLI_BIN=$(top_builddir)/src/zcash-cli$(EXEEXT)
|
||||
BITCOIND_BIN=$(top_builddir)/src/komodod$(EXEEXT)
|
||||
BITCOIN_CLI_BIN=$(top_builddir)/src/komodo-cli$(EXEEXT)
|
||||
#WALLET_UTILITY_BIN=$(top_builddir)/src/wallet-utility$(EXEEXT)
|
||||
BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EXEEXT)
|
||||
|
||||
if TARGET_DARWIN
|
||||
OSX_APP=Bitcoin-Qt.app
|
||||
OSX_DMG=Bitcoin-Core.dmg
|
||||
OSX_APP=Agama.app
|
||||
OSX_DMG=Agama.dmg
|
||||
OSX_BACKGROUND_IMAGE=background.tiff
|
||||
OSX_DEPLOY_SCRIPT=$(top_srcdir)/contrib/macdeploy/macdeployqtplus
|
||||
OSX_FANCY_PLIST=$(top_srcdir)/contrib/macdeploy/fancy.plist
|
||||
|
||||
@@ -6,28 +6,21 @@ And Homebrew:
|
||||
|
||||
http://brew.sh/
|
||||
|
||||
And this is the list of brew packages you'll need installed:
|
||||
then use the brewfile to install the necessary packages:
|
||||
|
||||
```shell
|
||||
brew tap discoteq/discoteq; brew install flock
|
||||
brew install autoconf autogen automake
|
||||
brew tap homebrew/versions; brew install homebrew/versions/gcc5
|
||||
brew install binutils
|
||||
brew install protobuf
|
||||
brew install coreutils
|
||||
brew install wget
|
||||
brew bundle
|
||||
```
|
||||
|
||||
Get all that installed, then run:
|
||||
|
||||
```shell
|
||||
git clone https://github.com/j-cimb-barker/komodo.git
|
||||
cd komodo
|
||||
git checkout dev
|
||||
git clone https://github.com/VerusCoin/VerusCoin.git
|
||||
cd VerusCoin
|
||||
./zcutil/build-mac.sh
|
||||
```
|
||||
|
||||
To build a distributable version of komodo then run the makeDistrib.sh script after building.
|
||||
To build a distributable version of VerusCoin 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 do a few things in the [Configuration](https://github.com/zcash/zcash/wiki/1.0-User-Guide#configuration) section of the Zcash User Guide differently because we are on the Mac. All instances of `~/.zcash` need to be replaced by `~/Library/Application\ Support/Zcash`
|
||||
The fetch-params.sh script, however, has already been altered to fetch the proving keys into the correct directory to conform to Mac specific naming conventions.
|
||||
|
||||
129
README.md
129
README.md
@@ -1,11 +1,17 @@
|
||||
## VerusCoin version 0.3.10-beta
|
||||
VerusCoin is a new, mineable and stakeable cryptocurrency. It is a live fork of Komodo that retains its Zcash lineage and improves it. VerusCoin will leverage the Komodo platform and dPoW notarization for enhanced security and cross-chain interoperability. We have added a variation of a zawy12, lwma difficulty algorithm, a new CPU-optimized hash algorithm and a new algorithm for fair proof of stake. We describe these changes and vision going forward in a [our Phase I white paper](http://185.25.51.16/papers/VerusPhaseI.pdf) and [our Vision](http://185.25.51.16/papers/VerusVision.pdf).
|
||||
- [VerusCoin web site https://veruscoin.io/ Wallets and CLI tools](https://veruscoin.io/)
|
||||
- [VerusCoin Explorer](https://explorer.veruscoin.io/)
|
||||
|
||||
## Komodo with Bitcore
|
||||
This version of Komodo contains Bitcore support for komodo and all its assetchains.
|
||||
|
||||
## Komodod
|
||||
This software is Komodo client, generally you will use this if you want to mine KMD or setup a full node.
|
||||
It downloads and stores the entire history of Komodo transactions; depending on the speed of your computer and network connection, the synchronization process could take a day or more once the blockchain has reached a significant size.
|
||||
This software is the VerusCoin enhanced Komodo client. Generally, you will use this if you want to mine VRSC or setup a full node. When you run the wallet it launches komodod automatically. On first launch it downloads Zcash parameters, roughly 1GB, which is mildly slow.
|
||||
The wallet downloads and stores the block chain or asset chain of the coin you select. It downloads and stores the entire history of the coins transactions; depending on the speed of your computer and network connection, the synchronization process could take a day or more once the blockchain has reached a significant size.
|
||||
|
||||
## Development Resources
|
||||
- VerusCoin:[https://veruscoin.io/](https://veruscoin.io/) Wallets and CLI tools
|
||||
- Komodo Web: [https://komodoplatform.com/](https://komodoplatform.com/)
|
||||
- Organization web: [https://komodoplatform.com/](https://komodoplatform.com/)
|
||||
- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/)
|
||||
@@ -49,7 +55,7 @@ sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoco
|
||||
Building
|
||||
--------
|
||||
|
||||
First time you'll need to get assorted startup values downloaded. This takes a moderate amount of time once but then does niot need to be repeated unless you bring a new system up. The command is:
|
||||
First time you'll need to get assorted startup values downloaded. This takes a moderate amount of time once but then does not need to be repeated unless you bring a new system up. The command is:
|
||||
```
|
||||
./zcutil/fetch-params.sh
|
||||
```
|
||||
@@ -65,27 +71,14 @@ Building for Windows:
|
||||
```
|
||||
./zcutil/build-win.sh
|
||||
```
|
||||
|
||||
Komodo
|
||||
VerusCoin
|
||||
------
|
||||
We have a release process that goes through several stages before it reaches master. This allows the most conservative users just use the master branch, which is only updated after the other branches have signed off on a release.
|
||||
We develop on dev and some other branches and produce releases of of the master branch, using pull requests to manage what goes into master.
|
||||
|
||||
99% of the activity is in the dev branch, this is where I am testing each change one by one and there are literally thousands of updates. Only use this branch if you really want to be on the bleeding edge. I try to keep things stable, but there are times where necessarily there are bugs in the dev branch, since I am actively developing and debugging here. A good rule is to wait for at least 4 hours from the last update before using the dev branch (unless you know what you are doing)
|
||||
|
||||
After things look good in the dev branch, it is propagated to the beta branch, this is the version the notary nodes use. They are knowledegable command line server guys and so they have a keen eye for anything that wasnt caught during the dev cycle.
|
||||
|
||||
After the notary nodes verify things are working and the latest release is deemed stable, it is propagated to the dPoW branch. From here an automated Jenkins process builds it for all OS, and since the notary nodes are all unix, it is possible for some issues to be caught at this stage. The dPoW branch is what goes into the GUI installers.
|
||||
|
||||
After the GUI are updated and released and it is verified that no significant support issues were created, the master branch is finally updated.
|
||||
|
||||
Master branch: exchanges and users that build from the repo without changing branches
|
||||
dPoW branch: autobuild into GUI installers, unix, osx, windows
|
||||
beta branch: notary nodes, command line unix
|
||||
dev branch: bleeding edge, possibly wont even compile, multiple updates per hour
|
||||
|
||||
```shell
|
||||
git clone https://github.com/jl777/komodo
|
||||
cd komodo
|
||||
git clone https://github.com/VerusCoin/VerusCoin
|
||||
cd VerusCoin
|
||||
#you might want to: git checkout <branch>; git pull
|
||||
./zcutil/fetch-params.sh
|
||||
# -j8 uses 8 threads - replace 8 with number of threads you want to use
|
||||
@@ -93,79 +86,16 @@ cd komodo
|
||||
#This can take some time.
|
||||
```
|
||||
|
||||
**komodo is experimental and a work-in-progress.** Use at your own risk.
|
||||
**The VerusCoin enhanced komodo is experimental and a work-in-progress.** Use at your own risk.
|
||||
|
||||
Deprecation Policy
|
||||
------------------
|
||||
|
||||
This release is considered deprecated one year after the release day. There
|
||||
is an automatic deprecation shutdown feature which will halt the node some
|
||||
time after this one year period. The automatic feature is based on block
|
||||
height and can be explicitly disabled.
|
||||
|
||||
|
||||
# to update an existing version, `git checkout dPoW` if not on that branch already
|
||||
```shell
|
||||
git pull
|
||||
./zcutil/fetch-params.sh
|
||||
./zcutil/build.sh -j8
|
||||
```
|
||||
To reset the blockchain, from *~/.komodo* `rm -rf blocks chainstate debug.log komodostate db.log`
|
||||
|
||||
Create komodo.conf
|
||||
------------------
|
||||
|
||||
```
|
||||
cd ~
|
||||
mkdir .komodo
|
||||
cd .komodo
|
||||
pico komodo.conf
|
||||
#Add the following lines to the komodo.conf file:
|
||||
rpcuser=bitcoinrpc
|
||||
rpcpassword=password
|
||||
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
|
||||
```
|
||||
|
||||
Start mining
|
||||
------------
|
||||
|
||||
```shell
|
||||
#iguana documentation shows how to get the btcpubkey and wifstrs that need to be used
|
||||
#bitcoin also need to be installed with txindex=1 and with rpc enabled
|
||||
cd ~
|
||||
cd komodo
|
||||
#This will return your pubkey eg. "0259e137e5594cf8287195d13aed816af75bd5c04ae673296b51f66e7e8346e8d8" for your address
|
||||
./src/komodo-cli validateaddress <yourwalletaddres>
|
||||
#This will give the privkey of your wallet address
|
||||
./src/komodo-cli dumpprivkey <yourwalletaddres>
|
||||
#This will import the privkey to be sure the mined coins are placed into your wallet address
|
||||
./src/komodo-cli importprivkey <yourwalletprivkey>
|
||||
#To stop the daemon:
|
||||
./src/komodo-cli stop
|
||||
#This starts komodo notary - replace genproclimit with number of threads you want to use and add your pubkey
|
||||
./src/komodod -gen -genproclimit=2 -notary -pubkey="0259e137e5594cf8287195d13aed816af75bd5c04ae673296b51f66e7e8346e8d8" &
|
||||
#This will get the stats:
|
||||
./src/komodo-cli getinfo
|
||||
#To view the process:
|
||||
ps -ef | grep komodod
|
||||
#To stop the daemon:
|
||||
./src/komodo-cli stop
|
||||
|
||||
#To view komodod output:
|
||||
tail -f ~/.komodo/debug.log
|
||||
#To view VRSC output:
|
||||
tail -f ~/.komodo/VRSC/debug.log
|
||||
Note that this directory is correct for Linux, not Mac or Windows
|
||||
#To view all command
|
||||
./src/komodo-cli help
|
||||
ASSETCHAINS: -ac_name=name -ac_supply=nnnnn
|
||||
Both komodod and komodo-cli recognize -ac_name=option so you can create fork from the commandline
|
||||
```
|
||||
=======
|
||||
**Zcash is unfinished and highly experimental.** Use at your own risk.
|
||||
|
||||
Where do I begin?
|
||||
@@ -173,26 +103,8 @@ Where do I begin?
|
||||
We have a guide for joining the main Zcash network:
|
||||
https://github.com/zcash/zcash/wiki/1.0-User-Guide
|
||||
|
||||
### Need Help?
|
||||
* See the documentation at the [Zcash Wiki](https://github.com/zcash/zcash/wiki)
|
||||
for help and more information.
|
||||
* Ask for help on the [Zcash](https://forum.z.cash/) forum.
|
||||
Participation in the Zcash project is subject to a
|
||||
[Code of Conduct](code_of_conduct.md).
|
||||
|
||||
Building
|
||||
--------
|
||||
Build Zcash along with most dependencies from source by running
|
||||
`./zcutil/build.sh`. Currently only Linux is officially supported.
|
||||
|
||||
License
|
||||
-------
|
||||
For license information see the file [COPYING](COPYING).
|
||||
|
||||
**NOTE TO EXCHANGES:**
|
||||
https://bitcointalk.org/index.php?topic=1605144.msg17732151#msg17732151
|
||||
There is a small chance that an outbound transaction will give an error due to mismatched values in wallet calculations. There is a -exchange option that you can run komodod with, but make sure to have the entire transaction history under the same -exchange mode. Otherwise you will get wallet conflicts.
|
||||
|
||||
#Older Komodo Details
|
||||
The remaining text is from the komodo source we forked when creating VerusCoin/Veruscoin.
|
||||
**To change modes:**
|
||||
|
||||
a) backup all privkeys (launch komodod with `-exportdir=<path>` and `dumpwallet`)
|
||||
@@ -250,6 +162,3 @@ Instead of generating 1 secret address, generate 100 and make a script file with
|
||||
./komodo-cli jumblr_secret <addr99>
|
||||
```
|
||||
And make sure to delete all traces of this when the JUMBLR is finished. You will end up with 100 addresses that have an average of 1000 KMD each. So as long as you are careful and dont do a 10,000 KMD transaction (that will link 10 of your secret addresses together), you can appear as 100 different people each with 1000 KMD.
|
||||
|
||||
|
||||
|
||||
|
||||
14
configure.ac
14
configure.ac
@@ -7,16 +7,16 @@ define(_CLIENT_VERSION_BUILD, 50)
|
||||
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
|
||||
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
|
||||
define(_CLIENT_VERSION_IS_RELEASE, true)
|
||||
define(_COPYRIGHT_YEAR, 2017)
|
||||
AC_INIT([Zcash],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://github.com/zcash/zcash/issues],[zcash])
|
||||
define(_COPYRIGHT_YEAR, 2018)
|
||||
AC_INIT([Verus-CLI],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://github.com/VerusCoin/VerusCoin/issues],[verus-cli])
|
||||
AC_CONFIG_SRCDIR([src/main.cpp])
|
||||
AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CONFIG_MACRO_DIR([build-aux/m4])
|
||||
|
||||
BITCOIN_DAEMON_NAME=zcashd
|
||||
BITCOIN_CLI_NAME=zcash-cli
|
||||
BITCOIN_TX_NAME=zcash-tx
|
||||
BITCOIN_DAEMON_NAME=komodod
|
||||
BITCOIN_CLI_NAME=komodo-cli
|
||||
BITCOIN_TX_NAME=komodo-tx
|
||||
|
||||
dnl Unless the user specified ARFLAGS, force it to be cr
|
||||
AC_ARG_VAR(ARFLAGS, [Flags for the archiver, defaults to <cr> if not set])
|
||||
@@ -232,7 +232,7 @@ CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
|
||||
|
||||
AC_ARG_WITH([utils],
|
||||
[AS_HELP_STRING([--with-utils],
|
||||
[build zcash-cli zcash-tx wallet-utility (default=yes)])],
|
||||
[build komodo-cli komodo-tx wallet-utility (default=yes)])],
|
||||
[build_bitcoin_utils=$withval],
|
||||
[build_bitcoin_utils=yes])
|
||||
|
||||
@@ -805,7 +805,7 @@ AC_MSG_CHECKING([whether to build bitcoind])
|
||||
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
|
||||
AC_MSG_RESULT($build_bitcoind)
|
||||
|
||||
AC_MSG_CHECKING([whether to build utils (zcash-cli zcash-tx wallet-utility)])
|
||||
AC_MSG_CHECKING([whether to build utils (komodo-cli komodo-tx wallet-utility)])
|
||||
AM_CONDITIONAL([BUILD_BITCOIN_UTILS], [test x$build_bitcoin_utils = xyes])
|
||||
AC_MSG_RESULT($build_bitcoin_utils)
|
||||
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
Source: zcash
|
||||
Source: VerusCoin
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: Zcash Company <team@z.cash>
|
||||
Homepage: https://z.cash
|
||||
Maintainer: VerusCoin <team@z.cash>
|
||||
Homepage: https://veruscoin.io
|
||||
Build-Depends: autoconf, automake, bsdmainutils, build-essential,
|
||||
git, g++-multilib, libc6-dev, libtool,
|
||||
m4, ncurses-dev, pkg-config, python,
|
||||
unzip, wget, zlib1g-dev
|
||||
Vcs-Git: https://github.com/zcash/zcash.git
|
||||
Vcs-Browser: https://github.com/zcash/zcash
|
||||
Vcs-Git: https://github.com/VeruscCoin/VerusCoin.git
|
||||
Vcs-Browser: https://github.com/VerusCoin/VerusCoin
|
||||
|
||||
Package: zcash
|
||||
Package: Verus-CLI
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: HTTPS for money.
|
||||
Based on Bitcoin's code, it intends to offer a far higher standard
|
||||
of privacy and anonymity through a sophisticiated zero-knowledge
|
||||
proving scheme which preserves confidentiality of transaction metadata.
|
||||
This package provides the daemon, zcashd, and the CLI tool,
|
||||
zcash-cli, to interact with the daemon.
|
||||
Description: VerusCoin is a new, mineable and stakeable cryptocurrency.
|
||||
It is a live fork of Komodo that retains its Zcash lineage and improves it.
|
||||
VerusCoin will leverage the Komodo platform and dPoW notarization for enhanced security and cross-chain interoperability.
|
||||
We have added a variation of a zawy12, lwma difficulty algorithm, a new CPU-optimized hash algorithm and a new algorithm for fair proof of stake.
|
||||
We describe these changes and vision going forward in a [our Phase I white paper](http://185.25.51.16/papers/VerusPhaseI.pdf) and
|
||||
[our Vision](http://185.25.51.16/papers/VerusVision.pdf).
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
usr/bin/zcashd
|
||||
usr/bin/zcash-cli
|
||||
usr/bin/komodod
|
||||
usr/bin/komodo-cli
|
||||
usr/bin/zcash-fetch-params
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
'''
|
||||
Run this script inside of src/ and it will look for all the files
|
||||
that were changed this year that still have the last year in the
|
||||
@@ -46,7 +48,7 @@ for extension in extensions:
|
||||
filePath = os.getcwd() + filePath
|
||||
modifiedTime = getLastGitModifiedDate(filePath)
|
||||
if len(modifiedTime) > 0 and str(year) in modifiedTime:
|
||||
print n,"Last Git Modified: ", modifiedTime, " - ", filePath
|
||||
print(n, "Last Git Modified: ", modifiedTime, " - ", filePath)
|
||||
os.popen(command % (last_year,year,filePath))
|
||||
n = n + 1
|
||||
|
||||
|
||||
12
kmd/linux/verus-cli/README.txt
Normal file
12
kmd/linux/verus-cli/README.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
VerusCoin Command Line Tools v0.3.10-beta
|
||||
Contents:
|
||||
komodod - VerusCoin's enhanced Komodo daemon
|
||||
komodo-cli - VerusCoin's Komodo command line utility
|
||||
verus - wrapper for komodo-cli that applies the command to the VRSC coin
|
||||
verusd - wrapper for komodod that sets the VerusCoin parameters to defaults properly
|
||||
|
||||
The first time on a new system you will need to run ./fetch-params before using komodod or verusd.
|
||||
|
||||
Run ./verusd to launch komodod, and use verus to run commands such as:
|
||||
./verus stop
|
||||
Which signals komodod (if it is running) to stop running.
|
||||
165
kmd/linux/verus-cli/fetch-params
Normal file
165
kmd/linux/verus-cli/fetch-params
Normal file
@@ -0,0 +1,165 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
PARAMS_DIR="$HOME/.zcash-params"
|
||||
|
||||
SPROUT_PKEY_NAME='sprout-proving.key'
|
||||
SPROUT_VKEY_NAME='sprout-verifying.key'
|
||||
SPROUT_URL="https://z.cash/downloads"
|
||||
SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo"
|
||||
|
||||
SHA256CMD="$(command -v sha256sum || echo shasum)"
|
||||
SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"
|
||||
|
||||
WGETCMD="$(command -v wget || echo '')"
|
||||
IPFSCMD="$(command -v ipfs || echo '')"
|
||||
|
||||
# fetch methods can be disabled with ZC_DISABLE_SOMETHING=1
|
||||
ZC_DISABLE_WGET="${ZC_DISABLE_WGET:-}"
|
||||
ZC_DISABLE_IPFS="${ZC_DISABLE_IPFS:-}"
|
||||
|
||||
function fetch_wget {
|
||||
if [ -z "$WGETCMD" ] || ! [ -z "$ZC_DISABLE_WGET" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local filename="$1"
|
||||
local dlname="$2"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Retrieving (wget): $SPROUT_URL/$filename
|
||||
EOF
|
||||
|
||||
wget \
|
||||
--progress=dot:giga \
|
||||
--output-document="$dlname" \
|
||||
--continue \
|
||||
--retry-connrefused --waitretry=3 --timeout=30 \
|
||||
"$SPROUT_URL/$filename"
|
||||
}
|
||||
|
||||
function fetch_ipfs {
|
||||
if [ -z "$IPFSCMD" ] || ! [ -z "$ZC_DISABLE_IPFS" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local filename="$1"
|
||||
local dlname="$2"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Retrieving (ipfs): $SPROUT_IPFS/$filename
|
||||
EOF
|
||||
|
||||
ipfs get --output "$dlname" "$SPROUT_IPFS/$filename"
|
||||
}
|
||||
|
||||
function fetch_failure {
|
||||
cat >&2 <<EOF
|
||||
|
||||
Failed to fetch the Zcash zkSNARK parameters!
|
||||
Try installing one of the following programs and make sure you're online:
|
||||
|
||||
* ipfs
|
||||
* wget
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
function fetch_params {
|
||||
local filename="$1"
|
||||
local output="$2"
|
||||
local dlname="${output}.dl"
|
||||
local expectedhash="$3"
|
||||
|
||||
if ! [ -f "$output" ]
|
||||
then
|
||||
for method in wget ipfs failure; do
|
||||
if "fetch_$method" "$filename" "$dlname"; then
|
||||
echo "Download successful!"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
"$SHA256CMD" $SHA256ARGS -c <<EOF
|
||||
$expectedhash $dlname
|
||||
EOF
|
||||
|
||||
# Check the exit code of the shasum command:
|
||||
CHECKSUM_RESULT=$?
|
||||
if [ $CHECKSUM_RESULT -eq 0 ]; then
|
||||
mv -v "$dlname" "$output"
|
||||
else
|
||||
echo "Failed to verify parameter checksums!" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Use flock to prevent parallel execution.
|
||||
function lock() {
|
||||
local lockfile=/tmp/fetch_params.lock
|
||||
# create lock file
|
||||
eval "exec 200>/$lockfile"
|
||||
# acquire the lock
|
||||
flock -n 200 \
|
||||
&& return 0 \
|
||||
|| return 1
|
||||
}
|
||||
|
||||
function exit_locked_error {
|
||||
echo "Only one instance of fetch-params.sh can be run at a time." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
lock fetch-params.sh \
|
||||
|| exit_locked_error
|
||||
|
||||
cat <<EOF
|
||||
Zcash - fetch-params.sh
|
||||
|
||||
This script will fetch the Zcash zkSNARK parameters and verify their
|
||||
integrity with sha256sum.
|
||||
|
||||
If they already exist locally, it will exit now and do nothing else.
|
||||
EOF
|
||||
|
||||
# Now create PARAMS_DIR and insert a README if necessary:
|
||||
if ! [ -d "$PARAMS_DIR" ]
|
||||
then
|
||||
mkdir -p "$PARAMS_DIR"
|
||||
README_PATH="$PARAMS_DIR/README"
|
||||
cat >> "$README_PATH" <<EOF
|
||||
This directory stores common Zcash zkSNARK parameters. Note that it is
|
||||
distinct from the daemon's -datadir argument because the parameters are
|
||||
large and may be shared across multiple distinct -datadir's such as when
|
||||
setting up test networks.
|
||||
EOF
|
||||
|
||||
# This may be the first time the user's run this script, so give
|
||||
# them some info, especially about bandwidth usage:
|
||||
cat <<EOF
|
||||
The parameters are currently just under 911MB in size, so plan accordingly
|
||||
for your bandwidth constraints. If the files are already present and
|
||||
have the correct sha256sum, no networking is used.
|
||||
|
||||
Creating params directory. For details about this directory, see:
|
||||
$README_PATH
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
||||
cd "$PARAMS_DIR"
|
||||
|
||||
fetch_params "$SPROUT_PKEY_NAME" "$PARAMS_DIR/$SPROUT_PKEY_NAME" "8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7"
|
||||
fetch_params "$SPROUT_VKEY_NAME" "$PARAMS_DIR/$SPROUT_VKEY_NAME" "4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82"
|
||||
}
|
||||
|
||||
main
|
||||
rm -f /tmp/fetch_params.lock
|
||||
exit 0
|
||||
5
kmd/linux/verus-cli/verus
Executable file
5
kmd/linux/verus-cli/verus
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
|
||||
./komodo-cli -ac_name=VRSC "$@"
|
||||
4
kmd/linux/verus-cli/verusd
Executable file
4
kmd/linux/verus-cli/verusd
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -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 -addnode=185.25.48.236 -addnode=185.64.105.111 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 "$@"
|
||||
17
kmd/mac/verus-cli/README.txt
Normal file
17
kmd/mac/verus-cli/README.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
VerusCoin Command Line Tools v0.3.9-beta
|
||||
Contents:
|
||||
komodod - VerusCoin's enhanced Komodo daemon.
|
||||
komodo-cli - VerusCoin's enhanced Komodo command line utility.
|
||||
verus - wrapper for komodo-cli that applies the command to the VRSC coin
|
||||
verusd - wrapper for komodod that sets the VerusCoin parameters to defaults properly
|
||||
fetch_params.sh - utility to download the zcash parameters needed to start the VerusCoin command line tools and scripts
|
||||
lib*.dylib - assorted dynamic libraries, dependencies needed by fetch-params.sh, komodod and/or komodo-cli
|
||||
|
||||
Command line tools are run from the terminal. You can launch the terminal on a Mac by using the Finder, selecting Applications and from that select Utilities, finally selecting Terminal from the Utilities folder.
|
||||
You will need to switch to the directory you extracted the verus-cl into. If you extracted it in the Download folder then the change directory command is
|
||||
cd ~/Downloads/verus-cli
|
||||
The first time on a new system you will need to run ./fetch-params before using komodod or verusd.
|
||||
|
||||
Run ./verusd to launch komodod, and use verus to run commands such as:
|
||||
./verus stop
|
||||
Which signals komodod (if it is running) to stop running.
|
||||
7
kmd/mac/verus-cli/fetch-params
Normal file
7
kmd/mac/verus-cli/fetch-params
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
curl "https://z.cash/downloads/sprout-proving.key" -o "$HOME/Library/Application Support/ZcashParams/sprout-proving.key"
|
||||
curl "https://z.cash/downloads/sprout-verifying.key" -o "$HOME/Library/Application Support/ZcashParams/sprout-verifying.key"
|
||||
|
||||
|
||||
7
kmd/mac/verus-cli/verus
Executable file
7
kmd/mac/verus-cli/verus
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
#set working directory to the location of this script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
|
||||
./komodo-cli -ac_name=VRSC "$@"
|
||||
6
kmd/mac/verus-cli/verusd
Executable file
6
kmd/mac/verus-cli/verusd
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
#set working directory to the location of this script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
|
||||
./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -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 -addnode=185.25.48.236 -addnode=185.64.105.111 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 "$@"
|
||||
21
kmd/windows/verus-cli/README.txt
Normal file
21
kmd/windows/verus-cli/README.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
VerusCoin Command Line Tools v0.3.10-beta
|
||||
Contents:
|
||||
komodod.exe - VerusCoin's enhanced Komodo daemon
|
||||
komodo-cli.exe - VerusCoin's Komodo command line utility
|
||||
verus.bat - wrapper for komodo-cli that applies the command to the VRSC coin
|
||||
verusd.bat - wrapper for komodod that sets the VerusCoin parameters to defaults properly
|
||||
|
||||
You need to run a command prompt, for example hit <Ctrl><Esc> and type cmd<Enter>
|
||||
From the command prompt change to the directory where you installed verus-cli. If you downloaded the file to your Downloads directory and extracted it there then the change directory command is
|
||||
cd \Users\MyName\Downloads\verus-cli
|
||||
From this directory you can run the Verus command line utilities.
|
||||
The first time on a new system you will need to run fetch-params before using komodod.exe or verusd.
|
||||
Many anti-virus products interfere with the VerusCoin tool's ability to open ports and will need to be configured to allow what the scanner says is unsafe behavior.
|
||||
Extreme cases can result in the virus scanner deleting Agama.exe or moving it to "protect" the system. You will to add the executables to a whitelist and re-extract the verus-cli-windows.zip file if that happens.
|
||||
Run verusd.bat to launch komodod, and use verus.bat to run commands such as:
|
||||
verus.bat stop
|
||||
Which signals komodod.exe (if it is running) to stop running.
|
||||
|
||||
Note that if you pass in command line options to verus.bat or verusd.bat that include an = like -ac_veruspos=50 you must surround it with double quotes like this:
|
||||
verusd.bat "-ac_veruspos=50"
|
||||
Otherwise Windows will drop the = and pass the two values in as separate command line options.
|
||||
21
kmd/windows/verus-cli/fetch-params.bat
Normal file
21
kmd/windows/verus-cli/fetch-params.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
call :GET_CURRENT_DIR
|
||||
cd %THIS_DIR%
|
||||
IF NOT EXIST %APPDATA%\ZcashParams (
|
||||
MKDIR %APPDATA%\ZcashParams
|
||||
)
|
||||
IF NOT EXIST %APPDATA%\ZcashParams\sprout-proving.key (
|
||||
ECHO Downloading Zcash trusted setup sprout-proving.key, this may take a while ...
|
||||
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-proving.key -O %APPDATA%\ZcashParams\sprout-proving.key
|
||||
)
|
||||
IF NOT EXIST %APPDATA%\ZcashParams\sprout-verifying.key (
|
||||
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
|
||||
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-verifying.key -O %APPDATA%\ZcashParams\sprout-verifying.key
|
||||
)
|
||||
goto :EOF
|
||||
:GET_CURRENT_DIR
|
||||
pushd %~dp0
|
||||
set THIS_DIR=%CD%
|
||||
popd
|
||||
goto :EOF
|
||||
|
||||
14
kmd/windows/verus-cli/verus.bat
Normal file
14
kmd/windows/verus-cli/verus.bat
Normal file
@@ -0,0 +1,14 @@
|
||||
@call :GET_CURRENT_DIR
|
||||
@cd %THIS_DIR%
|
||||
komodo-cli.exe -ac_name=VRSC %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
@goto :EOF
|
||||
|
||||
:GET_CURRENT_DIR
|
||||
@pushd %~dp0
|
||||
@set THIS_DIR=%CD%
|
||||
@popd
|
||||
@goto :EOF
|
||||
|
||||
|
||||
|
||||
|
||||
10
kmd/windows/verus-cli/verusd.bat
Normal file
10
kmd/windows/verus-cli/verusd.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
@call :GET_CURRENT_DIR
|
||||
@cd %THIS_DIR%
|
||||
komodod.exe -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -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 -addnode=185.25.48.236 -addnode=185.64.105.111 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
@goto :EOF
|
||||
|
||||
:GET_CURRENT_DIR
|
||||
@pushd %~dp0
|
||||
@set THIS_DIR=%CD%
|
||||
@popd
|
||||
@goto :EOF
|
||||
BIN
kmd/windows/verus-cli/wget64.exe
Normal file
BIN
kmd/windows/verus-cli/wget64.exe
Normal file
Binary file not shown.
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
TMP_DIR=~/tmp/komodo
|
||||
|
||||
# make a tmp directory
|
||||
mkdir -p $TMP_DIR
|
||||
echo "making $TMP_DIR"
|
||||
|
||||
binaries=("komodo-cli" "komodod")
|
||||
|
||||
for binary in "${binaries[@]}";
|
||||
do
|
||||
echo "copying $binary to $TMP_DIR"
|
||||
|
||||
cp src/$binary $TMP_DIR
|
||||
|
||||
# find the dylibs to copy for komodod
|
||||
DYLIBS=`otool -L $TMP_DIR/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'`
|
||||
echo "copying $DYLIBS to $TMP_DIR"
|
||||
|
||||
# copy the dylibs to the tmpdir
|
||||
for dylib in $DYLIBS; do cp -rf $dylib $TMP_DIR/; done
|
||||
|
||||
# modify komodod to point to dylibs
|
||||
echo "modifying $binary to use local libraries"
|
||||
for dylib in $DYLIBS; do install_name_tool -change $dylib @executable_path/`basename $dylib` $TMP_DIR/$binary; done;
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
binaries=("komodo-cli" "komodod")
|
||||
|
||||
for binary in "${binaries[@]}";
|
||||
do
|
||||
# find the dylibs to copy for komodod
|
||||
DYLIBS=`otool -L src/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'`
|
||||
echo "copying $DYLIBS to $src"
|
||||
# copy the dylibs to the srcdir
|
||||
for dylib in $DYLIBS; do cp -rf $dylib src/; done
|
||||
|
||||
# modify komodod to point to dylibs
|
||||
echo "modifying $binary to use local libraries"
|
||||
for dylib in $DYLIBS; do install_name_tool -change $dylib @executable_path/`basename $dylib` src/$binary; done;
|
||||
chmod +x src/$binary
|
||||
done
|
||||
8
makeReleaseLinux.sh
Executable file
8
makeReleaseLinux.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
cp src/komodod src/komodo-cli kmd/linux/verus-cli
|
||||
chmod +x kmd/linux/verus-cli/komodo
|
||||
chmod +x kmd/linux/verus-cli/komodod
|
||||
chmod +x kmd/linux/verus-cli/verus
|
||||
chmod +x kmd/linux/verus-cli/verusd
|
||||
chmod +x kmd/linux/verus-cli/fetch-params
|
||||
72
makeReleaseMac.sh
Executable file
72
makeReleaseMac.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
KMD_DIR=kmd/mac/verus-cli
|
||||
|
||||
binaries=("komodo-cli" "komodod")
|
||||
alllibs=()
|
||||
for binary in "${binaries[@]}";
|
||||
do
|
||||
# do the work in the destination directory
|
||||
cp src/$binary $KMD_DIR
|
||||
# find the dylibs to copy for komodod
|
||||
DYLIBS=`otool -L $KMD_DIR/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'`
|
||||
echo "copying $DYLIBS to $KMD_DIR"
|
||||
# copy the dylibs to the srcdir
|
||||
for dylib in $DYLIBS; do cp -rf $dylib $KMD_DIR; done
|
||||
done
|
||||
|
||||
libraries=("libgcc_s.1.dylib" "libgomp.1.dylib" "libidn2.0.dylib" "libstdc++.6.dylib")
|
||||
|
||||
for binary in "${libraries[@]}";
|
||||
do
|
||||
# Need to undo this for the dylibs when we are done
|
||||
chmod 755 $KMD_DIR/$binary
|
||||
# find the dylibs to copy for komodod
|
||||
DYLIBS=`otool -L $KMD_DIR/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'`
|
||||
echo "copying $DYLIBS to $KMD_DIR"
|
||||
# copy the dylibs to the srcdir
|
||||
for dylib in $DYLIBS; do cp -rf $dylib $KMD_DIR; alllibs+=($dylib); done
|
||||
done
|
||||
|
||||
indirectlibraries=("libintl.8.dylib" "libunistring.2.dylib")
|
||||
|
||||
for binary in "${indirectlibraries[@]}";
|
||||
do
|
||||
# Need to undo this for the dylibs when we are done
|
||||
chmod 755 src/$binary
|
||||
# find the dylibs to copy for komodod
|
||||
DYLIBS=`otool -L $KMD_DIR/$binary | grep "/usr/local" | awk -F' ' '{ print $1 }'`
|
||||
echo "copying indirect $DYLIBS to $KMD_DIR"
|
||||
# copy the dylibs to the dest dir
|
||||
for dylib in $DYLIBS; do cp -rf $dylib $KMD_DIR; alllibs+=($dylib); done
|
||||
done
|
||||
|
||||
for binary in "${binaries[@]}";
|
||||
do
|
||||
# modify komodod to point to dylibs
|
||||
echo "modifying $binary to use local libraries"
|
||||
for dylib in "${alllibs[@]}"
|
||||
do
|
||||
echo "Next lib is $dylib "
|
||||
install_name_tool -change $dylib @executable_path/`basename $dylib` $KMD_DIR/$binary
|
||||
done
|
||||
chmod +x $KMD_DIR/$binary
|
||||
done
|
||||
|
||||
for binary in "${libraries[@]}";
|
||||
do
|
||||
# modify libraries to point to dylibs
|
||||
echo "modifying $binary to use local libraries"
|
||||
for dylib in "${alllibs[@]}"
|
||||
do
|
||||
echo "Next lib is $dylib "
|
||||
install_name_tool -change $dylib @executable_path/`basename $dylib` $KMD_DIR/$binary
|
||||
done
|
||||
chmod +x $KMD_DIR/$binary
|
||||
done
|
||||
|
||||
chmod +x kmd/mac/verus-cli/fetch-params
|
||||
chmod +x kmd/linux/verus-cli/verus
|
||||
chmod +x kmd/linux/verus-cli/verusd
|
||||
|
||||
|
||||
3
makeReleaseWindows.sh
Executable file
3
makeReleaseWindows.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
cp src/komodod.exe src/komodo-cli.exe src/komodo-tx.exe kmd/windows/verus-cli
|
||||
39
qa/verus-cli-tests/verus-cli-tester.py
Normal file
39
qa/verus-cli-tests/verus-cli-tester.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from subprocess import Popen, check_output, call
|
||||
from time import sleep
|
||||
from os import environ, path
|
||||
|
||||
daemon_wrapper = "verusd"
|
||||
cli_wrapper = "verus"
|
||||
daemon_runtime_seconds = 600
|
||||
cli_commands = ["getblockchaininfo", "getmininginfo", "getwalletinfo", "stop"]
|
||||
|
||||
|
||||
def start_daemon(daemon_wrapper):
|
||||
try:
|
||||
Popen(daemon_wrapper, shell=True, close_fds=True)
|
||||
except:
|
||||
exit(1)
|
||||
|
||||
|
||||
def fetch_zcash_params():
|
||||
try:
|
||||
call("fetch-params", shell=True)
|
||||
except:
|
||||
exit(1)
|
||||
|
||||
|
||||
def run_cli_commands(cli_wrapper, commands):
|
||||
for command in commands:
|
||||
command = "%(cli_wrapper)s %(command)s" % locals()
|
||||
try:
|
||||
with open(path.join(environ["CI_PROJECT_DIR"], "log.txt"), "a") as log:
|
||||
command_output = check_output(command, shell=True)
|
||||
log.write("%(command_output)s\n" % locals())
|
||||
except:
|
||||
exit(1)
|
||||
|
||||
|
||||
fetch_zcash_params()
|
||||
start_daemon(daemon_wrapper)
|
||||
sleep(daemon_runtime_seconds)
|
||||
run_cli_commands(cli_wrapper, cli_commands)
|
||||
18
requirements-debian.txt
Normal file
18
requirements-debian.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
autoconf
|
||||
automake
|
||||
bsdmainutils
|
||||
build-essential
|
||||
curl
|
||||
g++-multilib
|
||||
git
|
||||
libc6-dev
|
||||
libcurl4-openssl-dev
|
||||
libtool
|
||||
ncurses-dev
|
||||
pkg-config
|
||||
python
|
||||
python-zmq
|
||||
m4
|
||||
unzip
|
||||
wget
|
||||
zlib1g-dev
|
||||
@@ -164,8 +164,10 @@ 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 \
|
||||
haraka.h \
|
||||
hash.h \
|
||||
httprpc.h \
|
||||
httpserver.h \
|
||||
@@ -189,6 +191,7 @@ BITCOIN_CORE_H = \
|
||||
pow.h \
|
||||
primitives/block.h \
|
||||
primitives/transaction.h \
|
||||
primitives/nonce.h \
|
||||
protocol.h \
|
||||
pubkey.h \
|
||||
random.h \
|
||||
@@ -235,6 +238,7 @@ BITCOIN_CORE_H = \
|
||||
wallet/wallet.h \
|
||||
wallet/wallet_ismine.h \
|
||||
wallet/walletdb.h \
|
||||
veruslaunch.h \
|
||||
zmq/zmqabstractnotifier.h \
|
||||
zmq/zmqconfig.h\
|
||||
zmq/zmqnotificationinterface.h \
|
||||
@@ -264,6 +268,10 @@ libbitcoin_server_a_SOURCES = \
|
||||
cc/betprotocol.cpp \
|
||||
chain.cpp \
|
||||
checkpoints.cpp \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp \
|
||||
deprecation.cpp \
|
||||
httprpc.cpp \
|
||||
httpserver.cpp \
|
||||
@@ -361,6 +369,8 @@ crypto_libbitcoin_crypto_a_SOURCES = \
|
||||
crypto/sha256.h \
|
||||
crypto/sha512.cpp \
|
||||
crypto/sha512.h \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp
|
||||
|
||||
@@ -381,7 +391,9 @@ crypto_libverus_crypto_a_CPPFLAGS = -O3 -Wint-conversion -march=native -funroll-
|
||||
crypto_libverus_crypto_a_CXXFLAGS = -O3 -Wint-conversion -march=native -funroll-loops -fomit-frame-pointer -fPIC $(AM_CXXFLAGS)
|
||||
crypto_libverus_crypto_a_SOURCES = \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka.c
|
||||
crypto/haraka.c \
|
||||
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)
|
||||
@@ -396,12 +408,17 @@ libbitcoin_common_a_SOURCES = \
|
||||
consensus/upgrades.cpp \
|
||||
core_read.cpp \
|
||||
core_write.cpp \
|
||||
crypto/haraka.h \
|
||||
crypto/haraka_portable.h \
|
||||
crypto/verus_hash.h \
|
||||
crypto/verus_hash.cpp \
|
||||
hash.cpp \
|
||||
key.cpp \
|
||||
keystore.cpp \
|
||||
netbase.cpp \
|
||||
primitives/block.cpp \
|
||||
primitives/transaction.cpp \
|
||||
primitives/nonce.cpp \
|
||||
protocol.cpp \
|
||||
pubkey.cpp \
|
||||
scheduler.cpp \
|
||||
@@ -412,6 +429,7 @@ libbitcoin_common_a_SOURCES = \
|
||||
script/script_error.cpp \
|
||||
script/sign.cpp \
|
||||
script/standard.cpp \
|
||||
veruslaunch.cpp \
|
||||
$(BITCOIN_CORE_H) \
|
||||
$(LIBZCASH_H)
|
||||
|
||||
@@ -529,6 +547,7 @@ komodo_cli_LDADD = \
|
||||
$(EVENT_LIBS) \
|
||||
$(LIBZCASH) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBVERUS_CRYPTO) \
|
||||
$(LIBZCASH_LIBS)
|
||||
|
||||
if ENABLE_WALLET
|
||||
@@ -609,6 +628,7 @@ libzcashconsensus_la_SOURCES = \
|
||||
crypto/sha512.cpp \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
primitives/nonce.cpp \
|
||||
pubkey.cpp \
|
||||
script/zcashconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
|
||||
@@ -302,6 +302,14 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBitcoinAddress::GetKeyID_NoCheck(CKeyID& keyID) const
|
||||
{
|
||||
uint160 id;
|
||||
memcpy(&id, &vchData[0], 20);
|
||||
keyID = CKeyID(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBitcoinAddress::IsScript() const
|
||||
{
|
||||
return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
|
||||
|
||||
@@ -163,6 +163,7 @@ public:
|
||||
|
||||
CTxDestination Get() const;
|
||||
bool GetKeyID(CKeyID &keyID) const;
|
||||
bool GetKeyID_NoCheck(CKeyID& keyID) const;
|
||||
bool GetIndexKey(uint160& hashBytes, int& type) const;
|
||||
bool IsScript() const;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,7 @@ using namespace std;
|
||||
* CChain implementation
|
||||
*/
|
||||
void CChain::SetTip(CBlockIndex *pindex) {
|
||||
lastTip = pindex;
|
||||
if (pindex == NULL) {
|
||||
vChain.clear();
|
||||
return;
|
||||
|
||||
16
src/chain.h
16
src/chain.h
@@ -321,6 +321,16 @@ public:
|
||||
//! Efficiently find an ancestor of this block.
|
||||
CBlockIndex* GetAncestor(int height);
|
||||
const CBlockIndex* GetAncestor(int height) const;
|
||||
|
||||
int32_t GetVerusPOSTarget() const
|
||||
{
|
||||
return GetBlockHeader().GetVerusPOSTarget();
|
||||
}
|
||||
|
||||
bool IsVerusPOSBlock() const
|
||||
{
|
||||
return GetBlockHeader().IsVerusPOSBlock();
|
||||
}
|
||||
};
|
||||
|
||||
/** Used to marshal pointers into hashes for db storage. */
|
||||
@@ -414,6 +424,7 @@ public:
|
||||
class CChain {
|
||||
private:
|
||||
std::vector<CBlockIndex*> vChain;
|
||||
CBlockIndex *lastTip;
|
||||
|
||||
public:
|
||||
/** Returns the index entry for the genesis block of this chain, or NULL if none. */
|
||||
@@ -426,6 +437,11 @@ public:
|
||||
return vChain.size() > 0 ? vChain[vChain.size() - 1] : NULL;
|
||||
}
|
||||
|
||||
/** Returns the last tip of the chain, or NULL if none. */
|
||||
CBlockIndex *LastTip() const {
|
||||
return vChain.size() > 0 ? lastTip : NULL;
|
||||
}
|
||||
|
||||
/** Returns the index entry at a particular height in this chain, or NULL if no such height exists. */
|
||||
CBlockIndex *operator[](int nHeight) const {
|
||||
if (nHeight < 0 || nHeight >= (int)vChain.size())
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
{
|
||||
strNetworkID = "main";
|
||||
strCurrencyUnits = "KMD";
|
||||
consensus.fCoinbaseMustBeProtected = false;//true;
|
||||
consensus.fCoinbaseMustBeProtected = false; // true this is only true wuth Verus and enforced after block 12800
|
||||
consensus.nSubsidySlowStartInterval = 20000;
|
||||
consensus.nSubsidyHalvingInterval = 840000;
|
||||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||
@@ -176,6 +176,8 @@ public:
|
||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
|
||||
// guarantees the first two characters, when base58 encoded, are "zc"
|
||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {22,154};
|
||||
// guarantees the first 4 characters, when base58 encoded, are "ZiVK"
|
||||
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAB,0xD3};
|
||||
// guarantees the first two characters, when base58 encoded, are "SK"
|
||||
base58Prefixes[ZCSPENDING_KEY] = {171,54};
|
||||
|
||||
@@ -232,6 +234,12 @@ void *chainparams_commandline(void *ptr)
|
||||
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
|
||||
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
|
||||
|
||||
// only require coinbase protection on Verus from the Komodo family of coins
|
||||
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
|
||||
{
|
||||
mainParams.consensus.fCoinbaseMustBeProtected = true;
|
||||
}
|
||||
|
||||
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH)
|
||||
{
|
||||
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
|
||||
@@ -250,18 +258,20 @@ void *chainparams_commandline(void *ptr)
|
||||
mainParams.consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
|
||||
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
|
||||
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
|
||||
mainParams.consensus.nLwmaPOSAjustedWeight = 45000;
|
||||
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
|
||||
}
|
||||
|
||||
checkpointData = //(Checkpoints::CCheckpointData)
|
||||
{
|
||||
boost::assign::map_list_of
|
||||
(0, mainParams.consensus.hashGenesisBlock),
|
||||
//(2500, uint256S("0x0e6a3d5a46eba97c4e7618d66a39f115729e1176433c98481124c2bf733aa54e"))
|
||||
//(15000, uint256S("0x00f0bd236790e903321a2d22f85bd6bf8a505f6ef4eddb20458a65d37e14d142")),
|
||||
//(100000, uint256S("0x0f02eb1f3a4b89df9909fec81a4bd7d023e32e24e1f5262d9fc2cc36a715be6f")),
|
||||
(int64_t)1481120910, // * UNIX timestamp of last checkpoint block
|
||||
(int64_t)110415, // * total number of transactions between genesis and last checkpoint
|
||||
(0, mainParams.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))
|
||||
@@ -493,6 +503,8 @@ public:
|
||||
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
|
||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
|
||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {20,81};
|
||||
// guarantees the first 4 characters, when base58 encoded, are "ZiVt"
|
||||
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAC,0x0C};
|
||||
base58Prefixes[ZCSPENDING_KEY] = {177,235};
|
||||
|
||||
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
|
||||
|
||||
@@ -253,7 +253,16 @@ bool CCoinsViewCache::HaveCoins(const uint256 &txid) const {
|
||||
|
||||
uint256 CCoinsViewCache::GetBestBlock() const {
|
||||
if (hashBlock.IsNull())
|
||||
{
|
||||
if (base)
|
||||
{
|
||||
hashBlock = base->GetBestBlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
hashBlock = uint256();
|
||||
}
|
||||
}
|
||||
return hashBlock;
|
||||
}
|
||||
|
||||
@@ -379,17 +388,34 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
|
||||
return coins->vout[input.prevout.n];
|
||||
}
|
||||
|
||||
const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const
|
||||
{
|
||||
const CCoins* coins = AccessCoins(input.prevout.hash);
|
||||
assert(coins);
|
||||
return coins->vout[input.prevout.n].scriptPubKey;
|
||||
}
|
||||
|
||||
//uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
|
||||
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
|
||||
const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& input)
|
||||
{
|
||||
assert(coins);
|
||||
if (coins->nHeight < 6400 && !strcmp(ASSETCHAINS_SYMBOL, "VRSC"))
|
||||
{
|
||||
std::string hc = input.prevout.hash.ToString();
|
||||
if (LaunchMap().lmap.count(hc))
|
||||
{
|
||||
CTransactionExceptionData &txData = LaunchMap().lmap[hc];
|
||||
if ((txData.voutMask & (((uint64_t)1) << (uint64_t)input.prevout.n)) != 0)
|
||||
{
|
||||
return txData.scriptPubKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
return coins->vout[input.prevout.n].scriptPubKey;
|
||||
}
|
||||
|
||||
const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const
|
||||
{
|
||||
const CCoins* coins = AccessCoins(input.prevout.hash);
|
||||
return GetSpendFor(coins, input);
|
||||
}
|
||||
|
||||
CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const
|
||||
{
|
||||
if ( interestp != 0 )
|
||||
|
||||
39
src/coins.h
39
src/coins.h
@@ -13,13 +13,18 @@
|
||||
#include "memusage.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#include "base58.h"
|
||||
#include "pubkey.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#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
|
||||
@@ -436,6 +441,37 @@ public:
|
||||
friend class CCoinsViewCache;
|
||||
};
|
||||
|
||||
class CTransactionExceptionData
|
||||
{
|
||||
public:
|
||||
CScript scriptPubKey;
|
||||
uint64_t voutMask;
|
||||
CTransactionExceptionData() : scriptPubKey(), voutMask() {}
|
||||
};
|
||||
|
||||
class CLaunchMap
|
||||
{
|
||||
public:
|
||||
std::unordered_map<std::string, CTransactionExceptionData> lmap;
|
||||
CLaunchMap() : lmap()
|
||||
{
|
||||
//printf("txid: %s -> addr: %s\n", whitelist_ids[i], whitelist_addrs[i]);
|
||||
CBitcoinAddress bcaddr(whitelist_address);
|
||||
CKeyID key;
|
||||
if (bcaddr.GetKeyID_NoCheck(key))
|
||||
{
|
||||
std::vector<unsigned char> address = std::vector<unsigned char>(key.begin(), key.end());
|
||||
for (int i = 0; i < WHITELIST_COUNT; i++)
|
||||
{
|
||||
std::string hash = uint256S(whitelist_ids[i]).ToString();
|
||||
lmap[hash].scriptPubKey << OP_DUP << OP_HASH160 << address << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
lmap[hash].voutMask = whitelist_masks[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
static CLaunchMap launchMap = CLaunchMap();
|
||||
|
||||
/** CCoinsView that adds a memory cache for transactions to another CCoinsView */
|
||||
class CCoinsViewCache : public CCoinsViewBacked
|
||||
{
|
||||
@@ -443,7 +479,6 @@ protected:
|
||||
/* Whether this cache has an active modifier. */
|
||||
bool hasModifier;
|
||||
|
||||
|
||||
/**
|
||||
* Make mutable so that we can "fill the cache" even from Get-methods
|
||||
* declared as "const".
|
||||
@@ -462,6 +497,7 @@ public:
|
||||
~CCoinsViewCache();
|
||||
|
||||
// Standard CCoinsView methods
|
||||
static CLaunchMap &LaunchMap() { return launchMap; }
|
||||
bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const;
|
||||
bool GetNullifier(const uint256 &nullifier) const;
|
||||
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
||||
@@ -535,6 +571,7 @@ public:
|
||||
|
||||
const CTxOut &GetOutputFor(const CTxIn& input) const;
|
||||
const CScript &GetSpendFor(const CTxIn& input) const;
|
||||
static const CScript &GetSpendFor(const CCoins *coins, const CTxIn& input);
|
||||
|
||||
friend class CCoinsModifier;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ Optimized Implementations for Haraka256 and Haraka512
|
||||
#include "crypto/haraka.h"
|
||||
|
||||
u128 rc[40];
|
||||
u128 rc0[40] = {0};
|
||||
|
||||
void load_constants() {
|
||||
rc[0] = _mm_set_epi32(0x0684704c,0xe620c00a,0xb2c5fef0,0x75817b9d);
|
||||
@@ -365,6 +366,37 @@ void haraka512(unsigned char *out, const unsigned char *in) {
|
||||
TRUNCSTORE(out, s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
|
||||
void haraka512_zero(unsigned char *out, const unsigned char *in) {
|
||||
u128 s[4], tmp;
|
||||
|
||||
s[0] = LOAD(in);
|
||||
s[1] = LOAD(in + 16);
|
||||
s[2] = LOAD(in + 32);
|
||||
s[3] = LOAD(in + 48);
|
||||
|
||||
AES4_zero(s[0], s[1], s[2], s[3], 0);
|
||||
MIX4(s[0], s[1], s[2], s[3]);
|
||||
|
||||
AES4_zero(s[0], s[1], s[2], s[3], 8);
|
||||
MIX4(s[0], s[1], s[2], s[3]);
|
||||
|
||||
AES4_zero(s[0], s[1], s[2], s[3], 16);
|
||||
MIX4(s[0], s[1], s[2], s[3]);
|
||||
|
||||
AES4_zero(s[0], s[1], s[2], s[3], 24);
|
||||
MIX4(s[0], s[1], s[2], s[3]);
|
||||
|
||||
AES4_zero(s[0], s[1], s[2], s[3], 32);
|
||||
MIX4(s[0], s[1], s[2], s[3]);
|
||||
|
||||
s[0] = _mm_xor_si128(s[0], LOAD(in));
|
||||
s[1] = _mm_xor_si128(s[1], LOAD(in + 16));
|
||||
s[2] = _mm_xor_si128(s[2], LOAD(in + 32));
|
||||
s[3] = _mm_xor_si128(s[3], LOAD(in + 48));
|
||||
|
||||
TRUNCSTORE(out, s[0], s[1], s[2], s[3]);
|
||||
}
|
||||
|
||||
void haraka512_4x(unsigned char *out, const unsigned char *in) {
|
||||
u128 s[4][4], tmp;
|
||||
|
||||
|
||||
@@ -30,7 +30,11 @@ Optimized Implementations for Haraka256 and Haraka512
|
||||
|
||||
#define NUMROUNDS 5
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef unsigned long long u64;
|
||||
#else
|
||||
typedef unsigned long u64;
|
||||
#endif
|
||||
typedef __m128i u128;
|
||||
|
||||
extern u128 rc[40];
|
||||
@@ -64,6 +68,16 @@ extern u128 rc[40];
|
||||
s2 = _mm_aesenc_si128(s2, rc[rci + 6]); \
|
||||
s3 = _mm_aesenc_si128(s3, rc[rci + 7]); \
|
||||
|
||||
#define AES4_zero(s0, s1, s2, s3, rci) \
|
||||
s0 = _mm_aesenc_si128(s0, rc0[rci]); \
|
||||
s1 = _mm_aesenc_si128(s1, rc0[rci + 1]); \
|
||||
s2 = _mm_aesenc_si128(s2, rc0[rci + 2]); \
|
||||
s3 = _mm_aesenc_si128(s3, rc0[rci + 3]); \
|
||||
s0 = _mm_aesenc_si128(s0, rc0[rci + 4]); \
|
||||
s1 = _mm_aesenc_si128(s1, rc0[rci + 5]); \
|
||||
s2 = _mm_aesenc_si128(s2, rc0[rci + 6]); \
|
||||
s3 = _mm_aesenc_si128(s3, rc0[rci + 7]); \
|
||||
|
||||
#define AES4_4x(s0, s1, s2, s3, rci) \
|
||||
AES4(s0[0], s0[1], s0[2], s0[3], rci); \
|
||||
AES4(s1[0], s1[1], s1[2], s1[3], rci); \
|
||||
@@ -105,6 +119,7 @@ void haraka256_4x(unsigned char *out, const unsigned char *in);
|
||||
void haraka256_8x(unsigned char *out, const unsigned char *in);
|
||||
|
||||
void haraka512(unsigned char *out, const unsigned char *in);
|
||||
void haraka512_zero(unsigned char *out, const unsigned char *in);
|
||||
void haraka512_4x(unsigned char *out, const unsigned char *in);
|
||||
void haraka512_8x(unsigned char *out, const unsigned char *in);
|
||||
|
||||
|
||||
375
src/crypto/haraka_portable.c
Normal file
375
src/crypto/haraka_portable.c
Normal file
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
Plain C implementation of the Haraka256 and Haraka512 permutations.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "haraka_portable.h"
|
||||
|
||||
#define HARAKAS_RATE 32
|
||||
|
||||
static const unsigned char haraka_rc[40][16] = {
|
||||
{0x9d, 0x7b, 0x81, 0x75, 0xf0, 0xfe, 0xc5, 0xb2, 0x0a, 0xc0, 0x20, 0xe6, 0x4c, 0x70, 0x84, 0x06},
|
||||
{0x17, 0xf7, 0x08, 0x2f, 0xa4, 0x6b, 0x0f, 0x64, 0x6b, 0xa0, 0xf3, 0x88, 0xe1, 0xb4, 0x66, 0x8b},
|
||||
{0x14, 0x91, 0x02, 0x9f, 0x60, 0x9d, 0x02, 0xcf, 0x98, 0x84, 0xf2, 0x53, 0x2d, 0xde, 0x02, 0x34},
|
||||
{0x79, 0x4f, 0x5b, 0xfd, 0xaf, 0xbc, 0xf3, 0xbb, 0x08, 0x4f, 0x7b, 0x2e, 0xe6, 0xea, 0xd6, 0x0e},
|
||||
{0x44, 0x70, 0x39, 0xbe, 0x1c, 0xcd, 0xee, 0x79, 0x8b, 0x44, 0x72, 0x48, 0xcb, 0xb0, 0xcf, 0xcb},
|
||||
{0x7b, 0x05, 0x8a, 0x2b, 0xed, 0x35, 0x53, 0x8d, 0xb7, 0x32, 0x90, 0x6e, 0xee, 0xcd, 0xea, 0x7e},
|
||||
{0x1b, 0xef, 0x4f, 0xda, 0x61, 0x27, 0x41, 0xe2, 0xd0, 0x7c, 0x2e, 0x5e, 0x43, 0x8f, 0xc2, 0x67},
|
||||
{0x3b, 0x0b, 0xc7, 0x1f, 0xe2, 0xfd, 0x5f, 0x67, 0x07, 0xcc, 0xca, 0xaf, 0xb0, 0xd9, 0x24, 0x29},
|
||||
{0xee, 0x65, 0xd4, 0xb9, 0xca, 0x8f, 0xdb, 0xec, 0xe9, 0x7f, 0x86, 0xe6, 0xf1, 0x63, 0x4d, 0xab},
|
||||
{0x33, 0x7e, 0x03, 0xad, 0x4f, 0x40, 0x2a, 0x5b, 0x64, 0xcd, 0xb7, 0xd4, 0x84, 0xbf, 0x30, 0x1c},
|
||||
{0x00, 0x98, 0xf6, 0x8d, 0x2e, 0x8b, 0x02, 0x69, 0xbf, 0x23, 0x17, 0x94, 0xb9, 0x0b, 0xcc, 0xb2},
|
||||
{0x8a, 0x2d, 0x9d, 0x5c, 0xc8, 0x9e, 0xaa, 0x4a, 0x72, 0x55, 0x6f, 0xde, 0xa6, 0x78, 0x04, 0xfa},
|
||||
{0xd4, 0x9f, 0x12, 0x29, 0x2e, 0x4f, 0xfa, 0x0e, 0x12, 0x2a, 0x77, 0x6b, 0x2b, 0x9f, 0xb4, 0xdf},
|
||||
{0xee, 0x12, 0x6a, 0xbb, 0xae, 0x11, 0xd6, 0x32, 0x36, 0xa2, 0x49, 0xf4, 0x44, 0x03, 0xa1, 0x1e},
|
||||
{0xa6, 0xec, 0xa8, 0x9c, 0xc9, 0x00, 0x96, 0x5f, 0x84, 0x00, 0x05, 0x4b, 0x88, 0x49, 0x04, 0xaf},
|
||||
{0xec, 0x93, 0xe5, 0x27, 0xe3, 0xc7, 0xa2, 0x78, 0x4f, 0x9c, 0x19, 0x9d, 0xd8, 0x5e, 0x02, 0x21},
|
||||
{0x73, 0x01, 0xd4, 0x82, 0xcd, 0x2e, 0x28, 0xb9, 0xb7, 0xc9, 0x59, 0xa7, 0xf8, 0xaa, 0x3a, 0xbf},
|
||||
{0x6b, 0x7d, 0x30, 0x10, 0xd9, 0xef, 0xf2, 0x37, 0x17, 0xb0, 0x86, 0x61, 0x0d, 0x70, 0x60, 0x62},
|
||||
{0xc6, 0x9a, 0xfc, 0xf6, 0x53, 0x91, 0xc2, 0x81, 0x43, 0x04, 0x30, 0x21, 0xc2, 0x45, 0xca, 0x5a},
|
||||
{0x3a, 0x94, 0xd1, 0x36, 0xe8, 0x92, 0xaf, 0x2c, 0xbb, 0x68, 0x6b, 0x22, 0x3c, 0x97, 0x23, 0x92},
|
||||
{0xb4, 0x71, 0x10, 0xe5, 0x58, 0xb9, 0xba, 0x6c, 0xeb, 0x86, 0x58, 0x22, 0x38, 0x92, 0xbf, 0xd3},
|
||||
{0x8d, 0x12, 0xe1, 0x24, 0xdd, 0xfd, 0x3d, 0x93, 0x77, 0xc6, 0xf0, 0xae, 0xe5, 0x3c, 0x86, 0xdb},
|
||||
{0xb1, 0x12, 0x22, 0xcb, 0xe3, 0x8d, 0xe4, 0x83, 0x9c, 0xa0, 0xeb, 0xff, 0x68, 0x62, 0x60, 0xbb},
|
||||
{0x7d, 0xf7, 0x2b, 0xc7, 0x4e, 0x1a, 0xb9, 0x2d, 0x9c, 0xd1, 0xe4, 0xe2, 0xdc, 0xd3, 0x4b, 0x73},
|
||||
{0x4e, 0x92, 0xb3, 0x2c, 0xc4, 0x15, 0x14, 0x4b, 0x43, 0x1b, 0x30, 0x61, 0xc3, 0x47, 0xbb, 0x43},
|
||||
{0x99, 0x68, 0xeb, 0x16, 0xdd, 0x31, 0xb2, 0x03, 0xf6, 0xef, 0x07, 0xe7, 0xa8, 0x75, 0xa7, 0xdb},
|
||||
{0x2c, 0x47, 0xca, 0x7e, 0x02, 0x23, 0x5e, 0x8e, 0x77, 0x59, 0x75, 0x3c, 0x4b, 0x61, 0xf3, 0x6d},
|
||||
{0xf9, 0x17, 0x86, 0xb8, 0xb9, 0xe5, 0x1b, 0x6d, 0x77, 0x7d, 0xde, 0xd6, 0x17, 0x5a, 0xa7, 0xcd},
|
||||
{0x5d, 0xee, 0x46, 0xa9, 0x9d, 0x06, 0x6c, 0x9d, 0xaa, 0xe9, 0xa8, 0x6b, 0xf0, 0x43, 0x6b, 0xec},
|
||||
{0xc1, 0x27, 0xf3, 0x3b, 0x59, 0x11, 0x53, 0xa2, 0x2b, 0x33, 0x57, 0xf9, 0x50, 0x69, 0x1e, 0xcb},
|
||||
{0xd9, 0xd0, 0x0e, 0x60, 0x53, 0x03, 0xed, 0xe4, 0x9c, 0x61, 0xda, 0x00, 0x75, 0x0c, 0xee, 0x2c},
|
||||
{0x50, 0xa3, 0xa4, 0x63, 0xbc, 0xba, 0xbb, 0x80, 0xab, 0x0c, 0xe9, 0x96, 0xa1, 0xa5, 0xb1, 0xf0},
|
||||
{0x39, 0xca, 0x8d, 0x93, 0x30, 0xde, 0x0d, 0xab, 0x88, 0x29, 0x96, 0x5e, 0x02, 0xb1, 0x3d, 0xae},
|
||||
{0x42, 0xb4, 0x75, 0x2e, 0xa8, 0xf3, 0x14, 0x88, 0x0b, 0xa4, 0x54, 0xd5, 0x38, 0x8f, 0xbb, 0x17},
|
||||
{0xf6, 0x16, 0x0a, 0x36, 0x79, 0xb7, 0xb6, 0xae, 0xd7, 0x7f, 0x42, 0x5f, 0x5b, 0x8a, 0xbb, 0x34},
|
||||
{0xde, 0xaf, 0xba, 0xff, 0x18, 0x59, 0xce, 0x43, 0x38, 0x54, 0xe5, 0xcb, 0x41, 0x52, 0xf6, 0x26},
|
||||
{0x78, 0xc9, 0x9e, 0x83, 0xf7, 0x9c, 0xca, 0xa2, 0x6a, 0x02, 0xf3, 0xb9, 0x54, 0x9a, 0xe9, 0x4c},
|
||||
{0x35, 0x12, 0x90, 0x22, 0x28, 0x6e, 0xc0, 0x40, 0xbe, 0xf7, 0xdf, 0x1b, 0x1a, 0xa5, 0x51, 0xae},
|
||||
{0xcf, 0x59, 0xa6, 0x48, 0x0f, 0xbc, 0x73, 0xc1, 0x2b, 0xd2, 0x7e, 0xba, 0x3c, 0x61, 0xc1, 0xa0},
|
||||
{0xa1, 0x9d, 0xc5, 0xe9, 0xfd, 0xbd, 0xd6, 0x4a, 0x88, 0x82, 0x28, 0x02, 0x03, 0xcc, 0x6a, 0x75}
|
||||
};
|
||||
|
||||
static unsigned char rc[40][16];
|
||||
static unsigned char rc0[40][16];
|
||||
static unsigned char rc_sseed[40][16];
|
||||
|
||||
static const unsigned char sbox[256] =
|
||||
{ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe,
|
||||
0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4,
|
||||
0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7,
|
||||
0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3,
|
||||
0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09,
|
||||
0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3,
|
||||
0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe,
|
||||
0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
|
||||
0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92,
|
||||
0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c,
|
||||
0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19,
|
||||
0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14,
|
||||
0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2,
|
||||
0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5,
|
||||
0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25,
|
||||
0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86,
|
||||
0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e,
|
||||
0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42,
|
||||
0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };
|
||||
|
||||
#define XT(x) (((x) << 1) ^ ((((x) >> 7) & 1) * 0x1b))
|
||||
|
||||
// Simulate _mm_aesenc_si128 instructions from AESNI
|
||||
void aesenc(unsigned char *s, const unsigned char *rk)
|
||||
{
|
||||
unsigned char i, t, u, v[4][4];
|
||||
for (i = 0; i < 16; ++i) {
|
||||
v[((i / 4) + 4 - (i%4) ) % 4][i % 4] = sbox[s[i]];
|
||||
}
|
||||
for (i = 0; i < 4; ++i) {
|
||||
t = v[i][0];
|
||||
u = v[i][0] ^ v[i][1] ^ v[i][2] ^ v[i][3];
|
||||
v[i][0] ^= u ^ XT(v[i][0] ^ v[i][1]);
|
||||
v[i][1] ^= u ^ XT(v[i][1] ^ v[i][2]);
|
||||
v[i][2] ^= u ^ XT(v[i][2] ^ v[i][3]);
|
||||
v[i][3] ^= u ^ XT(v[i][3] ^ t);
|
||||
}
|
||||
for (i = 0; i < 16; ++i) {
|
||||
s[i] = v[i / 4][i % 4] ^ rk[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Simulate _mm_unpacklo_epi32
|
||||
void unpacklo32(unsigned char *t, unsigned char *a, unsigned char *b)
|
||||
{
|
||||
unsigned char tmp[16];
|
||||
memcpy(tmp, a, 4);
|
||||
memcpy(tmp + 4, b, 4);
|
||||
memcpy(tmp + 8, a + 4, 4);
|
||||
memcpy(tmp + 12, b + 4, 4);
|
||||
memcpy(t, tmp, 16);
|
||||
}
|
||||
|
||||
// Simulate _mm_unpackhi_epi32
|
||||
void unpackhi32(unsigned char *t, unsigned char *a, unsigned char *b)
|
||||
{
|
||||
unsigned char tmp[16];
|
||||
memcpy(tmp, a + 8, 4);
|
||||
memcpy(tmp + 4, b + 8, 4);
|
||||
memcpy(tmp + 8, a + 12, 4);
|
||||
memcpy(tmp + 12, b + 12, 4);
|
||||
memcpy(t, tmp, 16);
|
||||
}
|
||||
|
||||
void load_constants_port()
|
||||
{
|
||||
/* Use the standard constants to generate tweaked ones. */
|
||||
memcpy(rc, haraka_rc, 40*16);
|
||||
}
|
||||
|
||||
void tweak_constants(const unsigned char *pk_seed, const unsigned char *sk_seed,
|
||||
unsigned long long seed_length)
|
||||
{
|
||||
unsigned char buf[40*16];
|
||||
|
||||
/* Use the standard constants to generate tweaked ones. */
|
||||
memcpy(rc, haraka_rc, 40*16);
|
||||
|
||||
/* Constants for sk.seed */
|
||||
if (sk_seed != NULL) {
|
||||
haraka_S(buf, 40*16, sk_seed, seed_length);
|
||||
memcpy(rc_sseed, buf, 40*16);
|
||||
}
|
||||
|
||||
/* Constants for pk.seed */
|
||||
haraka_S(buf, 40*16, pk_seed, seed_length);
|
||||
memcpy(rc, buf, 40*16);
|
||||
}
|
||||
|
||||
static void haraka_S_absorb(unsigned char *s, unsigned int r,
|
||||
const unsigned char *m, unsigned long long mlen,
|
||||
unsigned char p)
|
||||
{
|
||||
unsigned long long i;
|
||||
unsigned char t[r];
|
||||
|
||||
while (mlen >= r) {
|
||||
// XOR block to state
|
||||
for (i = 0; i < r; ++i) {
|
||||
s[i] ^= m[i];
|
||||
}
|
||||
haraka512_perm(s, s);
|
||||
mlen -= r;
|
||||
m += r;
|
||||
}
|
||||
|
||||
for (i = 0; i < r; ++i) {
|
||||
t[i] = 0;
|
||||
}
|
||||
for (i = 0; i < mlen; ++i) {
|
||||
t[i] = m[i];
|
||||
}
|
||||
t[i] = p;
|
||||
t[r - 1] |= 128;
|
||||
for (i = 0; i < r; ++i) {
|
||||
s[i] ^= t[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks,
|
||||
unsigned char *s, unsigned int r)
|
||||
{
|
||||
while (nblocks > 0) {
|
||||
haraka512_perm(s, s);
|
||||
memcpy(h, s, HARAKAS_RATE);
|
||||
h += r;
|
||||
nblocks--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void haraka_S(unsigned char *out, unsigned long long outlen,
|
||||
const unsigned char *in, unsigned long long inlen)
|
||||
{
|
||||
unsigned long long i;
|
||||
unsigned char s[64];
|
||||
unsigned char d[32];
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
s[i] = 0;
|
||||
}
|
||||
haraka_S_absorb(s, 32, in, inlen, 0x1F);
|
||||
|
||||
haraka_S_squeezeblocks(out, outlen / 32, s, 32);
|
||||
out += (outlen / 32) * 32;
|
||||
|
||||
if (outlen % 32) {
|
||||
haraka_S_squeezeblocks(d, 1, s, 32);
|
||||
for (i = 0; i < outlen % 32; i++) {
|
||||
out[i] = d[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void haraka512_perm(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
unsigned char s[64], tmp[16];
|
||||
|
||||
memcpy(s, in, 16);
|
||||
memcpy(s + 16, in + 16, 16);
|
||||
memcpy(s + 32, in + 32, 16);
|
||||
memcpy(s + 48, in + 48, 16);
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
// aes round(s)
|
||||
for (j = 0; j < 2; ++j) {
|
||||
aesenc(s, rc[4*2*i + 4*j]);
|
||||
aesenc(s + 16, rc[4*2*i + 4*j + 1]);
|
||||
aesenc(s + 32, rc[4*2*i + 4*j + 2]);
|
||||
aesenc(s + 48, rc[4*2*i + 4*j + 3]);
|
||||
}
|
||||
|
||||
// mixing
|
||||
unpacklo32(tmp, s, s + 16);
|
||||
unpackhi32(s, s, s + 16);
|
||||
unpacklo32(s + 16, s + 32, s + 48);
|
||||
unpackhi32(s + 32, s + 32, s + 48);
|
||||
unpacklo32(s + 48, s, s + 32);
|
||||
unpackhi32(s, s, s + 32);
|
||||
unpackhi32(s + 32, s + 16, tmp);
|
||||
unpacklo32(s + 16, s + 16, tmp);
|
||||
}
|
||||
|
||||
memcpy(out, s, 64);
|
||||
}
|
||||
|
||||
void haraka512_port(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i;
|
||||
|
||||
unsigned char buf[64];
|
||||
|
||||
haraka512_perm(buf, in);
|
||||
/* Feed-forward */
|
||||
for (i = 0; i < 64; i++) {
|
||||
buf[i] = buf[i] ^ in[i];
|
||||
}
|
||||
|
||||
/* Truncated */
|
||||
memcpy(out, buf + 8, 8);
|
||||
memcpy(out + 8, buf + 24, 8);
|
||||
memcpy(out + 16, buf + 32, 8);
|
||||
memcpy(out + 24, buf + 48, 8);
|
||||
}
|
||||
|
||||
void haraka512_perm_zero(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
unsigned char s[64], tmp[16];
|
||||
|
||||
memcpy(s, in, 16);
|
||||
memcpy(s + 16, in + 16, 16);
|
||||
memcpy(s + 32, in + 32, 16);
|
||||
memcpy(s + 48, in + 48, 16);
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
// aes round(s)
|
||||
for (j = 0; j < 2; ++j) {
|
||||
aesenc(s, rc0[4*2*i + 4*j]);
|
||||
aesenc(s + 16, rc0[4*2*i + 4*j + 1]);
|
||||
aesenc(s + 32, rc0[4*2*i + 4*j + 2]);
|
||||
aesenc(s + 48, rc0[4*2*i + 4*j + 3]);
|
||||
}
|
||||
|
||||
// mixing
|
||||
unpacklo32(tmp, s, s + 16);
|
||||
unpackhi32(s, s, s + 16);
|
||||
unpacklo32(s + 16, s + 32, s + 48);
|
||||
unpackhi32(s + 32, s + 32, s + 48);
|
||||
unpacklo32(s + 48, s, s + 32);
|
||||
unpackhi32(s, s, s + 32);
|
||||
unpackhi32(s + 32, s + 16, tmp);
|
||||
unpacklo32(s + 16, s + 16, tmp);
|
||||
}
|
||||
|
||||
memcpy(out, s, 64);
|
||||
}
|
||||
|
||||
void haraka512_port_zero(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i;
|
||||
|
||||
unsigned char buf[64];
|
||||
|
||||
haraka512_perm_zero(buf, in);
|
||||
/* Feed-forward */
|
||||
for (i = 0; i < 64; i++) {
|
||||
buf[i] = buf[i] ^ in[i];
|
||||
}
|
||||
|
||||
/* Truncated */
|
||||
memcpy(out, buf + 8, 8);
|
||||
memcpy(out + 8, buf + 24, 8);
|
||||
memcpy(out + 16, buf + 32, 8);
|
||||
memcpy(out + 24, buf + 48, 8);
|
||||
}
|
||||
|
||||
void haraka256_port(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
unsigned char s[32], tmp[16];
|
||||
|
||||
memcpy(s, in, 16);
|
||||
memcpy(s + 16, in + 16, 16);
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
// aes round(s)
|
||||
for (j = 0; j < 2; ++j) {
|
||||
aesenc(s, rc[2*2*i + 2*j]);
|
||||
aesenc(s + 16, rc[2*2*i + 2*j + 1]);
|
||||
}
|
||||
|
||||
// mixing
|
||||
unpacklo32(tmp, s, s + 16);
|
||||
unpackhi32(s + 16, s, s + 16);
|
||||
memcpy(s, tmp, 16);
|
||||
}
|
||||
|
||||
/* Feed-forward */
|
||||
for (i = 0; i < 32; i++) {
|
||||
out[i] = in[i] ^ s[i];
|
||||
}
|
||||
}
|
||||
|
||||
void haraka256_sk(unsigned char *out, const unsigned char *in)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
unsigned char s[32], tmp[16];
|
||||
|
||||
memcpy(s, in, 16);
|
||||
memcpy(s + 16, in + 16, 16);
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
// aes round(s)
|
||||
for (j = 0; j < 2; ++j) {
|
||||
aesenc(s, rc_sseed[2*2*i + 2*j]);
|
||||
aesenc(s + 16, rc_sseed[2*2*i + 2*j + 1]);
|
||||
}
|
||||
|
||||
// mixing
|
||||
unpacklo32(tmp, s, s + 16);
|
||||
unpackhi32(s + 16, s, s + 16);
|
||||
memcpy(s, tmp, 16);
|
||||
}
|
||||
|
||||
/* Feed-forward */
|
||||
for (i = 0; i < 32; i++) {
|
||||
out[i] = in[i] ^ s[i];
|
||||
}
|
||||
}
|
||||
33
src/crypto/haraka_portable.h
Normal file
33
src/crypto/haraka_portable.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef SPX_HARAKA_H
|
||||
#define SPX_HARAKA_H
|
||||
|
||||
/* load constants */
|
||||
void load_constants_port();
|
||||
|
||||
/* Tweak constants with seed */
|
||||
void tweak_constants(const unsigned char *pk_seed, const unsigned char *sk_seed,
|
||||
unsigned long long seed_length);
|
||||
|
||||
/* Haraka Sponge */
|
||||
void haraka_S(unsigned char *out, unsigned long long outlen,
|
||||
const unsigned char *in, unsigned long long inlen);
|
||||
|
||||
/* Applies the 512-bit Haraka permutation to in. */
|
||||
void haraka512_perm(unsigned char *out, const unsigned char *in);
|
||||
|
||||
/* Implementation of Haraka-512 */
|
||||
void haraka512_port(unsigned char *out, const unsigned char *in);
|
||||
|
||||
/* Applies the 512-bit Haraka permutation to in, using zero key. */
|
||||
void haraka512_perm_zero(unsigned char *out, const unsigned char *in);
|
||||
|
||||
/* Implementation of Haraka-512, using zero key */
|
||||
void haraka512_port_zero(unsigned char *out, const unsigned char *in);
|
||||
|
||||
/* Implementation of Haraka-256 */
|
||||
void haraka256_port(unsigned char *out, const unsigned char *in);
|
||||
|
||||
/* Implementation of Haraka-256 using sk.seed constants */
|
||||
void haraka256_sk(unsigned char *out, const unsigned char *in);
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,8 @@ bit output.
|
||||
#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];
|
||||
@@ -36,7 +38,7 @@ void CVerusHash::Hash(void *result, const void *data, size_t len)
|
||||
memcpy(bufPtr + 32, ptr + pos, i);
|
||||
memset(bufPtr + 32 + i, 0, 32 - i);
|
||||
}
|
||||
haraka512(bufPtr2, bufPtr);
|
||||
(*haraka512Function)(bufPtr2, bufPtr);
|
||||
bufPtr2 = bufPtr;
|
||||
bufPtr += nextOffset;
|
||||
nextOffset *= -1;
|
||||
@@ -44,6 +46,18 @@ void CVerusHash::Hash(void *result, const void *data, size_t len)
|
||||
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;
|
||||
@@ -56,7 +70,7 @@ CVerusHash &CVerusHash::Write(const unsigned char *data, size_t len)
|
||||
if (len - pos >= room)
|
||||
{
|
||||
memcpy(curBuf + 32 + curPos, data + pos, room);
|
||||
haraka512(result, curBuf);
|
||||
(*haraka512Function)(result, curBuf);
|
||||
tmp = curBuf;
|
||||
curBuf = result;
|
||||
result = tmp;
|
||||
@@ -73,3 +87,92 @@ CVerusHash &CVerusHash::Write(const unsigned char *data, size_t len)
|
||||
return *this;
|
||||
}
|
||||
|
||||
// to be declared and accessed from C
|
||||
void verus_hash(void *result, const void *data, size_t len)
|
||||
{
|
||||
return CVerusHash::Hash(result, data, len);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -11,17 +11,23 @@ This provides the PoW hash function for Verus, enabling CPU mining.
|
||||
#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);
|
||||
|
||||
CVerusHash() {}
|
||||
static void init();
|
||||
|
||||
CVerusHash() { }
|
||||
|
||||
CVerusHash &Write(const unsigned char *data, size_t len);
|
||||
|
||||
@@ -31,14 +37,25 @@ class CVerusHash
|
||||
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);
|
||||
haraka512(hash, curBuf);
|
||||
(*haraka512Function)(hash, curBuf);
|
||||
}
|
||||
else
|
||||
std::memcpy(hash, curBuf, 32);
|
||||
@@ -51,4 +68,66 @@ class CVerusHash
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
2
src/fiat/verus
Normal file → Executable file
2
src/fiat/verus
Normal file → Executable file
@@ -4,4 +4,4 @@
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
|
||||
../komodo-cli -ac_name=VERUSTEST "$@"
|
||||
../komodo-cli -ac_name=VRSC "$@"
|
||||
|
||||
51
src/hash.h
51
src/hash.h
@@ -203,7 +203,8 @@ public:
|
||||
int nType;
|
||||
int nVersion;
|
||||
|
||||
CVerusHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn), state() {}
|
||||
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);
|
||||
@@ -217,6 +218,9 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
int64_t *xI64p() { return state.ExtraI64Ptr(); }
|
||||
CVerusHash &GetState() { return state; }
|
||||
|
||||
template<typename T>
|
||||
CVerusHashWriter& operator<<(const T& obj) {
|
||||
// Serialize to this stream
|
||||
@@ -225,6 +229,42 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** 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, nType, nVersion);
|
||||
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)
|
||||
@@ -243,6 +283,15 @@ uint256 SerializeVerusHash(const T& obj, int nType=SER_GETHASH, int nVersion=PRO
|
||||
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]);
|
||||
|
||||
@@ -1103,7 +1103,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// set the hash algorithm to use for this chain
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
|
||||
{
|
||||
// initialize VerusHash
|
||||
CVerusHash::init();
|
||||
CVerusHashV2::init();
|
||||
CBlockHeader::SetVerusHash();
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if (!InitSanityCheck())
|
||||
|
||||
@@ -1258,7 +1258,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
||||
return(isPoS);
|
||||
}
|
||||
|
||||
// if slow flag is 1, this does a slower check that checks the target with consensus, otherwise quick, insecure check for internal integrity
|
||||
// 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;
|
||||
@@ -1266,20 +1266,25 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
||||
int32_t txn_count;
|
||||
uint32_t voutNum;
|
||||
bool isPOS = false;
|
||||
CTxDestination voutaddress, destaddress;
|
||||
CTxDestination voutaddress, destaddress, cbaddress;
|
||||
arith_uint256 target, hash;
|
||||
CTransaction tx;
|
||||
|
||||
if (!pblock->isVerusPOSBlock())
|
||||
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];
|
||||
char voutaddr[64], destaddr[64], cbaddr[64];
|
||||
|
||||
target.SetCompact(pblock->GetVerusPOSTarget());
|
||||
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;
|
||||
|
||||
@@ -1291,20 +1296,28 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - no transaction\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else if (!(pastBlockIndex = komodo_chainactive(height - COINBASE_MATURITY)))
|
||||
else if (!(pastBlockIndex = komodo_chainactive(height - 100)))
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - no past block hash\n",blkHash.ToString().c_str());
|
||||
fprintf(stderr,"WARNING: chain not fully loaded or invalid PoS block %s - no past block found\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = UintToArith256(tx.GetVerusPOSHash(voutNum, height, pastBlockIndex->GetBlockHash()));
|
||||
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;
|
||||
|
||||
hash = UintToArith256(tx.GetVerusPOSHash(&nonce, voutNum, height, pastHash));
|
||||
if (hash <= target)
|
||||
{
|
||||
if ((mapBlockIndex.count(blkHash) == 0) ||
|
||||
!(pastBlockIndex = mapBlockIndex[blkHash]) ||
|
||||
(height - pastBlockIndex->nHeight) < VERUS_MIN_STAKEAGE)
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - no prev block found\n",blkHash.ToString().c_str());
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - stake transaction too new\n",blkHash.ToString().c_str());
|
||||
}
|
||||
else if ( slowflag != 0 )
|
||||
{
|
||||
@@ -1317,24 +1330,37 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
|
||||
else
|
||||
{
|
||||
arith_uint256 cTarget;
|
||||
cTarget.SetCompact(lwmaGetNextPOSRequired(previndex, Params().GetConsensus()));
|
||||
uint32_t nBits = lwmaGetNextPOSRequired(previndex, Params().GetConsensus());
|
||||
cTarget.SetCompact(nBits);
|
||||
bool nonceOK = true;
|
||||
|
||||
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;
|
||||
}
|
||||
else if ( ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey, voutaddress) &&
|
||||
ExtractDestination(tx.vout[voutNum].scriptPubKey, destaddress) )
|
||||
}
|
||||
if ( nonceOK && ExtractDestination(pblock->vtx[txn_count-1].vout[0].scriptPubKey, voutaddress) &&
|
||||
ExtractDestination(tx.vout[voutNum].scriptPubKey, destaddress) &&
|
||||
CScriptExt::ExtractVoutDestination(pblock->vtx[0], 0, cbaddress) )
|
||||
{
|
||||
strcpy(voutaddr, CBitcoinAddress(voutaddress).ToString().c_str());
|
||||
strcpy(destaddr, CBitcoinAddress(destaddress).ToString().c_str());
|
||||
if ( strcmp(destaddr,voutaddr) == 0 )
|
||||
strcpy(cbaddr, CBitcoinAddress(cbaddress).ToString().c_str());
|
||||
if ( !strcmp(destaddr,voutaddr) && ( !strcmp(destaddr,cbaddr) || (height < 17840)) )
|
||||
{
|
||||
isPOS = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid stake destination\n",blkHash.ToString().c_str());
|
||||
fprintf(stderr,"ERROR: invalid PoS block %s - invalid stake or coinbase destination\n",blkHash.ToString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,15 +73,17 @@ uint32_t ASSETCHAINS_NUMALGOS = 2;
|
||||
uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH;
|
||||
uint32_t ASSETCHAINS_VERUSHASH = 1;
|
||||
const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "verushash"};
|
||||
uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xffffff};
|
||||
uint32_t ASSETCHAINS_NONCESHIFT[] = {32,40};
|
||||
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,512};
|
||||
uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff,0xfffffff};
|
||||
uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16};
|
||||
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096};
|
||||
uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH;
|
||||
|
||||
// Verus proof of stake controls
|
||||
int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS
|
||||
int32_t VERUS_BLOCK_POSUNITS = 1000; // one block is 1000 units
|
||||
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
|
||||
|
||||
uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
|
||||
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10;
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#define portable_mutex_lock pthread_mutex_lock
|
||||
#define portable_mutex_unlock pthread_mutex_unlock
|
||||
|
||||
extern void verus_hash(void *result, const void *data, size_t len);
|
||||
|
||||
struct allocitem { uint32_t allocsize,type; };
|
||||
struct queueitem { struct queueitem *next,*prev; uint32_t allocsize,type; };
|
||||
|
||||
@@ -1022,6 +1024,26 @@ 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
uint8_t hashSrc[8];
|
||||
uint64_t result, hashSrc64 = (uint64_t)ASSETCHAINS_MAGIC << 32 + nHeight;
|
||||
@@ -1031,14 +1053,16 @@ uint64_t komodo_block_prg(uint32_t nHeight)
|
||||
{
|
||||
hashSrc[i] = hashSrc64 & 0xff;
|
||||
hashSrc64 >>= 8;
|
||||
int8_t b = hashSrc[i];
|
||||
}
|
||||
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
|
||||
|
||||
vcalc_sha256(0, hashResult.bytes, hashSrc, sizeof(hashSrc));
|
||||
for ( i = 0; i < 8; i++ )
|
||||
{
|
||||
result = (result << 8) + hashResult.bytes[i];
|
||||
}
|
||||
return(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// given a block height, this returns the unlock time for that block height, derived from
|
||||
@@ -1051,6 +1075,13 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
|
||||
if ( ASSETCHAINS_TIMEUNLOCKFROM == ASSETCHAINS_TIMEUNLOCKTO )
|
||||
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
|
||||
@@ -1058,6 +1089,7 @@ int64_t komodo_block_unlocktime(uint32_t nHeight)
|
||||
if (unlocktime > ASSETCHAINS_TIMEUNLOCKTO)
|
||||
unlocktime--;
|
||||
}
|
||||
}
|
||||
return ((int64_t)unlocktime);
|
||||
}
|
||||
|
||||
|
||||
50
src/main.cpp
50
src/main.cpp
@@ -31,7 +31,9 @@
|
||||
#include "wallet/asyncrpcoperation_sendmany.h"
|
||||
#include "wallet/asyncrpcoperation_shieldcoinbase.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -908,7 +910,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
bool ContextualCheckCoinbaseTransaction(const CTransaction& tx, const int nHeight)
|
||||
{
|
||||
// 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)
|
||||
if (((uint64_t)(tx.GetValueOut()) >= ASSETCHAINS_TIMELOCKGTE) || (nHeight >= 31680) && komodo_ac_block_subsidy(nHeight) >= ASSETCHAINS_TIMELOCKGTE)
|
||||
{
|
||||
CScriptID scriptHash;
|
||||
|
||||
@@ -2066,7 +2068,8 @@ namespace Consensus {
|
||||
// Disabled on regtest
|
||||
if (fCoinbaseEnforcedProtectionEnabled &&
|
||||
consensusParams.fCoinbaseMustBeProtected &&
|
||||
!tx.vout.empty()) {
|
||||
!tx.vout.empty() &&
|
||||
(strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || (nSpendHeight >= 12800 && coins->nHeight >= 12800))) {
|
||||
return state.Invalid(
|
||||
error("CheckInputs(): tried to spend coinbase with transparent outputs"),
|
||||
REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs");
|
||||
@@ -3138,14 +3141,19 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
return false;
|
||||
|
||||
if (!fBare) {
|
||||
// Resurrect mempool transactions from the disconnected block.
|
||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
// resurrect mempool transactions from the disconnected block.
|
||||
for (int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
// ignore validation errors in resurrected transactions
|
||||
CTransaction &tx = block.vtx[i];
|
||||
list<CTransaction> removed;
|
||||
CValidationState stateDummy;
|
||||
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
// don't keep staking or invalid transactions
|
||||
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && block.IsVerusPOSBlock()) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
{
|
||||
mempool.remove(tx, removed, true);
|
||||
}
|
||||
}
|
||||
if (anchorBeforeDisconnect != anchorAfterDisconnect) {
|
||||
// The anchor may not change between block disconnects,
|
||||
// in which case we don't want to evict from the mempool yet!
|
||||
@@ -3160,9 +3168,18 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
assert(pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), newTree));
|
||||
// Let wallets know transactions went from 1-confirmed to
|
||||
// 0-confirmed or conflicted:
|
||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
for (int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
CTransaction &tx = block.vtx[i];
|
||||
if ((i == (block.vtx.size() - 1) && block.IsVerusPOSBlock()))
|
||||
{
|
||||
EraseFromWallets(tx.GetHash());
|
||||
}
|
||||
else
|
||||
{
|
||||
SyncWithWallets(tx, NULL);
|
||||
}
|
||||
}
|
||||
// Update cached incremental witnesses
|
||||
//fprintf(stderr,"chaintip false\n");
|
||||
GetMainSignals().ChainTip(pindexDelete, &block, newTree, false);
|
||||
@@ -3999,7 +4016,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
{
|
||||
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1;
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
bool checkBlockOne = (nHeight == 1);
|
||||
|
||||
// Check that all transactions are finalized
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
|
||||
@@ -4087,7 +4103,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
||||
komodo_requestedhash = block.hashPrevBlock;
|
||||
komodo_requestedcount = 0;
|
||||
}*/
|
||||
LogPrintf("AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str());
|
||||
LogPrintf("AcceptBlockHeader %s\n hashPrevBlock %s not found\n", hash.ToString().c_str(), block.hashPrevBlock.ToString().c_str());
|
||||
return(false);
|
||||
//return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||
}
|
||||
@@ -4139,7 +4155,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
CBlockIndex *&pindex = *ppindex;
|
||||
if (!AcceptBlockHeader(futureblockp,block, state, &pindex))
|
||||
if (!AcceptBlockHeader(futureblockp, block, state, &pindex))
|
||||
{
|
||||
if ( *futureblockp == 0 )
|
||||
{
|
||||
@@ -4343,7 +4359,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
|
||||
if ( 1 )
|
||||
{
|
||||
// without the komodo_ensure call, it is quite possible to get a non-error but null pindex returned from AcceptBlockHeader. In a 2 node network, it will be a long time before that block is reprocessed. Even though restarting makes it rescan, it seems much better to keep the nodes in sync
|
||||
komodo_ensure(pblock,hash);
|
||||
komodo_ensure(pblock, hash);
|
||||
}
|
||||
bool ret = AcceptBlock(&futureblock,*pblock, state, &pindex, fRequested, dbp);
|
||||
if (pindex && pfrom) {
|
||||
@@ -5624,9 +5640,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (strCommand == "version")
|
||||
{
|
||||
// Each connection can only send one version message
|
||||
@@ -6016,8 +6029,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
pindex = chainActive.Next(pindex);
|
||||
}
|
||||
|
||||
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
||||
vector<CBlock> vHeaders;
|
||||
// we must use CNetworkBlockHeader, as CBlockHeader won't include the 0x00 nTx count at the end for compatibility
|
||||
vector<CNetworkBlockHeader> vHeaders;
|
||||
int nLimit = MAX_HEADERS_RESULTS;
|
||||
LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id);
|
||||
//if ( pfrom->lasthdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pfrom->lasthdrsreq != (int32_t)(pindex ? pindex->nHeight : -1) )// no need to ever suppress this
|
||||
@@ -6025,6 +6038,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
pfrom->lasthdrsreq = (int32_t)(pindex ? pindex->nHeight : -1);
|
||||
for (; pindex; pindex = chainActive.Next(pindex))
|
||||
{
|
||||
CBlockHeader h = pindex->GetBlockHeader();
|
||||
//printf("size.%i, solution size.%i\n", (int)sizeof(h), (int)h.nSolution.size());
|
||||
//printf("hash.%s prevhash.%s nonce.%s\n", h.GetHash().ToString().c_str(), h.hashPrevBlock.ToString().c_str(), h.nNonce.ToString().c_str());
|
||||
vHeaders.push_back(pindex->GetBlockHeader());
|
||||
if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop)
|
||||
break;
|
||||
@@ -6169,7 +6185,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing
|
||||
{
|
||||
std::vector<CBlockHeader> headers;
|
||||
@@ -6195,6 +6210,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
CBlockIndex *pindexLast = NULL;
|
||||
BOOST_FOREACH(const CBlockHeader& header, headers) {
|
||||
//printf("size.%i, solution size.%i\n", (int)sizeof(header), (int)header.nSolution.size());
|
||||
//printf("hash.%s prevhash.%s nonce.%s\n", header.GetHash().ToString().c_str(), header.hashPrevBlock.ToString().c_str(), header.nNonce.ToString().c_str());
|
||||
|
||||
CValidationState state;
|
||||
if (pindexLast != NULL && header.hashPrevBlock != pindexLast->GetBlockHash()) {
|
||||
Misbehaving(pfrom->GetId(), 20);
|
||||
|
||||
@@ -751,7 +751,7 @@ private:
|
||||
public:
|
||||
CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), consensusBranchId(0), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
|
||||
CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, uint32_t consensusBranchIdIn, PrecomputedTransactionData* txdataIn) :
|
||||
scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue),
|
||||
scriptPubKey(CCoinsViewCache::GetSpendFor(&txFromIn, txToIn.vin[nInIn])), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue),
|
||||
ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), consensusBranchId(consensusBranchIdIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }
|
||||
|
||||
bool operator()();
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
extern int64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
|
||||
int64_t komodo_block_unlocktime(uint32_t nHeight);
|
||||
|
||||
void AtomicTimer::start()
|
||||
@@ -74,8 +75,21 @@ double AtomicTimer::rate(const AtomicCounter& count)
|
||||
|
||||
CCriticalSection cs_metrics;
|
||||
|
||||
double AtomicTimer::rate(const int64_t count)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
LOCK(cs_metrics);
|
||||
int64_t duration = total_time;
|
||||
if (threads > 0) {
|
||||
// Timer is running, so get the latest count
|
||||
duration += GetTime() - start_time;
|
||||
}
|
||||
return duration > 0 ? (double)count / duration : 0;
|
||||
}
|
||||
|
||||
boost::synchronized_value<int64_t> nNodeStartTime;
|
||||
boost::synchronized_value<int64_t> nNextRefresh;
|
||||
int64_t nHashCount;
|
||||
AtomicCounter transactionsValidated;
|
||||
AtomicCounter ehSolverRuns;
|
||||
AtomicCounter solutionTargetChecks;
|
||||
@@ -109,6 +123,11 @@ int64_t GetUptime()
|
||||
|
||||
double GetLocalSolPS()
|
||||
{
|
||||
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
|
||||
{
|
||||
return miningTimer.rate(nHashCount);
|
||||
}
|
||||
else
|
||||
return miningTimer.rate(solutionTargetChecks);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
extern int64_t nHashCount;
|
||||
|
||||
struct AtomicCounter {
|
||||
std::atomic<uint64_t> value;
|
||||
|
||||
@@ -52,6 +54,8 @@ public:
|
||||
uint64_t threadCount();
|
||||
|
||||
double rate(const AtomicCounter& count);
|
||||
double rate(const int64_t count);
|
||||
|
||||
};
|
||||
|
||||
extern AtomicCounter transactionsValidated;
|
||||
|
||||
277
src/miner.cpp
277
src/miner.cpp
@@ -107,11 +107,12 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
||||
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern CCriticalSection cs_metrics;
|
||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[];
|
||||
extern const char *ASSETCHAINS_ALGORITHMS[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||
@@ -127,11 +128,12 @@ 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 komodo_staked(CPubKey &pubkey, 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(CPubKey &pubkey, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig);
|
||||
int32_t verus_staked(CBlock *pBlock, CPubKey &pubkey, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig);
|
||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
||||
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, bool isStake)
|
||||
{
|
||||
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
||||
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||
// Create new block
|
||||
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||
@@ -368,7 +370,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
//fprintf(stderr,"dont have inputs\n");
|
||||
continue;
|
||||
}
|
||||
CAmount nTxFees = view.GetValueIn(chainActive.Tip()->nHeight,&interest,tx,chainActive.Tip()->nTime)-tx.GetValueOut();
|
||||
CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->nHeight,&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut();
|
||||
|
||||
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
||||
@@ -460,9 +462,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
{
|
||||
uint32_t nBitsPOS;
|
||||
arith_uint256 posHash;
|
||||
siglen = verus_staked(key, txStaked, nBitsPOS, posHash, utxosig);
|
||||
|
||||
siglen = verus_staked(pblock, key, txStaked, nBitsPOS, posHash, utxosig);
|
||||
blocktime = GetAdjustedTime();
|
||||
pblock->SetVerusPOSTarget(nBitsPOS);
|
||||
|
||||
// change the scriptPubKeyIn to the same output script exactly as the staking transaction
|
||||
if (siglen > 0)
|
||||
scriptPubKeyIn = CScript(txStaked.vout[0].scriptPubKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -479,7 +485,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked));
|
||||
nFees += txfees;
|
||||
pblock->nTime = blocktime;
|
||||
//printf("PoS ht.%d t%u\n",(int32_t)chainActive.Tip()->nHeight+1,blocktime);
|
||||
//printf("PoS ht.%d t%u\n",(int32_t)chainActive.LastTip()->nHeight+1,blocktime);
|
||||
} else return(0); //fprintf(stderr,"no utxos eligible for staking\n");
|
||||
}
|
||||
|
||||
@@ -546,6 +552,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, bool isStake)
|
||||
// Fill in header
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
pblock->hashReserved = uint256();
|
||||
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || NOTARY_PUBKEY33[0] == 0 )
|
||||
{
|
||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
@@ -716,11 +723,11 @@ static bool ProcessBlockFound(CBlock* pblock)
|
||||
#endif // ENABLE_WALLET
|
||||
{
|
||||
LogPrintf("%s\n", pblock->ToString());
|
||||
LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.Tip()->nHeight+1);
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
LOCK(cs_main);
|
||||
LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.Tip()->nHeight+1);
|
||||
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
|
||||
{
|
||||
uint256 hash; int32_t i;
|
||||
@@ -756,7 +763,7 @@ static bool ProcessBlockFound(CBlock* pblock)
|
||||
|
||||
// Process this block the same as if we had received it from another node
|
||||
CValidationState state;
|
||||
if (!ProcessNewBlock(1,chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
if (!ProcessNewBlock(1,chainActive.LastTip()->nHeight+1,state, NULL, pblock, true, NULL))
|
||||
return error("KomodoMiner: ProcessNewBlock, block not accepted");
|
||||
|
||||
TrackMinedBlock(pblock->GetHash());
|
||||
@@ -777,20 +784,38 @@ int32_t waitForPeers(const CChainParams &chainparams)
|
||||
{
|
||||
if (chainparams.MiningRequiresPeers())
|
||||
{
|
||||
do {
|
||||
bool fvNodesEmpty;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
if (!fvNodesEmpty )
|
||||
break;
|
||||
MilliSleep(1000);
|
||||
} while (true);
|
||||
if (fvNodesEmpty)
|
||||
{
|
||||
do {
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
fvNodesEmpty = vNodes.empty();
|
||||
}
|
||||
} while (fvNodesEmpty);
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
CBlockIndex *get_chainactive(int32_t height)
|
||||
{
|
||||
if ( chainActive.Tip() != 0 )
|
||||
{
|
||||
if ( height <= chainActive.Tip()->nHeight )
|
||||
return(chainActive[height]);
|
||||
// else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight);
|
||||
}
|
||||
//fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* A separate thread to stake, while the miner threads mine.
|
||||
*/
|
||||
@@ -817,22 +842,32 @@ void static VerusStaker(CWallet *pwallet)
|
||||
break;
|
||||
}
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
sleep(5);
|
||||
CBlockIndex *curTip = chainActive.Tip(), *lastTip;
|
||||
do {
|
||||
lastTip = curTip;
|
||||
printf("Verifying block height %d \n", lastTip->nHeight);
|
||||
MilliSleep(3000 + rand() % 1900);
|
||||
curTip = chainActive.Tip();
|
||||
} while (curTip != lastTip);
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
CBlockIndex* pindexPrev, *pindexCur;
|
||||
do {
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindexPrev = chainActive.Tip();
|
||||
}
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindexCur = chainActive.Tip();
|
||||
}
|
||||
} while (pindexPrev != pindexCur);
|
||||
|
||||
sleep(5);
|
||||
|
||||
{
|
||||
LOCK(cs_main);
|
||||
printf("Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL);
|
||||
//fprintf(stderr,"Staking height %d for %s\n", chainActive.Tip()->nHeight + 1, ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
|
||||
miningTimer.start();
|
||||
|
||||
@@ -845,7 +880,7 @@ void static VerusStaker(CWallet *pwallet)
|
||||
|
||||
// Create new block
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||
if ( Mining_height != pindexPrev->nHeight+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
@@ -863,8 +898,8 @@ void static VerusStaker(CWallet *pwallet)
|
||||
if ( ptr == 0 )
|
||||
{
|
||||
// wait to try another staking block until after the tip moves again
|
||||
while ( chainActive.Tip() == pindexPrev )
|
||||
sleep(5);
|
||||
while ( chainActive.LastTip() == pindexPrev )
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -881,7 +916,6 @@ void static VerusStaker(CWallet *pwallet)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
LogPrintf("Staking with %u transactions in block (%u bytes)\n", pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
//
|
||||
@@ -889,12 +923,13 @@ void static VerusStaker(CWallet *pwallet)
|
||||
//
|
||||
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);
|
||||
|
||||
pblock->nSolution = solnPlaceholder;
|
||||
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( Mining_height > ASSETCHAINS_MINHEIGHT )
|
||||
@@ -910,9 +945,9 @@ void static VerusStaker(CWallet *pwallet)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
printf("Block %d added to chain\n", chainActive.Tip()->nHeight);
|
||||
printf("Block %d added to chain\n", chainActive.LastTip()->nHeight);
|
||||
MilliSleep(250);
|
||||
continue;
|
||||
}
|
||||
@@ -924,27 +959,32 @@ void static VerusStaker(CWallet *pwallet)
|
||||
|
||||
uint256 hashTarget = ArithToUint256(arith_uint256().SetCompact(pblock->nBits));
|
||||
|
||||
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);
|
||||
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");
|
||||
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
|
||||
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
|
||||
ProcessBlockFound(pblock, *pwallet, reservekey);
|
||||
|
||||
sleep(3);
|
||||
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);
|
||||
printf(" hash: %s \ntarget: %s\n",
|
||||
CTransaction::_GetVerusPOSHash(&(pblock->nNonce), pblock->vtx[pblock->vtx.size()-1].vin[0].prevout.hash, 0, Mining_height, pindexPrev->GetBlockHeader().GetVerusEntropyHash(Mining_height - 100), pblock->vtx[pblock->vtx.size()-1].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();
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
sleep(5);
|
||||
|
||||
// In regression test mode, stop mining after a block is found.
|
||||
if (chainparams.MineBlocksOnDemand()) {
|
||||
throw boost::thread_interrupted();
|
||||
@@ -993,42 +1033,57 @@ void static BitcoinMiner_noeq()
|
||||
break;
|
||||
}
|
||||
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
sleep(5);
|
||||
CBlockIndex *curTip = chainActive.Tip(), *lastTip;
|
||||
do {
|
||||
lastTip = curTip;
|
||||
printf("Verifying block height %d \n", lastTip->nHeight);
|
||||
MilliSleep(3000 + rand() % 1900);
|
||||
curTip = chainActive.Tip();
|
||||
} while (curTip != lastTip);
|
||||
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
|
||||
sleep(5);
|
||||
printf("Mining height %d\n", chainActive.Tip()->nHeight + 1);
|
||||
// try a nice clean peer connection to start
|
||||
waitForPeers(chainparams);
|
||||
CBlockIndex *pindexPrev, *pindexCur;
|
||||
do {
|
||||
pindexPrev = chainActive.LastTip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
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 {
|
||||
fprintf(stderr,"Mining %s with %s\n", ASSETCHAINS_SYMBOL, ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
printf("Mining %s with %s\n", ASSETCHAINS_SYMBOL, ASSETCHAINS_ALGORITHMS[ASSETCHAINS_ALGO]);
|
||||
while (true)
|
||||
{
|
||||
miningTimer.stop();
|
||||
waitForPeers(chainparams);
|
||||
miningTimer.start();
|
||||
|
||||
pindexPrev = chainActive.LastTip();
|
||||
sleep(1);
|
||||
|
||||
// prevent forking on startup before the diff algorithm kicks in
|
||||
if (pindexPrev->nHeight < 50 || pindexPrev != chainActive.LastTip())
|
||||
{
|
||||
do {
|
||||
pindexPrev = chainActive.LastTip();
|
||||
MilliSleep(5000 + rand() % 5000);
|
||||
} while (pindexPrev != chainActive.LastTip());
|
||||
}
|
||||
|
||||
// Create new block
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
if ( Mining_height != pindexPrev->nHeight+1 )
|
||||
{
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
Mining_start = (uint32_t)time(NULL);
|
||||
}
|
||||
|
||||
//fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height);
|
||||
if (lastChainTipPrinted != pindexPrev)
|
||||
{
|
||||
printf("Mining height %d\n", Mining_height);
|
||||
lastChainTipPrinted = pindexPrev;
|
||||
}
|
||||
|
||||
miningTimer.start();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey);
|
||||
@@ -1042,6 +1097,7 @@ void static BitcoinMiner_noeq()
|
||||
fprintf(stderr,"created illegal block, retry\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||
if (!pblocktemplate.get())
|
||||
{
|
||||
@@ -1084,9 +1140,13 @@ void static BitcoinMiner_noeq()
|
||||
|
||||
Mining_start = 0;
|
||||
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
printf("Block %d added to chain\n", chainActive.Tip()->nHeight);
|
||||
if (lastChainTipPrinted != chainActive.LastTip())
|
||||
{
|
||||
lastChainTipPrinted = chainActive.LastTip();
|
||||
printf("Block %d added to chain\n", lastChainTipPrinted->nHeight);
|
||||
}
|
||||
MilliSleep(250);
|
||||
continue;
|
||||
}
|
||||
@@ -1102,18 +1162,36 @@ void static BitcoinMiner_noeq()
|
||||
|
||||
while (true)
|
||||
{
|
||||
// for speed check multiples at a time
|
||||
for (int i = 0; i < ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO]; i++)
|
||||
{
|
||||
solutionTargetChecks.increment();
|
||||
arith_uint256 arNonce = UintToArith256(pblock->nNonce);
|
||||
|
||||
// Update nNonce and nTime
|
||||
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
||||
CVerusHashWriter ss = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
ss << *((CBlockHeader *)pblock);
|
||||
int64_t *extraPtr = ss.xI64p();
|
||||
CVerusHash &vh = ss.GetState();
|
||||
uint256 hashResult = uint256();
|
||||
vh.ClearExtra();
|
||||
int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1;
|
||||
int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO];
|
||||
|
||||
if ( UintToArith256(pblock->GetHash()) <= hashTarget )
|
||||
// for speed check NONCEMASK at a time
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
*extraPtr = i;
|
||||
vh.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);
|
||||
|
||||
@@ -1126,27 +1204,33 @@ void static BitcoinMiner_noeq()
|
||||
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->nHeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO];
|
||||
}
|
||||
}
|
||||
|
||||
// In regression test mode, stop mining after a block is found.
|
||||
if (chainparams.MineBlocksOnDemand()) {
|
||||
throw boost::thread_interrupted();
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((UintToArith256(pblock->nNonce) & mask) == mask)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOCK(cs_metrics);
|
||||
nHashCount += i;
|
||||
}
|
||||
|
||||
// Check for stop or if block needs to be rebuilt
|
||||
@@ -1161,31 +1245,28 @@ void static BitcoinMiner_noeq()
|
||||
}
|
||||
}
|
||||
|
||||
if ((UintToArith256(pblock->nNonce) & mask) == mask)
|
||||
{
|
||||
fprintf(stderr,"%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576);
|
||||
break;
|
||||
}
|
||||
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
{
|
||||
fprintf(stderr,"timeout, retrying\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
if ( pindexPrev != chainActive.LastTip() )
|
||||
{
|
||||
printf("Block %d added to chain\n", chainActive.Tip()->nHeight);
|
||||
if (lastChainTipPrinted != chainActive.LastTip())
|
||||
{
|
||||
lastChainTipPrinted = chainActive.LastTip();
|
||||
printf("Block %d added to chain\n", lastChainTipPrinted->nHeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pblock->nBits = savebits;
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
if (chainparams.GetConsensus().fPowAllowMinDifficultyBlocks)
|
||||
{
|
||||
// Changing pblock->nTime can change work required on testnet:
|
||||
hashTarget.SetCompact(pblock->nBits);
|
||||
}
|
||||
#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
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
143
src/pow.cpp
143
src/pow.cpp
@@ -22,7 +22,8 @@
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH;
|
||||
extern int32_t VERUS_BLOCK_POSUNITS;
|
||||
extern char ASSETCHAINS_SYMBOL[65];
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD;
|
||||
unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
|
||||
unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params);
|
||||
|
||||
@@ -157,55 +158,142 @@ bool DoesHashQualify(const CBlockIndex *pbindex)
|
||||
|
||||
// the goal is to keep POS at a solve time that is a ratio of block time units. the low resolution makes a stable solution more challenging
|
||||
// and requires that the averaging window be quite long.
|
||||
unsigned int lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params)
|
||||
uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::Params& params)
|
||||
{
|
||||
arith_uint256 nextTarget {0}, sumTarget {0}, bnTmp, bnLimit;
|
||||
bnLimit = UintToArith256(params.posLimit);
|
||||
unsigned int nProofOfStakeLimit = bnLimit.GetCompact();
|
||||
uint32_t nProofOfStakeLimit = bnLimit.GetCompact();
|
||||
int64_t t = 0, solvetime = 0;
|
||||
int64_t k = params.nLwmaPOSAjustedWeight;
|
||||
int64_t N = params.nPOSAveragingWindow;
|
||||
|
||||
struct solveSequence {
|
||||
int64_t solveTime;
|
||||
bool consecutive;
|
||||
uint32_t nBits;
|
||||
solveSequence()
|
||||
{
|
||||
consecutive = 0;
|
||||
solveTime = 0;
|
||||
nBits = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Find the first block in the averaging interval as we total the linearly weighted average
|
||||
// of POS solve times
|
||||
const CBlockIndex* pindexFirst = pindexLast;
|
||||
const CBlockIndex* pindexNext;
|
||||
|
||||
int64_t t = 0, solvetime = 0, k = params.nLwmaPOSAjustedWeight, N = params.nPOSAveragingWindow;
|
||||
|
||||
for (int i = 0, j = N - 1; pindexFirst && i < N; i++, j--) {
|
||||
pindexNext = pindexFirst;
|
||||
// we measure our solve time in passing of blocks, where one bock == VERUS_BLOCK_POSUNITS units
|
||||
for (int x = 0; x < params.nPOSAveragingWindow; x++)
|
||||
// we need to make sure we have a starting nBits reference, which is either the last POS block, or the default
|
||||
// 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++)
|
||||
{
|
||||
solvetime += VERUS_BLOCK_POSUNITS;
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
// in this loop, unqualified blocks are assumed POS
|
||||
if (!pindexFirst || !DoesHashQualify(pindexFirst))
|
||||
if (!pindexFirst)
|
||||
return nProofOfStakeLimit;
|
||||
|
||||
CBlockHeader hdr = pindexFirst->GetBlockHeader();
|
||||
|
||||
if (hdr.IsVerusPOSBlock())
|
||||
{
|
||||
nBits = hdr.GetVerusPOSTarget();
|
||||
break;
|
||||
}
|
||||
if (!pindexFirst)
|
||||
break;
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
}
|
||||
|
||||
pindexFirst = pindexLast;
|
||||
std::vector<solveSequence> idx = std::vector<solveSequence>();
|
||||
idx.resize(N);
|
||||
|
||||
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
|
||||
// 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++)
|
||||
{
|
||||
pindexFirst = pindexFirst->pprev;
|
||||
|
||||
if (!pindexFirst)
|
||||
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->nHeight < 67680)
|
||||
{
|
||||
idx[i].solveTime = VERUS_BLOCK_POSUNITS * (x + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int64_t lastSolveTime = 0;
|
||||
idx[i].solveTime = VERUS_BLOCK_POSUNITS;
|
||||
for (int64_t j = 0; j < x; j++)
|
||||
{
|
||||
lastSolveTime = VERUS_BLOCK_POSUNITS + (lastSolveTime >> 1);
|
||||
idx[i].solveTime += lastSolveTime;
|
||||
}
|
||||
}
|
||||
idx[i].nBits = nBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
idx[i].consecutive = true;
|
||||
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;
|
||||
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 this is real time, return zero
|
||||
if (j == (N - 1))
|
||||
{
|
||||
// target of 0 (virtually impossible), if we hit max consecutive POS blocks
|
||||
nextTarget.SetCompact(0);
|
||||
return nextTarget.GetCompact();
|
||||
}
|
||||
}
|
||||
st >>= 1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int64_t i = N - 1; i >= 0; i--)
|
||||
{
|
||||
// weighted sum
|
||||
t += solvetime * j;
|
||||
t += idx[i].solveTime * i;
|
||||
|
||||
// Target sum divided by a factor, (k N^2).
|
||||
// The factor is a part of the final equation. However we divide
|
||||
// here to avoid potential overflow.
|
||||
bnTmp.SetCompact(pindexNext->nBits); // TODO(miketout): this must be POS nBits
|
||||
bnTmp.SetCompact(idx[i].nBits);
|
||||
sumTarget += bnTmp / (k * N * N);
|
||||
}
|
||||
|
||||
// Check we have enough blocks
|
||||
if (!pindexFirst)
|
||||
return nProofOfStakeLimit;
|
||||
|
||||
// Keep t reasonable in case strange solvetimes occurred.
|
||||
if (t < N * k / 3)
|
||||
t = N * k / 3;
|
||||
|
||||
bnTmp = bnLimit;
|
||||
nextTarget = t * sumTarget;
|
||||
if (nextTarget > bnTmp)
|
||||
nextTarget = bnTmp;
|
||||
if (nextTarget > bnLimit)
|
||||
nextTarget = bnLimit;
|
||||
|
||||
return nextTarget.GetCompact();
|
||||
}
|
||||
@@ -323,7 +411,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
return error("CheckProofOfWork(): nBits below minimum work");
|
||||
|
||||
// Check proof of work matches claimed amount
|
||||
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.isVerusPOSBlock() )
|
||||
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget && !blkHeader.IsVerusPOSBlock() )
|
||||
{
|
||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
||||
return true;
|
||||
@@ -357,7 +445,6 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
@@ -365,8 +452,6 @@ arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
bool fOverflow;
|
||||
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||
|
||||
// TODO(miketout): proof of stake blocks must be marked as having the minimum POW in this context
|
||||
|
||||
if (fNegative || fOverflow || bnTarget == 0)
|
||||
return 0;
|
||||
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
|
||||
|
||||
@@ -25,7 +25,13 @@
|
||||
#include <assert.h>
|
||||
|
||||
typedef uint16_t u16;
|
||||
#ifdef _WIN32
|
||||
typedef unsigned long long u64;
|
||||
#elif __linux__
|
||||
typedef uint64_t u64;
|
||||
#else
|
||||
typedef unsigned long u64;
|
||||
#endif
|
||||
|
||||
#ifdef EQUIHASH_TROMP_ATOMIC
|
||||
#include <atomic>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "utilstrencodings.h"
|
||||
#include "crypto/common.h"
|
||||
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
|
||||
|
||||
// default hash algorithm for block
|
||||
uint256 (CBlockHeader::*CBlockHeader::hashFunction)() const = &CBlockHeader::GetSHA256DHash;
|
||||
|
||||
@@ -20,13 +22,19 @@ uint256 CBlockHeader::GetSHA256DHash() const
|
||||
|
||||
uint256 CBlockHeader::GetVerusHash() const
|
||||
{
|
||||
if (hashPrevBlock == uint256())
|
||||
if (hashPrevBlock.IsNull())
|
||||
// always use SHA256D for genesis block
|
||||
return SerializeHash(*this);
|
||||
else
|
||||
return SerializeVerusHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetVerusV2Hash() const
|
||||
{
|
||||
// no check for genesis block and use the optimized hash
|
||||
return SerializeVerusHashV2(*this);
|
||||
}
|
||||
|
||||
void CBlockHeader::SetSHA256DHash()
|
||||
{
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetSHA256DHash;
|
||||
@@ -37,6 +45,48 @@ void CBlockHeader::SetVerusHash()
|
||||
CBlockHeader::hashFunction = &CBlockHeader::GetVerusHash;
|
||||
}
|
||||
|
||||
// returns false if unable to fast calculate the VerusPOSHash from the header. it can still be calculated from the 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 &value, 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()))
|
||||
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;
|
||||
value = hashWriter.GetHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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 CBlock::BuildMerkleTree(bool* fMutated) const
|
||||
{
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BITCOIN_PRIMITIVES_BLOCK_H
|
||||
|
||||
#include "primitives/transaction.h"
|
||||
#include "primitives/nonce.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#include "arith_uint256.h"
|
||||
@@ -25,7 +26,6 @@ public:
|
||||
static const size_t HEADER_SIZE=4+32+32+32+4+4+32; // excluding Equihash solution
|
||||
static const int32_t CURRENT_VERSION=4;
|
||||
static uint256 (CBlockHeader::*hashFunction)() const;
|
||||
|
||||
static void SetHashAlgo();
|
||||
|
||||
int32_t nVersion;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
uint256 hashReserved;
|
||||
uint32_t nTime;
|
||||
uint32_t nBits;
|
||||
uint256 nNonce;
|
||||
CPOSNonce nNonce;
|
||||
std::vector<unsigned char> nSolution;
|
||||
|
||||
CBlockHeader()
|
||||
@@ -85,12 +85,17 @@ public:
|
||||
uint256 GetVerusHash() const;
|
||||
static void SetVerusHash();
|
||||
|
||||
bool GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const;
|
||||
uint256 GetVerusEntropyHash(int32_t nHeight) const;
|
||||
|
||||
uint256 GetVerusV2Hash() const;
|
||||
|
||||
int64_t GetBlockTime() const
|
||||
{
|
||||
return (int64_t)nTime;
|
||||
}
|
||||
|
||||
int32_t GetVerusPOSTarget() const
|
||||
uint32_t GetVerusPOSTarget() const
|
||||
{
|
||||
uint32_t nBits = 0;
|
||||
|
||||
@@ -102,31 +107,66 @@ public:
|
||||
return nBits;
|
||||
}
|
||||
|
||||
bool isVerusPOSBlock() const
|
||||
bool IsVerusPOSBlock() const
|
||||
{
|
||||
arith_uint256 arNonce = UintToArith256(nNonce);
|
||||
arith_uint256 tmpNonce = ((arNonce << 128) >> 128);
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
hashWriter << ArithToUint256(tmpNonce);
|
||||
return (nNonce == ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | tmpNonce));
|
||||
return nNonce.IsPOSNonce();
|
||||
}
|
||||
|
||||
void SetVerusPOSTarget(int32_t nBits)
|
||||
void SetVerusPOSTarget(uint32_t nBits)
|
||||
{
|
||||
CVerusHashWriter hashWriter = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
|
||||
uint256 hash;
|
||||
arith_uint256 tmpNonce;
|
||||
|
||||
arith_uint256 arNonce = UintToArith256(nNonce);
|
||||
arNonce = ((arNonce >> 32) << 32) | nBits;
|
||||
|
||||
tmpNonce = ((arNonce << 128) >> 128);
|
||||
hashWriter << ArithToUint256(tmpNonce);
|
||||
// printf("before svpt: %s\n", ArithToUint256(arNonce).GetHex().c_str());
|
||||
|
||||
nNonce = ArithToUint256(UintToArith256(hashWriter.GetHash()) << 128 | tmpNonce);
|
||||
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
|
||||
// were being serialized by senders as CBlock and deserialized as CBlockHeader + an assumed extra
|
||||
// compact value. although it was working, I made this because it did break, and makes the connection
|
||||
// between CBlock and CBlockHeader more brittle.
|
||||
// by using this intentionally specified class instead, we remove an instability in the code that could break
|
||||
// due to unrelated changes, but stay compatible with the old method.
|
||||
class CNetworkBlockHeader : public CBlockHeader
|
||||
{
|
||||
public:
|
||||
std::vector<CTransaction> compatVec;
|
||||
|
||||
CNetworkBlockHeader() : CBlockHeader()
|
||||
{
|
||||
SetNull();
|
||||
}
|
||||
|
||||
CNetworkBlockHeader(const CBlockHeader &header)
|
||||
{
|
||||
SetNull();
|
||||
*((CBlockHeader*)this) = header;
|
||||
}
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
READWRITE(*(CBlockHeader*)this);
|
||||
READWRITE(compatVec);
|
||||
}
|
||||
|
||||
void SetNull()
|
||||
{
|
||||
CBlockHeader::SetNull();
|
||||
compatVec.clear();
|
||||
}
|
||||
};
|
||||
|
||||
class CBlock : public CBlockHeader
|
||||
{
|
||||
@@ -145,6 +185,7 @@ public:
|
||||
CBlock(const CBlockHeader &header)
|
||||
{
|
||||
SetNull();
|
||||
*((CBlockHeader*)this) = header;
|
||||
}
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
75
src/primitives/nonce.cpp
Normal file
75
src/primitives/nonce.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// 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.
|
||||
|
||||
#include "hash.h"
|
||||
#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 if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < (1000 + 100)))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPOSNonce::NewNonceActive(int32_t height)
|
||||
{
|
||||
if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < 96480))
|
||||
return false;
|
||||
else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < 1000))
|
||||
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);
|
||||
}
|
||||
|
||||
64
src/primitives/nonce.h
Normal file
64
src/primitives/nonce.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// 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.
|
||||
|
||||
#ifndef BITCOIN_PRIMITIVES_NONCE_H
|
||||
#define BITCOIN_PRIMITIVES_NONCE_H
|
||||
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#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
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "arith_uint256.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "hash.h"
|
||||
#include "nonce.h"
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <stdint.h>
|
||||
@@ -474,25 +475,39 @@ public:
|
||||
}
|
||||
|
||||
// verus hash will be the same for a given txid, output number, block height, and blockhash of 100 blocks past
|
||||
static uint256 _GetVerusPOSHash(const uint256 &txid, int32_t voutNum, int32_t height, const uint256 &pastHash, int64_t value)
|
||||
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 hashWriter.GetHash();
|
||||
return ArithToUint256(UintToArith256(hashWriter.GetHash()) / value);
|
||||
}
|
||||
}
|
||||
|
||||
uint256 GetVerusPOSHash(int32_t voutNum, int32_t height, const uint256 &pastHash) const
|
||||
// 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 ArithToUint256(UintToArith256(_GetVerusPOSHash(txid, voutNum, height, pastHash, (uint64_t)vout[voutNum].nValue)) / vout[voutNum].nValue);
|
||||
return _GetVerusPOSHash(pNonce, txid, voutNum, height, pastHash, (uint64_t)vout[voutNum].nValue);
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
@@ -268,6 +268,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
|
||||
result.push_back(Pair("difficulty", GetDifficulty(blockindex)));
|
||||
result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex()));
|
||||
result.push_back(Pair("anchor", blockindex->hashAnchorEnd.GetHex()));
|
||||
result.push_back(Pair("blocktype", block.IsVerusPOSBlock() ? "minted" : "mined"));
|
||||
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue));
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH;
|
||||
extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS;
|
||||
|
||||
/**
|
||||
* Return average network hashes per second based on the last 'lookup' blocks,
|
||||
@@ -320,7 +320,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
|
||||
if (params.size() > 1)
|
||||
{
|
||||
nGenProcLimit = params[1].get_int();
|
||||
if (nGenProcLimit == 0)
|
||||
if (ASSETCHAINS_LWMAPOS == 0 && nGenProcLimit == 0)
|
||||
fGenerate = false;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.push_back(Pair("localhashps" , getlocalsolps(params, false)));
|
||||
obj.push_back(Pair("localhashps" , GetBoolArg("-gen", false) ? getlocalsolps(params, false) : (double)0.0));
|
||||
}
|
||||
obj.push_back(Pair("networkhashps", getnetworksolps(params, false)));
|
||||
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
||||
|
||||
@@ -204,7 +204,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("verus proof of stake percent", ASSETCHAINS_LWMAPOS));
|
||||
obj.push_back(Pair("veruspos", ASSETCHAINS_LWMAPOS));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
|
||||
TxInErrorToJSON(txin, vErrors, "Input not found or already spent");
|
||||
continue;
|
||||
}
|
||||
const CScript& prevPubKey = coins->vout[txin.prevout.n].scriptPubKey;
|
||||
const CScript& prevPubKey = CCoinsViewCache::GetSpendFor(coins, txin);
|
||||
const CAmount& amount = coins->vout[txin.prevout.n].nValue;
|
||||
|
||||
SignatureData sigdata;
|
||||
|
||||
@@ -74,3 +74,42 @@ const CScriptExt &CScriptExt::TimeLockSpend(const CKeyID &key, int64_t unlocktim
|
||||
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.size() >= 7 && // minimum for any possible future to prevent out of bounds
|
||||
tx.vout[1].scriptPubKey.data()[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 se = CScriptExt(opretData.begin() + 1, opretData.end());
|
||||
|
||||
if (CScriptID(se) == scriptHash &&
|
||||
se.IsCheckLockTimeVerify(&unlocktime))
|
||||
{
|
||||
spk = se;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ExtractDestination(spk, addressRet);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ class CScriptExt : public CScript
|
||||
|
||||
// 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
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "uint256.h"
|
||||
#include "util.h"
|
||||
|
||||
#undef __cpuid
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/tuple/tuple_comparison.hpp>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#undef __cpuid
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/once.hpp>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "threadsafety.h"
|
||||
|
||||
#undef __cpuid
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
@@ -51,3 +51,7 @@ void UnregisterAllValidationInterfaces() {
|
||||
void SyncWithWallets(const CTransaction &tx, const CBlock *pblock) {
|
||||
g_signals.SyncTransaction(tx, pblock);
|
||||
}
|
||||
|
||||
void EraseFromWallets(const uint256 &hash) {
|
||||
g_signals.EraseTransaction(hash);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ void UnregisterValidationInterface(CValidationInterface* pwalletIn);
|
||||
void UnregisterAllValidationInterfaces();
|
||||
/** Push an updated transaction to all registered wallets */
|
||||
void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
|
||||
/** Erase a transaction from all registered wallets */
|
||||
void EraseFromWallets(const uint256 &hash);
|
||||
|
||||
class CValidationInterface {
|
||||
protected:
|
||||
|
||||
5
src/verusd
Executable file
5
src/verusd
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
#set working directory to the location of this script
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
cd $DIR
|
||||
./komodod -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -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 -addnode=185.25.48.72 -addnode=185.25.48.236 -addnode=185.64.105.111 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -ac_veruspos=50 -gen -genproclimit=0 "$@"
|
||||
1424
src/veruslaunch.cpp
Normal file
1424
src/veruslaunch.cpp
Normal file
File diff suppressed because it is too large
Load Diff
17
src/veruslaunch.h
Normal file
17
src/veruslaunch.h
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
// Copyright (c) 2018 The Verus developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef VERUS_LAUNCH_H
|
||||
#define VERUS_LAUNCH_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#define WHITELIST_COUNT 704
|
||||
|
||||
extern const char *whitelist_ids[WHITELIST_COUNT];
|
||||
extern const char *whitelist_address;
|
||||
extern uint64_t whitelist_masks[WHITELIST_COUNT];
|
||||
|
||||
#endif
|
||||
@@ -1606,7 +1606,13 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
||||
if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY))
|
||||
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);
|
||||
|
||||
if (wtx.IsCoinBase())
|
||||
{
|
||||
int btm;
|
||||
@@ -4661,7 +4667,7 @@ int32_t komodo_staked(CPubKey &pubkey, CMutableTransaction &txNew,uint32_t nBits
|
||||
return(siglen);
|
||||
}
|
||||
|
||||
int32_t verus_staked(CPubKey &pubkey, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig)
|
||||
int32_t verus_staked(CBlock *pBlock, CPubKey &pubkey, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig)
|
||||
{
|
||||
return pwalletMain->VerusStakeTransaction(txNew, nBits, hashResult, utxosig);
|
||||
return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig);
|
||||
}
|
||||
|
||||
@@ -998,8 +998,9 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
|
||||
// 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(arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, const arith_uint256 &target) const
|
||||
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;
|
||||
@@ -1007,52 +1008,61 @@ bool CWallet::VerusSelectStakeOutput(arith_uint256 &hashResult, CTransaction &st
|
||||
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 - COINBASE_MATURITY))
|
||||
if (pastBlockIndex = komodo_chainactive(nHeight - 100))
|
||||
{
|
||||
uint256 pastHash = pastBlockIndex->GetBlockHash();
|
||||
CBlockHeader bh = pastBlockIndex->GetBlockHeader();
|
||||
uint256 pastHash = bh.GetVerusEntropyHash(nHeight - 100);
|
||||
CPOSNonce curNonce;
|
||||
|
||||
BOOST_FOREACH(COutput &txout, vecOutputs)
|
||||
{
|
||||
if (txout.fSpendable && (UintToArith256(txout.tx->GetVerusPOSHash(txout.i, nHeight, pastHash)) <= target) && (txout.nDepth >= VERUS_MIN_STAKEAGE))
|
||||
if (txout.fSpendable && (UintToArith256(txout.tx->GetVerusPOSHash(&(pBlock->nNonce), txout.i, nHeight, pastHash)) <= target) && (txout.nDepth >= VERUS_MIN_STAKEAGE))
|
||||
{
|
||||
// get the smallest winner
|
||||
if (Solver(txout.tx->vout[txout.i].scriptPubKey, whichType, vSolutions) && (whichType == TX_PUBKEY || whichType == TX_PUBKEYHASH) &&
|
||||
(!pwinner || pwinner->tx->vout[pwinner->i].nValue > txout.tx->vout[txout.i].nValue))
|
||||
pwinner = &txout;
|
||||
curNonce = pBlock->nNonce;
|
||||
}
|
||||
}
|
||||
if (pwinner)
|
||||
{
|
||||
stakeSource = *(pwinner->tx);
|
||||
voutNum = pwinner->i;
|
||||
pBlock->nNonce = curNonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t CWallet::VerusStakeTransaction(CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig) const
|
||||
int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig) const
|
||||
{
|
||||
arith_uint256 target;
|
||||
CTransaction stakeSource;
|
||||
int32_t voutNum, siglen = 0;
|
||||
int64_t nValue;
|
||||
txnouttype whichType;
|
||||
std::vector<std::vector<unsigned char>> vSolutions;
|
||||
|
||||
CBlockIndex *tipindex = chainActive.Tip();
|
||||
CBlockIndex *tipindex;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
tipindex = chainActive.Tip();
|
||||
}
|
||||
bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());
|
||||
target.SetCompact(bnTarget);
|
||||
|
||||
if (!VerusSelectStakeOutput(hashResult, stakeSource, voutNum, tipindex->nHeight + 1, target) ||
|
||||
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->nHeight + 1, bnTarget) ||
|
||||
!Solver(stakeSource.vout[voutNum].scriptPubKey, whichType, vSolutions))
|
||||
{
|
||||
LogPrintf("Searched for eligible staking transactions, no winners found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// komodo create transaction code below this line
|
||||
bool signSuccess;
|
||||
SignatureData sigdata;
|
||||
uint64_t txfee;
|
||||
@@ -1076,7 +1086,7 @@ int32_t CWallet::VerusStakeTransaction(CMutableTransaction &txNew, uint32_t &bnT
|
||||
else
|
||||
return 0;
|
||||
|
||||
nValue = txNew.vout[0].nValue = voutNum - txfee;
|
||||
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);
|
||||
@@ -1568,7 +1578,7 @@ bool CWallet::IsMine(const CTransaction& tx)
|
||||
{
|
||||
for (int i = 0; i < tx.vout.size(); i++)
|
||||
{
|
||||
if (IsMine(tx, i) == ISMINE_SPENDABLE)
|
||||
if (IsMine(tx, i))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1149,8 +1149,8 @@ public:
|
||||
bool ignoreUnspendable=true);
|
||||
|
||||
// staking functions
|
||||
bool VerusSelectStakeOutput(arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, const arith_uint256 &target) const;
|
||||
int32_t VerusStakeTransaction(CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig) const;
|
||||
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) const;
|
||||
};
|
||||
|
||||
/** A key allocated from the key pool. */
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
BUILD_PATH="/tmp/zcbuild"
|
||||
PACKAGE_NAME="zcash"
|
||||
BUILD_PATH="/tmp/verus-cli"
|
||||
PACKAGE_NAME="verus-cli"
|
||||
SRC_PATH=`pwd`
|
||||
SRC_DEB=$SRC_PATH/contrib/debian
|
||||
SRC_DOC=$SRC_PATH/doc
|
||||
@@ -17,7 +17,13 @@ if [ ! -d $BUILD_PATH ]; then
|
||||
mkdir $BUILD_PATH
|
||||
fi
|
||||
|
||||
PACKAGE_VERSION=$($SRC_PATH/src/zcashd --version | grep version | cut -d' ' -f4 | tr -d v)
|
||||
## PACKAGE_VERSION=$($SRC_PATH/src/zcashd --version | grep version | cut -d' ' -f4 | tr -d v)
|
||||
## Need version setting from environment
|
||||
|
||||
PACKAGE_VERSION=0.3.10-beta
|
||||
|
||||
##
|
||||
## Also, what does the sed end up doing?
|
||||
DEBVERSION=$(echo $PACKAGE_VERSION | sed 's/-beta/~beta/' | sed 's/-rc/~rc/' | sed 's/-/+/')
|
||||
BUILD_DIR="$BUILD_PATH/$PACKAGE_NAME-$PACKAGE_VERSION-amd64"
|
||||
|
||||
@@ -38,8 +44,12 @@ chmod 0755 -R $BUILD_DIR/*
|
||||
#cp $SRC_DEB/preinst $BUILD_DIR/DEBIAN
|
||||
#cp $SRC_DEB/prerm $BUILD_DIR/DEBIAN
|
||||
# Copy binaries
|
||||
cp $SRC_PATH/src/zcashd $DEB_BIN
|
||||
cp $SRC_PATH/src/zcash-cli $DEB_BIN
|
||||
cp $SRC_PATH/src/komodod $DEB_BIN
|
||||
strip $DEB_BIN/komodod
|
||||
cp $SRC_PATH/src/verusd $DEB_BIN
|
||||
cp $SRC_PATH/src/komodo-cli $DEB_BIN
|
||||
strip $DEB_BIN/komodo-cli
|
||||
cp $SRC_PATH/src/verus $DEB_BIN
|
||||
cp $SRC_PATH/zcutil/fetch-params.sh $DEB_BIN/zcash-fetch-params
|
||||
# Copy docs
|
||||
cp $SRC_PATH/doc/release-notes/release-notes-1.0.0.md $DEB_DOC/changelog
|
||||
@@ -47,8 +57,8 @@ cp $SRC_DEB/changelog $DEB_DOC/changelog.Debian
|
||||
cp $SRC_DEB/copyright $DEB_DOC
|
||||
cp -r $SRC_DEB/examples $DEB_DOC
|
||||
# Copy manpages
|
||||
cp $SRC_DOC/man/zcashd.1 $DEB_MAN
|
||||
cp $SRC_DOC/man/zcash-cli.1 $DEB_MAN
|
||||
cp $SRC_DOC/man/komodod.1 $DEB_MAN
|
||||
cp $SRC_DOC/man/komodo-cli.1 $DEB_MAN
|
||||
cp $SRC_DOC/man/zcash-fetch-params.1 $DEB_MAN
|
||||
# Copy bash completion files
|
||||
cp $SRC_PATH/contrib/zcashd.bash-completion $DEB_CMP/zcashd
|
||||
@@ -56,14 +66,14 @@ cp $SRC_PATH/contrib/zcash-cli.bash-completion $DEB_CMP/zcash-cli
|
||||
# Gzip files
|
||||
gzip --best -n $DEB_DOC/changelog
|
||||
gzip --best -n $DEB_DOC/changelog.Debian
|
||||
gzip --best -n $DEB_MAN/zcashd.1
|
||||
gzip --best -n $DEB_MAN/zcash-cli.1
|
||||
gzip --best -n $DEB_MAN/komodod.1
|
||||
gzip --best -n $DEB_MAN/komodo-cli.1
|
||||
gzip --best -n $DEB_MAN/zcash-fetch-params.1
|
||||
|
||||
cd $SRC_PATH/contrib
|
||||
|
||||
# Create the control file
|
||||
dpkg-shlibdeps $DEB_BIN/zcashd $DEB_BIN/zcash-cli
|
||||
dpkg-shlibdeps $DEB_BIN/komodod $DEB_BIN/komodo-cli
|
||||
dpkg-gencontrol -P$BUILD_DIR -v$DEBVERSION
|
||||
|
||||
# Create the Debian package
|
||||
|
||||
@@ -9,9 +9,10 @@ set -eu -o pipefail
|
||||
set -x
|
||||
cd "$(dirname "$(readlink -f "$0")")/.."
|
||||
|
||||
cd depends/ && make HOST=$HOST V=1 NO_QT=1 && cd ../
|
||||
cd depends/ && make HOST=$HOST V=1 NO_QT=1
|
||||
cd ../
|
||||
./autogen.sh
|
||||
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site CXXFLAGS="-DPTW32_STATIC_LIB -DCURL_STATICLIB -DCURVE_ALT_BN128 -fopenmp -pthread" ./configure --prefix="${PREFIX}" --host=x86_64-w64-mingw32 --enable-static --disable-shared
|
||||
sed -i 's/-lboost_system-mt /-lboost_system-mt-s /' configure
|
||||
cd src/
|
||||
CC="${CC}" CXX="${CXX}" make V=1 komodod.exe komodo-cli.exe komodo-tx.exe
|
||||
CC="${CC} -g " CXX="${CXX} -g " make V=1 komodod.exe komodo-cli.exe komodo-tx.exe
|
||||
|
||||
Reference in New Issue
Block a user