Skip to content

Commit 8af069d

Browse files
more work
1 parent 538f017 commit 8af069d

File tree

8 files changed

+93
-63
lines changed

8 files changed

+93
-63
lines changed

packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ where
325325
Some(transaction),
326326
platform_version,
327327
)?;
328-
328+
329329
// Cleans up the expired locks for withdrawal amounts
330330
// This is for example when we make a withdrawal for 30 Dash
331331
// But we can only withdraw 1000 Dash a day

packages/rs-drive-abci/src/execution/platform_events/withdrawals/cleanup_expired_locks_of_withdrawal_amounts/v0/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ where
1919
transaction: &Transaction,
2020
platform_version: &PlatformVersion,
2121
) -> Result<(), Error> {
22-
if platform_version.drive_abci.withdrawal_constants.cleanup_expired_locks_of_withdrawal_amounts_limit == 0 {
22+
if platform_version
23+
.drive_abci
24+
.withdrawal_constants
25+
.cleanup_expired_locks_of_withdrawal_amounts_limit
26+
== 0
27+
{
2328
// No clean up
2429
return Ok(());
2530
}
@@ -31,8 +36,13 @@ where
3136
sum_path,
3237
QueryItem::RangeTo(..block_info.time_ms.to_be_bytes().to_vec()),
3338
);
34-
35-
path_query.query.limit = Some(platform_version.drive_abci.withdrawal_constants.cleanup_expired_locks_of_withdrawal_amounts_limit);
39+
40+
path_query.query.limit = Some(
41+
platform_version
42+
.drive_abci
43+
.withdrawal_constants
44+
.cleanup_expired_locks_of_withdrawal_amounts_limit,
45+
);
3646

3747
self.drive.batch_delete_items_in_path_query(
3848
&path_query,
@@ -53,7 +63,7 @@ where
5363
&mut vec![],
5464
&platform_version.drive,
5565
)?;
56-
66+
5767
Ok(())
5868
}
59-
}
69+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub(in crate::execution) mod append_signatures_and_broadcast_withdrawal_transactions;
22
pub(in crate::execution) mod build_untied_withdrawal_transactions_from_documents;
3+
pub(in crate::execution) mod cleanup_expired_locks_of_withdrawal_amounts;
34
pub(in crate::execution) mod dequeue_and_build_unsigned_withdrawal_transactions;
45
pub(in crate::execution) mod fetch_transactions_block_inclusion_status;
56
pub(in crate::execution) mod pool_withdrawals_into_transactions_queue;
67
pub(in crate::execution) mod update_broadcasted_withdrawal_statuses;
7-
pub(in crate::execution) mod cleanup_expired_locks_of_withdrawal_amounts;

packages/rs-drive-abci/tests/strategy_tests/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,6 @@ mod tests {
25882588
&simple_signer,
25892589
&mut rng,
25902590
platform_version,
2591-
25922591
);
25932592

25942593
let strategy = NetworkStrategy {

packages/rs-drive-abci/tests/strategy_tests/strategy.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,13 @@ impl NetworkStrategy {
15421542
platform_version,
15431543
)
15441544
} else {
1545-
create_state_transitions_for_identities(identities, balance_range, signer, rng, platform_version)
1545+
create_state_transitions_for_identities(
1546+
identities,
1547+
balance_range,
1548+
signer,
1549+
rng,
1550+
platform_version,
1551+
)
15461552
}
15471553
}
15481554

