-
Notifications
You must be signed in to change notification settings - Fork 108
fix(l1): added error for case where system contract code is empty #4731
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
|
crates/vm/backends/levm/mod.rs
Outdated
..Default::default() | ||
}; | ||
|
||
if !(contract_address == HISTORY_STORAGE_ADDRESS.address |
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.
would be better to have a vec of system contracts somewhere? Otherwise it will be easy to miss this when a new system contract is added?
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.
We do have a vec of system contracts. However this case is more specific; it's not any given system contract but those that have code (the function in which this check is in is already only reached when a system contract is called). We could build a vec specifically for the system contracts that do have code though (or add a has_code attribute to the existing ones)
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.
Done!
if vm.current_call_frame.gas_limit < min_gas_limit { | ||
return Err(TxValidationError::IntrinsicGasTooLow.into()); | ||
if vm.current_call_frame.gas_limit < floor_cost_by_tokens { | ||
return Err(TxValidationError::IntrinsicGasBelowFloorGasCost.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.
which ones does this fix? https://hive.ethpandaops.io/#/test/generic/1759727493-afbe365eb26fd5a231ad1aa9e83cd55d
crates/vm/backends/levm/mod.rs
Outdated
..Default::default() | ||
}; | ||
|
||
if !(contract_address == HISTORY_STORAGE_ADDRESS.address |
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'd personally add a comment that we have this code in order to pass the tests and that it's impossible in real scenarios. I am not in favor of adding the check but if we want it I'd just add that 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.
Sure, done here. Let me know if you think the comment is adequate
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.
It's great, thanks
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.
Is it possible that the changes in this file are somehow unrelated to the PR title? Like the PR is for when the code is empty in system contract calls, this is for other scenario, isn't it?
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.
Also did you add this because you saw a test that made it necessary or what?
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.
Those changes were from a separate PR I made before this one. That one already got merged though, so I'm not sure why those are showing up in the diff for this one
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.
Those are from this PR
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.
Ok there, merging the latest version of main into the branch fixed it, the files changed should show up properly now
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.
Does the deposit contract belong to the const of the contracts? Like I know the other two belong here because of EIP-2935 but I'm not sure about the other one. It does no harm anyway but I think it doesn't belong here.
Also, make sure to link the corresponding EIP for each contract that says that it should fail if there's no code
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7251.md
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7002.md#empty-code-failure
crates/vm/system_contracts.rs
Outdated
.filter(move |system_contract| system_contract.active_since_fork <= fork) | ||
} | ||
|
||
pub const SYSTEM_CONTRACTS_WITH_CODE: [SystemContract; 3] = [ |
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 don't think this is an accurate name. The contracts that should be here are just 2, the EIP 7002 and EIP 7251 contracts. Idk if we can call them PRAGUE_SYSTEM_CONTRACTS
or any name representative of that
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.
For example, the beacon root contract is a system contract with code but doesn't belong to the check we are trying to make. Correct me if I'm wrong
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.
Fair, I didn't know the details of the beacon roots contract. As for the rest, I'll fix it in a sec. I thought the deposits contract should be included too but I guess thinking about it now it needn't
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 still missing |
Sorry, my bad, idk how I missed that comment. Fixed it here |
Description
This PR adds a check for the case where a system contract code is empty. This is required to pass a few Hive tests recently added that ask to return an error in such a case.