-
Notifications
You must be signed in to change notification settings - Fork 39
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
Changes from 4 commits
fd22cf1
fc2db02
572821b
f437868
6416745
a3021bf
a2f0546
680c10f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,8 @@ pub struct BuilderConfig<Specific: Clone> { | |
|
|
||
| /// Configuration values that are specific to the block builder implementation used. | ||
| pub specific: Specific, | ||
| /// Maximum gas a transaction can use before being excluded. | ||
| pub max_gas_per_txn: Option<u64>, | ||
| } | ||
|
|
||
| impl<S: Debug + Clone> core::fmt::Debug for BuilderConfig<S> { | ||
|
|
@@ -145,6 +147,7 @@ impl<S: Default + Clone> Default for BuilderConfig<S> { | |
| da_config: OpDAConfig::default(), | ||
| specific: S::default(), | ||
| sampling_ratio: 100, | ||
| max_gas_per_txn: Some(25_000), | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -164,6 +167,7 @@ where | |
| block_time_leeway: Duration::from_secs(args.extra_block_deadline_secs), | ||
| da_config: Default::default(), | ||
| sampling_ratio: args.telemetry.sampling_ratio, | ||
| max_gas_per_txn: args.max_gas_per_txn, | ||
| specific: S::try_from(args)?, | ||
| }) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ use super::{TransactionBuilder, FUNDED_PRIVATE_KEYS}; | |
| pub trait TransactionBuilderExt { | ||
| fn random_valid_transfer(self) -> Self; | ||
| fn random_reverting_transaction(self) -> Self; | ||
| fn random_big_transaction(self) -> Self; | ||
| } | ||
|
|
||
| impl TransactionBuilderExt for TransactionBuilder { | ||
|
|
@@ -33,6 +34,10 @@ impl TransactionBuilderExt for TransactionBuilder { | |
| fn random_reverting_transaction(self) -> Self { | ||
| self.with_create().with_input(hex!("60006000fd").into()) // PUSH1 0x00 PUSH1 0x00 REVERT | ||
| } | ||
|
|
||
| fn random_big_transaction(self) -> Self { | ||
| self.with_create().with_input(hex!("3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006883d15f0000000000000000000000000000000000000000000000000000000000000004100504040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003090b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bacdc46b210000000000000000000000000000000000000000000000000000000da673855a3f900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000009536c7089100000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc0000000000000000000000000000000000000000000000000e92596fd629000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc00000000000000000000000000000000000000000000000000000000000000000c").into()) | ||
|
||
| } | ||
| } | ||
|
|
||
| pub trait ChainDriverExt { | ||
|
|
||
| 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,47 @@ async fn test_no_tx_pool(rbuilder: LocalInstance) -> eyre::Result<()> { | |||
|
|
||||
| Ok(()) | ||||
| } | ||||
|
|
||||
| #[rb_test(args = OpRbuilderArgs { | ||||
| max_gas_per_txn: Some(21000), | ||||
| ..Default::default() | ||||
| })] | ||||
| async fn chain_produces_big_txs(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?; | ||||
|
|
||||
| let count = rand::random_range(1..8); | ||||
|
||||
| let count = rand::random_range(1..8); |
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.
I think a test that sends a tx using an amount of gas below the threshold and one above and then checking that the tx that uses too much gas is excluded should be sufficient
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.
Please remove the default value