Skip to content

Commit

Permalink
fix index of storage keys in access list (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
noel2004 authored Mar 11, 2024
1 parent cc0bc9b commit a0df944
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions bus-mapping/src/evm/opcodes/begin_end_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ fn add_access_list_storage_key_copy_event(
let rw_counter_start = state.block_ctx.rwc;

// Build copy access list including addresses and storage keys.
let mut sks_acc: usize = 0;
let access_list = state
.tx
.access_list
Expand All @@ -886,9 +887,9 @@ fn add_access_list_storage_key_copy_event(
.map(|item| {
item.storage_keys
.iter()
.enumerate()
.map(|(idx, &sk)| {
.map(|&sk| {
let sk = sk.to_word();
sks_acc += 1;

// Add RW write operations for access list address storage keys
// (will lookup in copy circuit).
Expand All @@ -910,7 +911,7 @@ fn add_access_list_storage_key_copy_event(
Ok(CopyAccessList::new(
item.address,
sk,
idx as u64,
sks_acc as u64,
is_warm_prev,
))
})
Expand Down
6 changes: 4 additions & 2 deletions zkevm-circuits/src/witness/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl Transaction {
let mut assignments: Vec<[Value<F>; 5]> = vec![];

if self.access_list.is_some() {
let mut sks_acc: usize = 0;
for (al_idx, al) in self.access_list.as_ref().unwrap().0.iter().enumerate() {
assignments.push([
Value::known(F::from(self.id as u64)),
Expand All @@ -429,11 +430,12 @@ impl Transaction {
Value::known(al.address.to_scalar().unwrap()),
]);

for (sk_idx, sk) in al.storage_keys.iter().enumerate() {
for sk in al.storage_keys.iter() {
sks_acc += 1;
assignments.push([
Value::known(F::from(self.id as u64)),
Value::known(F::from(TxContextFieldTag::AccessListStorageKey as u64)),
Value::known(F::from(sk_idx as u64)),
Value::known(F::from(sks_acc as u64)),
rlc_be_bytes(&sk.to_fixed_bytes(), challenges.evm_word()),
Value::known(al.address.to_scalar().unwrap()),
]);
Expand Down

0 comments on commit a0df944

Please sign in to comment.