Skip to content

Conversation

@QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Jan 8, 2026

Issue being fixed or feature implemented

The expiration time for compacted address balances was previously set to 1 day. This change updates it to 1 week to allow for longer retention of address balance changes.

What was done?

  • Updated the expiration time constant from 1 day to 1 week across multiple files.
  • Adjusted related comments and test cases to reflect the new expiration duration.
  • Modified block spacing logic in tests to align with the new expiration timeframe.

How Has This Been Tested?

All relevant tests have been updated and executed to ensure that the new expiration logic functions correctly and that the expected outcomes are met.

Breaking Changes

None

Checklist

  • 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

    For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Chores
    • Updated system timing parameters and test assertions for address balance processing and block intervals.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added this to the v3.0.0 milestone Jan 8, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

The changes extend address balance expiration from 1 day to 1 week by replacing the ONE_DAY_IN_MS constant with ONE_WEEK_IN_MS and updating related test configurations. Block spacing adjustments from 20 minutes to 3 hours are applied to test cases, with corresponding recalculations of derived timing values and assertions.

Changes

Cohort / File(s) Summary
Expiration Window Constant Update
packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
Replaced public constant ONE_DAY_IN_MS (86,400,000 ms) with ONE_WEEK_IN_MS (604,800,000 ms); updated documentation to reflect "current block time + 1 week" expiration policy
Expiration Logic Implementation
packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs
Updated import and usage from ONE_DAY_IN_MS to ONE_WEEK_IN_MS in expiration time calculations; adjusted comments to reflect 1-week expiration window
Expiration Test Cases
packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
Updated test assertions and expected expiration keys to use ONE_WEEK_IN_MS instead of ONE_DAY_IN_MS across multiple compaction scenarios
Block Spacing & Timing Configuration
packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
Modified PlatformConfig.block_spacing_ms from 1,200,000 (20 minutes) to 10,800,000 (3 hours); recalculated all derived block numbers (e.g., 72→56, 136→120, 200→184, 264→248, 328→312) and updated related comments

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A week is grander than a day,
Those balance blocks shall longer stay,
Three hours now tween each chain link,
Expiration's stretched—no need to blink!
Constants dance in harmony's way.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: updating address expiration time from 1 day to 1 week, which is the primary objective across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f67ba29 and cc2caaf.

📒 Files selected for processing (4)
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
**/tests/**/*.{js,jsx,ts,tsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

**/tests/**/*.{js,jsx,ts,tsx,rs}: Name tests descriptively, starting with 'should …'
Unit and integration tests should not perform network calls; mock dependencies

Files:

  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/mimic/test_quorum.rs:159-164
Timestamp: 2024-11-20T16:16:01.830Z
Learning: QuantumExplorer prefers not to receive auto-generated messages asking to post on social media.
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:105-105
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In `run_block_proposal` in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, when retrieving `last_block_time_ms`, it's acceptable to use `platform_state` instead of `block_platform_state`, even after updating the protocol version.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
📚 Learning: 2024-11-25T01:17:02.001Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2347
File: packages/rs-drive/tests/query_tests.rs:438-460
Timestamp: 2024-11-25T01:17:02.001Z
Learning: In Rust test files (`packages/rs-drive/tests/query_tests.rs`), when code is used only in tests, defining explicit enums for fields (like the `status` field in the `Withdrawal` struct) may not be necessary; using primitive types is acceptable.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
📚 Learning: 2024-10-08T13:28:03.529Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-drive-abci/src/platform_types/platform_state/mod.rs:141-141
Timestamp: 2024-10-08T13:28:03.529Z
Learning: When converting `PlatformStateV0` to `PlatformStateForSavingV1` in `packages/rs-drive-abci/src/platform_types/platform_state/mod.rs`, only version `0` needs to be handled in the match on `platform_state_for_saving_structure_default` because the changes are retroactive.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs
📚 Learning: 2025-05-28T16:22:26.334Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2644
File: packages/rs-drive/src/cache/system_contracts.rs:18-19
Timestamp: 2025-05-28T16:22:26.334Z
Learning: In packages/rs-drive/src/cache/system_contracts.rs, the `active_since_protocol_version` field in `ActiveSystemDataContract` struct is intentionally added for future use, not current implementation. QuantumExplorer confirmed this is "meant for later" when questioned about the `#[allow(unused)]` attribute.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2206
File: packages/rs-drive-abci/tests/strategy_tests/main.rs:1162-1162
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust test file `packages/rs-drive-abci/tests/strategy_tests/main.rs`, specific protocol versions like `PROTOCOL_VERSION_1` are intentionally used in tests instead of `PROTOCOL_VERSION_LATEST`.

Applied to files:

  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
📚 Learning: 2024-10-06T16:18:07.994Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs:119-120
Timestamp: 2024-10-06T16:18:07.994Z
Learning: In the `run_block_proposal` function in `packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs`, it's acceptable to pass `platform_state` to `perform_events_on_first_block_of_protocol_change`, even if `block_platform_state` has been updated.

Applied to files:

  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs
🧬 Code graph analysis (2)
packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs (1)
packages/rs-drive/src/drive/initialization/v2/mod.rs (1)
  • drive (71-114)
packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs (1)
packages/rs-drive/src/drive/initialization/v2/mod.rs (1)
  • drive (71-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: PR title
  • GitHub Check: assign-milestone
  • GitHub Check: PR title
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (4)
packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/v0/mod.rs (1)

1-1: LGTM! Expiration window consistently updated from 1 day to 1 week.

The changes correctly update the import, documentation, and calculation to use ONE_WEEK_IN_MS. The use of saturating_add provides appropriate overflow protection.

Also applies to: 24-24, 157-158

packages/rs-drive-abci/tests/strategy_tests/test_cases/address_tests.rs (1)

2843-2851: LGTM! Test parameters correctly updated for 1-week expiration window.

The block spacing adjustment from 20 minutes to 3 hours, combined with the 1-week expiration window, yields correct calculations:

  • Expiration after 56 blocks (168 hours / 3 hours per block)
  • Timeline calculations are accurate: blocks 64→120, 128→184, 192→248, 256→312

The test logic correctly validates the new compaction and cleanup behavior.

Also applies to: 2862-2862, 2947-2953

packages/rs-drive/src/drive/saved_block_transactions/compact_address_balances/mod.rs (1)

12-13: LGTM! New constant correctly defined and documented.

ONE_WEEK_IN_MS is properly calculated (604,800,000 ms) and well within u64 bounds. The documentation clearly states the new 1-week expiration window for compacted address balances.

Also applies to: 23-23

packages/rs-drive/src/drive/saved_block_transactions/store_address_balances/v0/mod.rs (1)

883-883: LGTM! Test assertions correctly updated for 1-week expiration.

Both test functions properly use ONE_WEEK_IN_MS in their calculations and assertions, ensuring the expiration time storage logic is validated with the new 1-week window.

Also applies to: 944-944, 949-949, 952-952, 973-973, 1066-1066


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@QuantumExplorer QuantumExplorer changed the title feat: update address expiration time from 1 day to 1 week feat(platform): update address expiration time from 1 day to 1 week Jan 8, 2026
@QuantumExplorer QuantumExplorer merged commit a0f66ab into v3.0-dev Jan 8, 2026
58 of 60 checks passed
@QuantumExplorer QuantumExplorer deleted the featupdate-address-expiration-time branch January 8, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants