From d974a5c0e42d3bab35f00adc2dca867644b52be5 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Thu, 13 Sep 2018 12:54:52 -0700 Subject: [PATCH 1/6] Update verus fixed path for komodo-cli --- src/verus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verus b/src/verus index 8f6f56892..443633e3c 100755 --- a/src/verus +++ b/src/verus @@ -1,2 +1,2 @@ #!/bin/bash -komodo-cli -ac_name=VRSC "$@" +./komodo-cli -ac_name=VRSC "$@" From e7657bf1f689cb0f19f85b52c996dde4627d0b28 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Sun, 21 Oct 2018 11:09:52 -0700 Subject: [PATCH 2/6] Dev (#139) * Adding comments to structure GitLab-CI configuration enabling tests * Fixing verus shell script to change to its current directory upon call. --- .gitlab-ci.yml | 165 +++++++++++++++++++++++++++++++------------------ src/verus | 3 + 2 files changed, 108 insertions(+), 60 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc5aa3dd0..cffc3643a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,9 @@ stages: - build - test - deploy - - +######################################################################################################################## +####START#### PROJECT LEVEL VARIABLES ####START#### +######################################################################################################################## variables: VERSION: 0.4.0a VERUS_CLI_LINUX: Verus-CLI-Linux-v${VERSION}.tar.gz @@ -14,27 +15,35 @@ variables: Pipeline Trigger: ${CI_PIPELINE_SOURCE}\n Commit: ${CI_COMMIT_SHA}$\n ${CI_COMMIT_MESSAGE}" - - +######################################################################################################################## +####END#### PROJECT LEVEL VARIABLES ####END#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Build Stage: compile and package komodo binaries for Verus CLI ####START##### +######################################################################################################################## +######################################################################################################################## +####START#### LINUX ####START#### +######################################################################################################################## build:linux: image: asherd/verus-builders:verus-ubuntu variables: DOCKER_DRIVER: overlay2 stage: build cache: - key: ${CI_JOB_NAME} + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" paths: - depends/built script: - zcutil/build.sh -j$(nproc) - mkdir verus-cli - cp src/komodod - src/komodo-cli - src/verus - src/verusd - doc/man/verus-cli/linux/README.txt - zcutil/fetch-params.sh - verus-cli + src/komodo-cli + src/verus + src/verusd + doc/man/verus-cli/linux/README.txt + zcutil/fetch-params.sh + verus-cli - mv verus-cli/fetch-params.sh verus-cli/fetch-params - chmod +x verus-cli/komodod - chmod +x verus-cli/komodo-cli @@ -53,27 +62,30 @@ build:linux: - ${VERUS_CLI_LINUX} - ${VERUS_CLI_LINUX}.md5 expire_in: 1 week - - +######################################################################################################################## +####END#### LINUX ####END#### +######################################################################################################################## +####START#### WINDOWS ####START#### +######################################################################################################################## build:windows: image: asherd/verus-builders:verus-windows variables: DOCKER_DRIVER: overlay2 stage: build cache: - key: ${CI_JOB_NAME} + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" paths: - depends/built script: - zcutil/build-win.sh -j$(nproc) - mkdir verus-cli - cp src/komodod.exe - src/komodo-cli.exe - src/komodo-tx.exe - doc/man/verus-cli/windows/README.txt - zcutil/fetch-params.bat - zcutil/wget64.exe - verus-cli + src/komodo-cli.exe + src/komodo-tx.exe + doc/man/verus-cli/windows/README.txt + zcutil/fetch-params.bat + zcutil/wget64.exe + verus-cli - zip -r ${VERUS_CLI_WINDOWS} verus-cli - md5sum ${VERUS_CLI_WINDOWS} > ${VERUS_CLI_WINDOWS}.md5 - curl -F file=@"${VERUS_CLI_WINDOWS}" @@ -86,17 +98,19 @@ build:windows: - ${VERUS_CLI_WINDOWS} - ${VERUS_CLI_WINDOWS}.md5 expire_in: 1 week - - +######################################################################################################################## +####END#### WINDOWS ####END#### +######################################################################################################################## +####START#### MACOS ####START#### +######################################################################################################################## build:mac: stage: build tags: ["High Sierra"] cache: - key: ${CI_JOB_NAME} + key: "${CI_JOB_NAME}${CI_COMMIT_REF_NAME}" paths: - depends/built script: - - brew bundle - zcutil/build-mac.sh -j$(sysctl -n hw.physicalcpu) - ./makeReleaseMac.sh - tar -czvf ${VERUS_CLI_MACOS} verus-cli @@ -111,8 +125,21 @@ build:mac: - ${VERUS_CLI_MACOS} - ${VERUS_CLI_MACOS}.md5 expire_in: 1 week - - +######################################################################################################################## +####END#### MACOS ####END#### +######################################################################################################################## +######################################################################################################################## +####END#### Build Stage ####END#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Test stage: Test functionality of komodo binaries. Produce code quality and SAST reports. ####START#### +######################################################################################################################## +######################################################################################################################## +######################################################################################################################## +####START#### Code Quality ####START#### +######################################################################################################################## .code_quality: image: docker:stable variables: @@ -129,8 +156,12 @@ build:mac: "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code artifacts: paths: [gl-code-quality-report.json] - - +######################################################################################################################## +####END#### Code Quality ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Static Application Security Tests ####START#### +######################################################################################################################## .sast: image: docker:stable variables: @@ -147,31 +178,19 @@ build:mac: "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] - - +######################################################################################################################## +####END#### Static Application Security Tests ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Run Verus CLI on Ubuntu Xenial (16.04) ####START#### +######################################################################################################################## .ubuntu:xenial: image: ubuntu:xenial variables: DOCKER_DRIVER: overlay2 stage: test before_script: - - apt update && apt install -y wget libgomp1 libcurl3 python + - apt update && apt install -y wget libgomp1 libcurl4-gnutls-dev python - rm -rf /root/.komodo || true - mv .komodo /root/ || true script: @@ -188,15 +207,19 @@ build:mac: expire_in: 1 week dependencies: - build:linux - - +######################################################################################################################## +####END#### Run Verus CLI on Ubuntu Xenial (16.04) ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Run Verus CLI on Ubuntu Bionic (18.04) ####START#### +######################################################################################################################## .ubuntu:bionic: image: ubuntu:bionic variables: DOCKER_DRIVER: overlay2 stage: test before_script: - - apt update && apt install -y wget libgomp1 libcurl3 python + - apt update && apt install -y wget libgomp1 libcurl4-gnutls-dev python - rm -rf /root/.komodo || true - mv .komodo /root/ || true script: @@ -213,9 +236,13 @@ build:mac: expire_in: 1 week dependencies: - build:linux - - -.macos:sierra: # fetch-params.sh needs to be fixed for MacOS +######################################################################################################################## +####END#### Run Verus CLI on Ubuntu Bionic (18.04) ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Run Verus CLI on MacOS Sierra (10.12.6) ####START#### +######################################################################################################################## +.macos:sierra: stage: test tags: ["Sierra"] script: @@ -227,8 +254,12 @@ build:mac: expire_in: 1 week dependencies: - build:mac - - +######################################################################################################################## +####END#### Run Verus CLI on MacOS Sierra (10.12.6) ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Run Verus CLI on MacOS High Sierra (10.12.6) ####START#### +######################################################################################################################## .macos:high-sierra: stage: test tags: ["High Sierra"] @@ -241,8 +272,12 @@ build:mac: expire_in: 1 week dependencies: - build:mac - - +######################################################################################################################## +####START#### Run Verus CLI on MacOS High Sierra (10.12.6) ####START#### +######################################################################################################################## +######################################################################################################################## +####START#### Run Verus CLI on Windows 10 ####START#### +######################################################################################################################## .windows:10: stage: test tags: ["Windows 10"] @@ -255,8 +290,15 @@ build:mac: expire_in: 1 week dependencies: - build:windows - - +######################################################################################################################## +####END#### Run Verus CLI on Windows 10 ####END#### +######################################################################################################################## +######################################################################################################################## +####END#### Test Stage ####END#### +######################################################################################################################## +######################################################################################################################## +####START#### Deploy ####START#### +######################################################################################################################## deploy: stage: deploy image: google/cloud-sdk:alpine @@ -274,7 +316,7 @@ deploy: - echo "$AUTH_KEY" > AUTH_KEY.json && gcloud auth activate-service-account --key-file AUTH_KEY.json - - gsutil cp -r Windows Linux MacOS $STAGING/VerusCoin/$CI_COMMIT_REF_NAME/ + - gsutil cp -r Windows Linux MacOS $STAGING/${CI_PROJECT_NAME}/${CI_COMMIT_REF_NAME}/ - curl -X POST -F token="$CI_JOB_TOKEN" -F ref="$DOWNSTREAM_AGAMA_BRANCH" @@ -283,3 +325,6 @@ deploy: -F variables\[VERUS_CLI_WINDOWS\]="${VERUS_CLI_WINDOWS}" -F variables\[VERUS_CLI_MACOS\]="${VERUS_CLI_MACOS}" "https://gitlab.com/api/v4/projects/8018592/trigger/pipeline" +######################################################################################################################## +####END#### Deploy ####END#### +######################################################################################################################## diff --git a/src/verus b/src/verus index 443633e3c..7e4109b59 100755 --- a/src/verus +++ b/src/verus @@ -1,2 +1,5 @@ #!/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 "$@" From 8a1e0d0d5f4e73481ba40a5955eefdbb248ccc51 Mon Sep 17 00:00:00 2001 From: miketout Date: Tue, 23 Oct 2018 16:39:31 -0700 Subject: [PATCH 3/6] Add support for -zcashparamsdir parameter --- src/rpc/mining.cpp | 2 ++ src/util.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 409ab0137..b1bb404d2 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -878,6 +878,7 @@ UniValue submitblock(const UniValue& params, bool fHelp) ); CBlock block; + //LogPrintStr("Hex block submission: " + params[0].get_str()); if (!DecodeHexBlk(block, params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); @@ -903,6 +904,7 @@ UniValue submitblock(const UniValue& params, bool fHelp) CValidationState state; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); + //printf("submitblock, height=%d, coinbase sequence: %d, scriptSig: %s\n", chainActive.LastTip()->GetHeight()+1, block.vtx[0].vin[0].nSequence, block.vtx[0].vin[0].scriptSig.ToString().c_str()); bool fAccepted = ProcessNewBlock(1,chainActive.LastTip()->GetHeight()+1,state, NULL, &block, true, NULL); UnregisterValidationInterface(&sc); if (fBlockPresent) diff --git a/src/util.cpp b/src/util.cpp index 9a8391f63..5ce7c4967 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -556,6 +556,12 @@ static boost::filesystem::path ZC_GetBaseParamsDir() // Unix: ~/.zcash-params #ifdef _WIN32 // Windows + if (mapArgs.count("-zcashparamsdir")) { + path = fs::system_complete(mapArgs["-zcashparamsdir"]); + if (fs::is_directory(path)) { + return path; + } + } return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams"; #else fs::path pathRet; From 9532e6b7c999ba4e26225664b04e12a4264fd780 Mon Sep 17 00:00:00 2001 From: miketout Date: Tue, 23 Oct 2018 21:21:59 -0700 Subject: [PATCH 4/6] Hoisted path var in ZC_GetBaseParamsDir --- src/util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util.cpp b/src/util.cpp index 5ce7c4967..753f52ae4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -554,17 +554,17 @@ static boost::filesystem::path ZC_GetBaseParamsDir() // Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams // Mac: ~/Library/Application Support/ZcashParams // Unix: ~/.zcash-params + fs::path pathRet; #ifdef _WIN32 // Windows if (mapArgs.count("-zcashparamsdir")) { - path = fs::system_complete(mapArgs["-zcashparamsdir"]); - if (fs::is_directory(path)) { - return path; + pathRet = fs::system_complete(mapArgs["-zcashparamsdir"]); + if (fs::is_directory(pathRet)) { + return pathRet; } } return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams"; #else - fs::path pathRet; char* pszHome = getenv("HOME"); if (pszHome == NULL || strlen(pszHome) == 0) pathRet = fs::path("/"); From 4c8293dc76f0ab5a4da09545928ee0536113a0b1 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 25 Oct 2018 23:25:31 -0700 Subject: [PATCH 5/6] Fixed issue #145, should fix stake synching with wallets --- src/cc/CCinclude.h | 2 +- src/main.cpp | 42 ++++++++++++++++++++++++++-------------- src/rpc/server.cpp | 2 +- src/wallet/rpcwallet.cpp | 5 +++-- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index fa4ea7960..a1e433fdd 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -101,7 +101,7 @@ bool GetAddressUnspent(uint160 addressHash, int type,std::vectorGetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) { @@ -1579,6 +1571,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } + // if this is a valid stake transaction, don't put it in the mempool + CStakeParams p; + if (ValidateStakeTransaction(tx, p, false)) + { + return state.DoS(0, error("AcceptToMemoryPool: attempt to add staking transaction to the mempool"), + REJECT_INVALID, "staking"); + } + // is it already in the memory pool? uint256 hash = tx.GetHash(); if (pool.exists(hash)) @@ -1891,9 +1891,12 @@ bool GetAddressUnspent(uint160 addressHash, int type, else return(coins.vout[n].nValue); }*/ -bool myAddtomempool(CTransaction &tx) +bool myAddtomempool(CTransaction &tx, CValidationState *pstate) { - CValidationState state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; + CValidationState state; + if (!pstate) + pstate = &state; + CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) return(AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)); else return(true); @@ -4541,18 +4544,27 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { - CValidationState stateDummy; int32_t i,j,rejects=0,lastrejects=0; + int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); while ( 1 ) { for (i=0; i 0) + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + if (params.size() > 0) throw runtime_error("getbalance64\n"); total = total2 = 0; memset(nValues,0,sizeof(nValues)); From a12f70bf5506ebf86b2a052230a36014e0e25b1d Mon Sep 17 00:00:00 2001 From: miketout Date: Fri, 26 Oct 2018 01:04:07 -0700 Subject: [PATCH 6/6] Ensure that only valid staking transactions are synced with wallets --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0e2549326..11ed27928 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4558,9 +4558,9 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C Tx = tx; if ( myAddtomempool(Tx, &state) == false ) // happens with out of order tx in block on resync { - // take advantage of other checks, but if we were only rejected because it is a staking + // take advantage of other checks, but if we were only rejected because it is a valid staking // transaction, sync with wallets and don't mark as a reject - if (state.GetRejectReason() == "staking") + if (i == (block.vtx.size() - 1) && ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock() && state.GetRejectReason() == "staking") SyncWithWallets(Tx, &block); else rejects++;