-
Notifications
You must be signed in to change notification settings - Fork 117
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
Changes from 12 commits
aaa9f76
ab8ab37
1aa1d80
e35843e
5675249
ebed22a
aa57c47
fa6c430
2080e2f
b9fe38f
2749d4d
84ba906
9f9c021
67cc166
d9e8ef7
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 |
|---|---|---|
|
|
@@ -11,8 +11,6 @@ use crate::{ | |
| use bytes::Bytes; | ||
| use ethrex_common::{Address, U256, types::Fork}; | ||
|
|
||
| use std::cmp::max; | ||
|
|
||
| pub const MAX_REFUND_QUOTIENT: u64 = 5; | ||
|
|
||
| pub struct DefaultHook; | ||
|
|
@@ -248,6 +246,10 @@ pub fn validate_min_gas_limit(vm: &mut VM<'_>) -> Result<(), VMError> { | |
| let calldata = vm.current_call_frame.calldata.clone(); | ||
| let intrinsic_gas: u64 = vm.get_intrinsic_gas()?; | ||
|
|
||
| if vm.current_call_frame.gas_limit < intrinsic_gas { | ||
| return Err(TxValidationError::IntrinsicGasTooLow.into()); | ||
| } | ||
|
|
||
| // calldata_cost = tokens_in_calldata * 4 | ||
| let calldata_cost: u64 = gas_cost::tx_calldata(&calldata)?; | ||
|
|
||
|
|
@@ -261,9 +263,8 @@ pub fn validate_min_gas_limit(vm: &mut VM<'_>) -> Result<(), VMError> { | |
| .checked_add(TX_BASE_COST) | ||
| .ok_or(InternalError::Overflow)?; | ||
|
|
||
| let min_gas_limit = max(intrinsic_gas, floor_cost_by_tokens); | ||
| 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()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| Ok(()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,3 +69,9 @@ pub fn system_contracts_for_fork(fork: Fork) -> impl Iterator<Item = SystemContr | |
| .into_iter() | ||
| .filter(move |system_contract| system_contract.active_since_fork <= fork) | ||
| } | ||
|
|
||
| pub const SYSTEM_CONTRACTS_WITH_CODE: [SystemContract; 3] = [ | ||
|
||
| DEPOSIT_CONTRACT_ADDRESS, | ||
| WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, | ||
| CONSOLIDATION_REQUEST_PREDEPLOY_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.
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