Conversation
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Add queue-length checks before attempting internal matches: 1. At the top of run_internal_matching_engine(): bail if the account's serial task queue is non-empty. This mirrors v1's should_run_matching_engine() which prevented re-entering the matching engine unless the wallet's serial queue was confirmed empty. 2. In try_settle_match(): bail if the counterparty account's serial task queue is non-empty, avoiding a settlement attempt that would be rejected with 'serial preemption not allowed'. Together with PR #1420 (order_still_valid post-failure guard), this closes the gap between v1 and v2 internal match retry behavior.
- Remove v1 references from code comments - Consolidate 5 unit tests to 2 (order removed, unchanged) - Remove unused imports
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Add queue-length checks before attempting internal matches: 1. At the top of run_internal_matching_engine(): bail if the account's serial task queue is non-empty. This mirrors v1's should_run_matching_engine() which prevented re-entering the matching engine unless the wallet's serial queue was confirmed empty. 2. In try_settle_match(): bail if the counterparty account's serial task queue is non-empty, avoiding a settlement attempt that would be rejected with 'serial preemption not allowed'. Together with PR #1420 (order_still_valid post-failure guard), this closes the gap between v1 and v2 internal match retry behavior.
Add queue-length checks before attempting internal matches: 1. At the top of run_internal_matching_engine(): bail if the account's serial task queue is non-empty. This mirrors v1's should_run_matching_engine() which prevented re-entering the matching engine unless the wallet's serial queue was confirmed empty. 2. In try_settle_match(): bail if the counterparty account's serial task queue is non-empty, avoiding a settlement attempt that would be rejected with 'serial preemption not allowed'. Together with PR #1420 (order_still_valid post-failure guard), this closes the gap between v1 and v2 internal match retry behavior.
akirillo
left a comment
There was a problem hiding this comment.
as discussed, the order validity check seems irrelevant now that we rely on the post-task hook model for reinvoking the matching engine.
as we saw, the matching engine run will pull a fresh view of the order before attempting a match, so there's no need for a staleness check in the engine's hot path.
we can just log if the spawned match task fails.
The internal settlement path already refreshes both accounts and re-enqueues\nfresh matching engine runs via failure hooks, so the post-failure\norder_still_valid branch was no longer guarding a meaningful retry\nloop. Removing it keeps failure handling in one place and drops the\ntest-only scaffolding that existed solely to exercise that branch.\n\nConstraint: Internal settlement failure already triggers refresh-account then fresh matching-engine runs\nRejected: Keep order_still_valid as a defensive readback | duplicated recovery logic without gating an inline retry\nConfidence: high\nScope-risk: narrow\nReversibility: clean\nDirective: If inline retry logic is reintroduced in the matching engine, reevaluate whether a local freshness gate is needed there\nTested: cargo fmt --all; cargo test -p matching-engine-worker --lib\nNot-tested: live Base Sepolia harness repro from this worktree
|
Closing this out: I removed the After tracing the execution model, the extra validity check no longer seems necessary. On internal settlement failure, the system already recovers through hooks:
So we already have a fresh-state retry path after failure. I also removed the guard-specific test scaffolding and dependency additions, since they only existed to support that branch. Verification:
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Summary
order_still_validpath with fresh database reads after settlement failureV1 Validity Criteria
In v1,
wallet_still_validre-read two things from the database after settlement failure:It rejected continuing when:
V2 Validity Criteria
V2 does not have a wallet-level nullifier for Ring 0 order freshness, so the equivalent guard is order-centric.
order_still_validnow re-reads these database-backed values after settlement failure:order_id -> account_idmappingOrderIt rejects continuing when:
order_id -> account_idmapping is goneOrderrow is goneOrderdiffers from theOrdervalue used to choose the attempted matchExplicitly Excluded
ready_for_matchwallet_still_validdid not read it. It belongs to the order-book / gossip path, while this guard is intentionally limited to the same database checks v1 used in its post-failure validity method.Testing
cargo test -p matching-engine-worker order_still_valid -- --nocaptureNotes
Re-implement order still valid checkwarning disappears, but the fresh relayer startup failed before serving traffic witherror parsing command line args: "Invalid byte 45, offset 5."in/tmp/relayer-output-internal-match-guard.log, so I could not complete the repro-path verification in this session.