Repository navigation
fix(drive-abci): a transition whose version is not active is not a decode failure - #4993
Conversation
…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]>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
| 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.
Comment @coderabbitai help to get the list of available commands.
|
✅ Final review complete — no blockers (commit 32b49b0) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
lowbygpt-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); agentphase1-reviewer,glm-5.3-flash— architecture-layering (completed, effort high); agentphase1-reviewer,glm-5.3-flash— platform-versioning (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer,glm-5.3-flash— security-auditor (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 40% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 35% left, 5h 0% left) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6-astra— platform-versioning (completed, effort medium); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort medium); agentphase2-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.
|
Bots are done — your move: post |
Co-authored-by: Lil Claw <[email protected]>
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 thehandler 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::V1below protocol version 14 has always hit it. What isnew is the direction. Every narrowing of an
active_version_rangeso 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_v0mappingStateTransitionIsNotActiveErrortoInvalidEncoding, carrying the existingStateTransitionNotActiveErrorconsensus 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::StateTransitionErroras a family. The siblingInvalidStateTransitionErrorcarries its ownVec<ConsensusError>and is a separate decision; afamily-wide arm would have reclassified it silently.
With the arm, CheckTx returns
Okwith the consensus error's own code and info, so the client gets acoded 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 atprotocol version 1, and asserts
InvalidEncodingcarryingStateTransitionNotActiveError.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-targetsandcargo fmt --check --allare clean.In-place changes to shipped generations
This edits
decode_raw_state_transitionsgeneration 0, which every shipped table selects, soconsensus equivalence is established rather than assumed. Three steps:
UnpaidConsensusErrorandInternalErrormap toTxAction::Removedinprepare_proposal.tx_results, which is what accompanies the apphash in the response — there is an explicit
if tx_action != TxAction::Removedbefore the push.The proposal-level decision is unchanged too:
failed_countandinvalid_unpaid_countfeed one sumin
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:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestSummary by CodeRabbit
PR Hygiene ·
32b49b0/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.