-
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
Conversation
| let gas_used = result.gas_used(); | ||
| if gas_used > self.max_gas_per_txn { | ||
| info!("builder txn took execessive gas. not included in block"); | ||
| return Ok(()); |
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.
this is out builder transaction, not needed here
We should implement this logic inside execute_best_transactions
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.
ahh thank you for clarifying
|
Also this will need a test, looks good at this point |
akundaz
left a comment
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.
Hey, thanks for the contribution!
I just have a few suggestions:
- Let's make this cli argument optional, if it's not provided, we don't check a transaction's gas
- Keep the name consistent -- I like
max_gas_per_txn, so you should make the long arg thenbuilder.max_gas_per_txn
Otherwise I think this is good, just add a test and it should be good to merge!
|
I've added a utility function
|
crates/op-rbuilder/src/args/op.rs
Outdated
| pub chain_block_time: u64, | ||
|
|
||
| /// max gas a transaction can use | ||
| #[arg(long = "builder.max_gas_per_txn", default_value = "25000")] |
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
| da_config: OpDAConfig::default(), | ||
| specific: S::default(), | ||
| sampling_ratio: 100, | ||
| max_gas_per_txn: Some(25_000), |
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.
The default should be None
| } | ||
|
|
||
| fn random_big_transaction(self) -> Self { | ||
| self.with_create().with_input(hex!("3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006883d15f0000000000000000000000000000000000000000000000000000000000000004100504040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003090b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bacdc46b210000000000000000000000000000000000000000000000000000000da673855a3f900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000009536c7089100000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc0000000000000000000000000000000000000000000000000e92596fd629000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc00000000000000000000000000000000000000000000000000000000000000000c").into()) |
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 explain what this transaction is in code comments
| .with_validation_node(crate::tests::ExternalNode::reth().await?) | ||
| .await?; | ||
|
|
||
| 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.
Why are you creating a random number of transactions?
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.
Well I just used this and removed the outer loop...I can add that back again
| 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
| .send() | ||
| .await | ||
| .expect("Failed to send transaction"); | ||
| println!("{}", txs.len()); |
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.
debug
| let block = driver.build_new_block_with_current_timestamp(None).await?; | ||
| let txs = block.transactions; | ||
|
|
||
| println!("{}", txs.len()); |
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.
debug
| max_gas_per_txn: Some(25000), | ||
| ..Default::default() | ||
| })] | ||
| async fn chain_produces_small_tx(rbuilder: LocalInstance) -> eyre::Result<()> { |
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.
let's combine this test with chain_produces_big_tx_with_gas_limit
create 2 txs (big and small one)
And the check by hash that small transaction got included
| .await | ||
| .expect("Failed to send transaction"); | ||
|
|
||
| // insert txn with gas usage above limit |
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
| .with_validation_node(crate::tests::ExternalNode::reth().await?) | ||
| .await?; | ||
|
|
||
| // insert txn with gas usage but there is no limit |
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.
similarly assert that this tx is included in the block
|
@varun-doshi Sorry for slow review, we were really busy these 2 week |
|
@varun-doshi Looks great, will merge it once tests will pass! |
π Summary
Adds a cli parameter named
max_gas_per_txnto signiify if a transaction uses more gas than this value, it should not be added to the block being built.Fixes #202
β I have completed the following steps:
make lintmake test