111 uint64_t read_index_upper_bound =
min(
static_cast<uint64_t
>(
offset) + copy_size,
context.get_parent_cd_size());
112 uint64_t read_addr_upper_bound = read_index_upper_bound +
context.get_parent_cd_addr();
114 uint64_t write_addr_upper_bound =
static_cast<uint64_t
>(
dst_addr) + copy_size;
117 bool src_reads_exceed_mem =
gt.gt(read_addr_upper_bound, AVM_MEMORY_SIZE);
118 bool write_out_of_range =
gt.gt(write_addr_upper_bound, AVM_MEMORY_SIZE);
121 if (write_out_of_range) {
124 format(
"Attempting to write out of bounds memory: write_addr_upper_bound = ", write_addr_upper_bound));
128 uint64_t clamped_read_index_upper_bound =
129 src_reads_exceed_mem ? (AVM_MEMORY_SIZE -
context.get_parent_cd_addr()) : read_index_upper_bound;
133 if (
gt.gt(clamped_read_index_upper_bound,
static_cast<uint64_t
>(
offset))) {
134 uint32_t effective_reads =
static_cast<uint32_t
>(clamped_read_index_upper_bound -
offset);
135 padded_calldata =
context.get_calldata(
offset, effective_reads);
137 padded_calldata.resize(copy_size, MemoryValue::from<FF>(0));
140 for (uint32_t i = 0; i < copy_size; i++) {
141 memory.set(
dst_addr + i, MemoryValue::from<FF>(padded_calldata[i].as_ff()));
161 uint64_t read_index_upper_bound =
min(
static_cast<uint64_t
>(
offset) + copy_size,
context.get_last_rd_size());
162 uint64_t read_addr_upper_bound = read_index_upper_bound +
context.get_last_rd_addr();
164 uint64_t write_addr_upper_bound =
static_cast<uint64_t
>(
dst_addr) + copy_size;
167 bool src_reads_exceed_mem =
gt.gt(read_addr_upper_bound, AVM_MEMORY_SIZE);
168 bool write_out_of_range =
gt.gt(write_addr_upper_bound, AVM_MEMORY_SIZE);
171 if (write_out_of_range) {
174 format(
"Attempting to write out of bounds memory: write_addr_upper_bound = ", write_addr_upper_bound));
178 uint64_t clamped_read_index_upper_bound =
179 src_reads_exceed_mem ? (AVM_MEMORY_SIZE -
context.get_last_rd_addr()) : read_index_upper_bound;
183 if (
gt.gt(clamped_read_index_upper_bound,
static_cast<uint64_t
>(
offset))) {
184 uint32_t effective_reads =
static_cast<uint32_t
>(clamped_read_index_upper_bound -
offset);
185 padded_returndata =
context.get_returndata(
offset, effective_reads);
187 padded_returndata.resize(copy_size, MemoryValue::from<FF>(0));
190 for (uint32_t i = 0; i < copy_size; i++) {
191 memory.set(
dst_addr + i, MemoryValue::from<FF>(padded_returndata[i].as_ff()));
void rd_copy(ContextInterface &context, uint32_t copy_size, uint32_t offset, MemoryAddress dst_addr) override
Copies returndata from the last executed context to the dst_addr.
void cd_copy(ContextInterface &context, uint32_t copy_size, uint32_t offset, MemoryAddress dst_addr) override
Writes calldata into dst_addr. There is slight difference in how enqueued and nested contexts are han...