fix(#442): batch verify_campaigns now returns (verified_ids, failed_ids) - #720
fix(#442): batch verify_campaigns now returns (verified_ids, failed_ids)#720dedukpe wants to merge 4 commits into
Conversation
… prevent overflow Replace all unchecked i128 additions in contributions.rs and revenue.rs with checked_add(...).ok_or(Error::Overflow)? to prevent silent wrapping/overflow on high-balance tokens. Fixes: - contributions.rs: check_contribution_caps cap comparison - contributions.rs: update_contribution_accounting (5 locations): amount_raised, effective_amount_raised, contribution, lifetime, total_raised - contributions.rs: contribute() personal cap check - contributions.rs: batch_contribute() personal cap check - revenue.rs: deposit_revenue pool accumulation - revenue.rs: claim_revenue claimed + distributed accumulation - revenue.rs: claim_creator_revenue claimed accumulation Also changes update_contribution_accounting return type from () to Result<(), Error> so overflow errors propagate to callers. Note: verify_with_votes in voting.rs already uses checked_add for total_votes and total_weight (fixed in prior commit 0876e60).
fix(Iris-IV#445): replace unchecked i128 addition with checked_add to prevent overflow
|
thanks for the work here, the direction is good: returning that said, #606 implements the same failed-ids return for #442, is already mergeable (clean state, passing checks) and was opened earlier, so this one is redundant. a few notes in case anything gets salvaged:
since #606 covers #442 and is ready to merge, i would close this one as a duplicate. happy to see the batch-truncation observation filed as a follow-up issue against #606's version. |
Summary
Fixes #442 — the batch admin
verify_campaignsfunction previously captured onlyfirst_errorand continued processing, then returnedErr(first_error)if any campaign failed. This made it impossible for callers to distinguish partial success from total failure.Changes
Contract (
src/lib.rs)Result<u32, Error>toResult<(Vec<u32>, Vec<u32>), Error>(verified_ids, failed_ids)so callers can inspect exactly which campaigns succeeded and which failedErrand abort the entire batchcampaigns_bulk_verifiednow emits(verified_count, failed_count, total)instead of(verified_count, total)totalto reportbatch_size(capped at 50) instead of the rawcampaign_ids.len()for accuracyTests
test_verify_campaigns_extends_voting_state_ttl— destructures tuple instead of raw counttest_verify_campaigns_partial_failure_returns_err→ renamed totest_verify_campaigns_partial_failure_returns_ids— now asserts the specific verified and failed IDstest_verify_campaigns_extends_ttl_on_failure— destructures tuple for both first and second calls, asserts failed_ids contains the already-verified campaignDocumentation
EVENT_PAYLOADS.md— updatedcampaigns_bulk_verifiedpayload to(verified_count, failed_count, total)Breaking Change
This is a contract API breaking change — the return type of
verify_campaignschanges fromResult<u32, Error>toResult<(Vec<u32>, Vec<u32>), Error>. All clients and indexers that call this function will need to be updated.Linked Issue