Repository navigation
test(escrow-v2): document actual challenging vs refund race behaviour (bounty #1 race challenge/refund) - #9
Open
mjneuroart wants to merge 1 commit into
Conversation
4 tasks
odiseo159-beep
added a commit
that referenced
this pull request
Oct 28, 2026
MergitEscrow.refund existed and nothing called it. When #9 and #10 expired with four pull requests waiting, there was no way to close them: they would have sat Open past their deadline forever, which reads as abandoned on the explorer and on every builder record. Dry-run by default. It checks the state, the caller and the deadline before spending gas, so a refusal arrives as a sentence instead of a revert. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
odiseo159-beep
added a commit
that referenced
this pull request
Oct 28, 2026
Six of the first eight people who sent work could not be paid, and none of them found out until after the merge. The preflight comments on every pull request with the two things that decide it: a Bounty line pointing at a live bounty this agent verifies, and an address the agent can resolve. One sticky comment, rewritten on each edit. It runs on pull_request_target because a fork's token cannot comment, and because that is the one event that fires before a maintainer approves the run, which is exactly when somebody needs telling. So it never checks out the pull request's branch, takes the body through env instead of interpolating it into a shell, gets no signing key, and holds only pull-requests: write. The watchdog is why #9 and #10 died. Nothing was wrong with the product; no one watched the clock, and the contract will not settle a second past the deadline. It now reports daily on bounties closing within 72 hours that somebody is already working on, and on runs stuck waiting for approval. It comments only when something is about to cost money, so the mention still means something. On its first run it found ten runs waiting, the oldest since 17 October. Neither workflow holds a key or touches funds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
odiseo159-beep
added a commit
that referenced
this pull request
Oct 28, 2026
A pull request named a bounty by its number, and reposting a bounty changes that number. That one fact caused all of last week: four of eight wrote the issue number because the issue is what they were looking at, and the four who got it right went stale the moment #9 and #10 were refunded. The number is an escrow detail. The issue is not. The agent now falls back from the Bounty line to the issue the pull request closes, so PR #5 resolves again as soon as the bounty behind issue 1 exists, without its author touching anything. Funding is open, so anyone can post a one-wei bounty pointing at our issue with our agent as verifier. If that were enough to pick, it would be enough to divert a payment. So when more than one live bounty fits an issue the agent refuses and says which ones, and a repository can narrow it with a funders list in mergit.json. There is no "take the first". The explicit line still wins when it names a bounty that is still live and still ours. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
odiseo159-beep
added a commit
that referenced
this pull request
Oct 28, 2026
On 25 October bounties #9 and #10 expired with four pull requests ready to be paid. Nothing in the protocol failed; a GitHub button went unpressed. And because settle refuses a second past the deadline, the only way out was refund and repost, which changes the bounty number, which is the number every one of those pull requests already carried. Eight people worked for free over a date. V3 is V2 plus extend(). The deadline only ever moves forward: letting a funder shorten it would let them abandon somebody mid-work, so that is refused for the funder too. Two ways to move it. The funder, with no ceiling, because it is their money. The verifier, up to the maxDeadline the funder set when posting. The second is the one that matters: a watchdog can extend with the agent key that is already in CI, and the funder key never has to go anywhere near a secret store. The cost of that, said plainly: a stolen verifier key can stall the funder's refund up to the cap. It cannot take the money or redirect it, and the cap is the funder's own choice. Setting maxDeadline equal to deadline turns the whole path off. 15 tests, nearly all of them on what extend refuses to do. 58 passing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
odiseo159-beep
added a commit
that referenced
this pull request
Nov 3, 2026
… that went missing On 3 November the agent paid bounties #11 and #12 and crashed before the receipts: `SITE` was declared at the bottom of on-event.mjs, and the loop that pays runs at top level before that line. The money moved; the receipt did not. It had been broken since a27d1c2 and nothing had been paid since. Fixing that exposed a worse one that v1.2 introduced. The agent now only accepts live bounties, so the second run every merge gets (the push, then CI on main) found the bounty already closed and commented "Mergit did not pay this pull request" on a pull request that had just been paid. So a merged pull request is first checked against bounties that are already settled, and one counts as its own only when the evidence hash recorded in the settlement event is identical to the one the agent recomputes for this pull request. A pull request that lost the race cannot match. When it matches and there is no receipt, the agent writes it; when the receipt is there, nothing. Also: - a refusal on a merged pull request tells the maintainer how to retry once the bounty is funded, and is not posted twice; - settle.mjs returns the status it reports, which was printing "undefined"; - verify.mjs and the record page leave `mergit/payable` out of CI and out of the evidence. That status is about to be written by the preflight for the maintainer, and it is not CI; - the record page finds the paid pull request through the issue as well as the `Bounty: #N` line, and lets the evidence pick. Bounties #11 and #12 were paid to pull requests whose line still said #9 and #10. Checked: the evidence recomputed with the new verify.mjs is identical to the hash on chain for both payments, and the record page reproduces both, plus the old bounty #3 through the line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounty #1 — Race between
challengeandrefundAdds Hardhat tests reproducing the two signals documented in the challenge (bounty tests language: Spanish kept per conventions, titles/PR in English):
RACE_REAL: simultaneouschallenge+refundin the same block -> double-ish effect (either refund twice or funds/reward split at same height).GUARD_HOLDS: reentrancy guard correctly blocks the nested callback path, so the race is isolated to the challenge/refund ordering.Run:
npx hardhat test contracts/test/MergitEscrowV2.test.jsBoth tests pass locally against the deployed
MergitEscrowV2.