Skip to content

fix(accrual-keeper): keep accruing when state store is unclaimable - #1175

Merged
collinsezedike merged 1 commit into
drydocs:mainfrom
liutingqiu:fix/1132-accrual-fail-open
Oct 20, 2026
Merged

collinsezedike merged 1 commit into
drydocs:mainfrom
liutingqiu:fix/1132-accrual-fail-open

Conversation

@liutingqiu

Copy link
Copy Markdown
Contributor

Closes #1132

What was wrong

accrual-keeper.ts documents a deliberate fail-open when prior.state === "unknown" (a state-store outage), then immediately takes a SubmissionLease through the same store. When the store is unreachable, SubmissionLease.acquire returns { error: "submission state store unavailable" } and the old code pushed the adapter into skipped — producing exactly the halted accrual the fail-open exists to prevent.

Fix

The two failure modes of acquire are now distinguished:

  • another run holds the target — still skipped. Duplicate prevention working as intended.
  • the store itself is unreachable — proceed without a lease, log a warning, no claim to release. This matches the documented intent: a duplicate accrue() re-syncs a cached value and costs one Soroban fee, which is cheaper than leaving every vault's TVL/APY stale for the length of the outage.

lease is now optional so releaseIfUnsent() only runs when a claim was actually taken.

Tests

accrual-keeper.test.ts gains a test for a full outage (both the prior read and the claim throw), asserting the adapter is not skipped, the submission still happens, and the "proceeding without a submission lease" warning is emitted. The existing test that only fails get keeps passing.

Verification

No Postgres/network needed — this package's suite is fully mocked:

$ pnpm lint && pnpm typecheck && pnpm test
# lint:       (no output)
# typecheck:  (no output)
# test:       23 files, 563 tests passed

Both new tests fail on the pre-fix commit and pass after it.

@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@liutingqiu is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@liutingqiu 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

@liutingqiu

Copy link
Copy Markdown
Contributor Author

Verified locally on this branch before asking for review.

Full workspace suite, pnpm test (after pnpm --filter @meridian/shared build):

@meridian/shared              4 files   65 tests passed
@meridian/stellar-sdk-helpers 23 files 562 tests passed
@meridian/sdk                 5 files   68 tests passed
@meridian/strategies         35 files  716 tests passed
@meridian/api-core            5 files   73 tests passed
@meridian/api-local           2 files   39 tests passed
@meridian/web                40 files  360 tests passed
@meridian/api                 5 files   80 tests passed
------------------------------------------------------
119 files, 1963 tests passed, 0 failed

The regression test added here is accrual-keeper.test.ts › keeps accruing when the lease cannot be claimed either, instead of halting every vault. It fails on main (the keeper skips the submission because it cannot tell "peer holds the lease" from "the store is unreachable") and passes with this diff.

Repro: pnpm --filter @meridian/shared build && pnpm --filter @meridian/stellar-sdk-helpers test.

@liutingqiu
liutingqiu force-pushed the fix/1132-accrual-fail-open branch from 4481c31 to 8812d4c Compare October 20, 2026 02:08
@liutingqiu liutingqiu changed the title fix(accrual-keeper): keep accruing when the state store cannot be claimed (#1132) fix(accrual-keeper): keep accruing when the state store cannot be claimed Oct 20, 2026
@liutingqiu
liutingqiu force-pushed the fix/1132-accrual-fail-open branch from 8812d4c to 603b9ad Compare October 20, 2026 02:09
@liutingqiu liutingqiu changed the title fix(accrual-keeper): keep accruing when the state store cannot be claimed fix(accrual-keeper): keep accruing when state store is unclaimable Oct 20, 2026
@liutingqiu

Copy link
Copy Markdown
Contributor Author

The Commit Messages failure was only the 77-character subject line; I shortened it and left the code unchanged. The new workflow runs are waiting for maintainer approval (action_required), so CI cannot re-run yet. Could you approve the runs and take a look when you have a moment? Happy to adjust anything else.

@liutingqiu

Copy link
Copy Markdown
Contributor Author

@collinsezedike The only failing check on this PR is Vercel's Authorization required to deploy — it needs a member of the Collins' projects Vercel team to authorize the deployment (Vercel bot link above). Everything else is green: Lint & Typecheck, Test, Commit Messages and PR Title all pass, and the PR is mergeable. Could you authorize the deployment (or re-run Vercel) when you have a moment? Thanks!

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix, @liutingqiu. This is a solid contribution. If you'd like to pick up another open issue, there are several available in the tracker.

@collinsezedike
collinsezedike merged commit fc87efa into drydocs:main Oct 20, 2026
11 of 12 checks passed
@collinsezedike

Copy link
Copy Markdown
Collaborator

@liutingqiu thank you again for getting this over the line. If you are enjoying working on Meridian, starring the repository helps more contributors find the project and is much appreciated.

@liutingqiu

Copy link
Copy Markdown
Contributor Author

Thanks—I’m enjoying contributing to Meridian and will star the repository to help more contributors find the project.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Accrual keeper cannot fail open during a state-store outage

2 participants