Extend memory gadgets to handle dynamic offset and length#279
Conversation
8b8a7ac to
cc66d5c
Compare
3909ef6 to
c617ddc
Compare
| /// to integer. It handles the "no expansion" feature when length is zero. | ||
| #[derive(Clone, Debug)] | ||
| pub(crate) struct MemoryAddressGadget<F> { | ||
| memory_offset: Cell<F>, |
There was a problem hiding this comment.
memory_offset is starting point of address for expansion ?
There was a problem hiding this comment.
Yes, more precisely, the starting point of address for call_data or return_data specified by caller.
There was a problem hiding this comment.
My understanding of this gadget is that it aims to provide the max used address after a memory access by an opcode that takes offset and length like CALLDATACOPY, CODECOPY, EXTCODECOPY, RETURNDATACOPY. And I think this max address would then be used in the MemoryExpansionGadget to calculate the gas_cost of the possible expansion.
And MemoryAddressGadget returns max_address = 0 when the length = 0 so that no memory expansion is performed in such case, even if the offset is past the current max used address.
There was a problem hiding this comment.
Exactly, thanks for explanation!
This PR is part of #278, which extends memory gadgets to add/extend
MemoryAddressGadget- To handle dynamic offset and length expansion. It's also useful for memory expansion opcode likeCALLDATACOPY.MemoryExpansionGadget- To support multiple expansion size. It's useful for*CALL*which assign 2 memory chunks as expansion targets.It also refactors some frequently used constant and methods. For main changes, please refer to
memory_gadget.rs