fix(levm): fix precompiles problem with eip7702 - #2900
Conversation
Lines of code reportTotal lines added: Detailed view |
Benchmark Results ComparisonPR ResultsBenchmark Results: Factorial
Benchmark Results: Factorial - Recursive
Benchmark Results: Fibonacci
Benchmark Results: ManyHashes
Benchmark Results: BubbleSort
Benchmark Results: ERC20 - Transfer
Benchmark Results: ERC20 - Mint
Benchmark Results: ERC20 - Approval
Main ResultsBenchmark Results: Factorial
Benchmark Results: Factorial - Recursive
Benchmark Results: Fibonacci
Benchmark Results: ManyHashes
Benchmark Results: BubbleSort
Benchmark Results: ERC20 - Transfer
Benchmark Results: ERC20 - Mint
Benchmark Results: ERC20 - Approval
|
EF Tests ComparisonSame results between main branch and the current PR. |
| self.increase_account_balance(to, value)?; | ||
| } | ||
|
|
||
| if bytecode.is_empty() && is_delegation { |
There was a problem hiding this comment.
This was removed because it was just an early return. But the result it the same if the callframe is created and the bytecode is empty. I just thought that it was best to remove it for clarity and say that we execute empty code.
|
|
||
| if self.is_precompile()? { | ||
| // Execute precompile immediately and handle result. | ||
| if self.is_precompile(&code_address) && !is_delegation_7702 { |
There was a problem hiding this comment.
This check was added because precompile shouldn't be executed if it's target of delegation.
See here
| let precompile_result = match self.is_delegation_target(precompile_address) { | ||
| // Avoid executing precompile if it is target of a delegation in EIP-7702 transaction. | ||
| true => { | ||
| let gas_limit = self.current_call_frame()?.gas_limit; | ||
| if gas_limit == 0 { | ||
| // `pointer_to_precompile.json` tests that it should fail in a call with zero gas limit. | ||
| Err(VMError::PrecompileError(PrecompileError::NotEnoughGas)) | ||
| } else { | ||
| Ok(Bytes::new()) | ||
| } | ||
| } | ||
| // Otherwise, execute precompile | ||
| false => { | ||
| let callframe = self.current_call_frame_mut()?; | ||
| execute_precompile( | ||
| precompile_address, | ||
| &callframe.calldata, | ||
| &mut callframe.gas_used, | ||
| callframe.gas_limit, |
There was a problem hiding this comment.
We don't need these checks anymore because it's enough with the checks that are being performed in XCALL opcodes. Before we were making checks in external transactions too, which wasn't necessary at all.
**Motivation** - Fix holesky Prague syncing with LEVM **Description** - I previously misunderstood the behavior between [EIP 7702](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md) and precompiles and because of that some edge cases were breaking our VM. The current solution I believe is implemented correctly and is also simpler than what I thought. Before we were luckily (unluckily I'd say) passing all EFTests despite this misimplementation. <!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 --> Closes #issue_number
Motivation
Description
Before we were luckily (unluckily I'd say) passing all EFTests despite this misimplementation.
Closes #issue_number