Skip to content

test(dpp): pin V0 config parser consensus-frozen quirk#3514

Merged
QuantumExplorer merged 3 commits into
v3.1-devfrom
claude/heuristic-williams-65e2b9
Apr 23, 2026
Merged

test(dpp): pin V0 config parser consensus-frozen quirk#3514
QuantumExplorer merged 3 commits into
v3.1-devfrom
claude/heuristic-williams-65e2b9

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 21, 2026

Issue being fixed or feature implemented

While investigating packages/rs-dpp/src/data_contract/config/v0/mod.rs:177-185, I noticed that get_contract_configuration_properties_v0 reads the decryption bounded-key field from REQUIRES_IDENTITY_ENCRYPTION_BOUNDED_KEY (not the matching DECRYPTION constant). V1 at packages/rs-dpp/src/data_contract/config/v1/mod.rs:140 reads from the correct key.

It looks like a copy-paste typo from #1358 (2023-09), but it is part of V0 protocol behavior and must not be changed: altering the V0 parser's output would risk a fork on any node replaying historical V0 contracts, even if the function appears dead today.

So this PR does not fix the bug. Instead it locks the existing V0 behavior in place so nobody accidentally "fixes" it later.

What was done?

  • Added a CONSENSUS-FROZEN BUG comment directly at the offending line in V0, pointing at V1 as the correct reference.
  • Added a get_contract_configuration_properties_v0_consensus_lock test module asserting the current V0 behavior:
    • Setting only the ENCRYPTION property populates both encryption and decryption fields (the quirk).
    • Setting only the DECRYPTION property is ignored entirely by V0.
    • When both are set, the ENCRYPTION value wins for both fields; DECRYPTION is ignored.
    • When neither is set, both fields stay None.

No functional code change — V0 parsing behavior is unchanged. V1 is untouched.

Commit history

This branch has two commits on it. The first commit (fix(dpp): ...) was an incorrect attempt to patch the typo before I realized the consensus implications. The second commit (test(dpp): ...) reverts that change and replaces the regression tests with lock-in tests. Both kept for transparency; happy to squash before merge.

How Has This Been Tested?

cargo test -p dpp -- data_contract::config
# 34 passed; 0 failed (4 new lock-in tests)
cargo fmt -p dpp

Breaking Changes

None. Behavior of the V0 parser is preserved exactly.

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

  • Tests

    • Added unit tests for contract configuration property behavior validation.
  • Documentation

    • Added clarifying in-code comments for configuration parsing behavior.

`DataContractConfigV0::get_contract_configuration_properties_v0` read
both `requires_identity_encryption_bounded_key` and
`requires_identity_decryption_bounded_key` from the same map key
(`REQUIRES_IDENTITY_ENCRYPTION_BOUNDED_KEY`), so V0 configs parsed from
a property map could never set the two fields to different values. V1's
parser is correct; V0 had a copy-paste typo dating back to the initial
contract bounds feature in #1358.

The V0 dispatcher is currently dead (no active callers; parent is
marked `TODO: Remove, it's not using`), so the fix cannot alter any
already-ingested contract state or consensus hashes. Added regression
tests covering distinct values, absence, and decryption-only.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 30 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 30 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c00db9a-aa94-4449-ac14-d4f3cee5bad8

📥 Commits

Reviewing files that changed from the base of the PR and between 13da272 and 9af6efd.

📒 Files selected for processing (1)
  • packages/rs-dpp/src/data_contract/config/mod.rs
📝 Walkthrough

Walkthrough

Changes add unit tests for V0 data contract configuration properties parsing and document the intentional behavior where decryption-bounded-key values are sourced from the encryption constant in the V0 parser, ensuring historical behavior consistency.

Changes

Cohort / File(s) Summary
V0 Configuration Testing
packages/rs-dpp/src/data_contract/config/mod.rs
Added get_contract_configuration_properties_v0_consensus_lock test module with four unit tests verifying V0 parser behavior for identity encryption and decryption bounded-key properties, including edge cases where decryption key reads from encryption constant.
V0 Configuration Documentation
packages/rs-dpp/src/data_contract/config/v0/mod.rs
Added inline comment documenting that V0 parser intentionally reads decryption-bounded-key field from REQUIRES_IDENTITY_ENCRYPTION_BOUNDED_KEY constant rather than the decryption equivalent.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A quirk of V0, now locked in place,
Tests march forth at a rabbity pace,
Comments explain the encryption sleight,
Where decryption borrows—oh, what a sight!
History preserved, both wrong and right. 🔐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: pinning/locking in an existing V0 parser quirk through testing rather than fixing it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/heuristic-williams-65e2b9

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.

@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 21, 2026
Reverts the functional change from the prior commit on this branch.
`DataContractConfigV0::get_contract_configuration_properties_v0` reads
the decryption bounded-key field from the ENCRYPTION property key. This
is not a safe-to-patch typo: its behavior is part of V0 protocol output
and cannot be changed without risking a chain fork on replay. V1's
parser is already correct and handles the DECRYPTION key distinctly.

- Restore the original V0 lookup.
- Add a `CONSENSUS-FROZEN BUG` comment at the site so the quirk is not
  re-"fixed" by a future refactor.
- Replace the earlier regression tests with a lock-in test module that
  asserts the observable V0 behavior:
    * encryption property populates BOTH fields,
    * decryption property is ignored entirely,
    * encryption wins when both are set,
    * neither set leaves both `None`.
@QuantumExplorer QuantumExplorer changed the title fix(dpp): read decryption bounded-key from its own property in V0 parser test(dpp): pin V0 config parser consensus-frozen quirk Apr 22, 2026
@QuantumExplorer QuantumExplorer marked this pull request as ready for review April 22, 2026 09:37
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 22, 2026

Review Gate

Commit: 9af6efdc

  • Debounce: 29m ago (need 30m)

  • CI checks: checks still running (1 pending)

  • CodeRabbit review: comment found

  • Off-peak hours: off-peak (11:39 PM PT Wednesday)

  • Run review now (check to override)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 91.30435% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.30%. Comparing base (e0867b5) to head (9af6efd).
⚠️ Report is 5 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
packages/rs-dpp/src/data_contract/config/mod.rs 91.30% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3514      +/-   ##
============================================
+ Coverage     87.29%   87.30%   +0.01%     
============================================
  Files          2476     2476              
  Lines        285752   285766      +14     
============================================
+ Hits         249454   249501      +47     
+ Misses        36298    36265      -33     
Components Coverage Δ
dpp 86.31% <91.30%> (+0.05%) ⬆️
drive 86.61% <ø> (-0.01%) ⬇️
drive-abci 89.32% <ø> (+<0.01%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.10% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 55.66% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Conflicts:
#	packages/rs-dpp/src/data_contract/config/mod.rs
@QuantumExplorer
Copy link
Copy Markdown
Member Author

Reviewed AI based PR

@QuantumExplorer QuantumExplorer merged commit af35dbd into v3.1-dev Apr 23, 2026
38 checks passed
@QuantumExplorer QuantumExplorer deleted the claude/heuristic-williams-65e2b9 branch April 23, 2026 06:49
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.

2 participants