feat(l1_sender): redesign error handling with phase-based struct#1095
Open
Artemka374-claude wants to merge 3 commits intomatter-labs:mainfrom
Open
feat(l1_sender): redesign error handling with phase-based struct#1095Artemka374-claude wants to merge 3 commits intomatter-labs:mainfrom
Artemka374-claude wants to merge 3 commits intomatter-labs:mainfrom
Conversation
Replace the monolithic `run_l1_sender` function with `L1SenderLoop`,
a phase-based struct that categorizes all errors and handles them
appropriately instead of crashing the binary.
Error categories:
- Transient (RPC timeouts, rate limits) → exponential backoff, retry
- Recoverable (GasBlocked, BlobFeeBlocked, TxTimeout, NonceTooLow) →
wait for external condition, retry with 30s sleep
- Fatal (tx revert, data corruption, channel closed) → crash as before
Key changes:
- `L1SenderLoop` tracks three collections: `pending_commands`,
`in_flight`, and `completed`. Commands are never lost on errors —
partial send progress survives transient RPC failures.
- Gas and blob fee caps are checked before any tx is submitted.
Exceeding the cap now returns `GasBlocked`/`BlobFeeBlocked` instead
of warning and sending a doomed tx.
- Pending block fallback: replace `.expect("no pending block")` with
a fallback to `BlockId::latest()` to fix the known Infura crash.
- Metrics: add `GasBlocked`, `BlobFeeBlocked`, `TransientBackoff`
states; add `transient_errors` counter and `recoverable_errors`
labeled counter. Make `report_tx_receipt` / `report_blob_base_fee` /
`report_l1_eip_1559_estimation` non-fatal (log on parse error).
- Informational calls (`get_balance`, `get_transaction_count`) after
inclusion are now non-fatal — log warning and continue.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These docs were added for planning purposes and belong in the docs repo, not in the server codebase. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
run_l1_senderwithL1SenderLoop, a phase-based struct (receive→send_pending→wait_for_inclusion→forward_downstream) that categorizes all errors instead of crashing the binaryL1SendErrorenum with three variants:Transient(RPC issues → exponential backoff),Recoverable(gas/blob fee cap exceeded, tx timeout, nonce conflict → 30s wait + retry),Fatal(tx revert, data corruption, channel closed → crash as before)GasBlockedandBlobFeeBlockedmetric states for early alerting.expect("no pending block")with fallback toBlockId::latest()report_tx_receipt,report_blob_base_fee,report_l1_eip_1559_estimation,get_balance, andget_transaction_countnon-fatal (log warn and continue)Test Plan
cargo fmt --all --checkpassescargo clippy --all-targets --all-features --workspace -- -D warningspassescargo nextest run --release --workspace --exclude zksync_os_integration_tests— 175/175 tests pass--load-stateJSON parsing issue unrelated to this change)No new tests added — the L1 sender has no existing unit tests and adding meaningful ones requires mocking the alloy provider, which is a separate effort tracked as a follow-up.
🤖 Generated with Claude Code