mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Merge #6374: test: optimize feature asset locks test
2d05df04fd
refactor: use irange (pasta)4cc3ee6286
test: update feature_asset_locks.py to reflect changes (pasta)bfe1d2768d
refactor: activate DEPLOYMENT_WITHDRAWALS sooner on regtest (pasta)c8342e1b55
refactor: pull LimitBlocksToTrace into CChainParams (reduce regtest to 100) (pasta) Pull request description: ## Issue being fixed or feature implemented Minimize number of blocks needed to be mined in asset locks test Based on CI test goes from about 270s -> 213s ## What was done? Reduce number of blocks needed by reducing hard fork activation points ## How Has This Been Tested? Ran test locally, built ## Breaking Changes Breaking for regtests, nothing else. ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK2d05df04fd
UdjinM6: utACK2d05df04fd
Tree-SHA512: b52ec2570912ccb578b14baa4ef5c6e69454db7d83e7476c4451bca62b0c57e4c961e4bfafc9e5b0b4eebd6226840ac00505d3787316d7bdaeb64cb66b08fb30
This commit is contained in:
commit
88a8e7a077
@ -295,6 +295,8 @@ public:
|
||||
vSporkAddresses = {"Xgtyuk76vhuFW2iT7UAiHgNdWXCf3J34wh"};
|
||||
nMinSporkKeys = 1;
|
||||
|
||||
nCreditPoolPeriodBlocks = 576;
|
||||
|
||||
checkpointData = {
|
||||
{
|
||||
{1500, uint256S("0x000000aaf0300f59f49bc3e970bad15c11f961fe2347accffff19d96ec9778e3")},
|
||||
@ -484,6 +486,8 @@ public:
|
||||
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
|
||||
nMinSporkKeys = 1;
|
||||
|
||||
nCreditPoolPeriodBlocks = 576;
|
||||
|
||||
checkpointData = {
|
||||
{
|
||||
{255, uint256S("0x0000080b600e06f4c07880673f027210f9314575f5f875fafe51971e268b886a")},
|
||||
@ -664,6 +668,8 @@ public:
|
||||
vSporkAddresses = {"yjPtiKh2uwk3bDutTEA2q9mCtXyiZRWn55"};
|
||||
nMinSporkKeys = 1;
|
||||
|
||||
nCreditPoolPeriodBlocks = 576;
|
||||
|
||||
checkpointData = (CCheckpointData) {
|
||||
{
|
||||
{ 0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")},
|
||||
@ -812,9 +818,9 @@ public:
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].bit = 11;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nStartTime = 0;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nWindowSize = 600;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nThresholdStart = 600 / 5 * 4; // 80% of window size
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nThresholdMin = 600 / 5 * 3; // 60% of window size
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nWindowSize = 200;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nThresholdStart = 200 / 5 * 4; // 80% of window size
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nThresholdMin = 200 / 5 * 3; // 60% of window size
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].nFalloffCoeff = 5; // this corresponds to 10 periods
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_WITHDRAWALS].useEHF = true;
|
||||
|
||||
@ -866,6 +872,8 @@ public:
|
||||
vSporkAddresses = {"yj949n1UH6fDhw6HtVE5VMj2iSTaSWBMcW"};
|
||||
nMinSporkKeys = 1;
|
||||
|
||||
nCreditPoolPeriodBlocks = 100;
|
||||
|
||||
checkpointData = {
|
||||
{
|
||||
{0, uint256S("0x000008ca1832a4baf228eb1553c03d3a2c8e02399550dd6ea8d65cec3ef23d2e")},
|
||||
|
@ -152,6 +152,7 @@ public:
|
||||
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
|
||||
const std::vector<std::string>& SporkAddresses() const { return vSporkAddresses; }
|
||||
int MinSporkKeys() const { return nMinSporkKeys; }
|
||||
int CreditPoolPeriodBlocks() const { return nCreditPoolPeriodBlocks; }
|
||||
[[nodiscard]] std::optional<Consensus::LLMQParams> GetLLMQ(Consensus::LLMQType llmqType) const;
|
||||
|
||||
protected:
|
||||
@ -188,6 +189,8 @@ protected:
|
||||
int nMinSporkKeys;
|
||||
uint16_t nDefaultPlatformP2PPort;
|
||||
uint16_t nDefaultPlatformHTTPPort;
|
||||
/// The number of blocks the credit pool tracks; 576 (one day) on mainnet, reduced on regtest
|
||||
int nCreditPoolPeriodBlocks;
|
||||
|
||||
void AddLLMQ(Consensus::LLMQType llmqType);
|
||||
};
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <deploymentstatus.h>
|
||||
#include <logging.h>
|
||||
#include <node/blockstorage.h>
|
||||
#include <util/irange.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <algorithm>
|
||||
@ -153,7 +154,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo
|
||||
return opt_cbTx->creditPoolBalance;
|
||||
}();
|
||||
|
||||
// We use here sliding window with LimitBlocksToTrace to determine
|
||||
// We use here sliding window with Params().CreditPoolPeriodBlocks to determine
|
||||
// current limits for asset unlock transactions.
|
||||
// Indexes should not be duplicated since genesis block, but the Unlock Amount
|
||||
// of withdrawal transaction is limited only by this window
|
||||
@ -164,7 +165,7 @@ CCreditPool CCreditPoolManager::ConstructCreditPool(const CBlockIndex* const blo
|
||||
}
|
||||
|
||||
const CBlockIndex* distant_block_index = block_index;
|
||||
for (size_t i = 0; i < CCreditPoolManager::LimitBlocksToTrace; ++i) {
|
||||
for ([[maybe_unused]] auto _ : irange::range(Params().CreditPoolPeriodBlocks())) {
|
||||
distant_block_index = distant_block_index->pprev;
|
||||
if (distant_block_index == nullptr) break;
|
||||
}
|
||||
|
@ -114,7 +114,6 @@ private:
|
||||
static constexpr int DISK_SNAPSHOT_PERIOD = 576; // once per day
|
||||
|
||||
public:
|
||||
static constexpr int LimitBlocksToTrace = 576;
|
||||
static constexpr CAmount LimitAmountLow = 100 * COIN;
|
||||
static constexpr CAmount LimitAmountHigh = 1000 * COIN;
|
||||
static constexpr CAmount LimitAmountV22 = 2000 * COIN;
|
||||
|
@ -44,7 +44,7 @@ from test_framework.wallet_util import bytes_to_wif
|
||||
|
||||
llmq_type_test = 106 # LLMQType::LLMQ_TEST_PLATFORM
|
||||
tiny_amount = int(Decimal("0.0007") * COIN)
|
||||
blocks_in_one_day = 576
|
||||
blocks_in_one_day = 100
|
||||
HEIGHT_DIFF_EXPIRING = 48
|
||||
|
||||
class AssetLocksTest(DashTestFramework):
|
||||
@ -52,7 +52,7 @@ class AssetLocksTest(DashTestFramework):
|
||||
self.set_dash_test_params(4, 2, [[
|
||||
"-whitelist=127.0.0.1",
|
||||
"-llmqtestinstantsenddip0024=llmq_test_instantsend",
|
||||
"-testactivationheight=mn_rr@2500",
|
||||
"-testactivationheight=mn_rr@1400",
|
||||
]] * 4, evo_count=2)
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
@ -621,9 +621,10 @@ class AssetLocksTest(DashTestFramework):
|
||||
|
||||
|
||||
def test_mn_rr(self, node_wallet, node, pubkey):
|
||||
self.log.info(node_wallet.getblockcount())
|
||||
self.log.info("Activate mn_rr...")
|
||||
locked = self.get_credit_pool_balance()
|
||||
self.activate_mn_rr(expected_activation_height=2500)
|
||||
self.activate_mn_rr(expected_activation_height=1400)
|
||||
self.log.info(f'mn-rr height: {node.getblockcount()} credit: {self.get_credit_pool_balance()}')
|
||||
assert_equal(locked, self.get_credit_pool_balance())
|
||||
|
||||
@ -635,7 +636,7 @@ class AssetLocksTest(DashTestFramework):
|
||||
all_mn_rewards = platform_reward + owner_reward + operator_reward
|
||||
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 3 // 4) # 75/25 mn/miner reward split
|
||||
assert_equal(platform_reward, all_mn_rewards * 375 // 1000) # 0.375 platform share
|
||||
assert_equal(platform_reward, 34371430)
|
||||
assert_equal(platform_reward, 57741807)
|
||||
assert_equal(locked, self.get_credit_pool_balance())
|
||||
self.generate(node, 1)
|
||||
locked += platform_reward
|
||||
|
Loading…
Reference in New Issue
Block a user