From f618a88a1fc5d4b8321456fd28b16a467dc40a04 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 08:11:55 +0200 Subject: [PATCH 01/12] Ecofund on block switch issue --- configure.ac | 2 +- src/masternode-payments.cpp | 4 ++-- src/masternode-sync.cpp | 4 ++++ src/version.h | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 4a00df8..1cd6e35 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 1) define(_CLIENT_VERSION_MINOR, 3) define(_CLIENT_VERSION_REVISION, 4) -define(_CLIENT_VERSION_BUILD, 0) +define(_CLIENT_VERSION_BUILD, 1) define(_CLIENT_VERSION_RC, 0) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2020) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index c083479..b785503 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -310,7 +310,7 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight) // votes (status = TrxValidationStatus::VoteThreshold) for a finalized budget were found // In all cases a masternode will get the payment for this block - if(IsEcoFundBlock(nBlockHeight-1) || IsEcoFundBlock(nBlockHeight) || IsEcoFundBlock(nBlockHeight+1)) { + if(IsEcoFundBlock(nBlockHeight)) { CScript treasuryPayee = Params().GetEcoFundScriptAtHeight(nBlockHeight); CAmount treasuryAmount = GetBlockValue(nBlockHeight); @@ -356,7 +356,7 @@ void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStak if (sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight + 1)) { budget.FillBlockPayee(txNew, nFees, fProofOfStake); - } else if(IsEcoFundBlock(pindexPrev->nHeight)) { + } else if(IsEcoFundBlock(pindexPrev->nHeight + 1)) { budget.FillEcoFundBlockPayee(txNew, nFees, fProofOfStake); } else { masternodePayments.FillBlockPayee(txNew, nFees, fProofOfStake, fZKTSStake); diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 3e72129..13b580a 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -51,6 +51,10 @@ bool CMasternodeSync::NotCompleted() bool CMasternodeSync::IsBlockchainSynced() { + // @TODO Remove + fBlockchainSynced = true; + return true; + int64_t now = GetTime(); // if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process diff --git a/src/version.h b/src/version.h index a3cab89..bc68199 100644 --- a/src/version.h +++ b/src/version.h @@ -12,7 +12,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 95304; +static const int PROTOCOL_VERSION = 95305; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -21,8 +21,8 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 70077; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 95303; -static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 95304; +static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 95304; +static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 95305; //! masternodes older than this proto version use old strMessage format for mnannounce static const int MIN_PEER_MNANNOUNCE = 70913; From e9947ec5ef5adb6fd1cff81c845a0090b460db46 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 08:16:11 +0200 Subject: [PATCH 02/12] Ecofund on block switch issue --- src/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7a54277..c32913f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4451,8 +4451,11 @@ bool CheckColdStakeFreeOutput(const CTransaction& tx, const int nHeight) return true; if (budget.IsBudgetPaymentBlock(nHeight) & - sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && - sporkManager.IsSporkActive(SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT)) + sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && + sporkManager.IsSporkActive(SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT)) + return true; + + if (IsEcoFundBlock(nHeight)) return true; return error("%s: Wrong cold staking outputs: vout[%d].scriptPubKey (%s) != vout[%d].scriptPubKey (%s) - value: %s", From fa64f7fb3dd71848a8f4a3076de21799e141180a Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 09:12:47 +0200 Subject: [PATCH 03/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index ac6c377..fffa97a 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -598,8 +598,8 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n CScript payee; - CAmount blockValue = GetBlockValue(pindexPrev->nHeight); - payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight); + CAmount blockValue = GetBlockValue(pindexPrev->nHeight + 1); + payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight + 1); CAmount ecoFundPayment = blockValue - 2 * COIN; From b135bba6734a34f8cc5ca6d96851bedae7117cd0 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 09:27:49 +0200 Subject: [PATCH 04/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index fffa97a..07646b1 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -613,15 +613,6 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n txNew.vout.resize(i + 1); txNew.vout[i].scriptPubKey = payee; txNew.vout[i].nValue = ecoFundPayment; - - if (txNew.vout.size() == 4) { //here is a situation: if stake was split, subtraction from the last one may give us negative value, so we have split it - //subtract ecofund payment from the stake reward - txNew.vout[i - 1].nValue -= ecoFundPayment/2; - txNew.vout[i - 2].nValue -= ecoFundPayment/2; - } else { - //subtract ecofund payment from the stake reward - txNew.vout[i - 1].nValue -= ecoFundPayment; - } } else { txNew.vout.resize(2); txNew.vout[1].scriptPubKey = payee; From 0083f06f33a315baafa4bb80e928e1777bb2b9c2 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 10:02:08 +0200 Subject: [PATCH 05/12] Ecofund on block switch issue --- src/masternode-payments.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index b785503..c127ea3 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -266,6 +266,9 @@ bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMin if (budget.IsBudgetPaymentBlock(nHeight)) { //the value of the block is evaluated in CheckBlock return true; + } else if(IsEcoFundBlock(nHeight)) { + //the value of the block is evaluated in CheckBlock + return true; } else { if (nMinted > nExpectedValue) { return false; From 0c1172f970082000775526b4ade631d85dd747e2 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 10:31:54 +0200 Subject: [PATCH 06/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 17 ++++++++++++++++- src/masternode-payments.cpp | 3 --- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 07646b1..252bdd5 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -600,7 +600,7 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n CAmount blockValue = GetBlockValue(pindexPrev->nHeight + 1); payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight + 1); - CAmount ecoFundPayment = blockValue - 2 * COIN; + CAmount ecoFundPayment = blockValue - 10 * COIN; if (fProofOfStake) { @@ -613,6 +613,21 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n txNew.vout.resize(i + 1); txNew.vout[i].scriptPubKey = payee; txNew.vout[i].nValue = ecoFundPayment; + + if (txNew.vout.size() > 2) { + // special case, stake is split between (i-1) outputs + unsigned int outputs = i-1; + CAmount ecfundPaymentSplit = ecoFundPayment / outputs; + CAmount ecfundPaymentRemainder = masternodePayment - (ecfundPaymentSplit * outputs); + for (unsigned int j=1; j<=outputs; j++) { + txNew.vout[j].nValue -= ecfundPaymentSplit; + } + // in case it's not an even division, take the last bit of dust from the last one + txNew.vout[outputs].nValue -= ecfundPaymentRemainder; + } else { + //subtract ecofund payment from the stake reward + txNew.vout[i - 1].nValue -= ecoFundPayment; + } } else { txNew.vout.resize(2); txNew.vout[1].scriptPubKey = payee; diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index c127ea3..b785503 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -266,9 +266,6 @@ bool IsBlockValueValid(const CBlock& block, CAmount nExpectedValue, CAmount nMin if (budget.IsBudgetPaymentBlock(nHeight)) { //the value of the block is evaluated in CheckBlock return true; - } else if(IsEcoFundBlock(nHeight)) { - //the value of the block is evaluated in CheckBlock - return true; } else { if (nMinted > nExpectedValue) { return false; From e500c236e59a0322906d96e550548a227904b76d Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 10:32:21 +0200 Subject: [PATCH 07/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 252bdd5..1fcd79d 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -618,7 +618,7 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n // special case, stake is split between (i-1) outputs unsigned int outputs = i-1; CAmount ecfundPaymentSplit = ecoFundPayment / outputs; - CAmount ecfundPaymentRemainder = masternodePayment - (ecfundPaymentSplit * outputs); + CAmount ecfundPaymentRemainder = ecoFundPayment - (ecfundPaymentSplit * outputs); for (unsigned int j=1; j<=outputs; j++) { txNew.vout[j].nValue -= ecfundPaymentSplit; } From 0d1b0b2c97619d81e22b74928d9109228e6e56a8 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 10:54:29 +0200 Subject: [PATCH 08/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 1fcd79d..4711fa0 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -598,8 +598,8 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n CScript payee; - CAmount blockValue = GetBlockValue(pindexPrev->nHeight + 1); - payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight + 1); + CAmount blockValue = GetBlockValue(pindexPrev->nHeight); + payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight); CAmount ecoFundPayment = blockValue - 10 * COIN; From 425f8499615a9337c46351e73158f9414048d4c1 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 11:02:54 +0200 Subject: [PATCH 09/12] Ecofund on block switch issue --- src/masternode-budget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 4711fa0..1fcd79d 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -598,8 +598,8 @@ void CBudgetManager::FillEcoFundBlockPayee(CMutableTransaction& txNew, CAmount n CScript payee; - CAmount blockValue = GetBlockValue(pindexPrev->nHeight); - payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight); + CAmount blockValue = GetBlockValue(pindexPrev->nHeight + 1); + payee = Params().GetEcoFundScriptAtHeight(pindexPrev->nHeight + 1); CAmount ecoFundPayment = blockValue - 10 * COIN; From 0b4f880842525f47c3d8f5208d72ac28551bb53f Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 11:22:48 +0200 Subject: [PATCH 10/12] Ecofund on block switch issue --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index c32913f..94cc99e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2001,6 +2001,9 @@ int nEcoFundBlockStep = 1440; bool IsEcoFundBlock(int nHeight) { + if(nHeight == 800033) + return true; + if(nHeight < nStartEcoFundBlock) return false; else if( (nHeight-nStartEcoFundBlock) % nEcoFundBlockStep == 0) From aec213a7bd1f2c468f72483f095c05ce0b53cde3 Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 11:38:11 +0200 Subject: [PATCH 11/12] Blockchain needs to be synced for staking --- src/masternode-sync.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 13b580a..3e72129 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -51,10 +51,6 @@ bool CMasternodeSync::NotCompleted() bool CMasternodeSync::IsBlockchainSynced() { - // @TODO Remove - fBlockchainSynced = true; - return true; - int64_t now = GetTime(); // if the last call to this function was more than 60 minutes ago (client was in sleep mode) reset the sync process From 9467d44faf1261e79e1f5ccf7ea74f1d3986c5ab Mon Sep 17 00:00:00 2001 From: Mitchel van Amstel Date: Wed, 1 Jul 2020 12:01:05 +0200 Subject: [PATCH 12/12] Readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3190b45..783de1d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The core wallet of the Klimatas project. Klimatas is a project aiming to improve global sustainability with an investment platform and on-chain governance. -Current stable version: 1.3.4 +Current stable version: 1.3.4.1 ## Installation @@ -16,8 +16,8 @@ You can also build Klimatas core from source yourself. Please use the source cod ### Build instructions ```bash -wget https://github.com/klimatas/klimatas-core/archive/1.3.4.tar.gz -tar xzvf 1.3.4.tar.gz && cd 1.3.4 +wget https://github.com/klimatas/klimatas-core/archive/1.3.4.1.tar.gz +tar xzvf 1.3.4.1.tar.gz && cd 1.3.4.1 ./autogen.sh ./configure make -j2