Repository navigation
fix(dpp): preserve wasm class mismatch diagnostics - #5428
Conversation
Existing action-fee tests caught the regression in CI: ✖ before fix (7 public and 1 private failures), ✔ after fix (9 public and 3 private passes). Restore expected/provided errors from static class metadata before the existing module, prototype and pointer checks.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
✅ Final review complete — no blockers (commit b85ff37) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The change correctly restores class-mismatch diagnostics without altering validation order or accepted/rejected inputs. One diagnostic path reports an empty provided class for ordinary objects, and the newly duplicated formatter creates minor maintenance drift; neither issue affects safety or consensus behavior.
🟡 1 suggestion(s) | 💬 1 nitpick(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: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, well-contained WASM validation change that only restores diagnostic formatting while preserving the existing rejection order and behavior, with no consensus-critical or funds-related impact. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 94% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 14% left, 5h 100% left) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (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/wasm-dpp2/src/utils.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/utils.rs:164-170: Class-mismatch diagnostics omit the actual constructor name when metadata is absent
When the supplied value is a plain object, its constructor is typically `Object` and has no `__struct` property. The new fallback therefore formats the error as `Expected DocumentActionFeeAgreement, provided .`, omitting the actual constructor name. This does not change validation, but it falls short of the established diagnostic that this PR is restoring; use the already-validated constructor's `name` property as the fallback when `__struct` is absent.
- [NITPICK] packages/wasm-dpp2/src/utils.rs:166-170: Class-mismatch formatting is duplicated in the same function
The same error format string now appears in both the new static `__struct` mismatch branch and the existing instance `__type` mismatch branch. Extracting a small local `class_mismatch` formatter would keep these closely related diagnostics synchronized if the wording or fallback behavior changes again.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Legacy wasm-dpp conversion still dereferences freed or unvalidated pointers — The legacy
packages/wasm-dpp/src/utils.rsconversion path remains outside this PR and still reads__wbg_ptrafter only checking the prototype constructor name. It has no module-brand, prototype-membership, or zero-pointer validation, so a freed object can reachref_from_abi(0). Track this separately rather than expanding the current diagnostic-only fix.- Follow-up: Create a separate issue to harden or deprecate the legacy wasm-dpp conversion path.
|
Bots are done — your move: post |
Basic explanation
What this does: Restore the established expected/actual class diagnostic when a caller supplies an invalid WASM class argument.
Value: SDK callers keep informative validation errors, and seven existing action-fee regression cases pass again.
Risks: Low: only wrong-class diagnostic text changes. Class, module, prototype and pointer rejection conditions keep their ordering; consensus behavior is unaffected.
Issue being fixed or feature implemented
The common instance guard introduced in #5405 correctly refused invalid
actionFeeAgreementvalues but replaced their established diagnostic, causing seven existing SDK tests to fail. This follow-up restores those messages.What was done?
In
wasm_ptr_of_js_val, read the constructor's static__structonce and use the existing class-mismatch formatter when it is absent or different. The subsequent module/prototype checks still run before instance getters and pointer access. Assertions are unchanged.How Has This Been Tested?
-D warnings, explicit Rust formatting and whitespace checks pass.Compressed/browser packaging is left to resulting-head CI. No new or modified test assertions are needed: the existing tests reproduce the regression.
Breaking Changes
None.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
Summary by CodeRabbit
PR Hygiene ·
b85ff37/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.