fix(events): refuse submit and withdraw after winner selection and track updated_at - #158
Conversation
…ion exists (closes boundlessfi#131)
| pub applicant: Address, | ||
| pub content_uri: String, | ||
| pub submitted_at: u64, | ||
| pub updated_at: u64, |
There was a problem hiding this comment.
Contract Lifecycle & State: Persistent state decode breakage in Submission
Submission is a #[contracttype] persisted in env.storage().persistent(); adding the new updated_at field changes its serialized layout, so any pre-upgrade stored Submission values may fail to deserialize after upgrade, potentially trapping on reads (e.g., storage::get_submission) and breaking submit/withdraw flows for existing applicants.
Add an explicit storage migration/versioning strategy for existing Submission entries (e.g., store updated_at separately, or make it Option<u64> and treat None as submitted_at, or migrate all stored submissions during an upgrade/init path) before deploying this change to an existing network.
Fix with MCP
Almanax found a vulnerability. Can you take a look and fix it?
Finding ID: 92a825b0-4b35-4916-82d3-ba8e39854fbc
Actions
- Reply
/almanax ask <question>to ask a follow-up question. - Reply
/almanax dismiss [<reason>]and it won't appear again in future scans. - Reply
/almanax resolve [<reason>]to mark the finding as resolved. - Reply
/almanax severity <level> [<reason>]to override the severity.
|
/almanax resolve Made |

Summary of Changes
Closes #131
Reference:
docs/threat-model.mdv1.0, Tamp.17 (Priority 3).Problem
Single-release events remain
Activeuntil all prizes are claimed. Previously, an applicant could modify or withdraw their submission afterWinnersSelectedlanded. Additionally,submitted_atwas preserved across resubmissions without recording when the slot was last modified.Solution
contracts/events/src/event_ops.rs):submitandwithdraw_submission, check if winners have been recorded or prize claim expiry has been established (storage::winner_count(env, event_id) > 0 || storage::get_prize_claim_expiry(env, event_id).is_some()).Error::WinnersAlreadySelectedif attempted.contracts/events/src/types.rs):pub updated_at: u64toSubmissionstruct.contracts/events/src/tests/hackathon_pillar.rs):submit_and_withdraw_after_selection_rejectedtesting post-selection immutability.updated_attimestamps inresubmit_keeps_original_timestamp_and_updates_uri.