Skip to content

Add shared Postgres nonce queue for cross-repo transaction serialization#2876

Merged
sparrowDom merged 9 commits intosparrowDom/automated-actions-litefrom
sparrowDom/automated-actions-lite-nonce
Apr 15, 2026
Merged

Add shared Postgres nonce queue for cross-repo transaction serialization#2876
sparrowDom merged 9 commits intosparrowDom/automated-actions-litefrom
sparrowDom/automated-actions-lite-nonce

Conversation

@sparrowDom
Copy link
Copy Markdown
Member

@sparrowDom sparrowDom commented Apr 13, 2026

Both origin-dollar and arm-oeth cron containers use the same KMS signer, risking nonce collisions when transactions are sent concurrently.

Functionality:

  • This adds postgres backed nonce lock, so different processes don't have nonce race conditions

  • Timeout mechanism added and configured via NONCE_QUEUE_LOCK_TIMEOUT_MS. If process is waiting for longer than this configuration the process exits

  • add per chain gas price limit

  • functionality to repeat failed brodcasts is added

  • functionality to re-broadcast a transaction with a higher gas price is added

  • nonceQueue.ts: withNonceLock + wrapWithNonceQueue signer wrapper

  • action.ts: conditionally wraps signer when DATABASE_URL is set

  • docker-compose.yml: adds postgres service for local dev

  • cron-supervisor.ts: pool cleanup on shutdown

  • Includes integration tests verifying lock serialization

Both origin-dollar and arm-oeth cron containers use the same KMS signer,
risking nonce collisions when transactions are sent concurrently. This adds
a Postgres-backed nonce lock that wraps the signer transparently via
SELECT ... FOR UPDATE, holding the row lock for the full tx lifecycle.

- nonceQueue.ts: withNonceLock + wrapWithNonceQueue signer wrapper
- action.ts: conditionally wraps signer when DATABASE_URL is set
- docker-compose.yml: adds postgres service for local dev
- cron-supervisor.ts: pool cleanup on shutdown
- Includes integration tests verifying lock serialization
Comment thread contracts/tasks/lib/nonceQueue.test.ts
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.19%. Comparing base (f42b623) to head (340c42a).
⚠️ Report is 59 commits behind head on sparrowDom/automated-actions-lite.

Additional details and impacted files
@@                          Coverage Diff                          @@
##           sparrowDom/automated-actions-lite    #2876      +/-   ##
=====================================================================
+ Coverage                              48.21%   49.19%   +0.98%     
=====================================================================
  Files                                    112      112              
  Lines                                   4835     4844       +9     
  Branches                                1338     1343       +5     
=====================================================================
+ Hits                                    2331     2383      +52     
+ Misses                                  2500     2457      -43     
  Partials                                   4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread contracts/tasks/lib/nonceQueue.ts
@sparrowDom sparrowDom marked this pull request as ready for review April 15, 2026 09:12
@sparrowDom sparrowDom merged commit 0f17acc into sparrowDom/automated-actions-lite Apr 15, 2026
14 of 16 checks passed
@sparrowDom sparrowDom deleted the sparrowDom/automated-actions-lite-nonce branch April 15, 2026 09:12
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.

2 participants