Skip to content
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

fix(levm, l1): fix hive tests rpc #2176

Merged
merged 9 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 10 additions & 4 deletions crates/vm/backends/levm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ pub fn generic_system_contract_levm(
U256::zero(),
calldata.into(),
store_wrapper,
CacheDB::new(),
new_state.clone(),
vec![],
None,
)
Expand All @@ -463,9 +463,7 @@ pub fn generic_system_contract_levm(
report.new_state.remove(&system_address);

match report.result {
TxResult::Success => {
new_state.extend(report.new_state.clone());
}
TxResult::Success => {}
Copy link
Contributor

@tomip01 tomip01 Mar 11, 2025

Choose a reason for hiding this comment

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

We were adding the new states in two places. I removed this one and kept the second one

_ => {
return Err(EvmError::Custom(
"ERROR in generic_system_contract_levm(). TX didn't succeed.".to_owned(),
Expand All @@ -474,6 +472,14 @@ pub fn generic_system_contract_levm(
}

// new_state is a CacheDB coming from outside the function
for (address, account) in report.new_state.iter_mut() {
if let Some(existing_account) = new_state.get(address) {
let mut existing_storage = existing_account.storage.clone();
existing_storage.extend(account.storage.clone());
account.storage = existing_storage;
account.info.balance = existing_account.info.balance;
}
}
new_state.extend(report.new_state.clone());

Ok(report)
Expand Down
19 changes: 9 additions & 10 deletions crates/vm/levm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,15 @@ impl VM {
TxKind::Call(address_to) => {
default_touched_accounts.insert(address_to);

let bytecode = get_account_no_push_cache(&cache, db.clone(), address_to)
.info
.bytecode;
let mut substate = Substate {
selfdestruct_set: HashSet::new(),
touched_accounts: default_touched_accounts,
touched_storage_slots: default_touched_storage_slots,
created_accounts: HashSet::new(),
};

let (_is_delegation, _eip7702_gas_consumed, _code_address, bytecode) =
eip7702_get_code(&mut cache, db.clone(), &mut substate, address_to)?;

// CALL tx
let initial_call_frame = CallFrame::new(
Expand All @@ -252,13 +258,6 @@ impl VM {
false,
);

let substate = Substate {
selfdestruct_set: HashSet::new(),
touched_accounts: default_touched_accounts,
touched_storage_slots: default_touched_storage_slots,
created_accounts: HashSet::new(),
};

Ok(Self {
call_frames: vec![initial_call_frame],
db,
Expand Down
Loading