From 512eda122f2fb324328ae5d9b283f4b4a1c7a3cb Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 02:23:08 +0530 Subject: [PATCH 01/11] Add legacy filtering mode --- src/masternodes/govvariables/attributes.cpp | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index abaafda7aea..78f6a0df96b 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -623,6 +623,20 @@ Res ATTRIBUTES::Import(const UniValue & val) { return Res::Ok(); } +// Keys to exclude when using the legacy filter mode, to keep things the +// same as pre 2.7.x versions, to reduce noise. Eventually, the APIs that +// cause too much noise can be deprecated and this code removed. +std::set legacyTokenKeysBlacklist = { + TokenKeys::LoanCollateralEnabled, + TokenKeys::LoanCollateralFactor, + TokenKeys::LoanMintingEnabled, + TokenKeys::LoanMintingInterest, + TokenKeys::FixedIntervalPriceId, + TokenKeys::Ascendant, + TokenKeys::Descendant, + TokenKeys::Epitaph, +}; + UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &prefix) const { UniValue ret(UniValue::VOBJ); for (const auto& attribute : attributes) { @@ -630,8 +644,13 @@ UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &pre if (!attrV0) { continue; } - if (filter == GovVarsFilter::LiveAttributes && attrV0->type != AttributeTypes::Live) { - continue; + if (filter == GovVarsFilter::LiveAttributes && + attrV0->type != AttributeTypes::Live) { + continue; + } else if (filter == GovVarsFilter::Legacy) { + if (attrV0->type == AttributeTypes::Token && + legacyTokenKeysBlacklist.find(attrV0->key) != legacyTokenKeysBlacklist.end()) + continue; } try { std::string id; From 408001d523d91cd71e557c49ce4507c6b0f532f9 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 24 May 2022 06:49:05 +0100 Subject: [PATCH 02/11] Update test to call listgovs with all --- src/masternodes/mn_rpc.cpp | 32 +++++++++++--------------- test/functional/feature_token_split.py | 8 +++---- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index 46fee1718b0..aec9e699cbe 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -711,28 +711,24 @@ UniValue listgovs(const JSONRPCRequest& request) { }, }.Check(request); - GovVarsFilter mode; + GovVarsFilter mode{GovVarsFilter::Legacy}; std::string prefix; if (request.params.size() > 0) { prefix = request.params[0].getValStr(); } - if (prefix.empty()) { - prefix = "legacy"; - } - - if (prefix == "all") { - mode = GovVarsFilter::All; - } else if (prefix == "legacy") { - mode = GovVarsFilter::Legacy; - } else if (prefix == "gov") { - mode = GovVarsFilter::NoAttributes; - } else if (prefix == "live") { - mode = GovVarsFilter::LiveAttributes; - } else { - mode = GovVarsFilter::PrefixedAttributes; - const std::regex versionRegex("v[0-9].*"); - if (!std::regex_match(prefix.begin(), prefix.end(), versionRegex)) { - prefix = "v0/" + prefix; + if (!prefix.empty()) { + if (prefix == "all") { + mode = GovVarsFilter::All; + } else if (prefix == "gov") { + mode = GovVarsFilter::NoAttributes; + } else if (prefix == "live") { + mode = GovVarsFilter::LiveAttributes; + } else { + mode = GovVarsFilter::PrefixedAttributes; + const std::regex versionRegex("v[0-9].*"); + if (!std::regex_match(prefix.begin(), prefix.end(), versionRegex)) { + prefix = "v0/" + prefix; + } } } diff --git a/test/functional/feature_token_split.py b/test/functional/feature_token_split.py index 29b3ce00fd7..b8aae0943ab 100644 --- a/test/functional/feature_token_split.py +++ b/test/functional/feature_token_split.py @@ -253,7 +253,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['destructionHeight'], self.nodes[0].getblockcount()) # Check old token in Gov vars - result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/token/{token_id}/fixed_interval_price_id' not in result) if collateral: assert(f'v0/token/{token_id}/loan_collateral_enabled' not in result) @@ -316,7 +316,7 @@ def check_pool_split(self, pool_id, pool_symbol, token_id, token_symbol, token_s assert_equal(result['rewardLoanPct'], Decimal('0.00000000')) # Validate old Gov vars removed - result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/poolpairs/{pool_id}/token_a_fee_pct' not in result) assert(f'v0/poolpairs/{pool_id}/token_b_fee_pct' not in result) assert(f'v0/token/{token_id}/dex_in_fee_pct' not in result) @@ -617,7 +617,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check splits - result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2,') @@ -626,7 +626,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check TSLA entries removed - result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/oracles/splits/{split_height}' not in result) assert(f'v0/oracles/splits/500000' not in result) assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2,') From d4f58fb3ce8a7dbc2671070225a0ae3d7d81b8eb Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 24 May 2022 07:51:08 +0100 Subject: [PATCH 03/11] tests: fix setgov call --- src/masternodes/mn_rpc.cpp | 3 ++- test/functional/feature_setgov.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index aec9e699cbe..181fc225e0f 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -693,7 +693,8 @@ UniValue listgovs(const JSONRPCRequest& request) { "\nReturns information about all governance variables including pending changes\n", { {"prefix", RPCArg::Type::STR, RPCArg::Optional::OMITTED, - "One of all, legacy, gov, live. Any other string is treated as a prefix of attributes to filter with. `v0/` is assumed if not explicitly provided."}, + "One of all, gov, live. Defaults to the legacy view. Any other string is treated as\n" + "a prefix of attributes to filter with. `v0/` is assumed if not explicitly provided."}, }, RPCResult{ "[[{id:{...}},{height:{...}},...], ...] (array) Json array with JSON objects with variable information\n" diff --git a/test/functional/feature_setgov.py b/test/functional/feature_setgov.py index ea1fd9f2543..82a871bbc1d 100755 --- a/test/functional/feature_setgov.py +++ b/test/functional/feature_setgov.py @@ -620,7 +620,7 @@ def run_test(self): assert_equal(self.nodes[0].listgovs("live"), [[{'ATTRIBUTES': {}}]]) result_all = self.nodes[0].listgovs("all") - result_legacy = self.nodes[0].listgovs("legacy") + result_legacy = self.nodes[0].listgovs() result = self.nodes[0].listgovs() # For now it's all the same. From 41af1bde89a5a25fa393c3c5993fb138d407469e Mon Sep 17 00:00:00 2001 From: Diehard073055 Date: Tue, 24 May 2022 16:08:54 +0800 Subject: [PATCH 04/11] Add(listgovs): add AttributeOnly as listgovs attrs --- src/masternodes/govvariables/attributes.h | 1 + src/masternodes/mn_rpc.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/masternodes/govvariables/attributes.h b/src/masternodes/govvariables/attributes.h index 43cbe23465a..8b5a8b9ce7d 100644 --- a/src/masternodes/govvariables/attributes.h +++ b/src/masternodes/govvariables/attributes.h @@ -139,6 +139,7 @@ enum GovVarsFilter { Legacy, All, NoAttributes, + AttributesOnly, PrefixedAttributes, LiveAttributes, }; diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index 181fc225e0f..646de1ce08d 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -722,6 +722,9 @@ UniValue listgovs(const JSONRPCRequest& request) { mode = GovVarsFilter::All; } else if (prefix == "gov") { mode = GovVarsFilter::NoAttributes; + } else if (prefix == "attrs") { + mode = GovVarsFilter::AttributesOnly; + } else if (prefix == "live") { mode = GovVarsFilter::LiveAttributes; } else { @@ -759,7 +762,8 @@ UniValue listgovs(const JSONRPCRequest& request) { } } else { if (mode == GovVarsFilter::LiveAttributes || - mode == GovVarsFilter::PrefixedAttributes) { + mode == GovVarsFilter::PrefixedAttributes || + mode == GovVarsFilter::AttributesOnly){ continue; } val = var->Export(); From fd5bff551fc306706bce3ee59057942ad954ddfb Mon Sep 17 00:00:00 2001 From: Diehard073055 Date: Tue, 24 May 2022 16:19:29 +0800 Subject: [PATCH 05/11] update(listgovs test): to call listgovs with attrs --- test/functional/feature_setgov.py | 2 +- test/functional/feature_token_split.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/functional/feature_setgov.py b/test/functional/feature_setgov.py index 82a871bbc1d..f69411d8119 100755 --- a/test/functional/feature_setgov.py +++ b/test/functional/feature_setgov.py @@ -619,7 +619,7 @@ def run_test(self): # live test. No live on this. For now, just ensure, no other attrs are listed assert_equal(self.nodes[0].listgovs("live"), [[{'ATTRIBUTES': {}}]]) - result_all = self.nodes[0].listgovs("all") + result_all = self.nodes[0].listgovs("attrs") result_legacy = self.nodes[0].listgovs() result = self.nodes[0].listgovs() diff --git a/test/functional/feature_token_split.py b/test/functional/feature_token_split.py index b8aae0943ab..060c3ba1af6 100644 --- a/test/functional/feature_token_split.py +++ b/test/functional/feature_token_split.py @@ -253,7 +253,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['destructionHeight'], self.nodes[0].getblockcount()) # Check old token in Gov vars - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] assert(f'v0/token/{token_id}/fixed_interval_price_id' not in result) if collateral: assert(f'v0/token/{token_id}/loan_collateral_enabled' not in result) @@ -316,7 +316,7 @@ def check_pool_split(self, pool_id, pool_symbol, token_id, token_symbol, token_s assert_equal(result['rewardLoanPct'], Decimal('0.00000000')) # Validate old Gov vars removed - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] assert(f'v0/poolpairs/{pool_id}/token_a_fee_pct' not in result) assert(f'v0/poolpairs/{pool_id}/token_b_fee_pct' not in result) assert(f'v0/token/{token_id}/dex_in_fee_pct' not in result) @@ -617,7 +617,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check splits - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2,') @@ -626,7 +626,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check TSLA entries removed - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] assert(f'v0/oracles/splits/{split_height}' not in result) assert(f'v0/oracles/splits/500000' not in result) assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2,') From 3428242c762b05dcc1b592ca0cd1f5ec642222b6 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 16:32:24 +0530 Subject: [PATCH 06/11] Update feature_setgov.py --- test/functional/feature_setgov.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/feature_setgov.py b/test/functional/feature_setgov.py index f69411d8119..09bdfdf4a63 100755 --- a/test/functional/feature_setgov.py +++ b/test/functional/feature_setgov.py @@ -619,13 +619,13 @@ def run_test(self): # live test. No live on this. For now, just ensure, no other attrs are listed assert_equal(self.nodes[0].listgovs("live"), [[{'ATTRIBUTES': {}}]]) - result_all = self.nodes[0].listgovs("attrs") - result_legacy = self.nodes[0].listgovs() + result_all = self.nodes[0].listgovs("all") + result_legacy = self.nodes[0].listgovs("legacy") result = self.nodes[0].listgovs() # For now it's all the same. assert_equal(result, result_legacy) - assert_equal(result, result_all) + # assert_equal(result, result_all) assert_equal(result, [[{'ICX_TAKERFEE_PER_BTC': Decimal('0.00200000')}], [{'LP_DAILY_LOAN_TOKEN_REWARD': Decimal('13020.86331792')}], [{'LP_LOAN_TOKEN_SPLITS': {'1': Decimal('0.10000000'), '2': Decimal('0.20000000'), '3': Decimal('0.70000000')}}], [{'LP_DAILY_DFI_REWARD': Decimal('13427.10581184')}], [{'LOAN_LIQUIDATION_PENALTY': Decimal('0.01000000')}], [{'LP_SPLITS': {'1': Decimal('0.70000000'), '2': Decimal('0.20000000'), '3': Decimal('0.10000000')}}], [{'ORACLE_BLOCK_INTERVAL': 30}], [{'ORACLE_DEVIATION': Decimal('0.07000000')}], [{'ATTRIBUTES': {'v0/params/dfip2201/active': 'true', 'v0/params/dfip2201/premium': '0.025', 'v0/params/dfip2201/minswap': '0.001', 'v0/params/dfip2203/active': 'true', 'v0/params/dfip2203/reward_pct': '0.05', 'v0/params/dfip2203/block_period': '20160', 'v0/token/5/payback_dfi': 'true', 'v0/token/5/payback_dfi_fee_pct': '0.33', 'v0/token/5/loan_payback/1': 'true', 'v0/token/5/loan_payback/2': 'true', 'v0/token/5/loan_payback_fee_pct/1': '0.25', 'v0/token/5/dex_in_fee_pct': '0.6', 'v0/token/5/dex_out_fee_pct': '0.12', 'v0/token/5/dfip2203': 'true'}}]]) From 0c5329b8e86f673c35eca8e883901a6b5373bab0 Mon Sep 17 00:00:00 2001 From: Diehard073055 Date: Tue, 24 May 2022 19:38:39 +0800 Subject: [PATCH 07/11] fix(listgovs test): fix index out of bounds --- test/functional/feature_token_split.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/functional/feature_token_split.py b/test/functional/feature_token_split.py index 060c3ba1af6..b8aae0943ab 100644 --- a/test/functional/feature_token_split.py +++ b/test/functional/feature_token_split.py @@ -253,7 +253,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['destructionHeight'], self.nodes[0].getblockcount()) # Check old token in Gov vars - result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/token/{token_id}/fixed_interval_price_id' not in result) if collateral: assert(f'v0/token/{token_id}/loan_collateral_enabled' not in result) @@ -316,7 +316,7 @@ def check_pool_split(self, pool_id, pool_symbol, token_id, token_symbol, token_s assert_equal(result['rewardLoanPct'], Decimal('0.00000000')) # Validate old Gov vars removed - result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/poolpairs/{pool_id}/token_a_fee_pct' not in result) assert(f'v0/poolpairs/{pool_id}/token_b_fee_pct' not in result) assert(f'v0/token/{token_id}/dex_in_fee_pct' not in result) @@ -617,7 +617,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check splits - result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2,') @@ -626,7 +626,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check TSLA entries removed - result = self.nodes[0].listgovs("attrs")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] assert(f'v0/oracles/splits/{split_height}' not in result) assert(f'v0/oracles/splits/500000' not in result) assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2,') From ea0ecae9c1c1a81b47583141a14999e9800e97e7 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 20:38:55 +0530 Subject: [PATCH 08/11] Added attrs index fixes, change default, add v27 --- src/masternodes/govvariables/attributes.cpp | 8 ++++---- src/masternodes/govvariables/attributes.h | 2 +- src/masternodes/mn_rpc.cpp | 12 ++++++++---- test/functional/feature_token_split.py | 8 ++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index 78f6a0df96b..df65340b54b 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -626,7 +626,7 @@ Res ATTRIBUTES::Import(const UniValue & val) { // Keys to exclude when using the legacy filter mode, to keep things the // same as pre 2.7.x versions, to reduce noise. Eventually, the APIs that // cause too much noise can be deprecated and this code removed. -std::set legacyTokenKeysBlacklist = { +std::set attrsVersion27TokenHiddenSet = { TokenKeys::LoanCollateralEnabled, TokenKeys::LoanCollateralFactor, TokenKeys::LoanMintingEnabled, @@ -644,12 +644,12 @@ UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &pre if (!attrV0) { continue; } - if (filter == GovVarsFilter::LiveAttributes && + if (filter == GovVarsFilter::Version2Dot7 && attrV0->type != AttributeTypes::Live) { continue; - } else if (filter == GovVarsFilter::Legacy) { + } else if (filter == GovVarsFilter::) { if (attrV0->type == AttributeTypes::Token && - legacyTokenKeysBlacklist.find(attrV0->key) != legacyTokenKeysBlacklist.end()) + attrsVersion27TokenHiddenSet.find(attrV0->key) != attrsVersion27TokenHiddenSet.end()) continue; } try { diff --git a/src/masternodes/govvariables/attributes.h b/src/masternodes/govvariables/attributes.h index 8b5a8b9ce7d..2dc9e89699b 100644 --- a/src/masternodes/govvariables/attributes.h +++ b/src/masternodes/govvariables/attributes.h @@ -136,12 +136,12 @@ using CAttributeType = boost::variant; using CAttributeValue = boost::variant; enum GovVarsFilter { - Legacy, All, NoAttributes, AttributesOnly, PrefixedAttributes, LiveAttributes, + Version2Dot7, }; class ATTRIBUTES : public GovVariable, public AutoRegistrator diff --git a/src/masternodes/mn_rpc.cpp b/src/masternodes/mn_rpc.cpp index 646de1ce08d..be8c5e2c6ed 100644 --- a/src/masternodes/mn_rpc.cpp +++ b/src/masternodes/mn_rpc.cpp @@ -693,7 +693,7 @@ UniValue listgovs(const JSONRPCRequest& request) { "\nReturns information about all governance variables including pending changes\n", { {"prefix", RPCArg::Type::STR, RPCArg::Optional::OMITTED, - "One of all, gov, live. Defaults to the legacy view. Any other string is treated as\n" + "One of all, gov, attrs, live. Defaults to the all view. Any other string is treated as\n" "a prefix of attributes to filter with. `v0/` is assumed if not explicitly provided."}, }, RPCResult{ @@ -712,7 +712,7 @@ UniValue listgovs(const JSONRPCRequest& request) { }, }.Check(request); - GovVarsFilter mode{GovVarsFilter::Legacy}; + GovVarsFilter mode{GovVarsFilter::All}; std::string prefix; if (request.params.size() > 0) { prefix = request.params[0].getValStr(); @@ -724,12 +724,16 @@ UniValue listgovs(const JSONRPCRequest& request) { mode = GovVarsFilter::NoAttributes; } else if (prefix == "attrs") { mode = GovVarsFilter::AttributesOnly; - + } else if (prefix == "v/2.7") { + // Undocumented. Make be removed or deprecated without notice. + // Only here for unforeseen compatibility concern downstream + // for transitions. + mode = GovVarsFilter::Version2Dot7; } else if (prefix == "live") { mode = GovVarsFilter::LiveAttributes; } else { mode = GovVarsFilter::PrefixedAttributes; - const std::regex versionRegex("v[0-9].*"); + const std::regex versionRegex("^v[0-9].*"); if (!std::regex_match(prefix.begin(), prefix.end(), versionRegex)) { prefix = "v0/" + prefix; } diff --git a/test/functional/feature_token_split.py b/test/functional/feature_token_split.py index b8aae0943ab..a305e80d1be 100644 --- a/test/functional/feature_token_split.py +++ b/test/functional/feature_token_split.py @@ -253,7 +253,7 @@ def check_token_split(self, token_id, token_symbol, token_suffix, multiplier, mi assert_equal(result['destructionHeight'], self.nodes[0].getblockcount()) # Check old token in Gov vars - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[0][0]['ATTRIBUTES'] assert(f'v0/token/{token_id}/fixed_interval_price_id' not in result) if collateral: assert(f'v0/token/{token_id}/loan_collateral_enabled' not in result) @@ -316,7 +316,7 @@ def check_pool_split(self, pool_id, pool_symbol, token_id, token_symbol, token_s assert_equal(result['rewardLoanPct'], Decimal('0.00000000')) # Validate old Gov vars removed - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[0][0]['ATTRIBUTES'] assert(f'v0/poolpairs/{pool_id}/token_a_fee_pct' not in result) assert(f'v0/poolpairs/{pool_id}/token_b_fee_pct' not in result) assert(f'v0/token/{token_id}/dex_in_fee_pct' not in result) @@ -617,7 +617,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check splits - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[0][0]['ATTRIBUTES'] assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2,') assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2,') @@ -626,7 +626,7 @@ def check_govvar_deletion(self): self.nodes[0].generate(1) # Check TSLA entries removed - result = self.nodes[0].listgovs("all")[8][0]['ATTRIBUTES'] + result = self.nodes[0].listgovs("attrs")[0][0]['ATTRIBUTES'] assert(f'v0/oracles/splits/{split_height}' not in result) assert(f'v0/oracles/splits/500000' not in result) assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2,') From 53b45b8f79a228e6982f20e759f306383879106e Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 20:45:26 +0530 Subject: [PATCH 09/11] Enable more tests --- test/functional/feature_setgov.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/functional/feature_setgov.py b/test/functional/feature_setgov.py index 48f78f76022..a1db4089c27 100755 --- a/test/functional/feature_setgov.py +++ b/test/functional/feature_setgov.py @@ -620,12 +620,13 @@ def run_test(self): assert_equal(self.nodes[0].listgovs("live"), [[{'ATTRIBUTES': {}}]]) result_all = self.nodes[0].listgovs("all") - result_legacy = self.nodes[0].listgovs("legacy") + result_27 = self.nodes[0].listgovs("v/2.7") result = self.nodes[0].listgovs() - # For now it's all the same. - assert_equal(result, result_legacy) - # assert_equal(result, result_all) + # In this particular test, in the fork period, it's the same. + # TODO: Need to add more tests + assert_equal(result, result_27) + assert_equal(result, result_all) assert_equal(result, [[{'ICX_TAKERFEE_PER_BTC': Decimal('0.00200000')}], [{'LP_DAILY_LOAN_TOKEN_REWARD': Decimal('13020.86331792')}], [{'LP_LOAN_TOKEN_SPLITS': {'1': Decimal('0.10000000'), '2': Decimal('0.20000000'), '3': Decimal('0.70000000')}}], [{'LP_DAILY_DFI_REWARD': Decimal('13427.10581184')}], [{'LOAN_LIQUIDATION_PENALTY': Decimal('0.01000000')}], [{'LP_SPLITS': {'1': Decimal('0.70000000'), '2': Decimal('0.20000000'), '3': Decimal('0.10000000')}}], [{'ORACLE_BLOCK_INTERVAL': 30}], [{'ORACLE_DEVIATION': Decimal('0.07000000')}], [{'ATTRIBUTES': {'v0/params/dfip2201/active': 'true', 'v0/params/dfip2201/premium': '0.025', 'v0/params/dfip2201/minswap': '0.001', 'v0/params/dfip2203/active': 'true', 'v0/params/dfip2203/reward_pct': '0.05', 'v0/params/dfip2203/block_period': '20160', 'v0/token/5/payback_dfi': 'true', 'v0/token/5/payback_dfi_fee_pct': '0.33', 'v0/token/5/loan_payback/1': 'true', 'v0/token/5/loan_payback/2': 'true', 'v0/token/5/loan_payback_fee_pct/1': '0.25', 'v0/token/5/dex_in_fee_pct': '0.6', 'v0/token/5/dex_out_fee_pct': '0.12', 'v0/token/5/dfip2203': 'true'}}]]) From 5aa282f23860033ceeb0bcf83cf0ad9b4f5e703e Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 21:04:13 +0530 Subject: [PATCH 10/11] Update attributes.cpp --- src/masternodes/govvariables/attributes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index a4be186f1fd..450223b44a3 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -644,10 +644,10 @@ UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &pre if (!attrV0) { continue; } - if (filter == GovVarsFilter::Version2Dot7 && + if (filter == GovVarsFilter::Live && attrV0->type != AttributeTypes::Live) { continue; - } else if (filter == GovVarsFilter::) { + } else if (filter == GovVarsFilter::Version2Dot7) { if (attrV0->type == AttributeTypes::Token && attrsVersion27TokenHiddenSet.find(attrV0->key) != attrsVersion27TokenHiddenSet.end()) continue; From 48162af07de9a5827b44baf956a6b353efa731ad Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 May 2022 21:05:15 +0530 Subject: [PATCH 11/11] Update attributes.cpp --- src/masternodes/govvariables/attributes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/masternodes/govvariables/attributes.cpp b/src/masternodes/govvariables/attributes.cpp index 450223b44a3..1fcb6842380 100644 --- a/src/masternodes/govvariables/attributes.cpp +++ b/src/masternodes/govvariables/attributes.cpp @@ -644,7 +644,7 @@ UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &pre if (!attrV0) { continue; } - if (filter == GovVarsFilter::Live && + if (filter == GovVarsFilter::LiveAttributes && attrV0->type != AttributeTypes::Live) { continue; } else if (filter == GovVarsFilter::Version2Dot7) {