Skip to content

Fix/448 flash loan voting - #709

Open
Seunfunmi-319509 wants to merge 8 commits into
Iris-IV:mainfrom
Seunfunmi-319509:fix/448-flash-loan-voting
Open

Fix/448 flash loan voting#709
Seunfunmi-319509 wants to merge 8 commits into
Iris-IV:mainfrom
Seunfunmi-319509:fix/448-flash-loan-voting

Conversation

@Seunfunmi-319509

Copy link
Copy Markdown

📌 Description

Provide a clear and concise description of the changes in this PR.

🔗 Related Issues

Use GitHub's auto-close keywords with the # prefix (one issue per line):

Closes #448
Fixes #456
Resolves #789

Multiple issues can be closed by repeating the keyword on separate lines.

🧪 Changes Made

  • Bug fix
  • New feature
  • Refactor
  • Documentation update

✅ Checklist

  • Code compiles successfully
  • Tests added/updated and passing
  • Linting passes (no warnings/errors)
  • Documentation updated (if required)
  • No breaking changes (or clearly documented)

⚠️ Breaking Changes

If this PR introduces breaking changes, describe them here.

📸 Screenshots (if applicable)

Add screenshots to help reviewers understand the changes.

🧩 Additional Notes

Anything else reviewers should know.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Seunfunmi-319509 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

oshowunm added 7 commits July 31, 2026 13:37
…0% threshold gate

Add coverage job to CI using cargo-llvm-cov with LCOV report generation, Codecov upload, and 80% line coverage gate. Fix two test_update_campaign tests that decoded event payload as 2-tuple instead of 4-tuple (old_title, old_description, new_title, new_description).
This test verifies that extend_campaign_deadline correctly validates
the new deadline against the category duration cap when the cap is set
AFTER the campaign was created.

The fix is already present in the codebase (src/campaigns/update.rs:119-130)
which fetches the category cap at extension time and validates the total
duration against it.
…-IV#618

Upstream main merged PRs Iris-IV#616 and Iris-IV#618, which appended a duplicate #[contract] ProofOfHeartContract impl to src/lib.rs and src/admin.rs and added src/campaigns.rs (colliding with the existing src/campaigns/ module directory). That broke the crate build via mod-resolution and duplicate-contract errors. Drop them so the crate builds again.
@Seunfunmi-319509
Seunfunmi-319509 force-pushed the fix/448-flash-loan-voting branch from f042b9c to 7e86394 Compare July 31, 2026 13:22
…and document Iris-IV#448 fix

- Delete src/clients.rs (TypeScript-in-.rs), src/events.ts, src/types.ts, src/test.rs and src/proof_of_heart/ - orphaned, non-compiling leftovers from upstream PRs Iris-IV#616/Iris-IV#618 not wired into any module.
- Add CHANGELOG entry for the count-based voting fix (Iris-IV#448).
- Gitignore /lcov.info coverage output generated by the CI coverage job.
- test_snapshots/ is kept: it is tracked upstream and deleting it would blow past the GitHub API 20k-line PR-diff limit used by pr-collector.yml.
@Seunfunmi-319509
Seunfunmi-319509 force-pushed the fix/448-flash-loan-voting branch from 7e86394 to b501624 Compare July 31, 2026 13:31
@Seunfunmi-319509

Copy link
Copy Markdown
Author

kindly review

@davidmaronio

Copy link
Copy Markdown
Contributor

this is the most complete take on the flash-loan voting fix (#448) among the open PRs: cast_vote drops the balance-weight accumulation entirely, verify_with_votes computes approval bps from vote counts in u64 (src/voting.rs:838-842), the weight storage helpers are kept but marked #[expect(dead_code)] for ledger compatibility, and CHANGELOG.md plus EVENT_PAYLOADS.md were updated. the proptest rework to count-based helpers is thorough too.

a few asks:

  1. src/voting.rs:813 - the campaign_vote_cast event payload shrinks from (approve, balance, weight) to (approve, balance). that is a breaking change for any indexer decoding a 3-tuple. the docs cover it, but consider keeping a 3-tuple with weight fixed at 1 (like fix: use 1-address-1-vote model to prevent flash-loan voting (#469) #689 does) so existing decoders keep working, or call the break out loudly in the PR description for downstream consumers.

  2. src/tests/test_regressions.rs:276 - the [BUG] cast_vote accumulates token weights with unchecked addition — theoretical i128 overflow #354 overflow regression test was deleted outright. fix: use 1-address-1-vote model to prevent flash-loan voting (#469) #689 instead adapts it to assert a vote still succeeds with ApproveWeight near i128::MAX, which preserves the regression coverage; porting that version here would be better than deletion.

  3. src/tests/test_voting.rs:616-621 - widening the half-approval tolerance to 3333..=5000 makes the property nearly vacuous. with total >= 2 and integer division, half/total bps is bounded much tighter; something like 4990..=5000 with a minimum total of 1000, or an exact expected value computed in the test, keeps the property meaningful.

  4. the deletions of src/clients.rs, src/events.ts, src/types.ts, src/test.rs and the old placeholder rust files duplicate cleanup already on main and should vanish after rebase.

note #689 (issue #469) fixes the same attack with a smaller diff that keeps the weight columns at +1 per vote; maintainers should pick one, and this one is the cleaner end state. this branch is in conflict with main, so please resolve conflicts and rebase, then it is good from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants