Handle in-flight lock transactions - #1739
Open
ezforce wants to merge 1 commit into
Open
Conversation
ezforce
requested review from
a team,
Wollac,
austinabell,
capossele,
ec2,
jonastheis,
nahoc,
unizarr,
willemolding and
zeroecco
as code owners
March 14, 2026 19:40
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.
Summary
This change fixes a lock recovery gap in the broker and market lock flow.
When a lock transaction has already been accepted by the node or mempool, the RPC send path can return
already knownstyle errors even though the transaction is still live. Inv1.2.2, the broker treats that as a hard failure, marks the order as skipped, clears the lock cache, and never reconciles the on-chain lock state. If the transaction later lands, the order can remain locked by us without ever entering proving, which can lead to a slash.This PR changes that behavior so in-flight lock submissions are reconciled instead of being dropped.
Changes
already knownstyle lock send failures as in-flight lock submissionslock_request()andlock_request_with_signature()RequestLockedbefore treating an in-flight lock submission as a failureRequestAlreadyLockedwhen another prover already holds the lockLockTxInFlightwhen the lock transaction cannot be reconciled yetSkippedrows for unresolved in-flight lock submissionsRoot Cause
The previous flow failed in two places:
call.send().awaiterrors on lock submission were propagated directly, even for recoverable transaction-in-flight cases.Skipped, and invalidated the lock cache before it had a chance to observe that the chain was already locked by this prover.That combination made a successful lock transaction unrecoverable from the broker point of view.
Testing
Ran on
main:cargo test -p broker lock_order_recovers_when_request_is_already_locked_by_us_on_chain -- --nocapturecargo test -p broker already_known_ -- --nocaptureAdded regression coverage for:
already knownerror occurs without a visible broadcast yetPendingProvingafter analready knownerror once the lock becomes visible on-chainBackport
The same fix has been backported to
release-1.2in:codex/release-1.2-handle-in-flight-locks8b0080d5Note: local
release-1.2broker test execution is currently blocked by a pre-existingdeploy_hit_points()failure (HTTP error 502 with empty body) during test environment setup. The same failure also reproduces in an existing unmodified broker test, so it is not introduced by this patch.Note
Medium Risk
Changes lock transaction error-handling and broker state transitions around on-chain locking; incorrect classification could cause missed locks or repeated retries, impacting proving/slashing behavior.
Overview
Improves resilience to in-flight lock transactions where RPC
sendreturns "already known"/similar errors even though the tx may still land.The market client now classifies these send failures as recoverable, attempts to reconcile by querying
RequestLocked, and returns a newMarketError::LockTxInFlightwhen the lock can’t be confirmed yet (orRequestAlreadyLockedif another prover won). The broker consumes this new error/state: it can recover orders already locked by this prover, defers unresolved locks by keeping them in the lock cache (avoidingSkippedDB rows), and retries on the next tick; adds targeted regression tests with an injected provider that simulates these RPC failures.Written by Cursor Bugbot for commit 727d9b5. This will update automatically on new commits. Configure here.