Fix to handle successful run with Uint64 overflow for multiple opcodes#1317
Conversation
ed255
left a comment
There was a problem hiding this comment.
First pass review, so far I've reviewed:
- common_gadget
- circuits: jumpi, extcodecopy, codecopy, error_invalid_jump
ed255
left a comment
There was a problem hiding this comment.
Review completed: In general everything looks correct! My only notes are about a redundant constraint, and a few IsZero gadget that seem to be unused. I think they should be used: the Lt check is only correct if the value uses the specified number of bytes, and that's what the IsZero gadget inside of WordByteRangeGadget can check. So probably the logic should be something like:
let src_addr = select::expr(
code_offset.overflow(),
code_size.expr(),
select::expr(
code_offset.lt_cap(),
code_offset.valid_value(),
code_size.expr()),
);
Thanks for review. I will try to resolve merge conflicts and review comments. Thanks. |
…-cases-with-overflow-input-params
This reverts commit c17ba9d.
|
LGTM Amazing work @silathdiir Also I see that this PR also activates e.g. |
| from_bytes::expr(&self.original.cells[..VALID_BYTES]) | ||
| } | ||
|
|
||
| pub(crate) fn within_range(&self) -> Expression<F> { |
There was a problem hiding this comment.
Nitpick: maybe is more readable if we name not_overflow() instead valid_range(), overflow/not_overflow is more dualistic over the same thing.
There was a problem hiding this comment.
Rename within_range to not_overflow in commit 11f8eb3.
| for (i, byte) in calldata_bytes.iter_mut().enumerate() { | ||
| if call.is_root { | ||
| // Fetch from tx call data. | ||
| if src_addr.checked_add(i as u64).unwrap() < tx.call_data_length as u64 { |
There was a problem hiding this comment.
Maybe better just adding instead using checked_add with an unwrap later?
There was a problem hiding this comment.
Replace check_add and unwrap with just adding in commit 594553d.
| } | ||
| } else { | ||
| // Fetch from memory. | ||
| if src_addr.checked_add(i as u64).unwrap() |
There was a problem hiding this comment.
Replace check_add and unwrap with just adding in commit 594553d.
…-cases-with-overflow-input-params
…-cases-with-overflow-input-params
…` function (only leave it in `construct`).
… is Uint64 overflow` in `jumpi`.
Seems that |
It may be caused by |
Head branch was pushed to by a user without write access
Description
Fix successful run cases with Uint64 overflow for multiple opcodes.
Add
WordByteRangeGadgetto constrain if Word is within the specified byte range.Add
WordByteCapGadgetto constrain if Word is within the specified byte range (implemented by WordByteRangeGadget) and less than a maximum cap (used to replace a WordByteRangeGadget and LtGadget).Fix bus-mapping and zkevm-circuits to handle overflow cases. And add unit-tests for these cases.
TODO: will try to handle memory offset overflow with zero length in another PR (try to rebase for this local PR scroll-tech#393) and related issue #1301.
Rationale
Reference detailed code in
go-etherumas:. BLOCKHASH
. CALLDATALOAD
. CALLDATACOPY
. CODECOPY
. EXTCODECOPY
. JUMPI
Issue Link
Close #1276
Type of change
How Has This Been Tested?
Add unit-test cases for Uint64 overflow values.