Skip to content

Commit

Permalink
opt: remove extcodesize code hashing in ccc (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
lispc authored May 16, 2024
1 parent e5c5522 commit 0d820ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
10 changes: 9 additions & 1 deletion bus-mapping/src/evm/opcodes/extcodesize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ impl Opcode for Extcodesize {
let (code_hash, code_size) = if exists {
(
account.code_hash,
state.code(account.code_hash)?.len().into(),
if cfg!(feature = "scroll") {
debug_assert_eq!(
account.code_size,
state.code(account.code_hash)?.len().into()
);
account.code_size
} else {
state.code(account.code_hash)?.len().into()
},
)
} else {
(H256::zero(), Word::zero())
Expand Down
2 changes: 1 addition & 1 deletion eth-types/src/state_db/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl CodeDB {
// bustmapping do this job
unreachable!()
}
OpcodeId::EXTCODESIZE | OpcodeId::EXTCODECOPY => {
OpcodeId::EXTCODECOPY => {
let code = data.get_code_at(0);
if code.is_none() {
log::warn!("unable to fetch code from step. {step:?}");
Expand Down
11 changes: 1 addition & 10 deletions zkevm-circuits/src/witness/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,12 @@ impl MptUpdates {
MptUpdate::from_rows(key, rows, i, rows_len, old_root, new_root)
})
.collect();
let mpt_updates = MptUpdates {
MptUpdates {
old_root,
new_root,
updates,
..Default::default()
};
// FIXME: we can remove this assert after the code runs a while and everything is ok?
#[cfg(debug_assertions)]
{
let mut rows = rows.to_vec();
rows.sort_by_key(Rw::as_key);
let old_updates = Self::from_rws_with_mock_state_roots(&rows, old_root, new_root);
assert_eq!(old_updates.updates, mpt_updates.updates);
}
mpt_updates
}

pub(crate) fn from_rws_with_mock_state_roots(
Expand Down

0 comments on commit 0d820ac

Please sign in to comment.