-
Notifications
You must be signed in to change notification settings - Fork 38
feat: add transaction gas limit #214
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd22cf1
feat: add transaction gas limit
varun-doshi fc2db02
fix: update default
varun-doshi 572821b
fix: update best txns
varun-doshi f437868
chore: add test for max txn gas
varun-doshi 6416745
fix: apply suggestions
varun-doshi a3021bf
fix: tests
varun-doshi a2f0546
chore: update tests
varun-doshi 680c10f
fix: failing tests
varun-doshi 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
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
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
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 |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| use crate::tests::{LocalInstance, TransactionBuilderExt}; | ||
| use crate::{ | ||
| args::OpRbuilderArgs, | ||
| tests::{LocalInstance, TransactionBuilderExt}, | ||
| }; | ||
| use alloy_primitives::TxHash; | ||
|
|
||
| use core::{ | ||
| sync::atomic::{AtomicBool, Ordering}, | ||
| time::Duration, | ||
|
|
@@ -189,3 +193,77 @@ async fn test_no_tx_pool(rbuilder: LocalInstance) -> eyre::Result<()> { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[rb_test(args = OpRbuilderArgs { | ||
| max_gas_per_txn: Some(25000), | ||
| ..Default::default() | ||
| })] | ||
| async fn chain_produces_big_tx_with_gas_limit(rbuilder: LocalInstance) -> eyre::Result<()> { | ||
| let driver = rbuilder.driver().await?; | ||
|
|
||
| #[cfg(target_os = "linux")] | ||
| let driver = driver | ||
| .with_validation_node(crate::tests::ExternalNode::reth().await?) | ||
| .await?; | ||
|
|
||
| // insert valid txn under limit | ||
| let tx = driver | ||
| .create_transaction() | ||
| .random_valid_transfer() | ||
| .send() | ||
| .await | ||
| .expect("Failed to send transaction"); | ||
|
|
||
| // insert txn with gas usage above limit | ||
| let tx_high_gas = driver | ||
| .create_transaction() | ||
| .random_big_transaction() | ||
| .send() | ||
| .await | ||
| .expect("Failed to send transaction"); | ||
|
|
||
| let block = driver.build_new_block_with_current_timestamp(None).await?; | ||
| let txs = block.transactions; | ||
|
|
||
| assert!(txs.len() == 4); | ||
| // assert we included the tx with gas under limit | ||
| let inclusion_result = txs.hashes().find(|hash| hash == tx.tx_hash()); | ||
| assert!(inclusion_result.is_some()); | ||
|
|
||
| // assert we do not include the tx with gas above limit | ||
| let exclusion_result = txs.hashes().find(|hash| hash == tx_high_gas.tx_hash()); | ||
| assert!(exclusion_result.is_none()); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[rb_test(args = OpRbuilderArgs { | ||
| ..Default::default() | ||
| })] | ||
| async fn chain_produces_big_tx_without_gas_limit(rbuilder: LocalInstance) -> eyre::Result<()> { | ||
| let driver = rbuilder.driver().await?; | ||
|
|
||
| #[cfg(target_os = "linux")] | ||
| let driver = driver | ||
| .with_validation_node(crate::tests::ExternalNode::reth().await?) | ||
| .await?; | ||
|
|
||
| // insert txn with gas usage but there is no limit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly assert that this tx is included in the block |
||
| let tx = driver | ||
| .create_transaction() | ||
| .random_big_transaction() | ||
| .send() | ||
| .await | ||
| .expect("Failed to send transaction"); | ||
|
|
||
| let block = driver.build_new_block_with_current_timestamp(None).await?; | ||
| let txs = block.transactions; | ||
|
|
||
| // assert we included the tx | ||
| let inclusion_result = txs.hashes().find(|hash| hash == tx.tx_hash()); | ||
| assert!(inclusion_result.is_some()); | ||
|
|
||
| assert!(txs.len() == 4); | ||
|
|
||
| Ok(()) | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an assertion to verify that this tx isn't in the block