From 668681c238b43dff228713dfa48a7fb3bf66b62f Mon Sep 17 00:00:00 2001 From: miketout Date: Fri, 16 Sep 2022 16:32:50 -0700 Subject: [PATCH 01/10] Log earned notarization output when mining/staking --- src/miner.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b924a14dc..83905220b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -2075,13 +2075,17 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const std::vecto CValidationState state; CPBaaSNotarization earnedNotarization; + int numOuts = coinbaseTx.vout.size(); if (CPBaaSNotarization::CreateEarnedNotarization(ConnectedChains.FirstNotaryChain(), DestinationToTransferDestination(proposer), isStake, state, coinbaseTx.vout, - earnedNotarization)) + earnedNotarization) && + numOuts != coinbaseTx.vout.size() && + LogAcceptCategory("notarization")) { + LogPrintf("%s: entering earned notarization into block %u, notarization: %s\n", __func__, Mining_height, earnedNotarization.ToUniValue().write(1,2).c_str()); } CPBaaSNotarization lastImportNotarization; CUTXORef lastImportNotarizationUTXO; From fb5889e5886aa5e28e434ec7713ca28ec9b8d0c7 Mon Sep 17 00:00:00 2001 From: miketout Date: Tue, 20 Sep 2022 12:02:13 -0700 Subject: [PATCH 02/10] vdxfid client json parsing fix & misc cleanup --- src/komodo_globals.h | 2 +- src/pbaas/pbaas.cpp | 2 +- src/rpc/client.cpp | 1 + src/rpc/misc.cpp | 18 +++++++++++++----- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 4ba466576..303cd3bf0 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -96,7 +96,7 @@ uint32_t ASSETCHAINS_STARTING_DIFF = 0; // Verus proof of stake controls int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS int32_t VERUS_BLOCK_POSUNITS = 1024; // one block is 1000 units -int32_t VERUS_MIN_STAKEAGE = 150; // 1/2 this should also be a cap on the POS averaging window, or startup could be too easy +int32_t VERUS_MIN_STAKEAGE = 150; // 2x this should also be a cap on the POS averaging window, or startup could be too easy int32_t VERUS_CONSECUTIVE_POS_THRESHOLD = 7; // this gives us 9 in a row int32_t VERUS_PBAAS_CONSECUTIVE_POS_THRESHOLD = 3; // reduce to max 5 in a row int32_t VERUS_NOPOS_THRESHHOLD = 150; // if we have no POS blocks in this many blocks, reset difficulty diff --git a/src/pbaas/pbaas.cpp b/src/pbaas/pbaas.cpp index 7ce7348f5..e2c721a86 100644 --- a/src/pbaas/pbaas.cpp +++ b/src/pbaas/pbaas.cpp @@ -3780,7 +3780,7 @@ std::string CConnectedChains::GetFriendlyCurrencyName(const uint160 ¤cyID) std::string retName; uint160 curID = currencyID; CCurrencyDefinition curDef; - for (curDef = GetCachedCurrency(curID); curDef.IsValid(); curDef = GetCachedCurrency(curID)) + for (curDef = GetCachedCurrency(curID); curDef.IsValid(); curDef = curID.IsNull() ? CCurrencyDefinition() : GetCachedCurrency(curID)) { if (curDef.parent.IsNull()) { diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 10536fb4c..3a2ddda3f 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -1710,6 +1710,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "makeoffer", 1}, { "takeoffer", 1}, { "closeoffers", 0}, + { "getvdxfid", 1}, // Zcash addition { "z_setmigration", 0}, }; diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 22596c72f..8d9accd61 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1585,8 +1585,8 @@ bool timestampSort(std::pair a, } -void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript script, CAmount satoshis, bool friendlyNames=false); -void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript script, CAmount satoshis, bool friendlyNames) +void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript &script, CAmount satoshis, bool friendlyNames=false); +void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript &script, CAmount satoshis, bool friendlyNames) { if (CConstVerusSolutionVector::GetVersionByHeight(chainActive.Height()) >= CActivationHeight::ACTIVATE_PBAAS) { @@ -1609,7 +1609,7 @@ void CurrencyValuesAndNames(UniValue &output, bool spending, const CScript scrip currencyBal.push_back(make_pair(name, ValueFromAmount(oneBalance.second))); if (friendlyNames) { - currencyNames.push_back(make_pair(name, ConnectedChains.GetFriendlyCurrencyName(oneBalance.first))); + currencyNames.pushKV(name, ConnectedChains.GetFriendlyCurrencyName(oneBalance.first)); } } output.pushKV("currencyvalues", currencyBal); @@ -1795,7 +1795,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) std::string address = ""; - if (it->second.script.IsPayToCryptoCondition()) + COptCCParams p; + if (it->second.script.IsPayToCryptoCondition(p) && p.IsValid()) { txnouttype outType; std::vector addresses; @@ -1826,7 +1827,14 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) output.push_back(Pair("txid", it->first.txhash.GetHex())); output.push_back(Pair("outputIndex", (int)it->first.index)); output.push_back(Pair("script", HexStr(it->second.script.begin(), it->second.script.end()))); - CurrencyValuesAndNames(output, false, it->second.script, it->second.satoshis, friendlyNames); + if (p.IsValid()) + { + CurrencyValuesAndNames(output, false, it->second.script, it->second.satoshis, friendlyNames); + } + else + { + UniValue + } output.push_back(Pair("satoshis", it->second.satoshis)); output.push_back(Pair("height", it->second.blockHeight)); if (chainActive.Height() >= it->second.blockHeight) From 412c4947f2d171b020041cf2acff195e4fb89b55 Mon Sep 17 00:00:00 2001 From: miketout Date: Tue, 20 Sep 2022 19:34:55 -0700 Subject: [PATCH 03/10] Error message update --- src/rpc/pbaasrpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/pbaasrpc.cpp b/src/rpc/pbaasrpc.cpp index ab744710a..5187d4813 100644 --- a/src/rpc/pbaasrpc.cpp +++ b/src/rpc/pbaasrpc.cpp @@ -9739,7 +9739,7 @@ UniValue registernamecommitment(const UniValue& params, bool fHelp) if (!success) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Insufficient funds for identity registration"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Insufficient funds for identity commitment registration"); } // aggregate all inputs into one output with only the offer coins and offer indexes From 3c6a803fe46c64ac5a8d0492855ce7e04d5b2ba3 Mon Sep 17 00:00:00 2001 From: miketout Date: Tue, 20 Sep 2022 21:57:07 -0700 Subject: [PATCH 04/10] RPC request debug logging with -debug=rpcrequests --- src/rpc/misc.cpp | 4 ---- src/rpc/server.cpp | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 8d9accd61..f80c90d94 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1831,10 +1831,6 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp) { CurrencyValuesAndNames(output, false, it->second.script, it->second.satoshis, friendlyNames); } - else - { - UniValue - } output.push_back(Pair("satoshis", it->second.satoshis)); output.push_back(Pair("height", it->second.blockHeight)); if (chainActive.Height() >= it->second.blockHeight) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 7b3ef974d..10f1f01f2 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -729,6 +729,8 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method " + strMethod + " not found"); } + LogPrint("rpcrequests", "command %s, params:\n%s\n", strMethod.c_str(), params.write(1,2).c_str()); + g_rpcSignals.PreCommand(*pcmd); try From 8948798ee5a9e1433a97d9198f3f78b7ac77b565 Mon Sep 17 00:00:00 2001 From: who-biz <37732338+who-biz@users.noreply.github.com> Date: Wed, 21 Sep 2022 17:32:41 +0000 Subject: [PATCH 05/10] Add '-blocktime' and '-averagingwindow' startup flags - Gives VerusCoin a fully configurable DAA --- src/chainparams.cpp | 29 +++++++++++++++++++++++------ src/chainparams.h | 2 ++ src/consensus/params.h | 1 + src/init.cpp | 2 ++ src/main.h | 4 ++++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 1a79ce276..9ff31581f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -107,12 +107,10 @@ public: consensus.nEquihashN = N; consensus.nEquihashK = K; consensus.nPowAveragingWindow = 17; - consensus.nMaxFutureBlockTime = 7 * 60; // 7 mins assert(maxUint/UintToArith256(consensus.powLimit) >= consensus.nPowAveragingWindow); consensus.nPowMaxAdjustDown = 32; // 32% adjustment down consensus.nPowMaxAdjustUp = 16; // 16% adjustment up - consensus.nPowTargetSpacing = 1 * 60; consensus.nPreBlossomPowTargetSpacing = Consensus::PRE_BLOSSOM_POW_TARGET_SPACING; consensus.nPostBlossomPowTargetSpacing = Consensus::POST_BLOSSOM_POW_TARGET_SPACING; consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none; @@ -145,7 +143,6 @@ public: // (Zcash) vAlertPubKey = ParseHex("04b7ecf0baa90495ceb4e4090f6b2fd37eec1e9c85fac68a487f3ce11589692e4a317479316ee814e066638e1db54e37a10689b70286e6315b1087b6615d179264"); nDefaultPort = 7770; nMinerThreads = 0; - nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"; @@ -241,13 +238,25 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %lu coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,ASSETCHAINS_SUPPLY / COIN); + int64_t nBlockTime = GetArg("-blocktime",DEFAULT_BLOCKTIME_TARGET); + mainParams.SetBlockTime(nBlockTime); + if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: - // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing - mainParams.consensus.nLwmaAjustedWeight = 1350; - mainParams.consensus.nPowAveragingWindow = 45; + // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing + int64_t PowAveragingWindow = GetArg("-averagingwindow",DEFAULT_AVERAGING_WINDOW); + mainParams.consensus.nPowAveragingWindow = PowAveragingWindow; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); + + if (mainParams.consensus.nBlockTime != DEFAULT_BLOCKTIME_TARGET) + { + float weight = (float)((mainParams.consensus.nPowAveragingWindow+1)/2) * std::pow(0.9989f,(500.0f/((float)mainParams.consensus.nPowAveragingWindow))) * (float)mainParams.consensus.nBlockTime; + mainParams.consensus.nLwmaAjustedWeight = (((int)weight)/10)*10; // int conversion, round down to nearest mutiple of 10 + //LogPrintf(">>> nLwmaAjustedWeight = %ld\n",mainParams.consensus.nLwmaAjustedWeight); + } else { + mainParams.consensus.nLwmaAjustedWeight = 1350; + } } if (ASSETCHAINS_LWMAPOS != 0) @@ -780,6 +789,14 @@ bool AreParamsInitialized() return (pCurrentParams != NULL); } +void CChainParams::SetBlockTime(uint64_t blockTime) +{ + consensus.nBlockTime = blockTime; + consensus.nMaxFutureBlockTime = 7 * consensus.nBlockTime; + consensus.nPowTargetSpacing = consensus.nBlockTime; + nMaxTipAge = 24 * 60 * consensus.nBlockTime; +} + CChainParams &Params(CBaseChainParams::Network network) { switch (network) { case CBaseChainParams::MAIN: diff --git a/src/chainparams.h b/src/chainparams.h index 8a11acb58..f9c755b7c 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -125,6 +125,8 @@ public: CMessageHeader::MessageStartChars pchMessageStart; // jl777 moved Consensus::Params consensus; + void SetBlockTime(uint64_t blockTime); + protected: CChainParams() {} diff --git a/src/consensus/params.h b/src/consensus/params.h index 7637fe56d..0d42321d1 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -124,6 +124,7 @@ struct Params { int64_t nPowMaxAdjustDown; int64_t nPowMaxAdjustUp; int64_t nPowTargetSpacing; + int64_t nBlockTime; int64_t nLwmaAjustedWeight; /* Proof of stake parameters */ diff --git a/src/init.cpp b/src/init.cpp index 6a4c1eb8a..040bcb186 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -515,6 +515,8 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-miningdistribution={\"addressorid\":,...}", _("destination addresses and relative amounts used as ratios to divide total rewards + fees")); strUsage += HelpMessageOpt("-miningdistributionpassthrough", _("uses the same miningdistribution values and addresses/IDs as Verus when merge mining")); strUsage += HelpMessageOpt("-chain=pbaaschainname", _("loads either mainnet or resolves and loads a PBaaS chain if not vrsc or vrsctest")); + strUsage += HelpMessageOpt("-blocktime=", strprintf(_("Set target block time (in seconds) for difficulty adjustment (default: %d)"), DEFAULT_BLOCKTIME_TARGET)); + strUsage += HelpMessageOpt("-averagingwindow=", strprintf(_("Set averaging window for difficulty adjustment, in blocks (default: %d)"), DEFAULT_AVERAGING_WINDOW)); strUsage += HelpMessageOpt("-testnet", _("loads PBaaS network in testmode")); strUsage += HelpMessageGroup(_("Node relay options:")); diff --git a/src/main.h b/src/main.h index 8dd5ca1ce..b07b0fcc2 100644 --- a/src/main.h +++ b/src/main.h @@ -58,6 +58,10 @@ struct CNodeStateStats; #define DEFAULT_MEMPOOL_EXPIRY 1 #define _COINBASE_MATURITY 100 +/** Default block time target for difficulty adjustment, in seconds **/ +static const unsigned int DEFAULT_BLOCKTIME_TARGET = 60; +/** Default target spacing (blocks) for difficulty adjustment **/ +static const unsigned int DEFAULT_AVERAGING_WINDOW = 45; /** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SIZE; static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0; From 65ad097de4999970d29e004723d5f8d3aa895b36 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 22 Sep 2022 14:22:40 -0700 Subject: [PATCH 06/10] Explorer fix, make defaultid default to notaryid --- src/init.cpp | 4 ++-- src/rpc/misc.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 6a4c1eb8a..7a5b2d458 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1265,10 +1265,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } // get default IDs and addresses - auto defaultIDDest = DecodeDestination(GetArg("-defaultid", "")); - VERUS_DEFAULTID = defaultIDDest.which() == COptCCParams::ADDRTYPE_ID ? CIdentityID(GetDestinationID(defaultIDDest)) : CIdentityID(); auto notaryIDDest = DecodeDestination(GetArg("-notaryid", "")); VERUS_NOTARYID = notaryIDDest.which() == COptCCParams::ADDRTYPE_ID ? CIdentityID(GetDestinationID(notaryIDDest)) : CIdentityID(); + auto defaultIDDest = DecodeDestination(GetArg("-defaultid", VERUS_NOTARYID.IsNull() ? "" : EncodeDestination(notaryIDDest))); + VERUS_DEFAULTID = defaultIDDest.which() == COptCCParams::ADDRTYPE_ID ? CIdentityID(GetDestinationID(defaultIDDest)) : CIdentityID(); auto nodeIDDest = DecodeDestination(GetArg("-nodeid", "")); VERUS_NODEID = nodeIDDest.which() == COptCCParams::ADDRTYPE_ID ? GetDestinationID(nodeIDDest) : uint160(); VERUS_DEFAULT_ZADDR = GetArg("-cheatcatcher", ""); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index f80c90d94..53a3a9cda 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1639,7 +1639,14 @@ void CurrencyValuesAndNames(UniValue &output, bool spending, const CTransaction } else { - script = tx.vout[index].scriptPubKey; + if (tx.vout.size() > index && index >= 0) + { + script = tx.vout[index].scriptPubKey; + } + else + { + throw JSONRPCError(RPC_DATABASE_ERROR, "Unable to retrieve data to for currency output values"); + } } return CurrencyValuesAndNames(output, spending, script, satoshis, friendlyNames); } @@ -1672,7 +1679,10 @@ UniValue AddressMemPoolUni(const std::vector> &addresses delta.push_back(Pair("index", (int)it->first.index)); delta.push_back(Pair("satoshis", it->second.amount)); delta.push_back(Pair("spending", (bool)it->first.spending)); - CurrencyValuesAndNames(delta, it->first.spending, curTx, it->first.index, it->second.amount, friendlyNames); + if (!it->first.txhash.IsNull() && it->first.txhash == curTx.GetHash() || mempool.lookup(it->first.txhash, curTx)) + { + CurrencyValuesAndNames(delta, it->first.spending, curTx, it->first.index, it->second.amount, friendlyNames); + } delta.push_back(Pair("timestamp", it->second.time)); if (it->second.amount < 0) { delta.push_back(Pair("prevtxid", it->second.prevhash.GetHex())); @@ -1957,7 +1967,7 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp) } uint256 blockHash; - if (verbosity && (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash))) + if (verbosity && !it->first.txhash.IsNull() && (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash))) { CurrencyValuesAndNames(delta, it->first.spending, curTx, it->first.index, it->second, friendlyNames); } @@ -2049,7 +2059,7 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp) for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { uint256 blockHash; - if (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash)) + if (!it->first.txhash.IsNull() && (it->first.txhash == curTx.GetHash() || myGetTransaction(it->first.txhash, curTx, blockHash))) { if (it->first.spending) { CTransaction priorOutTx; From 294d57c16f2ee3bbc23b39198fdbfae8eb0c8d45 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Thu, 22 Sep 2022 15:38:57 -0700 Subject: [PATCH 07/10] Update deprecation height --- src/deprecation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deprecation.h b/src/deprecation.h index d6e64af46..0ac67f60e 100644 --- a/src/deprecation.h +++ b/src/deprecation.h @@ -9,7 +9,7 @@ // * Shut down 20 weeks' worth of blocks after the estimated release block height. // * A warning is shown during the 2 weeks' worth of blocks prior to shut down. -static const int APPROX_RELEASE_HEIGHT = 2203000; +static const int APPROX_RELEASE_HEIGHT = 2212000; static const int WEEKS_UNTIL_DEPRECATION = 20; static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 60 * 24); From 693a7eb80eafa53ae91fa1d6429141ec48a6c78a Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Thu, 22 Sep 2022 15:39:39 -0700 Subject: [PATCH 08/10] Update version --- .gitlab-ci.yml | 2 +- README.md | 2 +- doc/man/verus-cli/linux/README.txt | 2 +- doc/man/verus-cli/mac/README.txt | 2 +- doc/man/verus-cli/windows/README.txt | 2 +- src/version.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d16755ecc..a8a5d7bf4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: ######################################################################################################################## variables: - VERSION: 0.9.4-4 + VERSION: 0.9.4-5 VERUS_CLI_ARM64_LINUX: Verus-CLI-Linux-v${VERSION}-arm64.tar.gz VERUS_CLI_LINUX_X86_64: Verus-CLI-Linux-v${VERSION}-x86_64.tar.gz diff --git a/README.md b/README.md index a9230dcd2..44c37e62c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -## VerusCoin version 0.9.4-4 +## VerusCoin version 0.9.4-5 Arguably the world's most advanced technology, zero knowledge privacy-centric blockchain, Verus Coin brings Sapling performance and zero knowledge features to an intelligent system with interchain smart contracts and a completely original, combined proof of stake/proof of work consensus algorithm that solves the nothing at stake problem. With this and its approach towards CPU mining and ASICs, Verus Coin strives to be one of the most naturally decentralizing and attack resistant blockchains in existence. diff --git a/doc/man/verus-cli/linux/README.txt b/doc/man/verus-cli/linux/README.txt index 0cba39710..b60db241e 100644 --- a/doc/man/verus-cli/linux/README.txt +++ b/doc/man/verus-cli/linux/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v0.9.4-4 +VerusCoin Command Line Tools v0.9.4-5 Contents: verusd - VerusCoin daemon diff --git a/doc/man/verus-cli/mac/README.txt b/doc/man/verus-cli/mac/README.txt index ef30ed448..36beb99f3 100644 --- a/doc/man/verus-cli/mac/README.txt +++ b/doc/man/verus-cli/mac/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v0.9.4-4 +VerusCoin Command Line Tools v0.9.4-5 Contents: verusd - VerusCoin daemon. diff --git a/doc/man/verus-cli/windows/README.txt b/doc/man/verus-cli/windows/README.txt index 12f039455..2ac397627 100644 --- a/doc/man/verus-cli/windows/README.txt +++ b/doc/man/verus-cli/windows/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v0.9.4-4 +VerusCoin Command Line Tools v0.9.4-5 Contents: verusd.exe - VerusCoin daemon diff --git a/src/version.h b/src/version.h index c6b6f4702..b28a5a4c8 100644 --- a/src/version.h +++ b/src/version.h @@ -35,6 +35,6 @@ static const int MEMPOOL_GD_VERSION = 60002; static const int NO_BLOOM_VERSION = 170004; #define KOMODO_VERSION "0.2.1" -#define VERUS_VERSION "0.9.4-4" +#define VERUS_VERSION "0.9.4-5" #endif // BITCOIN_VERSION_H From dd0bc957999ec8a6014c249f79797c00500b2a50 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 22 Sep 2022 17:22:23 -0700 Subject: [PATCH 09/10] Change from float calc to dec_float for block time --- src/chainparams.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9ff31581f..6016f1640 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -238,22 +238,38 @@ void *chainparams_commandline(void *ptr) mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff; fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %lu coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,ASSETCHAINS_SUPPLY / COIN); - int64_t nBlockTime = GetArg("-blocktime",DEFAULT_BLOCKTIME_TARGET); + bool isVerusActive = _IsVerusActive(); + + int64_t nBlockTime = isVerusActive ? DEFAULT_BLOCKTIME_TARGET : GetArg("-blocktime", DEFAULT_BLOCKTIME_TARGET); mainParams.SetBlockTime(nBlockTime); if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH) { // this is only good for 60 second blocks with an averaging window of 45. for other parameters, use: // nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing - int64_t PowAveragingWindow = GetArg("-averagingwindow",DEFAULT_AVERAGING_WINDOW); + int64_t PowAveragingWindow = isVerusActive ? DEFAULT_AVERAGING_WINDOW : GetArg("-averagingwindow", DEFAULT_AVERAGING_WINDOW); mainParams.consensus.nPowAveragingWindow = PowAveragingWindow; mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); - if (mainParams.consensus.nBlockTime != DEFAULT_BLOCKTIME_TARGET) + if (!isVerusActive && mainParams.consensus.nBlockTime != DEFAULT_BLOCKTIME_TARGET) { - float weight = (float)((mainParams.consensus.nPowAveragingWindow+1)/2) * std::pow(0.9989f,(500.0f/((float)mainParams.consensus.nPowAveragingWindow))) * (float)mainParams.consensus.nBlockTime; - mainParams.consensus.nLwmaAjustedWeight = (((int)weight)/10)*10; // int conversion, round down to nearest mutiple of 10 - //LogPrintf(">>> nLwmaAjustedWeight = %ld\n",mainParams.consensus.nLwmaAjustedWeight); + cpp_dec_float_50 averagingFactor(std::to_string((mainParams.consensus.nPowAveragingWindow+1)/2)); + cpp_dec_float_50 factorBase("0.9989"); + cpp_dec_float_50 factorExponent = cpp_dec_float_50("500") / cpp_dec_float_50(std::to_string(mainParams.consensus.nPowAveragingWindow)); + cpp_dec_float_50 blockTime(std::to_string(mainParams.consensus.nBlockTime)); + + cpp_dec_float_50 weight = averagingFactor * std::pow(factorBase, factorExponent) * blockTime; + std::stringstream ss(weight.str(0, std::ios_base::fmtflags::_S_fixed)); + try + { + ss >> mainParams.consensus.nLwmaAjustedWeight; + } + catch(const std::exception& e) + { + fprintf(stderr,"%s: error calculating adjusted blocktime weight\n", __func__); + assert(false); + } + LogPrint("blocktime", "nLwmaAjustedWeight = %ld\n", mainParams.consensus.nLwmaAjustedWeight); } else { mainParams.consensus.nLwmaAjustedWeight = 1350; } @@ -272,7 +288,7 @@ void *chainparams_commandline(void *ptr) } // this includes VRSCTEST, unlike the checkpoints and changes below - if (_IsVerusActive()) + if (isVerusActive) { mainParams.consensus.fCoinbaseMustBeProtected = true; } From aaf43efda567b76a3d631e710aeda6b6f05ea752 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 22 Sep 2022 17:37:29 -0700 Subject: [PATCH 10/10] Build fix --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6016f1640..0be0ccbe2 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -258,7 +258,7 @@ void *chainparams_commandline(void *ptr) cpp_dec_float_50 factorExponent = cpp_dec_float_50("500") / cpp_dec_float_50(std::to_string(mainParams.consensus.nPowAveragingWindow)); cpp_dec_float_50 blockTime(std::to_string(mainParams.consensus.nBlockTime)); - cpp_dec_float_50 weight = averagingFactor * std::pow(factorBase, factorExponent) * blockTime; + cpp_dec_float_50 weight = averagingFactor * pow(factorBase, factorExponent) * blockTime; std::stringstream ss(weight.str(0, std::ios_base::fmtflags::_S_fixed)); try {