Skip to content

Commit d32705f

Browse files
authored
refactor SameContextGadget:assign_exec_step to include block, call (#1380)
* refactor SameContextGadget:assign_exec_step to include block, call * fix clippy
1 parent 61841f1 commit d32705f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+158
-103
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ impl<F: Field> ExecutionGadget<F> for AddSubGadget<F> {
7676
offset: usize,
7777
block: &Block,
7878
_: &Transaction,
79-
_: &Call,
79+
call: &Call,
8080
step: &ExecStep,
8181
) -> Result<(), Error> {
82-
self.same_context.assign_exec_step(region, offset, step)?;
82+
self.same_context
83+
.assign_exec_step(region, offset, block, call, step)?;
8384

8485
let opcode = step.opcode.unwrap();
8586
let indices = if opcode == OpcodeId::SUB {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ impl<F: Field> ExecutionGadget<F> for AddModGadget<F> {
145145
offset: usize,
146146
block: &Block,
147147
_: &Transaction,
148-
_: &Call,
148+
call: &Call,
149149
step: &ExecStep,
150150
) -> Result<(), Error> {
151-
self.same_context.assign_exec_step(region, offset, step)?;
151+
self.same_context
152+
.assign_exec_step(region, offset, block, call, step)?;
152153

153154
// get stack values
154155
let [mut r, n, b, a] = [3, 2, 1, 0]

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ impl<F: Field> ExecutionGadget<F> for AddressGadget<F> {
6868
call: &Call,
6969
step: &ExecStep,
7070
) -> Result<(), Error> {
71-
self.same_context.assign_exec_step(region, offset, step)?;
71+
self.same_context
72+
.assign_exec_step(region, offset, block, call, step)?;
7273

7374
let address = block.rws[step.rw_indices[1]].stack_value();
7475
debug_assert_eq!(call.callee_address, address.to_address());

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ impl<F: Field> ExecutionGadget<F> for BalanceGadget<F> {
107107
call: &Call,
108108
step: &ExecStep,
109109
) -> Result<(), Error> {
110-
self.same_context.assign_exec_step(region, offset, step)?;
110+
self.same_context
111+
.assign_exec_step(region, offset, block, call, step)?;
111112

112113
let address = block.rws[step.rw_indices[0]].stack_value();
113114
self.address_word

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ impl<F: Field> ExecutionGadget<F> for BitwiseGadget<F> {
8383
offset: usize,
8484
block: &Block,
8585
_: &Transaction,
86-
_: &Call,
86+
call: &Call,
8787
step: &ExecStep,
8888
) -> Result<(), Error> {
89-
self.same_context.assign_exec_step(region, offset, step)?;
89+
self.same_context
90+
.assign_exec_step(region, offset, block, call, step)?;
9091

9192
let [a, b, c] = [step.rw_indices[0], step.rw_indices[1], step.rw_indices[2]]
9293
.map(|idx| block.rws[idx].stack_value());

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

+10-9
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ impl<F: Field> ExecutionGadget<F> for BlockCtxU64Gadget<F> {
8383
offset: usize,
8484
block: &Block,
8585
_: &Transaction,
86-
_: &Call,
86+
call: &Call,
8787
step: &ExecStep,
8888
) -> Result<(), Error> {
8989
self.value_u64
9090
.same_context
91-
.assign_exec_step(region, offset, step)?;
91+
.assign_exec_step(region, offset, block, call, step)?;
9292

9393
let value = block.rws[step.rw_indices[0]].stack_value();
9494

@@ -124,12 +124,12 @@ impl<F: Field> ExecutionGadget<F> for BlockCtxU160Gadget<F> {
124124
offset: usize,
125125
block: &Block,
126126
_: &Transaction,
127-
_: &Call,
127+
call: &Call,
128128
step: &ExecStep,
129129
) -> Result<(), Error> {
130130
self.value_u160
131131
.same_context
132-
.assign_exec_step(region, offset, step)?;
132+
.assign_exec_step(region, offset, block, call, step)?;
133133

134134
let value = block.rws[step.rw_indices[0]].stack_value();
135135

@@ -169,14 +169,14 @@ impl<F: Field> ExecutionGadget<F> for BlockCtxU256Gadget<F> {
169169
offset: usize,
170170
block: &Block,
171171
_: &Transaction,
172-
_: &Call,
172+
call: &Call,
173173
step: &ExecStep,
174174
) -> Result<(), Error> {
175175
log::debug!("BlockCtxU256Gadget assign for {:?}", step.opcode);
176176

177177
self.value_u256
178178
.same_context
179-
.assign_exec_step(region, offset, step)?;
179+
.assign_exec_step(region, offset, block, call, step)?;
180180

181181
let value = block.rws[step.rw_indices[0]].stack_value();
182182

@@ -221,12 +221,13 @@ impl<F: Field> ExecutionGadget<F> for DifficultyGadget<F> {
221221
&self,
222222
region: &mut CachedRegion<'_, '_, F>,
223223
offset: usize,
224-
_block: &Block,
224+
block: &Block,
225225
_: &Transaction,
226-
_: &Call,
226+
call: &Call,
227227
step: &ExecStep,
228228
) -> Result<(), Error> {
229-
self.same_context.assign_exec_step(region, offset, step)
229+
self.same_context
230+
.assign_exec_step(region, offset, block, call, step)
230231
}
231232
}
232233

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ impl<F: Field> ExecutionGadget<F> for BlockHashGadget<F> {
142142
offset: usize,
143143
block: &Block,
144144
tx: &Transaction,
145-
_: &Call,
145+
call: &Call,
146146
step: &ExecStep,
147147
) -> Result<(), Error> {
148-
self.same_context.assign_exec_step(region, offset, step)?;
148+
self.same_context
149+
.assign_exec_step(region, offset, block, call, step)?;
149150

150151
let chain_id = block.chain_id;
151152
let current_block_number = block.context.ctxs[&tx.block_number].number;

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ impl<F: Field> ExecutionGadget<F> for ByteGadget<F> {
9595
offset: usize,
9696
block: &Block,
9797
_: &Transaction,
98-
_: &Call,
98+
call: &Call,
9999
step: &ExecStep,
100100
) -> Result<(), Error> {
101-
self.same_context.assign_exec_step(region, offset, step)?;
101+
self.same_context
102+
.assign_exec_step(region, offset, block, call, step)?;
102103

103104
// Inputs/Outputs
104105
let index = block.rws[step.rw_indices[0]].stack_value().to_le_bytes();

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ impl<F: Field> ExecutionGadget<F> for CallDataCopyGadget<F> {
178178
call: &Call,
179179
step: &ExecStep,
180180
) -> Result<(), Error> {
181-
self.same_context.assign_exec_step(region, offset, step)?;
181+
self.same_context
182+
.assign_exec_step(region, offset, block, call, step)?;
182183

183184
let [memory_offset, data_offset, length] =
184185
[step.rw_indices[0], step.rw_indices[1], step.rw_indices[2]]

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ impl<F: Field> ExecutionGadget<F> for CallDataLoadGadget<F> {
268268
call: &Call,
269269
step: &ExecStep,
270270
) -> Result<(), Error> {
271-
self.same_context.assign_exec_step(region, offset, step)?;
271+
self.same_context
272+
.assign_exec_step(region, offset, block, call, step)?;
272273

273274
// Assign to the buffer reader gadget.
274275
let (src_id, call_data_offset, call_data_length) = if call.is_root {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ impl<F: Field> ExecutionGadget<F> for CallDataSizeGadget<F> {
6565
offset: usize,
6666
block: &Block,
6767
_tx: &Transaction,
68-
_call: &Call,
68+
call: &Call,
6969
step: &ExecStep,
7070
) -> Result<(), Error> {
71-
self.same_context.assign_exec_step(region, offset, step)?;
71+
self.same_context
72+
.assign_exec_step(region, offset, block, call, step)?;
7273

7374
let call_data_size = block.rws[step.rw_indices[1]].stack_value();
7475

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ impl<F: Field> ExecutionGadget<F> for CallerGadget<F> {
6666
offset: usize,
6767
block: &Block,
6868
_: &Transaction,
69-
_: &Call,
69+
call: &Call,
7070
step: &ExecStep,
7171
) -> Result<(), Error> {
72-
self.same_context.assign_exec_step(region, offset, step)?;
72+
self.same_context
73+
.assign_exec_step(region, offset, block, call, step)?;
7374

7475
let caller = block.rws[step.rw_indices[1]].stack_value();
7576

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ impl<F: Field> ExecutionGadget<F> for CallValueGadget<F> {
6565
offset: usize,
6666
block: &Block,
6767
_: &Transaction,
68-
_: &Call,
68+
call: &Call,
6969
step: &ExecStep,
7070
) -> Result<(), Error> {
71-
self.same_context.assign_exec_step(region, offset, step)?;
71+
self.same_context
72+
.assign_exec_step(region, offset, block, call, step)?;
7273

7374
let call_value = block.rws[step.rw_indices[1]].stack_value();
7475

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ impl<F: Field> ExecutionGadget<F> for ChainIdGadget<F> {
6262
offset: usize,
6363
block: &Block,
6464
_: &Transaction,
65-
_: &Call,
65+
call: &Call,
6666
step: &ExecStep,
6767
) -> Result<(), Error> {
68-
self.same_context.assign_exec_step(region, offset, step)?;
68+
self.same_context
69+
.assign_exec_step(region, offset, block, call, step)?;
6970

7071
let chain_id = block.rws[step.rw_indices[0]].stack_value().as_u64();
7172
self.chain_id

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ impl<F: Field> ExecutionGadget<F> for CodeCopyGadget<F> {
148148
call: &Call,
149149
step: &ExecStep,
150150
) -> Result<(), Error> {
151-
self.same_context.assign_exec_step(region, offset, step)?;
151+
self.same_context
152+
.assign_exec_step(region, offset, block, call, step)?;
152153

153154
// 1. `dest_offset` is the bytes offset in the memory where we start to
154155
// write.

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ impl<F: Field> ExecutionGadget<F> for CodesizeGadget<F> {
7171
offset: usize,
7272
block: &Block,
7373
_transaction: &Transaction,
74-
_call: &Call,
74+
call: &Call,
7575
step: &ExecStep,
7676
) -> Result<(), Error> {
77-
self.same_context.assign_exec_step(region, offset, step)?;
77+
self.same_context
78+
.assign_exec_step(region, offset, block, call, step)?;
7879

7980
let codesize = block.rws[step.rw_indices[0]].stack_value().as_u64();
8081

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ impl<F: Field> ExecutionGadget<F> for ComparatorGadget<F> {
110110
offset: usize,
111111
block: &Block,
112112
_: &Transaction,
113-
_: &Call,
113+
call: &Call,
114114
step: &ExecStep,
115115
) -> Result<(), Error> {
116-
self.same_context.assign_exec_step(region, offset, step)?;
116+
self.same_context
117+
.assign_exec_step(region, offset, block, call, step)?;
117118

118119
let opcode = step.opcode.unwrap();
119120

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ impl<F: Field> ExecutionGadget<F> for DupGadget<F> {
6060
offset: usize,
6161
block: &Block,
6262
_: &Transaction,
63-
_: &Call,
63+
call: &Call,
6464
step: &ExecStep,
6565
) -> Result<(), Error> {
66-
self.same_context.assign_exec_step(region, offset, step)?;
66+
self.same_context
67+
.assign_exec_step(region, offset, block, call, step)?;
6768

6869
let value = block.rws[step.rw_indices[0]].stack_value();
6970
self.value.assign(region, offset, region.word_rlc(value))?;

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ impl<F: Field> ExecutionGadget<F> for ExponentiationGadget<F> {
187187
offset: usize,
188188
block: &Block,
189189
_tx: &Transaction,
190-
_call: &Call,
190+
call: &Call,
191191
step: &ExecStep,
192192
) -> Result<(), Error> {
193-
self.same_context.assign_exec_step(region, offset, step)?;
193+
self.same_context
194+
.assign_exec_step(region, offset, block, call, step)?;
194195

195196
let [base, exponent, exponentiation] =
196197
[step.rw_indices[0], step.rw_indices[1], step.rw_indices[2]]

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
175175
call: &Call,
176176
step: &ExecStep,
177177
) -> Result<(), Error> {
178-
self.same_context.assign_exec_step(region, offset, step)?;
178+
self.same_context
179+
.assign_exec_step(region, offset, block, call, step)?;
179180

180181
let [external_address, memory_offset, code_offset, memory_length] =
181182
[0, 1, 2, 3].map(|idx| block.rws[step.rw_indices[idx]].stack_value());

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ impl<F: Field> ExecutionGadget<F> for ExtcodehashGadget<F> {
9999
call: &Call,
100100
step: &ExecStep,
101101
) -> Result<(), Error> {
102-
self.same_context.assign_exec_step(region, offset, step)?;
102+
self.same_context
103+
.assign_exec_step(region, offset, block, call, step)?;
103104

104105
let address = block.rws[step.rw_indices[0]].stack_value();
105106
self.address_word

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ impl<F: Field> ExecutionGadget<F> for ExtcodesizeGadget<F> {
120120
call: &Call,
121121
step: &ExecStep,
122122
) -> Result<(), Error> {
123-
self.same_context.assign_exec_step(region, offset, step)?;
123+
self.same_context
124+
.assign_exec_step(region, offset, block, call, step)?;
124125

125126
let address = block.rws[step.rw_indices[0]].stack_value();
126127
self.address_word

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ impl<F: Field> ExecutionGadget<F> for GasGadget<F> {
6464
&self,
6565
region: &mut CachedRegion<'_, '_, F>,
6666
offset: usize,
67-
_block: &Block,
67+
block: &Block,
6868
_transaction: &Transaction,
69-
_call: &Call,
69+
call: &Call,
7070
step: &ExecStep,
7171
) -> Result<(), Error> {
72-
self.same_context.assign_exec_step(region, offset, step)?;
72+
self.same_context
73+
.assign_exec_step(region, offset, block, call, step)?;
7374

7475
// The GAS opcode takes into account the reduction of gas available due
7576
// to the instruction itself.

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<F: Field> ExecutionGadget<F> for GasPriceGadget<F> {
6868
offset: usize,
6969
block: &Block,
7070
tx: &Transaction,
71-
_: &Call,
71+
call: &Call,
7272
step: &ExecStep,
7373
) -> Result<(), Error> {
7474
let gas_price = block.rws[step.rw_indices[1]].stack_value();
@@ -79,7 +79,8 @@ impl<F: Field> ExecutionGadget<F> for GasPriceGadget<F> {
7979
self.gas_price
8080
.assign(region, offset, region.word_rlc(gas_price))?;
8181

82-
self.same_context.assign_exec_step(region, offset, step)?;
82+
self.same_context
83+
.assign_exec_step(region, offset, block, call, step)?;
8384

8485
Ok(())
8586
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ impl<F: Field> ExecutionGadget<F> for IsZeroGadget<F> {
5858
offset: usize,
5959
block: &Block,
6060
_: &Transaction,
61-
_: &Call,
61+
call: &Call,
6262
step: &ExecStep,
6363
) -> Result<(), Error> {
64-
self.same_context.assign_exec_step(region, offset, step)?;
64+
self.same_context
65+
.assign_exec_step(region, offset, block, call, step)?;
6566

6667
let value = block.rws[step.rw_indices[0]].stack_value();
6768
let value = region.word_rlc(value);

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ impl<F: Field> ExecutionGadget<F> for JumpGadget<F> {
6565
offset: usize,
6666
block: &Block,
6767
_: &Transaction,
68-
_: &Call,
68+
call: &Call,
6969
step: &ExecStep,
7070
) -> Result<(), Error> {
71-
self.same_context.assign_exec_step(region, offset, step)?;
71+
self.same_context
72+
.assign_exec_step(region, offset, block, call, step)?;
7273

7374
let destination = block.rws[step.rw_indices[0]].stack_value();
7475
self.destination.assign(

0 commit comments

Comments
 (0)