Skip to content

Add reentrancy-safe state updates before token transfers in slash_on_miss and claim in accountability_vault #352

@1nonlypiece

Description

@1nonlypiece

Add reentrancy-safe state updates before token transfers in slash_on_miss and claim in accountability_vault

Description

In contracts/accountability_vault/src/lib.rs, slash_on_miss and claim transfer the SEP-41 token before persisting the updated Vault status. Reorder to a checks-effects-interactions pattern so the vault is marked Failed/Completed and staked zeroed in storage before the external token::Client::transfer call. Add tests in contracts/accountability_vault/src/test.rs proving the terminal state is committed even under a failing transfer.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Apply checks-effects-interactions in slash_on_miss and claim in contracts/accountability_vault/src/lib.rs
  • Zero staked and set status before token::Client::transfer
  • Add a re-entrancy/ordering test in contracts/accountability_vault/src/test.rs
  • Document the invariant in contracts/README.md

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/cei-ordering
  • Implement changes
    • Modify contracts/accountability_vault/src/lib.rs
    • Add test cases to contracts/accountability_vault/src/test.rs
    • Update contracts/README.md
    • Add inline safety comments
  • Test and commit
    • Run tests, cover edge cases
    • Include test output and notes

Example commit message

feat: apply checks-effects-interactions to vault payouts

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions