Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 554bdcf

Browse files
authored
fix calldatasize inside create (#753)
* fix calldatasize inside create * fix call.call_data_len * testing
1 parent 8e09a8d commit 554bdcf

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

bus-mapping/src/circuit_input_builder/transaction.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ impl TransactionContext {
9393
reversion_groups: Vec::new(),
9494
l1_fee: geth_trace.l1_fee,
9595
};
96-
tx_ctx.push_call_ctx(0, eth_tx.input.to_vec());
96+
tx_ctx.push_call_ctx(
97+
0,
98+
if eth_tx.to.is_none() {
99+
Vec::new()
100+
} else {
101+
eth_tx.input.to_vec()
102+
},
103+
);
97104

98105
Ok(tx_ctx)
99106
}
@@ -344,7 +351,7 @@ impl Transaction {
344351
code_hash,
345352
depth: 1,
346353
value: eth_tx.value,
347-
call_data_length: eth_tx.input.len().try_into().unwrap(),
354+
call_data_length: 0,
348355
..Default::default()
349356
}
350357
};

bus-mapping/src/evm/opcodes.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,7 @@ pub fn gen_begin_tx_ops(
754754
CallContextField::CallDataOffset,
755755
call.call_data_offset.into(),
756756
),
757-
(
758-
CallContextField::CallDataLength,
759-
state.tx.input.len().into(),
760-
),
757+
(CallContextField::CallDataLength, 0.into()),
761758
(CallContextField::Value, call.value),
762759
(CallContextField::IsStatic, (call.is_static as usize).into()),
763760
(CallContextField::LastCalleeId, 0.into()),

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
412412
call_callee_address.expr(),
413413
),
414414
(CallContextFieldTag::CallDataOffset, 0.expr()),
415-
(
416-
CallContextFieldTag::CallDataLength,
417-
tx_call_data_length.expr(),
418-
),
415+
(CallContextFieldTag::CallDataLength, 0.expr()),
419416
(CallContextFieldTag::Value, tx_value.expr()),
420417
(CallContextFieldTag::IsStatic, 0.expr()),
421418
(CallContextFieldTag::LastCalleeId, 0.expr()),
@@ -1236,6 +1233,7 @@ mod test {
12361233
PUSH1(0)
12371234
MSTORE
12381235

1236+
CALLDATASIZE
12391237
PUSH1(2)
12401238
PUSH1(0)
12411239
RETURN

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,14 @@ impl<F: Field> ExecutionGadget<F> for CallDataCopyGadget<F> {
194194

195195
// Call data length and call data offset
196196
let (call_data_length, call_data_offset) = if call.is_root {
197-
(tx.call_data_length as u64, 0_u64)
197+
(
198+
if tx.is_create {
199+
0
200+
} else {
201+
tx.call_data_length as u64
202+
},
203+
0_u64,
204+
)
198205
} else {
199206
(call.call_data_length, call.call_data_offset)
200207
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ mod test {
835835
PUSH10(memory_value)
836836
PUSH1(memory_address)
837837
MSTORE
838+
CALLDATASIZE
838839
PUSH2(5)
839840
PUSH2(32u64 - u64::try_from(memory_bytes.len()).unwrap())
840841
};

0 commit comments

Comments
 (0)