test: independently verify the fee-bump deadline fix (PR #14) with a simulated clock #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "agent/fee-bump-deadline-tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Independent verification of PR #14 (fee-bump deadline re-stamp)
Tests only, no production change. Branch:
agent/fee-bump-deadline-tests.Commits tested
ea8e68949d5276(PR #14 merge),a447820(main),8f582ea(this branch)Red / green — the same
test/feeBumpDeadline.test.tson both trees:Full output for both runs is attached:
docs/fee-bump-deadline-test-output.txt.On the branch:
npm test= 19 files / 252 tests pass,npm run typecheckandnpm run buildpass.Nothing is signed or broadcast:
makeContractCall,broadcastTransactionand the node'stx-status read are mocked, and a simulated chain owns the clock and the mempool.
What the suite covers
submitWithConfirmationis driven exactly as the kit drives it — the original submit plus allthree fee bumps — for add-liquidity, swap, a small withdrawal (1 bin) and a large withdrawal
(40 bins):
deadline = sign time + TX_DEADLINE_SECONDS(the plan's own deadline isstale by the prepare→sign gap, which is what makes the old code observably wrong);
(0.05 → 0.075 → 0.1125 → 0.15 STX);
Does it still recur on a larger withdrawal? Yes — but the stamp is no longer the reason
The router compares the deadline against
stacks-block-time, and that is a staircase, not aclock: it is the burn time of the Bitcoin block that opened the current tenure, so it only
advances when the next Bitcoin block arrives (~600 s). Measured on mainnet: Stacks heights
9637165–9637176 all carry
burn_block_time = 1796239037.The router asserts the deadline after the fold over the positions, so the fee is spent either
way. A 40-bin withdrawal is 13,743 B and 43 post-conditions (bins + 3) — it misses the current
tenure and lands in the next one, whose burn time is ~600 s past even the freshest deadline
(
sign time + 120 s). It is minedERR_DEADLINE_PASSED, the fee is burned, and the wallet neverfinds out: it already reported
timeout.So the size is not the cause — crossing the tenure boundary is, and the large withdrawal is
what makes crossing it likely. The suite pins both halves:
reports
timeoutafter three bumps, and the transaction is then minedabort_by_response;same tenure — the same 40-bin call succeeds inside the current tenure.
What the fix still misses
TX_CONFIRMATION_TIMEOUT_MSequals the deadline window, so the first bump is always signedafter the original deadline has expired.
is fatal and the bump machinery never engages.
(
MINIMUM_TX_FEE_RATE_PER_BYTE,MemPoolRejection::FeeTooLow), so a 40-bin withdrawal needs≈13.7 k µSTX — above the kit's 10 000 µSTX floor.
timeout, nottimeout_max_fee.SubmitResult.feereports the last bumped fee, not the fee the confirmed transaction paid.The one-pager with the measurements is
docs/fee-bump-deadline-findings.md.Note on the test counts: the AIBTC submission message quotes an earlier run of this suite (16 tests). The suite was extended afterwards to 22 tests (the cases the bounty asks for, plus characterisation tests for the residual issues), so the red/green numbers above - 21 failed | 1 passed on
ea8e689, 22 passed on8f582ea- are the final ones, and the attached output is from that final run.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.