-
Notifications
You must be signed in to change notification settings - Fork 107
chore(l1): remove/justify clones from common #4769
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
base: main
Are you sure you want to change the base?
Conversation
Lines of code reportTotal lines added: Detailed view
|
Benchmark Results ComparisonNo significant difference was registered for any benchmark run. Detailed ResultsBenchmark Results: BubbleSort
Benchmark Results: ERC20Approval
Benchmark Results: ERC20Mint
Benchmark Results: ERC20Transfer
Benchmark Results: Factorial
Benchmark Results: FactorialRecursive
Benchmark Results: Fibonacci
Benchmark Results: FibonacciRecursive
Benchmark Results: ManyHashes
Benchmark Results: MstoreBench
Benchmark Results: Push
Benchmark Results: SstoreBench_no_opt
|
} | ||
|
||
pub fn get_receipts(&self) -> Vec<Vec<Receipt>> { | ||
pub fn get_receipts(&mut self) -> Vec<Vec<Receipt>> { |
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.
Maybe we should change the name to take_receipts
? as to reflect the new behaviour
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 would also suggest changing it into an into_receipts
method that consumes the Receipts
message as we don't seem to use the struct afterwards
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.
Looking at this I also noticed that there is an overlooked clone at file peer_handler.rs
just a few lines below where this method is called (Line 708) that could be removed similarly
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.
Sure. Fixed here!
Co-authored-by: fmoletta <[email protected]>
let Some(blob_hashes) = self.tx.blob_versioned_hashes() else { | ||
self.current_call_frame.stack.push_zero()?; | ||
return Ok(OpcodeResult::Continue); | ||
}; | ||
|
||
let index = match u256_to_usize(index) { | ||
Ok(index) if index < blob_hashes.len() => index, |
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.
Maybe we could use unwrap_or_default(&vec![])
here and let the logic below handle the case of no blobs as to not repeat the same logic (early zero return) twice
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.
That sadly wouldn't work since the vec![] got dropped (and we need a reference). I did this, let me know what you think
let tx = if authorization_list.is_some() { | ||
Transaction::EIP7702Transaction(EIP7702Transaction { | ||
to: match test_tx.to { | ||
TxKind::Call(to) => to, | ||
TxKind::Create => return Err(EFTestRunnerError::EIP7702ShouldNotBeCreateType), | ||
}, | ||
value: test_tx.value, | ||
data: test_tx.data.clone(), | ||
access_list, | ||
authorization_list: list, | ||
access_list: access_list, | ||
authorization_list: authorization_list.unwrap(), |
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 was this change needed?
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.
Ah, that was because I removed the blob hashes field from the environment (since it required cloning the blob hashes from the transaction). The way the runner worked was that for EIP4844 transactions, it encoded them as EIP1599 txs and then injected the blob parameters via the environment. Because this would cause tests to fail now the environment didn't have the blob hashes, I had to add some extra logic to build the test transaction as an EIP4844 one when appropriate
Motivation
Cleaning up our code and improving it's performance. This PR is part of a broader campaign to remove clones from our code.
Description
This PR removes most of the .clone() calls from the types and utils of the common crate. Those clones that couldn't be removed are justified with an
// ok-clone
commentPart of #4668