Skip to content

smartcontract: use validate_program_account! macro across processors#3436

Open
elitegreg wants to merge 6 commits intomainfrom
gm/validate-program-account-macro
Open

smartcontract: use validate_program_account! macro across processors#3436
elitegreg wants to merge 6 commits intomainfrom
gm/validate-program-account-macro

Conversation

@elitegreg
Copy link
Copy Markdown
Contributor

Summary

  • Replace manual assert_eq!/assert! account validation with the validate_program_account! macro across 19 processor files in doublezero-serviceability
  • Fix bug in link/resume.rs where link_account.is_writable was never validated despite the account being written to via try_acc_write
  • Add consistent data_is_empty checks (via the macro) to accounts that previously lacked them

Details

The validate_program_account! macro consolidates four common checks (owner, non-empty, writable, PDA match) into a single call. Many processors were doing these checks manually and inconsistently. This PR standardizes them while preserving custom error handling where needed (e.g., AccessPassNotFound for empty accesspass accounts).

Files modified

  • link/: accept, activate, closeaccount, delete, reject, resume, sethealth, suspend, update
  • user/: activate, ban, check_access_pass, closeaccount, delete, reject, requestban, update
  • device/: delete
  • multicastgroup/: subscribe

Bug fix

link/resume.rs writes to link_account (line 83) but never checked is_writable. All other link processors that write validate writability. The macro now enforces this.

Testing Verification

  • make rust-fmt passes
  • make rust-lint passes (clippy clean)
  • cargo test -p doublezero-serviceability — all tests pass

@elitegreg elitegreg force-pushed the gm/validate-program-account-macro branch 2 times, most recently from 5eb914d to b4a1ebd Compare April 3, 2026 15:19
@elitegreg elitegreg marked this pull request as ready for review April 3, 2026 15:31
@elitegreg elitegreg enabled auto-merge (squash) April 3, 2026 15:37
@elitegreg elitegreg requested a review from vihu April 3, 2026 15:55
Replace manual assert_eq!/assert! account validation checks with the
validate_program_account! macro in 19 processor files. This adds
consistent data_is_empty checks that were previously missing and fixes
a bug in link/resume.rs where is_writable was not validated despite
the account being written to.
@elitegreg elitegreg force-pushed the gm/validate-program-account-macro branch from a0561b9 to 63cfed0 Compare April 3, 2026 20:12
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