@@ -1703,7 +1709,11 @@ fn create_signed_instant_asset_lock_proofs_for_identities(
17031709
let secret_key = SecretKey::from_str(hex::encode(pk_fixed).as_str()).unwrap();
17041710
let private_key = PrivateKey::new(secret_key, Network::Dash);
17051711

1706-
let mut asset_lock_proof = instant_asset_lock_proof_fixture_with_dynamic_range(private_key, balance_range, rng);
1712+
let mut asset_lock_proof = instant_asset_lock_proof_fixture_with_dynamic_range(
1713+
private_key,
1714+
balance_range,
1715+
rng,
1716+
);
17071717

17081718
// Sign transaction and update instant lock
17091719
let AssetLockProof::Instant(InstantAssetLockProof { instant_lock, .. }) =

packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ mod tests {
1414
use dpp::withdrawal::WithdrawalTransactionIndex;
1515
use dpp::{dash_to_credits, dash_to_duffs};
1616
use drive::config::DEFAULT_QUERY_LIMIT;
17+
use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY;
1718
use drive::drive::identity::withdrawals::paths::{
1819
get_withdrawal_root_path, WITHDRAWAL_TRANSACTIONS_SUM_AMOUNT_TREE_KEY,
1920
};
21+
use drive::drive::system::misc_path;
2022
use drive::util::grove_operations::DirectQueryType;
2123
use drive_abci::config::{
2224
ChainLockConfig, ExecutionConfig, InstantLockConfig, PlatformConfig, PlatformTestConfig,
@@ -27,8 +29,6 @@ mod tests {
2729
use platform_version::version::PlatformVersion;
2830
use std::collections::BTreeMap;
2931
use std::sync::{Arc, Mutex};
30-
use drive::drive::balances::TOTAL_SYSTEM_CREDITS_STORAGE_KEY;
31-
use drive::drive::system::misc_path;
3232
use strategy_tests::frequency::Frequency;
3333
use strategy_tests::operations::{Operation, OperationType};
3434
use strategy_tests::{IdentityInsertInfo, StartIdentities, Strategy};
@@ -1251,7 +1251,7 @@ mod tests {
12511251
Purpose::TRANSFER,
12521252
[(SecurityLevel::CRITICAL, vec![KeyType::ECDSA_SECP256K1])].into(),
12531253
)]
1254-
.into(),
1254+
.into(),
12551255
start_balance_range: dash_to_duffs!(200)..=dash_to_duffs!(200),
12561256
},
12571257
identity_contract_nonce_gaps: None,
@@ -1412,11 +1412,22 @@ mod tests {
14121412

14131413
assert_eq!(pooled_withdrawals, 0);
14141414

1415-
let total_credits_balance = outcome.abci_app.platform.drive.calculate_total_credits_balance(None, &platform_version.drive).expect("expected to get total credits balance");
1415+
let total_credits_balance = outcome
1416+
.abci_app
1417+
.platform
1418+
.drive
1419+
.calculate_total_credits_balance(None, &platform_version.drive)
1420+
.expect("expected to get total credits balance");
14161421

1417-
assert_eq!(total_credits_balance.total_identity_balances, 409997575280380); // Around 4100 Dash.
1422+
assert_eq!(
1423+
total_credits_balance.total_identity_balances,
1424+
409997575280380
1425+
); // Around 4100 Dash.
14181426

1419-
assert_eq!(total_credits_balance.total_in_trees().unwrap(), 410000000000000); // Around 4100 Dash.
1427+
assert_eq!(
1428+
total_credits_balance.total_in_trees().unwrap(),
1429+
410000000000000
1430+
); // Around 4100 Dash.
14201431

14211432
let total_credits_in_platform = outcome
14221433
.abci_app
@@ -1429,7 +1440,8 @@ mod tests {
14291440
None,
14301441
&mut vec![],
14311442
&platform_version.drive,
1432-
).expect("expected to get total credits in platform");
1443+
)
1444+
.expect("expected to get total credits in platform");
14331445

14341446
assert_eq!(total_credits_in_platform, Some(410000000000000));
14351447

@@ -1491,20 +1503,19 @@ mod tests {
14911503
};
14921504

14931505
// Run Block 3 onwards: initiates withdrawals
1494-
let
1495-
ChainExecutionOutcome {
1496-
abci_app,
1497-
proposers,
1498-
validator_quorums: quorums,
1499-
current_validator_quorum_hash: current_quorum_hash,
1500-
current_proposer_versions,
1501-
end_time_ms,
1502-
identity_nonce_counter,
1503-
identity_contract_nonce_counter,
1504-
instant_lock_quorums,
1505-
identities,
1506-
..
1507-
} = {
1506+
let ChainExecutionOutcome {
1507+
abci_app,
1508+
proposers,
1509+
validator_quorums: quorums,
1510+
current_validator_quorum_hash: current_quorum_hash,
1511+
current_proposer_versions,
1512+
end_time_ms,
1513+
identity_nonce_counter,
1514+
identity_contract_nonce_counter,
1515+
instant_lock_quorums,
1516+
identities,
1517+
..
1518+
} = {
15081519
let outcome = continue_chain_for_strategy(
15091520
abci_app,
15101521
ChainExecutionParameters {
@@ -1650,20 +1661,19 @@ mod tests {
16501661

16511662
let hour_in_ms = 1000 * 60 * 60;
16521663

1653-
let
1654-
ChainExecutionOutcome {
1655-
abci_app,
1656-
proposers,
1657-
validator_quorums: quorums,
1658-
current_validator_quorum_hash: current_quorum_hash,
1659-
current_proposer_versions,
1660-
end_time_ms,
1661-
identity_nonce_counter,
1662-
identity_contract_nonce_counter,
1663-
instant_lock_quorums,
1664-
identities,
1665-
..
1666-
} = {
1664+
let ChainExecutionOutcome {
1665+
abci_app,
1666+
proposers,
1667+
validator_quorums: quorums,
1668+
current_validator_quorum_hash: current_quorum_hash,
1669+
current_proposer_versions,
1670+
end_time_ms,
1671+
identity_nonce_counter,
1672+
identity_contract_nonce_counter,
1673+
instant_lock_quorums,
1674+
identities,
1675+
..
1676+
} = {
16671677
let outcome = continue_chain_for_strategy(
16681678
abci_app,
16691679
ChainExecutionParameters {
@@ -1799,21 +1809,19 @@ mod tests {
17991809
outcome
18001810
};
18011811

1802-
1803-
let
1804-
ChainExecutionOutcome {
1805-
abci_app,
1806-
proposers,
1807-
validator_quorums: quorums,
1808-
current_validator_quorum_hash: current_quorum_hash,
1809-
current_proposer_versions,
1810-
end_time_ms,
1811-
identity_nonce_counter,
1812-
identity_contract_nonce_counter,
1813-
instant_lock_quorums,
1814-
identities,
1815-
..
1816-
} = {
1812+
let ChainExecutionOutcome {
1813+
abci_app,
1814+
proposers,
1815+
validator_quorums: quorums,
1816+
current_validator_quorum_hash: current_quorum_hash,
1817+
current_proposer_versions,
1818+
end_time_ms,
1819+
identity_nonce_counter,
1820+
identity_contract_nonce_counter,
1821+
instant_lock_quorums,
1822+
identities,
1823+
..
1824+
} = {
18171825
let outcome = continue_chain_for_strategy(
18181826
abci_app,
18191827
ChainExecutionParameters {

packages/rs-drive/src/util/batch/drive_op_batch/withdrawals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use dpp::fee::{Credits, SignedCredits};
1515
use dpp::prelude::TimestampMillis;
1616
use dpp::version::PlatformVersion;
1717
use dpp::withdrawal::{WithdrawalTransactionIndex, WithdrawalTransactionIndexAndBytes};
18+
use grovedb::Element;
1819
use grovedb::{batch::KeyInfoPath, EstimatedLayerInformation, TransactionArg};
19-
use grovedb::{Element};
2020

2121
/// Operations for Withdrawals
2222
#[derive(Clone, Debug)]

packages/strategy-tests/src/transitions.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,11 @@ pub fn create_state_transitions_for_identities(
10331033
.unwrap();
10341034
let sk: [u8; 32] = pk.try_into().unwrap();
10351035
let secret_key = SecretKey::from_str(hex::encode(sk).as_str()).unwrap();
1036-
let asset_lock_proof =
1037-
instant_asset_lock_proof_fixture_with_dynamic_range(PrivateKey::new(secret_key, Network::Dash), amount_range, rng);
1036+
let asset_lock_proof = instant_asset_lock_proof_fixture_with_dynamic_range(
1037+
PrivateKey::new(secret_key, Network::Dash),
1038+
amount_range,
1039+
rng,
1040+
);
10381041
let identity_create_transition =
10391042
IdentityCreateTransition::try_from_identity_with_signer(
10401043
&identity.clone(),

0 commit comments

Comments
 (0)