From 62c30f982aba8da39d08ded7a97c0c11e2e37b6f Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 29 Jun 2020 12:48:12 -0600 Subject: [PATCH 01/16] Add enforce value --- src/chainparams.cpp | 5 +++++ src/consensus/consensus.h | 1 + src/consensus/params.h | 1 + src/consensus/tx_verify.cpp | 22 +++++++++++++++++++++- src/consensus/tx_verify.h | 2 +- src/rpc/blockchain.cpp | 1 + src/validation.cpp | 19 ++++++++++++++++--- src/validation.h | 2 ++ src/versionbits.cpp | 4 ++++ 9 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c53ab63e3e..9bf547c42f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -151,6 +151,11 @@ class CMainParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nTimeout = 1620324000; // UTC: Thu May 06 2021 18:00:00 consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideRuleChangeActivationThreshold = 1714; // Approx 85% of 2016 consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideMinerConfirmationWindow = 2016; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 1593453600; // UTC: Mon Jun 29 2020 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2020 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1209; // Approx 60% of 2016 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 2016; // The best chain should have at least this much work consensus.nMinimumChainWork = uint256S("000000000000000000000000000000000000000000000020d4ac871fb7009b63"); // Block 1186833 diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 1c25eaad91..e84f0a4cc2 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -37,6 +37,7 @@ static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * UNUSED_VAR static bool fAssetsIsActive = false; UNUSED_VAR static bool fRip5IsActive = false; UNUSED_VAR static bool fTransferScriptIsActive = false; +UNUSED_VAR static bool fEnforcedValuesIsActive = false; unsigned int GetMaxBlockWeight(); unsigned int GetMaxBlockSerializedSize(); diff --git a/src/consensus/params.h b/src/consensus/params.h index 67ec240d81..cac538e4e4 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -19,6 +19,7 @@ enum DeploymentPos DEPLOYMENT_ASSETS, // Deployment of RIP2 DEPLOYMENT_MSG_REST_ASSETS, // Delpoyment of RIP5 and Restricted assets DEPLOYMENT_TRANSFER_SCRIPT_SIZE, + DEPLOYMENT_ENFORCE_VALUE, // DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113. // DEPLOYMENT_SEGWIT, // Deployment of BIP141, BIP143, and BIP147. // NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index cd73a51538..4b79efaefb 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -166,7 +166,7 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i return nSigOps; } -bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fCheckDuplicateInputs) +bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fCheckDuplicateInputs, bool fMempoolCheck, bool fBlockCheck) { // Basic checks that don't depend on any context if (tx.vin.empty()) @@ -308,7 +308,27 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe // Specific check and error message to go with to make sure the amount is 0 if (txout.nValue != 0) return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-issued-amount-isn't-zero"); + } else if (nType == TX_REISSUE_ASSET) { + // Specific check and error message to go with to make sure the amount is 0 + if (AreEnforcedValuesDeployed()) { + // We only want to not accept these txes when checking them from CheckBlock. + // We don't want to change the behavior when reading transactions from the database + // when AreEnforcedValuesDeployed return true + if (fBlockCheck) { + if (txout.nValue != 0) { + return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-reissued-amount-isn't-zero"); + } + } + } + + if (fMempoolCheck) { + // Don't accept to the mempool no matter what on these types of transactions + if (txout.nValue != 0) { + return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-reissued-amount-isn't-zero"); + } + } } + } } diff --git a/src/consensus/tx_verify.h b/src/consensus/tx_verify.h index 1abd84c51e..9b919720fb 100644 --- a/src/consensus/tx_verify.h +++ b/src/consensus/tx_verify.h @@ -26,7 +26,7 @@ class CNullAssetTxData; /** Transaction validation functions */ /** Context-independent validity checks */ -bool CheckTransaction(const CTransaction& tx, CValidationState& state, bool fCheckDuplicateInputs=true); +bool CheckTransaction(const CTransaction& tx, CValidationState& state, bool fCheckDuplicateInputs=true, bool fMempoolCheck = false, bool fBlockCheck = false); namespace Consensus { /** diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 7718df7050..5c9560673d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1433,6 +1433,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) BIP9SoftForkDescPushBack(bip9_softforks, "assets", consensusParams, Consensus::DEPLOYMENT_ASSETS); BIP9SoftForkDescPushBack(bip9_softforks, "messaging_restricted", consensusParams, Consensus::DEPLOYMENT_MSG_REST_ASSETS); BIP9SoftForkDescPushBack(bip9_softforks, "transfer_script", consensusParams, Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE); + BIP9SoftForkDescPushBack(bip9_softforks, "enforce", consensusParams, Consensus::DEPLOYMENT_ENFORCE_VALUE); obj.push_back(Pair("softforks", softforks)); obj.push_back(Pair("bip9_softforks", bip9_softforks)); diff --git a/src/validation.cpp b/src/validation.cpp index b30ee1d372..7a12d99edb 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -515,7 +515,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; - if (!CheckTransaction(tx, state)) + if (!CheckTransaction(tx, state, true, true)) return false; // state filled in by CheckTransaction // Coinbase is only valid in a block, not as a loose transaction @@ -3997,7 +3997,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P // Check transactions for (const auto& tx : block.vtx) - if (!CheckTransaction(*tx, state)) + if (!CheckTransaction(*tx, state, true, false, true)) return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), strprintf("Transaction check failed (tx hash %s) %s %s", tx->GetHash().ToString(), state.GetDebugMessage(), state.GetRejectReason())); @@ -5703,7 +5703,20 @@ double GuessVerificationProgress(const ChainTxData& data, CBlockIndex *pindex) { } /** RVN START */ -bool AreAssetsDeployed() { +bool AreEnforcedValuesDeployed() +{ + if (fEnforcedValuesIsActive) + return true; + + const ThresholdState thresholdState = VersionBitsTipState(GetParams().GetConsensus(), Consensus::DEPLOYMENT_ENFORCE_VALUE); + if (thresholdState == THRESHOLD_ACTIVE) + fEnforcedValuesIsActive = true; + + return fEnforcedValuesIsActive; +} + +bool AreAssetsDeployed() +{ if (fAssetsIsActive) return true; diff --git a/src/validation.h b/src/validation.h index c8fefec80f..c1062f58c7 100644 --- a/src/validation.h +++ b/src/validation.h @@ -595,6 +595,8 @@ bool AreMessagesDeployed(); bool AreRestrictedAssetsDeployed(); +bool AreEnforcedValuesDeployed(); + bool IsRip5Active(); diff --git a/src/versionbits.cpp b/src/versionbits.cpp index 7d3804f9ca..1442f5f06f 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -26,6 +26,10 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B { /*.name =*/ "transfer_script", /*.gbt_force =*/ true, + }, + { + /*.name =*/ "enforce_value", + /*.gbt_force =*/ true, } }; From 905952cf8cc1a834b1f205bead90656d03ea6c4f Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 29 Jun 2020 13:32:17 -0600 Subject: [PATCH 02/16] Add unit test for enforced value --- src/consensus/tx_verify.cpp | 2 +- src/test/assets/asset_tx_tests.cpp | 63 ++++++++++++++++++++++++++++++ src/validation.cpp | 6 +++ src/validation.h | 3 ++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 4b79efaefb..29de87faa5 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -324,7 +324,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe if (fMempoolCheck) { // Don't accept to the mempool no matter what on these types of transactions if (txout.nValue != 0) { - return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-reissued-amount-isn't-zero"); + return state.DoS(100, false, REJECT_INVALID, "bad-mempool-txns-asset-reissued-amount-isn't-zero"); } } } diff --git a/src/test/assets/asset_tx_tests.cpp b/src/test/assets/asset_tx_tests.cpp index fcfcc89bb5..43f575bdc9 100644 --- a/src/test/assets/asset_tx_tests.cpp +++ b/src/test/assets/asset_tx_tests.cpp @@ -13,6 +13,7 @@ #include #include #include +#include BOOST_FIXTURE_TEST_SUITE(asset_tx_tests, BasicTestingSetup) @@ -477,4 +478,66 @@ BOOST_FIXTURE_TEST_SUITE(asset_tx_tests, BasicTestingSetup) BOOST_CHECK_MESSAGE(!CheckNewAsset(asset, error), "Test13: " + error); } + BOOST_AUTO_TEST_CASE(asset_tx_enforce_value_test) + { + BOOST_TEST_MESSAGE("Running Asset TX Enforce Value Test"); + + SelectParams(CBaseChainParams::MAIN); + + // Create the reissue asset + CReissueAsset reissueAsset("ENFORCE_VALUE", 100, 8, true, ""); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(GetParams().GlobalBurnAddress())); + reissueAsset.ConstructTransaction(scriptPubKey); + + // Create an invalid reissue asset with nValue not equal to zero + CTxOut txOut; + txOut.nValue = 500; + txOut.scriptPubKey = scriptPubKey; + + // Create views + CCoinsView view; + CCoinsViewCache coins(&view); + CAssetsCache assetCache; + + // Create a random hash + uint256 hash = uint256S("BF50CB9A63BE0019171456252989A459A7D0A5F494735278290079D22AB704A2"); + + // Add the coin to the cache + COutPoint outpoint(hash, 1); + coins.AddCoin(outpoint, Coin(txOut, 10, 0), true); + + // Create input + CTxIn in; + in.prevout = outpoint; + + // Create transaction and input for the outpoint of the coin we just created + CMutableTransaction mutTx; + + // Add the input, and an output into the transaction + mutTx.vin.emplace_back(in); + mutTx.vout.emplace_back(txOut); + + CTransaction tx(mutTx); + CValidationState state; + + bool fCheckMempool = true; + bool fCheckBlock = false; + + // Check that the CheckTransaction will fail when trying to add it to the mempool + bool fCheck = !CheckTransaction(tx, state, true, fCheckMempool, fCheckBlock); + + BOOST_CHECK(fCheck); + BOOST_CHECK(state.GetRejectReason() == "bad-mempool-txns-asset-reissued-amount-isn't-zero"); + + // Check that the CheckTransaction will fail when trying to add it to a block + fCheckMempool = false; + fCheckBlock = true; + // Turn on the BIP that enforces the block check + SetEnforcedValues(true); + + fCheck = !CheckTransaction(tx, state, true, fCheckMempool, fCheckBlock); + BOOST_CHECK(fCheck); + BOOST_CHECK(state.GetRejectReason() == "bad-txns-asset-reissued-amount-isn't-zero"); + } + BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/src/validation.cpp b/src/validation.cpp index 7a12d99edb..dda6561fde 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5703,6 +5703,12 @@ double GuessVerificationProgress(const ChainTxData& data, CBlockIndex *pindex) { } /** RVN START */ + +// Only used by test framework +void SetEnforcedValues(bool value) { + fEnforcedValuesIsActive = value; +} + bool AreEnforcedValuesDeployed() { if (fEnforcedValuesIsActive) diff --git a/src/validation.h b/src/validation.h index c1062f58c7..14f5b2cadc 100644 --- a/src/validation.h +++ b/src/validation.h @@ -597,6 +597,9 @@ bool AreRestrictedAssetsDeployed(); bool AreEnforcedValuesDeployed(); +// Only used by test framework +void SetEnforcedValues(bool value); + bool IsRip5Active(); From 787d4c09f365c8864ecb3a84f048ca8a6243c1e3 Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 29 Jun 2020 13:39:01 -0600 Subject: [PATCH 03/16] add testnet and regtest params --- src/chainparams.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9bf547c42f..172a03edb2 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -307,6 +307,11 @@ class CTestNetParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nTimeout = 1618509600; // UTC: Thu Apr 15 2021 18:00:00 consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideRuleChangeActivationThreshold = 1310; consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideMinerConfirmationWindow = 2016; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 1593453600; // UTC: Mon Jun 29 2020 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2020 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1209; // Approx 60% of 2016 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 2016; // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000168050db560b4"); @@ -517,6 +522,11 @@ class CRegTestParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nTimeout = 999999999999ULL; consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideRuleChangeActivationThreshold = 208; consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideMinerConfirmationWindow = 288; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 0; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 999999999999ULL; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 108; + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 144; // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); From 9c8fbc0d9e0f14317bd986d82a61c32c80f2ea7d Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 29 Jun 2020 14:37:01 -0600 Subject: [PATCH 04/16] Added activation with bip is locked in --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index dda6561fde..a0b1e688f2 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5715,7 +5715,7 @@ bool AreEnforcedValuesDeployed() return true; const ThresholdState thresholdState = VersionBitsTipState(GetParams().GetConsensus(), Consensus::DEPLOYMENT_ENFORCE_VALUE); - if (thresholdState == THRESHOLD_ACTIVE) + if (thresholdState == THRESHOLD_ACTIVE || thresholdState == THRESHOLD_LOCKED_IN) fEnforcedValuesIsActive = true; return fEnforcedValuesIsActive; From 8141607052efda8a2e6168673840a06fcc3d225c Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 29 Jun 2020 15:43:50 -0600 Subject: [PATCH 05/16] Remove DoS score --- src/consensus/tx_verify.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 29de87faa5..4dd18b3b42 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -316,7 +316,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe // when AreEnforcedValuesDeployed return true if (fBlockCheck) { if (txout.nValue != 0) { - return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-reissued-amount-isn't-zero"); + return state.DoS(0, false, REJECT_INVALID, "bad-txns-asset-reissued-amount-isn't-zero"); } } } @@ -324,7 +324,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe if (fMempoolCheck) { // Don't accept to the mempool no matter what on these types of transactions if (txout.nValue != 0) { - return state.DoS(100, false, REJECT_INVALID, "bad-mempool-txns-asset-reissued-amount-isn't-zero"); + return state.DoS(0, false, REJECT_INVALID, "bad-mempool-txns-asset-reissued-amount-isn't-zero"); } } } From c455cfce9d09d22475f2a69da4c9e08ad6b6286f Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 30 Jun 2020 09:10:31 -0600 Subject: [PATCH 06/16] Add checks when coming from database, to accept the blocks --- src/validation.cpp | 19 ++++++++++++++----- src/validation.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index a0b1e688f2..9d7ef58571 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3951,7 +3951,7 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, return true; } -bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW, bool fCheckMerkleRoot) +bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW, bool fCheckMerkleRoot, bool fDBCheck) { // These are checks that are independent of context. @@ -3996,10 +3996,19 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase"); // Check transactions - for (const auto& tx : block.vtx) - if (!CheckTransaction(*tx, state, true, false, true)) + for (const auto& tx : block.vtx) { + // We only want to check the blocks when they are added to our chain + // We want to make sure when nodes shutdown and restart that they still + // verify the blocks in the database correctly even if Enforce Value BIP is active + bool fCheckBlock = true; + if (fDBCheck){ + fCheckBlock = false; + } + if (!CheckTransaction(*tx, state, true, false, fCheckBlock)) return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), - strprintf("Transaction check failed (tx hash %s) %s %s", tx->GetHash().ToString(), state.GetDebugMessage(), state.GetRejectReason())); + strprintf("Transaction check failed (tx hash %s) %s %s", tx->GetHash().ToString(), + state.GetDebugMessage(), state.GetRejectReason())); + } unsigned int nSigOps = 0; for (const auto& tx : block.vtx) @@ -4878,7 +4887,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus())) return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); // check level 1: verify block validity - if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams.GetConsensus(), true, true)) // fCheckAssetDuplicate set to false, because we don't want to fail because the asset exists in our database, when loading blocks from our asset databse + if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams.GetConsensus(), true, true, true)) // fCheckAssetDuplicate set to false, because we don't want to fail because the asset exists in our database, when loading blocks from our asset databse return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__, pindex->nHeight, pindex->GetBlockHash().ToString(), FormatStateMessage(state)); // check level 2: verify undo validity diff --git a/src/validation.h b/src/validation.h index 14f5b2cadc..f5ba96e7d1 100644 --- a/src/validation.h +++ b/src/validation.h @@ -451,7 +451,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus /** Functions for validating blocks and updating the block tree */ /** Context-independent validity checks */ -bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true); +bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true, bool fDBCheck = false); /** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true); From 185a052578fb96eaee98f2497b97198e297d4036 Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 30 Jun 2020 13:41:24 -0600 Subject: [PATCH 07/16] Make soft fork active at 70% --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 172a03edb2..4bf19e4178 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -154,7 +154,7 @@ class CMainParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 1593453600; // UTC: Mon Jun 29 2020 18:00:00 consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2020 18:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1209; // Approx 60% of 2016 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1411; // Approx 70% of 2016 consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 2016; // The best chain should have at least this much work From 627a6f069c9b642f2dd686d6c1a4e862ced8ddea Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Mon, 6 Jul 2020 12:03:40 -0600 Subject: [PATCH 08/16] Create version string from integer values --- src/version.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 8fbd3508d5..497f126deb 100644 --- a/src/version.h +++ b/src/version.h @@ -6,17 +6,18 @@ #ifndef RAVEN_VERSION_H #define RAVEN_VERSION_H +#include /** * network protocol versioning */ -// Update these four values on every release cycle +// Update these three values on every release cycle // These values should match the values in configure.ac // Used for checking the Ravencoin releases on github -static const std::string SOFTWARE_VERSION = "v4.2.0"; static const int MAIN_SOFTWARE_VERSION = 4; static const int SECOND_SOFTWARE_VERSION = 2; static const int THIRD_SOFTWARE_VERSION = 0; +static const std::string SOFTWARE_VERSION = strprintf("v%d.%d.%d", MAIN_SOFTWARE_VERSION, SECOND_SOFTWARE_VERSION, THIRD_SOFTWARE_VERSION); static const int PROTOCOL_VERSION = 70028; From ae65a292a6cb2f81185363aa0446483197f559af Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 7 Jul 2020 10:13:29 -0600 Subject: [PATCH 09/16] Add decodeblock rpc call --- src/rpc/blockchain.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++ src/rpc/blockchain.h | 1 + 2 files changed, 71 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 5c9560673d..198d22da4d 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -263,6 +263,36 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx return result; } +UniValue decodeblockToJSON(const CBlock& block) +{ + UniValue result(UniValue::VOBJ); + result.push_back(Pair("hash", block.GetHash().GetHex())); + + result.push_back(Pair("strippedsize", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS))); + result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); + result.push_back(Pair("weight", (int)::GetBlockWeight(block))); + result.push_back(Pair("height", (int)block.nHeight)); + result.push_back(Pair("version", block.nVersion)); + result.push_back(Pair("versionHex", strprintf("%08x", block.nVersion))); + result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); + UniValue txs(UniValue::VARR); + for(const auto& tx : block.vtx) + { + UniValue objTx(UniValue::VOBJ); + TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags()); + txs.push_back(objTx); + } + result.push_back(Pair("tx", txs)); + result.push_back(Pair("time", block.GetBlockTime())); + result.push_back(Pair("nonce", (uint64_t)block.nNonce)); + result.push_back(Pair("bits", strprintf("%08x", block.nBits))); + result.push_back(Pair("headerhash", block.GetKAWPOWHeaderHash().GetHex())); + result.push_back(Pair("mixhash", block.mix_hash.GetHex())); + result.push_back(Pair("nonce64", (uint64_t)block.nNonce64)); + + return result; +} + UniValue getblockcount(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) @@ -990,6 +1020,45 @@ UniValue getblock(const JSONRPCRequest& request) return blockToJSON(block, pblockindex, verbosity >= 2); } +UniValue decodeblock(const JSONRPCRequest& request) +{ + if (request.fHelp || request.params.size() != 1) + throw std::runtime_error( + "decodeblock \"blockhex\"\n" + "\nArguments:\n" + "1. \"blockhex\" (string, required) The block hex\n" + "\nResult:\n" + "{\n" + " \"hash\" : \"hash\", (string) the block hash (same as provided)\n" + " \"size\" : n, (numeric) The block size\n" + " \"strippedsize\" : n, (numeric) The block size excluding witness data\n" + " \"weight\" : n (numeric) The block weight as defined in BIP 141\n" + " \"height\" : n, (numeric) The block height or index\n" + " \"version\" : n, (numeric) The block version\n" + " \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n" + " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" + " \"tx\" : [ (array of string) The transaction ids\n" + " \"transactionid\" (string) The transaction id\n" + " ,...\n" + " ],\n" + " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" + " \"nonce\" : n, (numeric) The nonce\n" + " \"bits\" : \"1d00ffff\", (string) The bits\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("decodeblock", "\"xxxx\"") + + HelpExampleRpc("decodeblock", "\"xxxx\"") + ); + + std::string strHex = request.params[0].get_str(); + CBlock block; + DecodeHexBlk(block, strHex); + + return decodeblockToJSON(block); +} + + + struct CCoinsStats { int nHeight; @@ -1833,6 +1902,7 @@ static const CRPCCommand commands[] = { "blockchain", "getbestblockhash", &getbestblockhash, {} }, { "blockchain", "getblockcount", &getblockcount, {} }, { "blockchain", "getblock", &getblock, {"blockhash","verbosity|verbose"} }, + { "blockchain", "decodeblock", &decodeblock, {"blockhex",} }, { "blockchain", "getblockdeltas", &getblockdeltas, {} }, { "blockchain", "getblockhashes", &getblockhashes, {} }, { "blockchain", "getblockhash", &getblockhash, {"height"} }, diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 5f49047e4d..a22781a9f7 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -30,6 +30,7 @@ void RPCNotifyBlockChange(bool ibd, const CBlockIndex *); /** Block description to JSON */ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false); +UniValue decodeblockToJSON(const CBlock& block); /** Mempool information to JSON */ UniValue mempoolInfoToJSON(); From 09578af86232b3804e5f4db452d8cea2c9f9f59d Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 7 Jul 2020 14:00:52 -0600 Subject: [PATCH 10/16] Add additional failsafe else statement --- src/consensus/tx_verify.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 4dd18b3b42..abb4c24f69 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -308,7 +308,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe // Specific check and error message to go with to make sure the amount is 0 if (txout.nValue != 0) return state.DoS(100, false, REJECT_INVALID, "bad-txns-asset-issued-amount-isn't-zero"); - } else if (nType == TX_REISSUE_ASSET) { + } else if (nType == TX_REISSUE_ASSET) { // Specific check and error message to go with to make sure the amount is 0 if (AreEnforcedValuesDeployed()) { // We only want to not accept these txes when checking them from CheckBlock. @@ -327,8 +327,9 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe return state.DoS(0, false, REJECT_INVALID, "bad-mempool-txns-asset-reissued-amount-isn't-zero"); } } + } else { + return state.DoS(0, false, REJECT_INVALID, "bad-asset-type-not-any-of-the-main-three"); } - } } From 7dd92dc10dc897b26ecdac3a175485e4f51e6f4d Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 7 Jul 2020 14:28:53 -0600 Subject: [PATCH 11/16] Add variable name, and fix typos --- src/chainparams.cpp | 6 +++--- src/rpc/blockchain.cpp | 2 +- src/validation.cpp | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 4bf19e4178..14d595dd42 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -153,7 +153,7 @@ class CMainParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideMinerConfirmationWindow = 2016; consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 1593453600; // UTC: Mon Jun 29 2020 18:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2020 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2021 18:00:00 consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1411; // Approx 70% of 2016 consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 2016; @@ -309,8 +309,8 @@ class CTestNetParams : public CChainParams { consensus.vDeployments[Consensus::DEPLOYMENT_TRANSFER_SCRIPT_SIZE].nOverrideMinerConfirmationWindow = 2016; consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].bit = 9; consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nStartTime = 1593453600; // UTC: Mon Jun 29 2020 18:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2020 18:00:00 - consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1209; // Approx 60% of 2016 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nTimeout = 1624989600; // UTC: Mon Jun 29 2021 18:00:00 + consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideRuleChangeActivationThreshold = 1411; // Approx 70% of 2016 consensus.vDeployments[Consensus::DEPLOYMENT_ENFORCE_VALUE].nOverrideMinerConfirmationWindow = 2016; // The best chain should have at least this much work. diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 198d22da4d..015aae9f40 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1902,7 +1902,7 @@ static const CRPCCommand commands[] = { "blockchain", "getbestblockhash", &getbestblockhash, {} }, { "blockchain", "getblockcount", &getblockcount, {} }, { "blockchain", "getblock", &getblock, {"blockhash","verbosity|verbose"} }, - { "blockchain", "decodeblock", &decodeblock, {"blockhex",} }, + { "blockchain", "decodeblock", &decodeblock, {"blockhex"} }, { "blockchain", "getblockdeltas", &getblockdeltas, {} }, { "blockchain", "getblockhashes", &getblockhashes, {} }, { "blockchain", "getblockhash", &getblockhash, {"height"} }, diff --git a/src/validation.cpp b/src/validation.cpp index 9d7ef58571..955ec38588 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -515,7 +515,10 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; - if (!CheckTransaction(tx, state, true, true)) + + bool fCheckDuplicates = true; + bool fCheckMempool = true; + if (!CheckTransaction(tx, state, fCheckDuplicates, fCheckMempool)) return false; // state filled in by CheckTransaction // Coinbase is only valid in a block, not as a loose transaction @@ -3996,15 +3999,19 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase"); // Check transactions + bool fCheckBlock = true; + bool fCheckDuplicates = true; + bool fCheckMempool = false; for (const auto& tx : block.vtx) { // We only want to check the blocks when they are added to our chain // We want to make sure when nodes shutdown and restart that they still // verify the blocks in the database correctly even if Enforce Value BIP is active - bool fCheckBlock = true; + fCheckBlock = true; if (fDBCheck){ fCheckBlock = false; } - if (!CheckTransaction(*tx, state, true, false, fCheckBlock)) + + if (!CheckTransaction(*tx, state, fCheckDuplicates, fCheckMempool, fCheckBlock)) return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), strprintf("Transaction check failed (tx hash %s) %s %s", tx->GetHash().ToString(), state.GetDebugMessage(), state.GetRejectReason())); @@ -4887,7 +4894,10 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus())) return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); // check level 1: verify block validity - if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams.GetConsensus(), true, true, true)) // fCheckAssetDuplicate set to false, because we don't want to fail because the asset exists in our database, when loading blocks from our asset databse + bool fCheckPoW = true; + bool fCheckMerkleRoot = true; + bool fDBCheck = true; + if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams.GetConsensus(), fCheckPoW, fCheckMerkleRoot, fDBCheck)) // fCheckAssetDuplicate set to false, because we don't want to fail because the asset exists in our database, when loading blocks from our asset databse return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__, pindex->nHeight, pindex->GetBlockHash().ToString(), FormatStateMessage(state)); // check level 2: verify undo validity From 8c1fb71a146cd6aa4b9e634ea026f65e0f9f4fcb Mon Sep 17 00:00:00 2001 From: AkshayCM Date: Mon, 6 Jul 2020 21:36:48 +0300 Subject: [PATCH 12/16] [Qt] Use version nums from configure --- src/qt/ravengui.cpp | 14 +++++++------- src/version.h | 9 --------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/qt/ravengui.cpp b/src/qt/ravengui.cpp index 50de4a5340..9bee7a81da 100644 --- a/src/qt/ravengui.cpp +++ b/src/qt/ravengui.cpp @@ -865,40 +865,40 @@ void RavenGUI::createToolBars() bool fNewSoftwareFound = false; bool fStopSearch = false; if (list.size() >= 4) { - if (MAIN_SOFTWARE_VERSION < list[1].toInt()) { + if (CLIENT_VERSION_MAJOR < list[1].toInt()) { fNewSoftwareFound = true; } else { - if (MAIN_SOFTWARE_VERSION > list[1].toInt()) { + if (CLIENT_VERSION_MAJOR > list[1].toInt()) { fStopSearch = true; } } if (!fStopSearch) { - if (SECOND_SOFTWARE_VERSION < list[2].toInt()) { + if (CLIENT_VERSION_MINOR < list[2].toInt()) { fNewSoftwareFound = true; } else { - if (SECOND_SOFTWARE_VERSION > list[2].toInt()) { + if (CLIENT_VERSION_MINOR > list[2].toInt()) { fStopSearch = true; } } } if (!fStopSearch) { - if (THIRD_SOFTWARE_VERSION < list[3].toInt()) { + if (CLIENT_VERSION_REVISION < list[3].toInt()) { fNewSoftwareFound = true; } } } if (fNewSoftwareFound) { - labelVersionUpdate->setToolTip(QString::fromStdString(strprintf("Currently running: %s\nLatest version: %s", SOFTWARE_VERSION, + labelVersionUpdate->setToolTip(QString::fromStdString(strprintf("Currently running: %s\nLatest version: %s", FormatFullVersion(), latestVersion))); labelVersionUpdate->show(); // Only display the message on startup to the user around 1/2 of the time if (GetRandInt(2) == 1) { bool fRet = uiInterface.ThreadSafeQuestion( - strprintf("\nCurrently running: %s\nLatest version: %s", SOFTWARE_VERSION, + strprintf("\nCurrently running: %s\nLatest version: %s", FormatFullVersion(), latestVersion) + "\n\nWould you like to visit the releases page?", "", "New Wallet Version Found", diff --git a/src/version.h b/src/version.h index 497f126deb..78be20971e 100644 --- a/src/version.h +++ b/src/version.h @@ -6,19 +6,10 @@ #ifndef RAVEN_VERSION_H #define RAVEN_VERSION_H -#include /** * network protocol versioning */ -// Update these three values on every release cycle -// These values should match the values in configure.ac -// Used for checking the Ravencoin releases on github -static const int MAIN_SOFTWARE_VERSION = 4; -static const int SECOND_SOFTWARE_VERSION = 2; -static const int THIRD_SOFTWARE_VERSION = 0; -static const std::string SOFTWARE_VERSION = strprintf("v%d.%d.%d", MAIN_SOFTWARE_VERSION, SECOND_SOFTWARE_VERSION, THIRD_SOFTWARE_VERSION); - static const int PROTOCOL_VERSION = 70028; //! initial proto version, to be increased after version/verack negotiation From 405e1ee30a22f31cb0a0d426eb2a0be49d38b496 Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 7 Jul 2020 14:35:42 -0600 Subject: [PATCH 13/16] Remove magic numbers --- src/qt/ravengui.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/qt/ravengui.cpp b/src/qt/ravengui.cpp index 9bee7a81da..19f6208a51 100644 --- a/src/qt/ravengui.cpp +++ b/src/qt/ravengui.cpp @@ -862,29 +862,32 @@ void RavenGUI::createToolBars() // List the found values QStringList list = rx.capturedTexts(); + static const int CLIENT_VERSION_MAJOR_INDEX = 1; + static const int CLIENT_VERSION_MINOR_INDEX = 2; + static const int CLIENT_VERSION_REVISION_INDEX = 3; bool fNewSoftwareFound = false; bool fStopSearch = false; if (list.size() >= 4) { - if (CLIENT_VERSION_MAJOR < list[1].toInt()) { + if (CLIENT_VERSION_MAJOR < list[CLIENT_VERSION_MAJOR_INDEX].toInt()) { fNewSoftwareFound = true; } else { - if (CLIENT_VERSION_MAJOR > list[1].toInt()) { + if (CLIENT_VERSION_MAJOR > list[CLIENT_VERSION_MAJOR_INDEX].toInt()) { fStopSearch = true; } } if (!fStopSearch) { - if (CLIENT_VERSION_MINOR < list[2].toInt()) { + if (CLIENT_VERSION_MINOR < list[CLIENT_VERSION_MINOR_INDEX].toInt()) { fNewSoftwareFound = true; } else { - if (CLIENT_VERSION_MINOR > list[2].toInt()) { + if (CLIENT_VERSION_MINOR > list[CLIENT_VERSION_MINOR_INDEX].toInt()) { fStopSearch = true; } } } if (!fStopSearch) { - if (CLIENT_VERSION_REVISION < list[3].toInt()) { + if (CLIENT_VERSION_REVISION < list[CLIENT_VERSION_REVISION_INDEX].toInt()) { fNewSoftwareFound = true; } } From e889065bb0783b3e5e70192924d6bbbbdd857b48 Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Tue, 7 Jul 2020 14:59:06 -0600 Subject: [PATCH 14/16] Add define constants --- src/validation.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 955ec38588..f615ae3ba7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -67,6 +67,13 @@ #define MICRO 0.000001 #define MILLI 0.001 +#define CHECK_DUPLICATE_TRANSACTION_TRUE true +#define CHECK_DUPLICATE_TRANSACTION_FALSE false +#define CHECK_MEMPOOL_TRANSACTION_TRUE true +#define CHECK_MEMPOOL_TRANSACTION_FALSE false +#define CHECK_BLOCK_TRANSACTION_TRUE true +#define CHECK_BLOCK_TRANSACTION_FALSE false + /** * Global state */ @@ -3999,16 +4006,16 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P return state.DoS(100, false, REJECT_INVALID, "bad-cb-multiple", false, "more than one coinbase"); // Check transactions - bool fCheckBlock = true; - bool fCheckDuplicates = true; - bool fCheckMempool = false; + bool fCheckBlock = CHECK_BLOCK_TRANSACTION_TRUE; + bool fCheckDuplicates = CHECK_DUPLICATE_TRANSACTION_TRUE; + bool fCheckMempool = CHECK_MEMPOOL_TRANSACTION_FALSE; for (const auto& tx : block.vtx) { // We only want to check the blocks when they are added to our chain // We want to make sure when nodes shutdown and restart that they still // verify the blocks in the database correctly even if Enforce Value BIP is active - fCheckBlock = true; + fCheckBlock = CHECK_BLOCK_TRANSACTION_TRUE; if (fDBCheck){ - fCheckBlock = false; + fCheckBlock = CHECK_BLOCK_TRANSACTION_FALSE; } if (!CheckTransaction(*tx, state, fCheckDuplicates, fCheckMempool, fCheckBlock)) From f5dd386a8323957fb6630b419872713de0e347c5 Mon Sep 17 00:00:00 2001 From: lsji07 <39772657+lsji07@users.noreply.github.com> Date: Tue, 7 Jul 2020 22:17:00 +0100 Subject: [PATCH 15/16] Update Roadmap README.md Resubmitted as believe this was auto cancelled when carrying the develop branches were switched. Updated Unique asset info to reflect the naming convention used with # rather than : Updated x16r info to make current. Updated Completed status on the Roadmap. --- roadmap/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/roadmap/README.md b/roadmap/README.md index 13b65a9437..5f1ef3cb92 100644 --- a/roadmap/README.md +++ b/roadmap/README.md @@ -1,11 +1,11 @@ # Ravencoin Roadmap -### Phase 1 - Complete +### Phase 1 - (Complete) Ravencoin (RVN) is a Proof of Work coin built on the Bitcoin UTXO model. As with other Bitcoin derivatives, RVN coins are distributed to persons augmenting the Raven network by mining Raven. * x1000 coin distribution (21 Billion Total) * 10x faster blocks (1 per minute) -* In app CPU mining +* In app CPU verification, with GPU specific PoW decentralised mining * Dark Gravity Wave difficulty adjustment (180 block average) * Addresses start with R... for regular addresses, or r... for multisig * Network Port: 8767 @@ -15,7 +15,7 @@ Ravencoin (RVN) is a Proof of Work coin built on the Bitcoin UTXO model. As with #### ASIC Resistance -ASIC Resistance - A published commitment to continual attempts at ASIC resistance. If ASICs are created for x16r, then we will, at a specific block number, modify one of the algorithms to add some varients of Equihash or similar efforts to increase the resistance to ASIC miners for Raven. +ASIC Resistance - A published commitment to continual attempts at ASIC resistance. If ASICs are created for x16r, then we will, at a specific block number, modify one of the algorithms to add some varients of Equihash or similar efforts to increase the resistance to ASIC miners for Raven. ASIC's have been developed for X16R (and X16RV2) and the community has forked to KAWPOW (a variant of ethash and progpow) to maximise the ASIC resistance by reducing the potential efficiency increase of ASICs by requiring the feature set and capabilities within over the counter consumer graphics cards. We are not anticipating future forks to change the algorithm as the current algorithm allows a fair distribution of RVN via PoW to the community. #### Asset Support @@ -35,7 +35,7 @@ AB .FIRST apple -The RVN used to issue assets will be sent to a burn address, which will reduce the amount of RVN available. +The RVN used to issue assets will be sent to a burn address, which will reduce the amount of RVN available. Asset transfers require the standard RVN transaction fees for transfer from one address to another. @@ -45,7 +45,7 @@ Metadata about the token can be stored in IPFS. #### Rewards -Reward capabilities will be added to allow payment (in RVN) to all holders of an asset. Payments of RVN would be distributed to all asset holders pro rata. This is useful for paying dividends, dividing payments, or rewarding a group of token holders. +Reward capabilities will be added to allow payment (in RVN) to all holders of an asset. Payments of RVN would be distributed to all asset holders pro rata. This is useful for paying dividends, dividing payments, or rewarding a group of token holders. Example: A small software company issues an asset GAMECO that represents a share of the project. GAMECO tokens can be traded with others. Once the software company profits, those profits can be distributed to all holders of GAMECO by sending the profits (via RVN) to all holders of GAMECO. @@ -65,11 +65,10 @@ Once created, assets can be made unique for a cost of 5 RVN. Only non-divisible The costs to make unique assets will be sent to a burn address. Some examples of unique assets: -* Imagine that an art dealer issues the asset named ART. The dealer can then make unique ART assets by attaching a name or a serialized number to each piece of art. These unique tokens can be transferred to the new owner along with the artwork as a proof of authenticity. The tokens ART:MonaLisa and ART:VenusDeMilo are not fungible and represent distinct pieces of art. -* A software developer can issue the asset with the name of their software ABCGAME, and then assign each ABCGAME token a unique id or license key. The game tokens could be transferred as the license transfers. Each token ABCGAME:398222 and ABCGAME: -are unique tokens. -* In game assets. A game ZYX_GAME could create unique limited edition in-game assets that are owned and used by the game player. Example: ZYX_GAME:Sword005 and ZYX_GAME:Purse -* RVN based unique assets can be tied to real world assets. Create an asset named GOLDVAULT. Each gold coin or gold bar in a vault can be serialized and audited. Associated unique assets GOLDVAULT:444322 and GOLDVAULT:555994 can be created to represent the specific assets in the physical gold vault. The public nature of the chain allows for full transparency. +* Imagine that an art dealer issues the asset named ART. The dealer can then make unique ART assets by attaching a name or a serialized number to each piece of art. These unique tokens can be transferred to the new owner along with the artwork as a proof of authenticity. The tokens ART#MonaLisa and ART#VenusDeMilo are not fungible and represent distinct pieces of art. +* A software developer can issue the asset with the name of their software ABCGAME, and then assign each ABCGAME token a unique id or license key. The game tokens could be transferred as the license transfers. Each token ABCGAME#398222 and ABCGAME#398223 are unique tokens. +* In game assets. A game ZYX_GAME could create unique limited edition in-game assets that are owned and used by the game player. Example: ZYX_GAME#Sword005 and ZYX_GAME#Purse +* RVN based unique assets can be tied to real world assets. Create an asset named GOLDVAULT. Each gold coin or gold bar in a vault can be serialized and audited. Associated unique assets GOLDVAULT#444322 and GOLDVAULT#555994 can be created to represent the specific assets in the physical gold vault. The public nature of the chain allows for full transparency. ### Phase 5 - Messaging @@ -93,7 +92,7 @@ Speeds adoption into the larger crypto ecosystem. [More on compatibility mode...](./compatibility-mode/README.md) -### Phase 8 - Mobile Wallet compatible Mnemonic Seed +### Phase 8 - Mobile Wallet compatible Mnemonic Seed (Complete) Switches to a default of generating a 128 bit seed from which the master key is generated. This allows easy backup for anyone that doesn't import private keys. Warnings added to back up wallet.dat when importing private keys. @@ -106,7 +105,7 @@ Issue an asset with unique name. Unit as 1 for whole units, or 0.00000001 for sa original issuer. `issueunique (root_name, asset_tags, ipfs_hash, to_address, change_address) ` -Creates a unique asset from a pool of assets with a specific name. Example: If the asset name is SOFTLICENSE, then this could make unique assets like SOFTLICENSE:38293 and SOFTLICENSE:48382 This would be called once per unique asset needed. +Creates a unique asset from a pool of assets with a specific name. Example: If the asset name is SOFTLICENSE, then this could make unique assets like SOFTLICENSE#38293 and SOFTLICENSE#48382 This would be called once per unique asset needed. `reissue (reissue asset_name, qty, to_address, change_address, reissuable, new_unit, new_ipfs )` Issue more of a specific asset. This is only allowed by the original issuer of the asset and if the reissuable flag was set to true at the time of original issuance. @@ -128,3 +127,4 @@ Lists addresses by asset. `getassetdata (asset_name)` Lists asset data of an asset. + From 7758d85f80328e5328eb4373669c39271e10f09e Mon Sep 17 00:00:00 2001 From: blondfrogs Date: Thu, 9 Jul 2020 09:48:03 -0600 Subject: [PATCH 16/16] Version bump 4.2.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3878c751a1..b82b208447 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 4) define(_CLIENT_VERSION_MINOR, 2) -define(_CLIENT_VERSION_REVISION, 0) +define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2020)