governance: Implement reduced governance fee (#4241)

* Implement hf for reduced governance fee

Signed-off-by: pasta <pasta@dashboost.org>

* update VersionBitsDeploymentInfo

* Adjust activation times for gov fee hard fork

* Use raw timestamps

* Adjust timestamps

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
PastaPastaPasta 2021-11-01 11:31:48 -04:00 committed by GitHub
parent 12c399b3f0
commit 2204c85370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 6 deletions

View File

@ -216,6 +216,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 2420; // 60% of 4032 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 1638316800; // Dec 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 1669852800; // Dec 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work. // The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000549cd3ccb81a55892330"); // 1450000 consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000549cd3ccb81a55892330"); // 1450000
@ -426,6 +435,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 999999999999ULL; // TODO renable this before first RC
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work. // The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000022f14ac5d56b5ef"); // 470000 consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000022f14ac5d56b5ef"); // 470000
@ -608,6 +626,15 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100 consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 1635724800; // Nov 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
// The best chain should have at least this much work. // The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000000000000"); consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000000000000");
@ -810,6 +837,13 @@ public:
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdStart = 80; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdStart = 80;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 80;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 60;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5;
// The best chain should have at least this much work. // The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00"); consensus.nMinimumChainWork = uint256S("0x00");

View File

@ -23,6 +23,7 @@ enum DeploymentPos
DEPLOYMENT_DIP0008, // Deployment of ChainLock enforcement DEPLOYMENT_DIP0008, // Deployment of ChainLock enforcement
DEPLOYMENT_REALLOC, // Deployment of Block Reward Reallocation DEPLOYMENT_REALLOC, // Deployment of Block Reward Reallocation
DEPLOYMENT_DIP0020, // Deployment of DIP0020, DIP0021 and LMQ_100_67 quorums DEPLOYMENT_DIP0020, // Deployment of DIP0020, DIP0021 and LMQ_100_67 quorums
DEPLOYMENT_GOV_FEE, // Deployment of decreased governance proposal fee
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp // NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp
MAX_VERSION_BITS_DEPLOYMENTS MAX_VERSION_BITS_DEPLOYMENTS
}; };

View File

@ -507,12 +507,13 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingConf
} }
} }
CAmount CGovernanceObject::GetMinCollateralFee() const CAmount CGovernanceObject::GetMinCollateralFee(bool fork_active) const
{ {
// Only 1 type has a fee for the moment but switch statement allows for future object types // Only 1 type has a fee for the moment but switch statement allows for future object types
switch (nObjectType) { switch (nObjectType) {
case GOVERNANCE_OBJECT_PROPOSAL: case GOVERNANCE_OBJECT_PROPOSAL:
return GOVERNANCE_PROPOSAL_FEE_TX; if (fork_active) return GOVERNANCE_PROPOSAL_FEE_TX;
else return GOVERNANCE_PROPOSAL_FEE_TX_OLD;
case GOVERNANCE_OBJECT_TRIGGER: case GOVERNANCE_OBJECT_TRIGGER:
return 0; return 0;
default: default:
@ -524,7 +525,6 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
{ {
strError = ""; strError = "";
fMissingConfirmations = false; fMissingConfirmations = false;
CAmount nMinFee = GetMinCollateralFee();
uint256 nExpectedHash = GetHash(); uint256 nExpectedHash = GetHash();
CTransactionRef txCollateral; CTransactionRef txCollateral;
@ -555,6 +555,10 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
CScript findScript; CScript findScript;
findScript << OP_RETURN << ToByteVector(nExpectedHash); findScript << OP_RETURN << ToByteVector(nExpectedHash);
AssertLockHeld(cs_main);
bool fork_active = VersionBitsState(LookupBlockIndex(nBlockHash), Params().GetConsensus(), Consensus::DEPLOYMENT_GOV_FEE, versionbitscache) == ThresholdState::ACTIVE;
CAmount nMinFee = GetMinCollateralFee(fork_active);
LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n", LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
txCollateral->vout.size(), ScriptToAsmStr(findScript, false), nMinFee); txCollateral->vout.size(), ScriptToAsmStr(findScript, false), nMinFee);

View File

@ -30,7 +30,8 @@ static constexpr int GOVERNANCE_OBJECT_UNKNOWN = 0;
static constexpr int GOVERNANCE_OBJECT_PROPOSAL = 1; static constexpr int GOVERNANCE_OBJECT_PROPOSAL = 1;
static constexpr int GOVERNANCE_OBJECT_TRIGGER = 2; static constexpr int GOVERNANCE_OBJECT_TRIGGER = 2;
static constexpr CAmount GOVERNANCE_PROPOSAL_FEE_TX = (5.0 * COIN); static constexpr CAmount GOVERNANCE_PROPOSAL_FEE_TX = (1 * COIN);
static constexpr CAmount GOVERNANCE_PROPOSAL_FEE_TX_OLD = (5 * COIN);
static constexpr int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6; static constexpr int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6;
static constexpr int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS = 1; static constexpr int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS = 1;
@ -258,7 +259,7 @@ public:
} }
} }
CAmount GetMinCollateralFee() const; CAmount GetMinCollateralFee(bool fork_active) const;
UniValue GetJSONObject() const; UniValue GetJSONObject() const;

View File

@ -220,7 +220,10 @@ static UniValue gobject_prepare(const JSONRPCRequest& request)
} }
CTransactionRef tx; CTransactionRef tx;
if (!pwallet->GetBudgetSystemCollateralTX(*locked_chain, tx, govobj.GetHash(), govobj.GetMinCollateralFee(), outpoint)) {
bool fork_active = VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_GOV_FEE) == ThresholdState::ACTIVE;
if (!pwallet->GetBudgetSystemCollateralTX(*locked_chain, tx, govobj.GetHash(), govobj.GetMinCollateralFee(fork_active), outpoint)) {
std::string err = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked."; std::string err = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked.";
if (!request.params[6].isNull() && !request.params[7].isNull()) { if (!request.params[6].isNull() && !request.params[7].isNull()) {
err += "Please verify your specified output is valid and is enough for the combined proposal fee and transaction fee."; err += "Please verify your specified output is valid and is enough for the combined proposal fee and transaction fee.";

View File

@ -47,4 +47,9 @@ const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_B
/*.gbt_force =*/ true, /*.gbt_force =*/ true,
/*.check_mn_protocol =*/ false, /*.check_mn_protocol =*/ false,
}, },
{
/*.name =*/ "gov_fee",
/*.gbt_force =*/ true,
/*.check_mn_protocol =*/ false,
},
}; };