Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.
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
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/execution/gasprice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<F: Field> ExecutionGadget<F> for GasPriceGadget<F> {
_: &Call,
step: &ExecStep,
) -> Result<(), Error> {
let gas_price = block.rws.sorted_stack_rw()[0].stack_value();
let gas_price = block.rws[step.rw_indices[1]].stack_value();

self.tx_id
.assign(region, offset, Some(F::from(tx.id as u64)))?;
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/evm_circuit/execution/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<F: Field> ExecutionGadget<F> for OriginGadget<F> {
_: &Call,
step: &ExecStep,
) -> Result<(), Error> {
let origin = block.rws.sorted_stack_rw()[0].stack_value();
let origin = block.rws[step.rw_indices[1]].stack_value();

// Assing TxId.
self.tx_id
Expand Down
42 changes: 0 additions & 42 deletions zkevm-circuits/src/evm_circuit/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,48 +377,6 @@ impl std::ops::Index<(RwTableTag, usize)> for RwMap {
}
}

impl RwMap {
/// These "sorted_xx" methods are used in state circuit
pub fn sorted_memory_rw(&self) -> Vec<Rw> {
let mut sorted = self.0[&RwTableTag::Memory].clone();
sorted.sort_by_key(|x| match x {
Rw::Memory {
call_id,
memory_address,
..
} => (*call_id, *memory_address),
_ => panic!("invalid memory rw"),
});
sorted
}

pub fn sorted_stack_rw(&self) -> Vec<Rw> {
let mut sorted = self.0[&RwTableTag::Stack].clone();
sorted.sort_by_key(|x| match x {
Rw::Stack {
call_id,
stack_pointer,
..
} => (*call_id, *stack_pointer),
_ => panic!("invalid stack rw"),
});
sorted
}

pub fn sorted_storage_rw(&self) -> Vec<Rw> {
let mut sorted = self.0[&RwTableTag::AccountStorage].clone();
sorted.sort_by_key(|x| match x {
Rw::AccountStorage {
account_address,
storage_key,
..
} => (*account_address, *storage_key),
_ => panic!("invalid storage rw"),
});
sorted
}
}

#[derive(Clone, Copy, Debug)]
pub enum Rw {
Start {
Expand Down