Skip to content

Commit

Permalink
Read caller's CalleeAddress instead of CallerAddress for new cont…
Browse files Browse the repository at this point in the history
…ext's caller (privacy-scaling-explorations#605)

* fix: `CalleeAddress` instead of `CallerAddress`

* refactor: rename `caller_address` to `current_address`

Co-authored-by: z2trillion <[email protected]>
  • Loading branch information
han0110 and z2trillion authored Jul 6, 2022
1 parent 1dc1c4b commit ec63120
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bus-mapping/src/evm/opcodes/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Opcode for Call {
(current_call.is_persistent as u64).into(),
),
(
CallContextField::CallerAddress,
CallContextField::CalleeAddress,
current_call.address.to_word(),
),
(
Expand Down
18 changes: 9 additions & 9 deletions zkevm-circuits/src/evm_circuit/execution/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(crate) struct CallGadget<F> {
opcode: Cell<F>,
tx_id: Cell<F>,
reversion_info: ReversionInfo<F>,
caller_address: Cell<F>,
current_address: Cell<F>,
is_static: Cell<F>,
depth: Cell<F>,
gas: Word<F>,
Expand Down Expand Up @@ -90,8 +90,8 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {

let tx_id = cb.call_context(None, CallContextFieldTag::TxId);
let mut reversion_info = cb.reversion_info(None);
let [caller_address, is_static, depth] = [
CallContextFieldTag::CallerAddress,
let [current_address, is_static, depth] = [
CallContextFieldTag::CalleeAddress,
CallContextFieldTag::IsStatic,
CallContextFieldTag::Depth,
]
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {
});
let transfer = TransferGadget::construct(
cb,
caller_address.expr(),
current_address.expr(),
callee_address.clone(),
value.clone(),
&mut callee_reversion_info,
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {
(CallContextFieldTag::CallerId, cb.curr.state.call_id.expr()),
(CallContextFieldTag::TxId, tx_id.expr()),
(CallContextFieldTag::Depth, depth.expr() + 1.expr()),
(CallContextFieldTag::CallerAddress, caller_address.expr()),
(CallContextFieldTag::CallerAddress, current_address.expr()),
(CallContextFieldTag::CalleeAddress, callee_address),
(CallContextFieldTag::CallDataOffset, cd_address.offset()),
(CallContextFieldTag::CallDataLength, cd_address.length()),
Expand Down Expand Up @@ -305,7 +305,7 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {
opcode,
tx_id,
reversion_info,
caller_address,
current_address,
is_static,
depth,
gas: gas_word,
Expand Down Expand Up @@ -339,7 +339,7 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {
call: &Call,
step: &ExecStep,
) -> Result<(), Error> {
let [tx_id, caller_address, is_static, depth, callee_rw_counter_end_of_reversion, callee_is_persistent] =
let [tx_id, current_address, is_static, depth, callee_rw_counter_end_of_reversion, callee_is_persistent] =
[
step.rw_indices[0],
step.rw_indices[3],
Expand Down Expand Up @@ -383,8 +383,8 @@ impl<F: Field> ExecutionGadget<F> for CallGadget<F> {
call.rw_counter_end_of_reversion,
call.is_persistent,
)?;
self.caller_address
.assign(region, offset, caller_address.to_scalar())?;
self.current_address
.assign(region, offset, current_address.to_scalar())?;
self.is_static
.assign(region, offset, Some(F::from(is_static.low_u64())))?;
self.depth
Expand Down

0 comments on commit ec63120

Please sign in to comment.