Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/vm/backends/levm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod tracing;
use super::BlockExecutionResult;
use crate::system_contracts::{
BEACON_ROOTS_ADDRESS, CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS, HISTORY_STORAGE_ADDRESS,
SYSTEM_ADDRESS, WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
SYSTEM_ADDRESS, SYSTEM_CONTRACTS_WITH_CODE, WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
};
use crate::{EvmError, ExecutionResult};
use bytes::Bytes;
Expand Down Expand Up @@ -381,6 +381,18 @@ pub fn generic_system_contract_levm(
..Default::default()
};

// This check is not necessary in practice, since contract deployment has succesfully happened in all relevant testnets and mainnet
// However, it's necessary to pass some of the Hive tests related to system contract deployment, which is why we have it
if SYSTEM_CONTRACTS_WITH_CODE
.iter()
.any(|contract| contract.address == contract_address)
&& db.get_account_code(contract_address)?.is_empty()
{
return Err(EvmError::SystemContractCallFailed(format!(
"System contract: {contract_address} has no code after deployment"
)));
};

let tx = &Transaction::EIP1559Transaction(EIP1559Transaction {
to: TxKind::Call(contract_address),
value: U256::zero(),
Expand Down
6 changes: 6 additions & 0 deletions crates/vm/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEPOSIT_CONTRACT_ADDRESS,
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS,
CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS,
];
Loading