Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit 8dca7b4

Browse files
committed
updated broken indices
1 parent 4a6de58 commit 8dca7b4

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

zkevm-circuits/src/evm_circuit/execution/end_tx.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
MulWordByU64Gadget,
1212
},
1313
tx::EndTxHelperGadget,
14-
CachedRegion, Cell,
14+
CachedRegion, Cell, StepRws,
1515
},
1616
witness::{Block, Call, ExecStep, Transaction},
1717
},
@@ -152,9 +152,14 @@ impl<F: Field> ExecutionGadget<F> for EndTxGadget<F> {
152152
step: &ExecStep,
153153
) -> Result<(), Error> {
154154
let gas_used = tx.gas() - step.gas_left;
155-
let (refund, _) = block.get_rws(step, 2).tx_refund_value_pair();
156-
let (caller_balance, caller_balance_prev) = block.get_rws(step, 3).account_balance_pair();
157-
let (coinbase_code_hash_prev, _) = block.get_rws(step, 4).account_codehash_pair();
155+
156+
let mut rws = StepRws::new(block, step);
157+
158+
rws.offset_add(2);
159+
160+
let (refund, _) = rws.next().tx_refund_value_pair();
161+
let (caller_balance, caller_balance_prev) = rws.next().account_balance_pair();
162+
let (coinbase_code_hash_prev, _) = rws.next().account_codehash_pair();
158163

159164
self.tx_id
160165
.assign(region, offset, Value::known(F::from(tx.id)))?;
@@ -209,16 +214,10 @@ impl<F: Field> ExecutionGadget<F> for EndTxGadget<F> {
209214
self.coinbase_code_hash_is_zero
210215
.assign_u256(region, offset, coinbase_code_hash_prev)?;
211216
if !coinbase_reward.is_zero() {
212-
let coinbase_balance_pair = block
213-
.get_rws(
214-
step,
215-
if coinbase_code_hash_prev.is_zero() {
216-
6
217-
} else {
218-
5
219-
},
220-
)
221-
.account_balance_pair();
217+
if coinbase_code_hash_prev.is_zero() {
218+
rws.offset_add(1)
219+
}
220+
let coinbase_balance_pair = rws.next().account_balance_pair();
222221
self.coinbase_reward.assign(
223222
region,
224223
offset,

zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
204204
call.is_persistent,
205205
)?;
206206

207-
rws.offset_add(4);
207+
rws.offset_add(3);
208208

209209
let (_, is_warm) = rws.next().tx_access_list_value_pair();
210210
self.is_warm

zkevm-circuits/src/evm_circuit/execution/extcodehash.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
constraint_builder::{
99
EVMConstraintBuilder, ReversionInfo, StepStateTransition, Transition::Delta,
1010
},
11-
select, AccountAddress, CachedRegion, Cell,
11+
select, AccountAddress, CachedRegion, Cell, StepRws,
1212
},
1313
witness::{Block, Call, ExecStep, Transaction},
1414
},
@@ -106,7 +106,10 @@ impl<F: Field> ExecutionGadget<F> for ExtcodehashGadget<F> {
106106
) -> Result<(), Error> {
107107
self.same_context.assign_exec_step(region, offset, step)?;
108108

109-
let address = block.get_rws(step, 0).stack_value();
109+
let mut rws = StepRws::new(block, step);
110+
111+
let address = rws.next().stack_value();
112+
110113
self.address_word.assign_u256(region, offset, address)?;
111114

112115
self.tx_id
@@ -118,11 +121,13 @@ impl<F: Field> ExecutionGadget<F> for ExtcodehashGadget<F> {
118121
call.is_persistent,
119122
)?;
120123

121-
let (_, is_warm) = block.get_rws(step, 4).tx_access_list_value_pair();
124+
rws.offset_add(3);
125+
126+
let (_, is_warm) = rws.next().tx_access_list_value_pair();
122127
self.is_warm
123128
.assign(region, offset, Value::known(F::from(is_warm as u64)))?;
124129

125-
let code_hash = block.get_rws(step, 5).account_codehash_pair().0;
130+
let code_hash = rws.next().account_codehash_pair().0;
126131
self.code_hash.assign_u256(region, offset, code_hash)?;
127132

128133
Ok(())

zkevm-circuits/src/evm_circuit/execution/logs.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ impl<F: Field> ExecutionGadget<F> for LogGadget<F> {
203203

204204
let mut rws = StepRws::new(block, step);
205205

206-
let [memory_start, msize] = [0, 1].map(|_| rws.next().stack_value());
206+
let memory_start = rws.next().stack_value();
207+
let msize = rws.next().stack_value();
208+
207209
let memory_address = self
208210
.memory_address
209211
.assign(region, offset, memory_start, msize)?;
@@ -223,8 +225,9 @@ impl<F: Field> ExecutionGadget<F> for LogGadget<F> {
223225
// It takes 6 + is_persistent reads or writes to reach the topic stack write section.
224226
// Each topic takes at least 1 stack read. They take an additional tx log write if the
225227
// call is persistent.
226-
rws.offset_add(6 + is_persistent + topic * (1 + is_persistent));
227-
rws.next().stack_value()
228+
block
229+
.get_rws(step, 6 + is_persistent + topic * (1 + is_persistent))
230+
.stack_value()
228231
});
229232
for i in 0..4 {
230233
let topic = topics.next();

0 commit comments

Comments
 (0)