fix(dpp): use DIP-0002 version 3 in asset-lock tx fixtures#3621
fix(dpp): use DIP-0002 version 3 in asset-lock tx fixtures#3621QuantumExplorer merged 4 commits intov3.1-devfrom
Conversation
After the rust-dashcore bump in #3617, three round-trip tests in instant_asset_lock_proof::tests started failing with DecodingError("data not consumed entirely when explicitly deserializing"). rust-dashcore PR #726 tightened Transaction decoding: when version < 3 and nTxType != 0 it now decodes as ClassicalWithNonStandardVersionTypeBytes and does not consume any special-transaction payload bytes. The fixture constructed a Transaction with version 0 plus an AssetLockPayload, so encode emitted the payload but decode left those bytes unconsumed. Real DIP-0002 special transactions (AssetLock included) use version 3; the fixture was always malformed and only round-tripped because the old decoder ignored the version field. Set the fixture's version to 3 and update the matching version assertion in test_transaction_accessor. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (3)
📝 WalkthroughWalkthroughFixtures and test helpers for instant asset lock now construct Transactions with version 3; unit tests asserting transaction versions were updated. Additionally, multiple strategy tests adjusted voting contender selection to identifier-based lookup, updated expected root hash, and tweaked two withdrawal balance assertions. ChangesInstant Asset Lock Proof Version Compliance
Strategy Tests Expectations
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Review GateCommit:
|
…ck tx builders Same root cause as the prior commit: rust-dashcore's tightened decoder (PR dashpay/rust-dashcore#726, in the v0.42-dev bump) refuses to consume a special-transaction payload when the outer Transaction's version is < 3 with a non-zero nTxType, so any AssetLock transaction built with version 0 round-trips with trailing payload bytes and fails decode. The earlier commit only fixed the dpp test fixture. Three other places build AssetLock transactions the same broken way and surface in CI as "data not consumed entirely" failures across drive-abci strategy tests (address_funding_from_asset_lock + address_credit_withdrawal flows): - packages/strategy-tests/src/transitions.rs (two builders used by the drive-abci strategy_tests harness for fixed and dynamic-amount asset locks) - packages/rs-dpp/.../validate_asset_lock_transaction_structure/v0/mod.rs (test-only make_asset_lock_transaction helper) Switch each outer Transaction.version from 0 to 3. The inner AssetLockPayload.version (a separate u8 field) is left alone. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bumping the asset-lock test fixtures from version=0 to version=3 changes the asset-lock transaction's txid (and therefore every identity id derived from `OutPoint::new(tx.txid(), output_index)`). That cascades into nine strategy_tests with hardcoded expectations: - Six voting tests asserted contender ordering by relying on a specific identifier sort order. Refactor each to look contenders up by identity id, so the assertion is robust to future txid shifts. Drop a brittle document-byte snapshot that embedded the identity id (and would have needed updating on every fixture change anyway). - Two withdrawal tests hardcoded the post-run total identity balances — the new value differs by ~106k duffs because identity ordering changes the order in which fees are accrued. Update to the recomputed total. - One identity-and-document test hardcoded the GroveDB root hash after inserting 150 identities — update to the recomputed hash. All nine tests pass locally; full strategy_tests suite (90 tests) is green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3621 +/- ##
=========================================
Coverage 88.29% 88.29%
=========================================
Files 2479 2479
Lines 301659 301659
=========================================
+ Hits 266346 266355 +9
+ Misses 35313 35304 -9
🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
I verified the checked-out worktree at 64a45ab083edc23c004dd98f7fafd625b3309248 and reviewed the three commits that make up this PR’s asset-lock fix and follow-up test rebaseline. The changed fixture and helper builders now consistently use outer Transaction.version = 3 for AssetLock special transactions while leaving the payload’s internal version at 0, which matches DIP-0002 and explains the txid and identity-id shifts reflected in the strategy-test updates. I did not find a concrete correctness, consensus, or test-masking issue in the reviewed changes; targeted dpp asset-lock tests passed in this checkout.
Reviewed commit: 64a45ab
…lues QuantumExplorer asked to keep the actual document hex assertions instead of falling back to is_some() (PR #3621 review on voting_tests.rs:594). Restore the two snapshots in run_chain_block_two_state_transitions_ conflicting_unique_index_inserted_same_block_version_8 with the new serialized bytes — same identity-lookup pattern used for the other five voting tests, so the snapshots are anchored to identity1/identity2 rather than first/second contender ordering. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Self Reviewed |
Issue being fixed or feature implemented
After the rust-dashcore bump in #3617 (v0.42-dev, commit
428b60d), three round-trip tests inpackages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rsstarted failing deterministically onv3.1-dev:test_raw_instant_lock_proof_preserves_output_indextest_raw_instant_lock_proof_round_triptest_try_from_value_round_tripAll panicked with
DecodingError("parse failed: data not consumed entirely when explicitly deserializing").What was done?
Root cause. rust-dashcore PR dashpay/rust-dashcore#726 (in commit
d6dd5da) tightenedTransactiondecoding to fix a real mainnet round-trip bug:version >= 3→ resolvenTxTypeviaTransactionType::try_from, consume the payload normally.version < 3andnTxType == 0→Classic, no payload section.version < 3andnTxType != 0→ newClassicalWithNonStandardVersionTypeBytes(raw)variant, no payload section is consumed (treated like Classic on the wire).The fixture in
packages/rs-dpp/src/tests/fixtures/instant_asset_lock_proof_fixture.rswas constructing aTransactionwithversion: 0plusSome(AssetLockPayloadType(...)).Encodablederivestx_type()from the payload (AssetLock, u16 = 8) and writes the payload bytes afterlock_time. Post-#726, decode now hits the newClassicalWithNonStandardVersionTypeBytes(8)branch and never reads those payload bytes — leaving them unconsumed and tripping thedata not consumed entirelyerror.The fixture was always invalid: real DIP-0002 special transactions (including
AssetLock) useversion: 3. The old decoder masked the bug because it didn't gate behavior onversion. The dashcore change is intentional and shouldn't be reverted.Fix. Two-line change to make the fixture's transaction match real DIP-0002 wire format:
packages/rs-dpp/src/tests/fixtures/instant_asset_lock_proof_fixture.rs— setversion: 3(was0) on theAssetLocktransaction.packages/rs-dpp/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs— updatedtest_transaction_accessor's version assertion from0to3to match.No
dppserialization-code change is needed; the fixture was the only thing constructing a malformedversion=0 + special payloadcombination.How Has This Been Tested?
cargo fmt --allclean.Breaking Changes
None. Test-fixture-only change.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit