-
Notifications
You must be signed in to change notification settings - Fork 29
feat(l1-sender): Add ability to resubmit transactions #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Artemka374
wants to merge
37
commits into
main
Choose a base branch
from
afo/l1-sender-enhancements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
eeb42e6
feat(l1_sender): replace monolithic loop with per-transaction Tokio task
Artemka374-claude 8a83129
test(l1_sender): fix resubmission test fee caps for anvil 1.5.1
Artemka374-claude 648ea7e
Merge branch 'feat/l1-sender-task-per-tx' of https://github.com/Artem…
Artemka374 4509647
return back `process_prepending_passthrough_commands`
Artemka374 aa15edf
try to reduce unnecessary diff
Artemka374 6ea964a
temporarily disable prover tests in CI
Artemka374 f8e8d43
remove channels
Artemka374 2094ebc
change fee rules for resubmitting
Artemka374 7842bd7
use backoff from external dependency
Artemka374 b7ef3cc
remove backoff completely
Artemka374 3b5a848
try to remove some strange redundant impls
Artemka374 a84439c
random nl
Artemka374 8da0853
random NL #2
Artemka374 8c909ed
remove dead module
Artemka374 5ec9ca4
use allloy's watcher instead of customly built
Artemka374 0b85613
inline some other unnecessary functions
Artemka374 8e09fcc
fmt and other fixes
Artemka374 02f145e
fmt
Artemka374 c01a583
always submit at least one tx
Artemka374 97b63a3
fmt
Artemka374 141002d
upd tests
Artemka374 671bae8
fix submission loop
Artemka374 f995b7b
cap the first tx
Artemka374 f340c16
fmt
Artemka374 c7ec214
update metrics a bit
Artemka374 8b1c498
Merge origin/main into afo/l1-sender-enhancements
Artemka374 0ee8aa7
estimate blob fee
Artemka374 7f74188
report configured blob fee
Artemka374 caf893f
use fallback in case of estimation error
Artemka374 8b890a0
fmt
Artemka374 71d7f2c
fix some issues
Artemka374 7f9cc80
only check blob fee when sending commit txs
Artemka374 522952b
a few more fixes
Artemka374 f6c6099
remove tx_resubmissions metric
Artemka374 a9ac343
add required confirmations
Artemka374 e6c3969
fix clippy
Artemka374 17fb2e5
fix tests
Artemka374 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| use alloy::network::TransactionBuilder; | ||
| use alloy::primitives::{Address, U256}; | ||
| use alloy::providers::Provider; | ||
| use alloy::providers::ext::AnvilApi; | ||
| use alloy::rpc::types::TransactionRequest; | ||
| use smart_config::EtherAmount; | ||
| use std::time::Duration; | ||
| use zksync_os_integration_tests::assert_traits::{DEFAULT_TIMEOUT, ReceiptAssert}; | ||
| use zksync_os_integration_tests::provider::ZksyncTestingProvider; | ||
| use zksync_os_integration_tests::{CURRENT_TO_L1, Tester, test_multisetup}; | ||
|
|
||
| /// Exercises the per-transaction resubmission loop: | ||
| /// | ||
| /// 1. Start the node with a very short `transaction_timeout` (5 s) so the timeout fires | ||
| /// quickly in the test. | ||
| /// 2. Disable L1 auto-mining so the first submitted transaction is never included. | ||
| /// 3. Send an L2 transaction to trigger the batcher pipeline (commit → prove → execute). | ||
| /// 4. Wait long enough for the timeout to fire at least once and a replacement transaction | ||
| /// to be submitted. | ||
| /// 5. Re-enable L1 mining. | ||
| /// 6. Wait for the L2 block to be finalized on L1, confirming the pipeline recovered. | ||
| #[test_multisetup([CURRENT_TO_L1])] | ||
| #[test_runtime(flavor = "multi_thread")] | ||
| async fn l1_sender_resubmits_after_timeout() -> anyhow::Result<()> { | ||
| // A very short timeout to make the test fast. The node will re-evaluate after 5 s. | ||
| const TX_TIMEOUT: Duration = Duration::from_secs(5); | ||
|
|
||
| let tester = Tester::setup_with_overrides(|config| { | ||
| config.l1_sender_config.transaction_timeout = TX_TIMEOUT; | ||
| // Raise fee caps well above what Anvil reports so fee-cap gating does not | ||
| // prevent transaction submission during the test. | ||
| config.l1_sender_config.max_priority_fee_per_gas = EtherAmount(10 * 1_000_000_000); // 10 gwei | ||
| config.l1_sender_config.max_fee_per_gas = EtherAmount(500 * 1_000_000_000); // 500 gwei | ||
| // Fast block production so we get a batch quickly. | ||
| config.sequencer_config.block_time = Duration::from_millis(200); | ||
| }) | ||
| .await?; | ||
|
|
||
| // Stop auto-mining so L1 transactions stay pending indefinitely. | ||
| tester | ||
| .l1_provider() | ||
| .anvil_set_auto_mine(false) | ||
| .await | ||
| .expect("anvil_set_auto_mine(false)"); | ||
|
|
||
| // Submit an L2 transaction. This will eventually be batched and trigger the commit | ||
| // sender to submit an L1 transaction (which will time out because mining is paused). | ||
| let receipt = tester | ||
| .l2_provider | ||
| .send_transaction( | ||
| TransactionRequest::default() | ||
| .with_to(Address::random()) | ||
| .with_value(U256::from(1u64)), | ||
| ) | ||
| .await? | ||
| .expect_successful_receipt() | ||
| .await?; | ||
| let l2_block = receipt | ||
| .block_number | ||
| .expect("receipt must have a block number"); | ||
|
|
||
| // Give the node time to submit the first L1 transaction and for the timeout to fire | ||
| // at least once. Two full timeout periods is enough. | ||
| tokio::time::sleep(TX_TIMEOUT * 2).await; | ||
|
|
||
| // Re-enable auto-mining. Any replacement transactions submitted during the timeout | ||
| // window will now be included. | ||
| tester | ||
| .l1_provider() | ||
| .anvil_set_auto_mine(true) | ||
| .await | ||
| .expect("anvil_set_auto_mine(true)"); | ||
|
|
||
| // Mine a few blocks to ensure pending transactions are included promptly. | ||
| tester | ||
| .l1_provider() | ||
| .anvil_mine(Some(3u64), None) | ||
| .await | ||
| .expect("anvil_mine"); | ||
|
|
||
| // Wait for the block to be finalized (executed) on L1. If resubmission works the | ||
| // pipeline should complete within DEFAULT_TIMEOUT from this point. | ||
| tester | ||
| .l2_zk_provider | ||
| .wait_finalized_with_timeout(l2_block, DEFAULT_TIMEOUT) | ||
| .await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod batcher; | ||
| mod external_node; | ||
| mod l1_sender_resubmission; | ||
| mod mempool; | ||
| mod rebuild; | ||
| mod restart; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.