Skip to content

test(platform): additional token distribution tests and fixes #2550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 17, 2025

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Apr 16, 2025

Issue being fixed or feature implemented

A series of tests and fixes for token distribution.

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
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Expanded support for distribution functions with new parameters and enhanced configuration options, including more descriptive parameter names and additional fields for step-decreasing amounts.
    • Added new constants for parameter limits and defaults to improve clarity and safety.
    • Added validation for perpetual token distributions during data contract creation and update state transitions.
    • Introduced new tests covering valid and invalid perpetual distribution configurations in data contract creation.
  • Improvements

    • Enhanced validation logic for distribution functions, providing stricter parameter checks and clearer error messages.
    • Improved evaluation logic for distribution functions, with safer arithmetic, better boundary handling, and consistent clamping of results.
    • Updated display formatting and documentation for distribution functions to reflect new fields and naming conventions.
    • Logging subsystem now prevents multiple initializations without errors, improving reliability in repeated setups.
    • Centralized max cycle logic in reward distribution calculations for consistency.
  • Bug Fixes

    • Fixed underflow and overflow handling in distribution function calculations.
    • Updated tests to reflect new parameter names and validation rules.
  • Chores

    • Added a new development dependency for serial testing.
    • Minor test and import updates to align with new parameter names.

Copy link
Contributor

coderabbitai bot commented Apr 16, 2025

## Walkthrough

This set of changes refactors and extends the token distribution logic for perpetual distributions. The `DistributionFunction` enum variants, especially `StepDecreasingAmount`, are updated with more descriptive field names and new parameters. Encoding, decoding, evaluation, and validation logic are revised to use these new names and parameters, with enhanced boundary checks, overflow handling, and parameter validation. Constants for parameter bounds are added, and documentation is improved throughout. Logging initialization is made idempotent, and related tests and display formatting are updated to match the new structures and logic.

## Changes

| File(s) | Change Summary |
|---------|---------------|
| `.../distribution_function/encode.rs`, `.../distribution_function/mod.rs` | Refactored `DistributionFunction` variants with new/renamed fields, updated encoding/decoding logic, added constants for parameter bounds, and improved documentation and display formatting. |
| `.../distribution_function/evaluate.rs` | Revised evaluation logic for all distribution function variants, focusing on integer arithmetic, overflow handling, clamping, and parameter renaming. Updated tests for new behavior and parameter names. |
| `.../distribution_function/validation.rs` | Enhanced validation logic with new parameter checks, error handling, and test coverage. Method signature updated to accept `PlatformVersion`. |
| `.../reward_distribution_type/mod.rs` | Changed max cycle logic to use a constant for fixed amount distributions, updated parameter names, and unified calculation path. |
| `.../invalid_token_distribution_function_incoherence_error.rs` | Minor change to error message formatting by removing a trailing period. |
| `.../src/logging/logger.rs` | Added static `OnceLock` to prevent multiple logging initializations, added `as_subscriber` method, and made `try_install` idempotent. |
| `.../src/logging/mod.rs` | Updated logging test to use explicit dispatcher setup instead of global install. |
| `.../batch/tests/token/distribution/perpetual/time_based.rs` | Updated tests to use new constant name `MAX_LINEAR_SLOPE_A_PARAM` in linear distribution function configuration. |
| `.../Cargo.toml` | Added `serial_test` as a development dependency. |
| `.../data_contract_create/basic_structure/v0/mod.rs` | Added validation of perpetual token distributions during data contract creation. |
| `.../data_contract_create/mod.rs` | Added new tests verifying valid and invalid perpetual distribution configurations during data contract creation. |
| `.../data_contract_update/basic_structure/v0/mod.rs` | Added validation of perpetual token distributions during data contract update. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant DistributionFunction
    participant Validator
    participant Evaluator

    User->>DistributionFunction: Define variant with parameters
    DistributionFunction->>Validator: validate(start_moment, platform_version)
    Validator-->>DistributionFunction: Validation result
    User->>DistributionFunction: encode()/decode()
    User->>Evaluator: evaluate(x)
    Evaluator-->>User: Distribution amount (with clamping, overflow checks)

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • shumkov

Poem

In fields of code where tokens flow,
New names and checks now help us grow.
With bounds and clamps, our sums align,
Each function’s path is clear by design.
Logging’s calm, no panic in sight—
Bunnies rejoice, for all is right!
🐇✨


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 0296e0b25172fa4a727f4ad22968c0ba4cfca688 and 9448791cbfd4b170ad069fc249440164b378b38d.

</details>

<details>
<summary>📒 Files selected for processing (4)</summary>

