Skip to content

fix(drive-abci): a transition whose version is not active is not a decode failure - #4993

Merged
QuantumExplorer merged 2 commits into
v5.0-devfrom
fix/not-active-is-not-a-decode-failure
Oct 20, 2026
Merged

QuantumExplorer merged 2 commits into
v5.0-devfrom
fix/not-active-is-not-a-decode-failure

Conversation

@shumkov

@shumkov shumkov commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

A state transition whose version is not active at the current protocol version decodes fine — its
bytes parsed. What failed is a version check. It was falling through to the catch-all that reports a
protocol error as FailedToDecode, so a client error was reported as if the payload were malformed.

That classification decides where it goes next. A decode failure makes CheckTx return Err, and the
handler logs the whole transition, hex-encoded, at ERROR on every attempt — uncharged and
unauthenticated. For a transition carrying an Orchard proof that is roughly twice its size per
submission.

The shape is not new: a DataContractCreate::V1 below protocol version 14 has always hit it. What is
new is the direction. Every narrowing of an active_version_range so far has been forward-inactive
— a transition only updated clients build, so nobody is sending one yet. The first backward-inactive
case is arriving, and at its activation every client still retrying the old version reaches this path
at once. The block-side log is self-limiting, since including such a transition costs the proposer a
rejected block; CheckTx is not.

What was done?

One arm in decode_raw_state_transitions_v0 mapping StateTransitionIsNotActiveError to
InvalidEncoding, carrying the existing StateTransitionNotActiveError consensus error (code 10603)
built from the transition type, the current protocol version and the start of its active range.

The arm matches the variant, not ProtocolError::StateTransitionError as a family. The sibling
InvalidStateTransitionError carries its own Vec<ConsensusError> and is a separate decision; a
family-wide arm would have reclassified it silently.

With the arm, CheckTx returns Ok with the consensus error's own code and info, so the client gets a
coded rejection and the node logs nothing at ERROR.

How Has This Been Tested?

A new unit test builds a BatchTransition::V1 (active only from protocol version 9), decodes it at
protocol version 1, and asserts InvalidEncoding carrying StateTransitionNotActiveError.

Green with the arm, red without it — the test fails on "a transition whose version is not active
decoded fine; reporting it as a decode failure sends it down the internal-error path, which logs the
whole transition" — and green again once restored. cargo clippy -p drive-abci --all-features --all-targets and cargo fmt --check --all are clean.

In-place changes to shipped generations

This edits decode_raw_state_transitions generation 0, which every shipped table selects, so
consensus equivalence is established rather than assumed. Three steps:

  • Both UnpaidConsensusError and InternalError map to TxAction::Removed in prepare_proposal.
  • A removed transition's result is never pushed to tx_results, which is what accompanies the app
    hash in the response — there is an explicit if tx_action != TxAction::Removed before the push.
  • Neither class can have written state, because decoding precedes every access to the drive.

The proposal-level decision is unchanged too: failed_count and invalid_unpaid_count feed one sum
in process_proposal, which rejects the proposal on either.

Breaking Changes

None to consensus. Clients submitting a transition whose version is not yet active now receive a
coded consensus rejection instead of an internal error, which is the intended improvement.

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
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Bug Fixes
    • Inactive state transitions now produce a more specific consensus error that includes the transition type and relevant protocol version details. Other decoding errors continue to be reported as before.

PR Hygiene · 32b49b0

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build failed
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

…code failure

Its bytes parsed. What failed is a version check, which makes it a client error owed a
coded answer, and until now it fell through to the catch-all that reports a protocol error
as `FailedToDecode`.

The cost is in what that classification leads to. A decode failure returns `Err` from
CheckTx, and the handler logs the whole transition, hex-encoded, at ERROR on every
attempt — uncharged and unauthenticated. For a transition carrying an Orchard proof that
is roughly twice the transition's size per submission.

The shape is not new; a `DataContractCreate::V1` below protocol version 14 has always hit
it. What is new is the direction. Every narrowing of an `active_version_range` so far has
been forward-inactive: a transition only updated clients build, so nobody is sending one
yet. `ShieldFromAssetLock` version 0 refused at protocol version 14 is the first
backward-inactive case, and at activation every wallet still retrying the old version
arrives here at once. The block-side log is self-limiting, since including such a
transition costs the proposer a rejected block; CheckTx is not.

The arm matches the variant rather than `ProtocolError::StateTransitionError` as a family.
The sibling `InvalidStateTransitionError` carries its own `Vec<ConsensusError>` and is a
separate decision.

