Skip to content

fix(contract): report insufficient token pool on payout - #148

Open
nasirudeenbadirudeen87-cloud wants to merge 6 commits into
DocForum:mainfrom
nasirudeenbadirudeen87-cloud:fix/issue-38
Open

nasirudeenbadirudeen87-cloud wants to merge 6 commits into
DocForum:mainfrom
nasirudeenbadirudeen87-cloud:fix/issue-38

Conversation

@nasirudeenbadirudeen87-cloud

@nasirudeenbadirudeen87-cloud nasirudeenbadirudeen87-cloud commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

  • Check the token balance before both release and refund, returning PoolInsufficient (error 21) if the requested payout is not backed.
  • Add a clawback-token regression test and document the remaining shared-pool risk.
  • Each payout adds one read-only token balance call. Exact resource deltas have not been measured in this change.

Validation: git diff --check passed. Tests/build were not run, per contributor workflow.

Closes #38

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@nasirudeenbadirudeen87-cloud 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

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@nasirudeenbadirudeen87-cloud

This PR has merge conflicts with main, which has moved on since this branch was created. Please rebase onto the latest main (or merge main into your branch), resolve the conflicts, and push. CI will then re-run, and the PR can be merged once it's conflict-free, CI is green and it's been reviewed. Thanks!

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@nasirudeenbadirudeen87-cloud Thanks for the PR. It can't be merged yet. To unblock it:

Merge conflicts: this branch conflicts with main. Please rebase onto the latest main (git fetch upstream && git rebase upstream/main), resolve the conflicts (often ROADMAP.md, ARCHITECTURE*.md or prisma/schema.prisma), and force-push.

Push to this same branch and CI will re-run. Once it's green and conflict-free, it'll be reviewed for merge.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 20, 2026
@github-actions github-actions Bot added needs-rebase Has merge conflicts with main; the author needs to rebase and removed needs-rebase Has merge conflicts with main; the author needs to rebase labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown

@nasirudeenbadirudeen87-cloud This PR now has merge conflicts with main, most likely because #149 ([Phase E5] Add opt-in payee acceptance before release) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-escrow.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared files like ROADMAP.md and ARCHITECTURE*.md. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 25, 2026
Ruruxy and others added 2 commits October 26, 2026 09:49
Upstream now uses discriminant 21 for InvalidRefundTo, so PoolInsufficient
moves to 35 (next free code); the solvency check sits after the acceptance
gate in settle(). Pass the new refund_to argument in the clawback test,
regenerate the SDK bindings with the pinned Stellar CLI, and update the
docs/snapshot to the new code.

@afeezorobsco-cyber afeezorobsco-cyber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweep: malware scan clean, CI green.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 27, 2026
@github-actions

Copy link
Copy Markdown

@nasirudeenbadirudeen87-cloud This PR now has merge conflicts with main, most likely because #241 (feat(sdk): network presets with explicit mainnet opt-in guard) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-escrow.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@zeemscript

Copy link
Copy Markdown

@afeezorobsco-cyber The current head passes the reported contract, generated-bindings, resource-baseline, fuzz, and malware checks, but GitHub still reports a merge conflict against current main in the contract and shared docs. The current main branch now includes liability accounting, so the payout solvency behavior needs to be reconciled with that model before I can safely update this branch.

@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 27, 2026
@nasirudeenbadirudeen87-cloud

Copy link
Copy Markdown
Author

@afeezorobsco-cyber I merged current main and updated the payout solvency guard to compare each token balance with its aggregate funded liability. The full contract suite, focused clawback regression, release WASM build, generated-binding check, and resource baseline pass locally. PR #148 is mergeable and its refreshed malware scan passed. Please review the contract version ordering with other pending escrow changes and review the audit delta.

@github-actions github-actions Bot added the needs-rebase Has merge conflicts with main; the author needs to rebase label Oct 28, 2026
@github-actions

Copy link
Copy Markdown

@nasirudeenbadirudeen87-cloud This PR now has merge conflicts with main, most likely because #154 (fix(contract): keep failed releases recoverable) was just merged, so it can't be merged until it's rebased:

git fetch upstream            # upstream = https://github.com/DocForum/docforum-escrow.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-lease

The usual culprits are shared docs like ROADMAP.md and ARCHITECTURE*.md. If the conflict is in the ROADMAP.md changelog, move your entry into a new file under changelog.d/ (see changelog.d/README.md) rather than resolving it in place, so it can't conflict again. CI re-runs when you push, and the needs-rebase label is removed automatically once the conflicts are resolved.

Automated message. It won't repeat unless the PR conflicts again after your next push.

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

@nasirudeenbadirudeen87-cloud Heads-up: #268 just changed how contract PRs work in this repo. Your PR changes contracts/escrow/src/lib.rs, so CI's new "Contract changes use a fragment, not a version bump" step will fail it until you make these changes (details in contract-changes.d/README.md):

  1. Revert your CONTRACT_VERSION change. This branch sets 2.6.0. Leave the line exactly as it is on main (currently 2.3.0). A maintainer bumps it once per batch now, so nobody picks the same "next" version any more.

  2. Add a fragment, e.g. contract-changes.d/38-fix-contract-report-insufficient-token-p.md:

    bump: minor
    ---
    Issue #38: one-paragraph summary of the contract change.

    Use patch for a behaviour fix with no interface change, minor for new entry points, arguments, events or errors, and major for breaking changes.

  3. Switch your new Error codes to provisional ones (issue number × 100 + n). This branch adds PoolInsufficient = 38; use PoolInsufficient = 3800. The fold assigns the final numbers. Don't renumber existing codes.

This should also make your next merge from main much easier: the version line was the one thing every contract PR conflicted on.

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

Labels

needs-rebase Has merge conflicts with main; the author needs to rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase E5] Solvency check at payout with a clear error when the token pool is short

4 participants