* `packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/validation.rs` (88 hunks)
* `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs` (2 hunks)
* `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs` (4 hunks)
* `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/basic_structure/v0/mod.rs` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (1)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: QuantumExplorer
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.


</details>

</details><details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs (1)</summary><blockquote>

<details>
<summary>packages/wasm-dpp/src/data_contract/data_contract.rs (1)</summary>

* `token_configuration` (435-443)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (19)</summary>

* GitHub Check: Rust packages (dash-sdk) / Linting
* GitHub Check: Rust packages (dash-sdk) / Formatting
* GitHub Check: Rust packages (dash-sdk) / Check each feature
* GitHub Check: Rust packages (dash-sdk) / Tests
* GitHub Check: Rust packages (dash-sdk) / Unused dependencies
* GitHub Check: Rust packages (drive-abci) / Linting
* GitHub Check: Rust packages (drive-abci) / Tests
* GitHub Check: Rust packages (drive) / Tests
* GitHub Check: Rust packages (drive-abci) / Check each feature
* GitHub Check: Rust packages (dpp) / Tests
* GitHub Check: Rust packages (dpp) / Check each feature
* GitHub Check: Rust packages (drive) / Linting
* GitHub Check: Rust packages (dpp) / Linting
* GitHub Check: Rust packages (wasm-dpp) / Linting
* GitHub Check: Rust packages (wasm-dpp) / Tests
* GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
* GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
* GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
* GitHub Check: Build JS packages / Build JS

</details>

<details>
<summary>🔇 Additional comments (24)</summary><blockquote>

<details>
<summary>packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/basic_structure/v0/mod.rs (2)</summary>

`6-7`: **Import additions for token perpetual distribution support.**

The added imports enable access to token distribution rules and perpetual distribution accessors, which are needed for the new validation logic.

---

`71-84`: **Added validation for perpetual token distributions.**

Good implementation of perpetual distribution validation in data contract updates. The code properly checks for the existence of a perpetual distribution, then validates its distribution function starting at moment zero (current moment with no offset).

The comment explaining the use of 0 as the start moment is helpful for understanding the intent.

</details>
<details>
<summary>packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/basic_structure/v0/mod.rs (2)</summary>

`10-11`: **Import additions for token perpetual distribution support.**

The added imports enable access to token distribution rules and perpetual distribution accessors, consistent with the changes in the data contract update validation.

---

`86-99`: **Added validation for perpetual token distributions.**

Good implementation of perpetual distribution validation for data contract creation. This mirrors the validation logic added to the data contract update validation, providing consistency across both state transition types.

The validation properly checks if a perpetual distribution exists, then validates its distribution function using the platform version, returning early with any validation failures.

</details>
<details>
<summary>packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_create/mod.rs (5)</summary>

`415-420`: **Added imports for token perpetual distribution.**

These imports bring in the necessary types for the new test cases covering perpetual distribution functionality.

---

`1071-1182`: **Added test for valid perpetual distribution.**

Comprehensive test case that verifies a data contract with a valid perpetual distribution is created successfully and results in the correct token balance (100,000) being assigned.

The test properly configures an Exponential distribution function with appropriate parameters and validates that the state transition executes successfully.

---

`1364-1369`: **Added imports for token_errors test module.**

These imports bring in the necessary types for the new error case tests related to perpetual distributions.

---

`1818-1934`: **Added test for invalid perpetual distribution (divide by zero error).**

Good test case that verifies the system correctly rejects a data contract with an invalid perpetual distribution where all parameters are zero, which would cause a divide-by-zero error. The test confirms the expected error type is returned and no token balance is assigned.

---

`1937-2040`: **Added test for unsupported random distribution function.**

Good test case that verifies the system correctly rejects a data contract with a Random distribution function, which is currently unsupported. The test properly confirms that an UnsupportedFeatureError is returned and no token balance is assigned.

</details>
<details>
<summary>packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/validation.rs (15)</summary>

`7-15`: **Good addition of PlatformVersion for feature versioning.**

The addition of `PlatformVersion` and `UnsupportedFeatureError` enables version-aware validation, which is a good practice for maintaining backward compatibility while adding new features.

---

`18-21`: **Good API enhancement with platform version parameter.**

Adding the platform version parameter to the validation method enables context-aware validation, allowing for different validation rules based on the platform version.

---

`37-69`: **Properly handling unsupported Random distribution feature.**

Good approach for preventing use of the Random distribution in unsupported platform versions. Instead of silently failing or allowing invalid behavior, you explicitly return an error indicating the feature is not yet supported.

---

`75-79`: **Well-structured parameter renaming for better clarity.**

More descriptive field names like `distribution_start_amount` and `trailing_distribution_interval_amount` improve code clarity compared to the previous generic names.

---

`107-119`: **Good validation for max_interval_count parameter.**

The validation ensures that max_interval_count is within a reasonable range (2 to 1024), preventing extreme values that could lead to performance issues or excessive resource consumption.

---

`324-333`: **Good check preventing m==n in Polynomial functions.**

This validation prevents a case where the polynomial function would be equivalent to a linear function when m equals n, ensuring proper usage of the polynomial distribution type.

---

`335-357`: **Complete validation of polynomial parameter 'a' and 'm'.**

Adding comprehensive validation for both the 'a' and 'm' parameters ensures that the polynomial function will behave as expected, preventing undefined behavior.

---

`358-369`: **Proper validation of polynomial parameter 'n'.**

The addition of an upper bound check for 'n' prevents potential numerical issues with very large exponents.

---

`500-510`: **Proper validation of exponential parameter 'n'.**

The added validation for 'n' parameter ensures it doesn't exceed the maximum allowed value, preventing potential numerical issues.

---

`702-712`: **Properly structured validation for logarithmic parameter 'a'.**

The validation now properly checks that 'a' is within the allowed range using the correct constants (MIN_LOG_A_PARAM and MAX_LOG_A_PARAM).

---

`840-851`: **Added missing validation for InvertedLogarithmic 'a' parameter.**

This validation ensures that 'a' parameter is within the allowed range, adding consistency with other distribution function validations.

---

`1452-1473`: **Good test coverage for invalid zero 'a' parameter in Polynomial.**

This test ensures that validation properly rejects a Polynomial function with an 'a' parameter of zero, which would result in a constant function.

---

`1599-1617`: **Critical test case for m == n validation in Polynomial functions.**

This test verifies the new validation that prevents m from being equal to n, which ensures proper usage of the polynomial distribution type.

---

`2320-2341`: **Good test coverage for invalid zero 'm' parameter in Logarithmic.**

This test ensures that validation properly rejects a Logarithmic function with an 'm' parameter of zero, which would result in an undefined logarithm.

---

`2477-2516`: **Comprehensive tests for InvertedLogarithmic 'a' parameter validation.**

These tests thoroughly verify the validation logic for the 'a' parameter, including checks for zero value and values outside the allowed range.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIaRFwACm4vagAzfApmAEouNFpadXh8DDRfAgBrMkgC+Ip4ATwirDjcZEx6VPgAD2loyAB3NGQHAWZ1Gno5MNgPbERKSABFbExcRwBRLuSMhaHrOwxHAQWAJgB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AEnE6vQGvuH25Ix94zI2ryoX2DRbYfQEAA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=dashpay/platform&utm_content=2550):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@thephez thephez added this to the v2.0.0 milestone Apr 16, 2025
@QuantumExplorer QuantumExplorer changed the title V2.0 dev distributions test(platform): additional token distribution tests and fixes Apr 17, 2025
@QuantumExplorer QuantumExplorer marked this pull request as ready for review April 17, 2025 21:44
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs (1)

401-407: Copy‑paste typo in error message

Inside the Logarithmic branch we return
"InvertedLogarithmic: evaluation overflow".

-                        "InvertedLogarithmic: evaluation overflow",
+                        "Logarithmic: evaluation overflow",
packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs (1)

12-19: Comment maths does not match the constant

MAX_DISTRIBUTION_CYCLES_PARAM is set to 32_767 (2^15‑1) but the comment
says 2^(63 - 48) - 1. That evaluates to 2^15‑1, yet the indirection
makes the reader stop and do the math. Consider stating it directly:

-/// This is applied to linear distribution.
-/// For all other distributions we use a versioned max cycles contained in the platform version.
-/// That other version is much lower because the calculations for other distributions are more
-/// complex.
+/// Applies to linear distributions only.  Other distribution types use a
+/// version‑specific, lower limit because their calculations are more complex.
packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/encode.rs (1)

20-40: Keep encode/decode order in a single source of truth

Encode, Decode, and BorrowDecode now duplicate the exact same field
ordering logic for every variant. Any future change risks introducing a
subtle mismatch.

Consider factoring the common field‑ordering into a helper macro or
#[derive(Encode, Decode)] on a lightweight struct for each variant. This
removes the manual duplication, reduces review surface, and prevents
serialization bugs.

packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/validation.rs (1)

86-92: Misleading field name in validation error

The error message still refers to the generic placeholder n, but the field being validated was renamed to distribution_start_amount. This will confuse developers and API users when the error is surfaced.

-InvalidTokenDistributionFunctionInvalidParameterError::new(
-    "n".to_string(),
+InvalidTokenDistributionFunctionInvalidParameterError::new(
+    "distribution_start_amount".to_string(),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db1fcb8 and 0296e0b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/encode.rs (11 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs (27 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/mod.rs (14 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/validation.rs (88 hunks)
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/reward_distribution_type/mod.rs (3 hunks)
  • packages/rs-dpp/src/errors/consensus/basic/data_contract/invalid_token_distribution_function_incoherence_error.rs (1 hunks)
  • packages/rs-drive-abci/Cargo.toml (1 hunks)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/distribution/perpetual/time_based.rs (3 hunks)
  • packages/rs-drive-abci/src/logging/logger.rs (3 hunks)
  • packages/rs-drive-abci/src/logging/mod.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: QuantumExplorer
PR: dashpay/platform#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.
⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Detect immutable structure changes
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive-abci) / Formatting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (drive-abci) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Formatting
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (14)
packages/rs-drive-abci/src/logging/mod.rs (1)

109-111: Improved test reliability with explicit dispatcher setup

This change improves the testing approach by explicitly creating and setting a tracing dispatcher rather than installing it globally. This approach aligns with the new idempotent logging initialization in logger.rs, preventing potential conflicts between tests that manipulate the global logging state.

packages/rs-drive-abci/src/logging/logger.rs (3)

56-60: LGTM: Good addition of idempotent logging initialization

The addition of OnceLock is a clean way to track the logging initialization state without using mutable statics or other less safe approaches.


173-178: Well-designed API extension for subscriber creation

This new as_subscriber() method nicely separates the creation of the subscriber from its installation, providing more flexibility for clients (like tests) that need more control over dispatcher lifetime.


192-207: Improved error handling with idempotent initialization

The modification to try_install() makes it properly idempotent by checking the LOGGING_INSTALLED status before attempting initialization. This is a significant improvement that prevents errors when the method is called multiple times, while maintaining the expected behavior.

packages/rs-drive-abci/Cargo.toml (1)

109-109: Added new serial_test dependency for test organization.

The addition of the serial_test dependency will help ensure tests that could interfere with each other run in sequence rather than in parallel, supporting more robust testing of token distribution functionality.

packages/rs-dpp/src/errors/consensus/basic/data_contract/invalid_token_distribution_function_incoherence_error.rs (1)

13-13: Improved error message format.

Removed the trailing period in the error message format for better consistency and readability when rendering error messages with dynamic content.

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/distribution/perpetual/time_based.rs (3)

14-14: Updated import to use renamed constant.

Import now references the more descriptive MAX_LINEAR_SLOPE_A_PARAM constant which aligns with the broader parameter naming refactoring in the distribution function module.


1105-1106: Updated constant references for linear distribution.

Updated to use the renamed MAX_LINEAR_SLOPE_A_PARAM constant and improved the code formatting with aligned comments for better readability.


1290-1291: Updated constant references in second test case.

Consistently updated the constant usage to MAX_LINEAR_SLOPE_A_PARAM with aligned comments, maintaining consistency throughout the test file.

packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/reward_distribution_type/mod.rs (4)

4-4: Updated import to include MAX_DISTRIBUTION_CYCLES_PARAM.

Import now includes the MAX_DISTRIBUTION_CYCLES_PARAM constant which is used to standardize cycle limits for fixed amount distributions.


157-165: Improved cycle limit handling with clearer parameter names.

The implementation now:

  1. Renames the parameter to the more descriptive max_non_fixed_amount_cycles
  2. Uses a dedicated constant MAX_DISTRIBUTION_CYCLES_PARAM for fixed amount distributions
  3. Provides a clearer distinction between handling of fixed vs. non-fixed amount distributions

This approach centralizes the cycle limit definition and makes the code more maintainable.


175-175: Updated to use the new max_cycles variable.

Modified the BlockBasedMoment calculation to use the newly defined max_cycles variable, which now properly handles fixed vs. non-fixed amount distributions.


182-182: Updated to use the new max_cycles variable.

Modified the TimeBasedMoment calculation to use the newly defined max_cycles variable, ensuring consistent handling across all moment types.

packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/distribution_function/evaluate.rs (1)

44-46: Edge‑case when max - min == u64::MAX

range = max.saturating_sub(*min).saturating_add(1);
If min = 0 and max = u64::MAX, range saturates to u64::MAX, but the
correct range size is 2^64. z % range will then never yield max.
Given the 48‑bit cap this is unlikely, yet consider guarding with validation
or dropping the +1 and accepting half‑open [min,max) semantics.

@QuantumExplorer QuantumExplorer merged commit 5460f4d into v2.0-dev Apr 17, 2025
65 checks passed
@QuantumExplorer QuantumExplorer deleted the v2.0-dev-distributions branch April 17, 2025 23:02
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