This edits a generation every shipped table selects, so consensus equivalence is the thing
to establish rather than assume. It holds in three steps. Both `UnpaidConsensusError` and
`InternalError` map to `TxAction::Removed` in `prepare_proposal`. A removed transition's
result is never pushed to `tx_results`, which is what accompanies the app hash in the
response. And neither class can have written state, because decoding precedes every access
to the drive. The proposal-level decision is also unchanged: `failed_count` and
`invalid_unpaid_count` feed one sum in `process_proposal`, which rejects on either.

Test would have caught this: with the arm removed the new test fails on "a transition whose
version is not active decoded fine; reporting it as a decode failure sends it down the
internal-error path" (green with, red without, green again after restoring).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 25, 2026
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 000e04f6-2d37-440d-8c52-824dd4b1322e
📥 Commits

Reviewing files that changed from the base of the PR and between 32b49b0 and f40d97c.

📒 Files selected for processing: 1
  • packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs
+---------------------------------------------+
| HD, 4K, 8K...I see bugs in all resolutions. |
+---------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: dashpay/platform/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 497adcc0-4b59-4098-86cc-ff7c66e2967d

📥 Commits

Reviewing files that changed from the base of the PR and between 92857f7 and 32b49b0.

📒 Files selected for processing (1)
  • packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The state transition decoder now maps inactive-transition protocol errors to InvalidEncoding with a StateTransitionNotActiveError. A test checks this result for a batch transition decoded under protocol version 1.

Changes: Inactive transition error handling

Layer / File(s) Summary
Map inactive transition errors
packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs
The decoder reports the transition type, current protocol version, and active-range start in a StateTransitionNotActiveError. Other protocol errors still produce FailedToDecode. A test checks the classification for an inactive batch transition.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: quantumexplorer

Merge Risk: ⚪ Minimal · up to 32b49

The inactive-transition rejection is classified as intended. No actionable issue remains before merge.

Security architecture risk: 🔵 Low · up to 32b49

Inactive transitions remain rejected, but now receive a coded rejection instead of taking a path that logs the full submission as an internal error. No new acceptance path was found. The effect of the version detail returned to clients during backward deactivation remains uncertain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The affected exposure is submissions reaching the public CheckTx handler with a transition version inactive at the node's current protocol version. The changed branch rejects those submissions rather than expanding access to state-changing processing.

Security Findings and Attack Paths

  • inferred — The former fallback could send an inactive-version submission to the full-transaction ERROR log. The new branch routes that specific error to a coded rejection, reducing this logging exposure; other propagated errors can still reach the logging branch.

Trust Boundaries and Controls

  • observed — The decoder enforces the configured maximum transition size before deserialization. Both inactive-version classifications terminate CheckTx before later validation and fee or proof work; the change is in rejection classification, not authorization to execute.

Hardening Proposals

  • proposed — Before a backward-deactivation rollout, verify the coded response for an expired range and whether clients need an explicit retired-version indication rather than only the range start.
🚥 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 describes the main change: classifying transitions with inactive versions as a non-decode-failure outcome.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 25, 2026
@thepastaclaw

thepastaclaw commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 32b49b0) · triage: low

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

The inactive-version reclassification correctly returns a coded client rejection while preserving proposal removal, proposal rejection, fees, and committed state. No blocking issues were verified; one targeted suggestion remains to assert the newly mapped error metadata in the regression test. Verification was source-based at the exact requested head; diff whitespace checks passed, but tests were not independently rerun.

🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: architecture-layering); reviewer 3: glm-5.3-flash (agent: phase1-reviewer, role: platform-versioning); reviewer 4: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 5: glm-5.3-flash (agent: phase1-reviewer, role: security-auditor); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 10: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: low by gpt-6-astra (effort low) — The diff adds one narrowly matched error-classification arm in decode_raw_state_transitions_v0 and a regression test, changing client rejection and logging behavior without introducing intricate logic or changing consensus acceptance.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — architecture-layering (completed, effort high); agent phase1-reviewer, glm-5.3-flash — platform-versioning (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer, glm-5.3-flash — security-auditor (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 40% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 35% left, 5h 0% left)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort medium); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6-astra — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6-astra — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/decode_raw_state_transitions/v0/mod.rs:244-251: Assert the client-visible metadata in the inactive-version regression test
  The test checks the new rejection classification but leaves the error metadata unchecked. The new arm maps two identically typed protocol-version values into the client-visible error, so swapping current and required versions or using the range end would still pass this test. For this fixture, assert current_protocol_version() == 1, required_protocol_version() == 9, and state_transition_type() == "DocumentsBatch([])" to cover both the classification and the payload introduced by this change.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Sep 25, 2026
@QuantumExplorer
QuantumExplorer merged commit 5303dd3 into v5.0-dev Oct 20, 2026
9 of 10 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/not-active-is-not-a-decode-failure branch October 20, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants