ethereum.forks.london.vm.instructions.systemethereum.forks.arrow_glacier.vm.instructions.system
Ethereum Virtual Machine (EVM) System Instructions.
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Implementations of the EVM system related instructions.
generic_create ¶
Core logic used by the CREATE* family of opcodes.
def generic_create(evm: Evm, endowment: U256, contract_address: Address, memory_start_position: U256, memory_size: U256) -> None:
| 63 | <snip> |
|---|---|
| 66 | # This import causes a circular import error |
| 67 | # if it's not moved inside this method |
| 68 | from ...vm.interpreter import STACK_DEPTH_LIMIT, process_create_message |
| 69 | |
| 70 | call_data = memory_read_bytes( |
| 71 | evm.memory, memory_start_position, memory_size |
| 72 | ) |
| 73 | |
| 74 | create_message_gas = max_message_call_gas(Uint(evm.gas_left)) |
| 75 | evm.gas_left -= create_message_gas |
| 76 | if evm.message.is_static: |
| 77 | raise WriteInStaticContext |
| 78 | evm.return_data = b"" |
| 79 | |
| 80 | sender_address = evm.message.current_target |
| 81 | sender = get_account(evm.message.tx_env.state, sender_address) |
| 82 | |
| 83 | if ( |
| 84 | sender.balance < endowment |
| 85 | or sender.nonce == Uint(2**64 - 1) |
| 86 | or evm.message.depth + Uint(1) > STACK_DEPTH_LIMIT |
| 87 | ): |
| 88 | evm.gas_left += create_message_gas |
| 89 | push(evm.stack, U256(0)) |
| 90 | return |
| 91 | |
| 92 | evm.accessed_addresses.add(contract_address) |
| 93 | |
| 94 | if account_has_code_or_nonce( |
| 95 | evm.message.tx_env.state, contract_address |
| 96 | ) or account_has_storage(evm.message.tx_env.state, contract_address): |
| 97 | increment_nonce(evm.message.tx_env.state, evm.message.current_target) |
| 98 | push(evm.stack, U256(0)) |
| 99 | return |
| 100 | |
| 101 | increment_nonce(evm.message.tx_env.state, evm.message.current_target) |
| 102 | |
| 103 | child_message = Message( |
| 104 | block_env=evm.message.block_env, |
| 105 | tx_env=evm.message.tx_env, |
| 106 | caller=evm.message.current_target, |
| 107 | target=Bytes0(), |
| 108 | gas=create_message_gas, |
| 109 | value=endowment, |
| 110 | data=b"", |
| 111 | code=call_data, |
| 112 | current_target=contract_address, |
| 113 | depth=evm.message.depth + Uint(1), |
| 114 | code_address=None, |
| 115 | should_transfer_value=True, |
| 116 | is_static=False, |
| 117 | accessed_addresses=evm.accessed_addresses.copy(), |
| 118 | accessed_storage_keys=evm.accessed_storage_keys.copy(), |
| 119 | parent_evm=evm, |
| 120 | ) |
| 121 | child_evm = process_create_message(child_message) |
| 122 | |
| 123 | if child_evm.error: |
| 124 | incorporate_child_on_error(evm, child_evm) |
| 125 | evm.return_data = child_evm.output |
| 126 | push(evm.stack, U256(0)) |
| 127 | else: |
| 128 | incorporate_child_on_success(evm, child_evm) |
| 129 | evm.return_data = b"" |
| 130 | push(evm.stack, U256.from_be_bytes(child_evm.message.current_target)) |
create ¶
Creates a new account with associated code.
Parameters
evm : The current EVM frame.
def create(evm: Evm) -> None:
| 134 | <snip> |
|---|---|
| 143 | # STACK |
| 144 | endowment = pop(evm.stack) |
| 145 | memory_start_position = pop(evm.stack) |
| 146 | memory_size = pop(evm.stack) |
| 147 | |
| 148 | # GAS |
| 149 | extend_memory = calculate_gas_extend_memory( |
| 150 | evm.memory, [(memory_start_position, memory_size)] |
| 151 | ) |
| 152 | |
| 153 | charge_gas(evm, GasCosts.OPCODE_CREATE_BASE + extend_memory.cost) |
| 154 | |
| 155 | # OPERATION |
| 156 | evm.memory += b"\x00" * extend_memory.expand_by |
| 157 | contract_address = compute_contract_address( |
| 158 | evm.message.current_target, |
| 159 | get_account( |
| 160 | evm.message.tx_env.state, evm.message.current_target |
| 161 | ).nonce, |
| 162 | ) |
| 163 | |
| 164 | generic_create( |
| 165 | evm, endowment, contract_address, memory_start_position, memory_size |
| 166 | ) |
| 167 | |
| 168 | # PROGRAM COUNTER |
| 169 | evm.pc += Uint(1) |
create2 ¶
Creates a new account with associated code.
It's similar to the CREATE opcode except that the address of the new account depends on the init_code instead of the nonce of sender.
Parameters
evm : The current EVM frame.
def create2(evm: Evm) -> None:
| 173 | <snip> |
|---|---|
| 185 | # STACK |
| 186 | endowment = pop(evm.stack) |
| 187 | memory_start_position = pop(evm.stack) |
| 188 | memory_size = pop(evm.stack) |
| 189 | salt = pop(evm.stack).to_be_bytes32() |
| 190 | |
| 191 | # GAS |
| 192 | extend_memory = calculate_gas_extend_memory( |
| 193 | evm.memory, [(memory_start_position, memory_size)] |
| 194 | ) |
| 195 | call_data_words = ceil32(Uint(memory_size)) // Uint(32) |
| 196 | charge_gas( |
| 197 | evm, |
| 198 | GasCosts.OPCODE_CREATE_BASE |
| 199 | + GasCosts.OPCODE_KECCAK256_PER_WORD * call_data_words |
| 200 | + extend_memory.cost, |
| 201 | ) |
| 202 | |
| 203 | # OPERATION |
| 204 | evm.memory += b"\x00" * extend_memory.expand_by |
| 205 | contract_address = compute_create2_contract_address( |
| 206 | evm.message.current_target, |
| 207 | salt, |
| 208 | memory_read_bytes(evm.memory, memory_start_position, memory_size), |
| 209 | ) |
| 210 | |
| 211 | generic_create( |
| 212 | evm, endowment, contract_address, memory_start_position, memory_size |
| 213 | ) |
| 214 | |
| 215 | # PROGRAM COUNTER |
| 216 | evm.pc += Uint(1) |
return_ ¶
Halts execution returning output data.
Parameters
evm : The current EVM frame.
def return_(evm: Evm) -> None:
| 220 | <snip> |
|---|---|
| 229 | # STACK |
| 230 | memory_start_position = pop(evm.stack) |
| 231 | memory_size = pop(evm.stack) |
| 232 | |
| 233 | # GAS |
| 234 | extend_memory = calculate_gas_extend_memory( |
| 235 | evm.memory, [(memory_start_position, memory_size)] |
| 236 | ) |
| 237 | |
| 238 | charge_gas(evm, GasCosts.ZERO + extend_memory.cost) |
| 239 | |
| 240 | # OPERATION |
| 241 | evm.memory += b"\x00" * extend_memory.expand_by |
| 242 | evm.output = memory_read_bytes( |
| 243 | evm.memory, memory_start_position, memory_size |
| 244 | ) |
| 245 | |
| 246 | evm.running = False |
| 247 | |
| 248 | # PROGRAM COUNTER |
| 249 | pass |
GenericCall ¶
Parameters for the core logic of the CALL* family of opcodes.
| 252 | @final |
|---|
| 253 | @dataclass |
|---|
class GenericCall:
gas¶
| 259 | gas: Uint |
|---|
value¶
| 260 | value: U256 |
|---|
caller¶
| 261 | caller: Address |
|---|
to¶
| 262 | to: Address |
|---|
code_address¶
| 263 | code_address: Address |
|---|
should_transfer_value¶
| 264 | should_transfer_value: bool |
|---|
is_staticcall¶
| 265 | is_staticcall: bool |
|---|
memory_input_start_position¶
| 266 | memory_input_start_position: U256 |
|---|
memory_input_size¶
| 267 | memory_input_size: U256 |
|---|
memory_output_start_position¶
| 268 | memory_output_start_position: U256 |
|---|
memory_output_size¶
| 269 | memory_output_size: U256 |
|---|
generic_call ¶
Perform the core logic of the CALL* family of opcodes.
def generic_call(evm: Evm, params: GenericCall) -> None:
| 273 | <snip> |
|---|---|
| 276 | from ...vm.interpreter import STACK_DEPTH_LIMIT, process_message |
| 277 | |
| 278 | evm.return_data = b"" |
| 279 | |
| 280 | if evm.message.depth + Uint(1) > STACK_DEPTH_LIMIT: |
| 281 | evm.gas_left += params.gas |
| 282 | push(evm.stack, U256(0)) |
| 283 | return |
| 284 | |
| 285 | call_data = memory_read_bytes( |
| 286 | evm.memory, |
| 287 | params.memory_input_start_position, |
| 288 | params.memory_input_size, |
| 289 | ) |
| 290 | account = get_account(evm.message.tx_env.state, params.code_address) |
| 291 | code = get_code(evm.message.tx_env.state, account.code_hash) |
| 292 | child_message = Message( |
| 293 | block_env=evm.message.block_env, |
| 294 | tx_env=evm.message.tx_env, |
| 295 | caller=params.caller, |
| 296 | target=params.to, |
| 297 | gas=params.gas, |
| 298 | value=params.value, |
| 299 | data=call_data, |
| 300 | code=code, |
| 301 | current_target=params.to, |
| 302 | depth=evm.message.depth + Uint(1), |
| 303 | code_address=params.code_address, |
| 304 | should_transfer_value=params.should_transfer_value, |
| 305 | is_static=params.is_staticcall or evm.message.is_static, |
| 306 | accessed_addresses=evm.accessed_addresses.copy(), |
| 307 | accessed_storage_keys=evm.accessed_storage_keys.copy(), |
| 308 | parent_evm=evm, |
| 309 | ) |
| 310 | child_evm = process_message(child_message) |
| 311 | |
| 312 | if child_evm.error: |
| 313 | incorporate_child_on_error(evm, child_evm) |
| 314 | evm.return_data = child_evm.output |
| 315 | push(evm.stack, U256(0)) |
| 316 | else: |
| 317 | incorporate_child_on_success(evm, child_evm) |
| 318 | evm.return_data = child_evm.output |
| 319 | push(evm.stack, U256(1)) |
| 320 | |
| 321 | actual_output_size = min( |
| 322 | params.memory_output_size, U256(len(child_evm.output)) |
| 323 | ) |
| 324 | memory_write( |
| 325 | evm.memory, |
| 326 | params.memory_output_start_position, |
| 327 | child_evm.output[:actual_output_size], |
| 328 | ) |
call ¶
Message-call into an account.
Parameters
evm : The current EVM frame.
def call(evm: Evm) -> None:
| 332 | <snip> |
|---|---|
| 341 | # STACK |
| 342 | gas = Uint(pop(evm.stack)) |
| 343 | to = to_address_masked(pop(evm.stack)) |
| 344 | value = pop(evm.stack) |
| 345 | memory_input_start_position = pop(evm.stack) |
| 346 | memory_input_size = pop(evm.stack) |
| 347 | memory_output_start_position = pop(evm.stack) |
| 348 | memory_output_size = pop(evm.stack) |
| 349 | |
| 350 | # GAS |
| 351 | extend_memory = calculate_gas_extend_memory( |
| 352 | evm.memory, |
| 353 | [ |
| 354 | (memory_input_start_position, memory_input_size), |
| 355 | (memory_output_start_position, memory_output_size), |
| 356 | ], |
| 357 | ) |
| 358 | |
| 359 | if to in evm.accessed_addresses: |
| 360 | access_gas_cost = GasCosts.WARM_ACCESS |
| 361 | else: |
| 362 | evm.accessed_addresses.add(to) |
| 363 | access_gas_cost = GasCosts.COLD_ACCOUNT_ACCESS |
| 364 | |
| 365 | code_address = to |
| 366 | |
| 367 | create_gas_cost = GasCosts.NEW_ACCOUNT |
| 368 | if value == 0 or is_account_alive(evm.message.tx_env.state, to): |
| 369 | create_gas_cost = Uint(0) |
| 370 | transfer_gas_cost = Uint(0) if value == 0 else GasCosts.CALL_VALUE |
| 371 | message_call_gas = calculate_message_call_gas( |
| 372 | value, |
| 373 | gas, |
| 374 | Uint(evm.gas_left), |
| 375 | memory_cost=extend_memory.cost, |
| 376 | extra_gas=access_gas_cost + create_gas_cost + transfer_gas_cost, |
| 377 | ) |
| 378 | charge_gas(evm, message_call_gas.cost + extend_memory.cost) |
| 379 | if evm.message.is_static and value != U256(0): |
| 380 | raise WriteInStaticContext |
| 381 | evm.memory += b"\x00" * extend_memory.expand_by |
| 382 | sender_balance = get_account( |
| 383 | evm.message.tx_env.state, evm.message.current_target |
| 384 | ).balance |
| 385 | if sender_balance < value: |
| 386 | push(evm.stack, U256(0)) |
| 387 | evm.return_data = b"" |
| 388 | evm.gas_left += message_call_gas.sub_call |
| 389 | else: |
| 390 | generic_call( |
| 391 | evm, |
| 392 | GenericCall( |
| 393 | gas=message_call_gas.sub_call, |
| 394 | value=value, |
| 395 | caller=evm.message.current_target, |
| 396 | to=to, |
| 397 | code_address=code_address, |
| 398 | should_transfer_value=True, |
| 399 | is_staticcall=False, |
| 400 | memory_input_start_position=memory_input_start_position, |
| 401 | memory_input_size=memory_input_size, |
| 402 | memory_output_start_position=memory_output_start_position, |
| 403 | memory_output_size=memory_output_size, |
| 404 | ), |
| 405 | ) |
| 406 | |
| 407 | # PROGRAM COUNTER |
| 408 | evm.pc += Uint(1) |
callcode ¶
Message-call into this account with alternative account’s code.
Parameters
evm : The current EVM frame.
def callcode(evm: Evm) -> None:
| 412 | <snip> |
|---|---|
| 421 | # STACK |
| 422 | gas = Uint(pop(evm.stack)) |
| 423 | code_address = to_address_masked(pop(evm.stack)) |
| 424 | value = pop(evm.stack) |
| 425 | memory_input_start_position = pop(evm.stack) |
| 426 | memory_input_size = pop(evm.stack) |
| 427 | memory_output_start_position = pop(evm.stack) |
| 428 | memory_output_size = pop(evm.stack) |
| 429 | |
| 430 | # GAS |
| 431 | to = evm.message.current_target |
| 432 | |
| 433 | extend_memory = calculate_gas_extend_memory( |
| 434 | evm.memory, |
| 435 | [ |
| 436 | (memory_input_start_position, memory_input_size), |
| 437 | (memory_output_start_position, memory_output_size), |
| 438 | ], |
| 439 | ) |
| 440 | |
| 441 | if code_address in evm.accessed_addresses: |
| 442 | access_gas_cost = GasCosts.WARM_ACCESS |
| 443 | else: |
| 444 | evm.accessed_addresses.add(code_address) |
| 445 | access_gas_cost = GasCosts.COLD_ACCOUNT_ACCESS |
| 446 | |
| 447 | transfer_gas_cost = Uint(0) if value == 0 else GasCosts.CALL_VALUE |
| 448 | message_call_gas = calculate_message_call_gas( |
| 449 | value, |
| 450 | gas, |
| 451 | Uint(evm.gas_left), |
| 452 | extend_memory.cost, |
| 453 | access_gas_cost + transfer_gas_cost, |
| 454 | ) |
| 455 | charge_gas(evm, message_call_gas.cost + extend_memory.cost) |
| 456 | |
| 457 | # OPERATION |
| 458 | evm.memory += b"\x00" * extend_memory.expand_by |
| 459 | sender_balance = get_account( |
| 460 | evm.message.tx_env.state, evm.message.current_target |
| 461 | ).balance |
| 462 | if sender_balance < value: |
| 463 | push(evm.stack, U256(0)) |
| 464 | evm.return_data = b"" |
| 465 | evm.gas_left += message_call_gas.sub_call |
| 466 | else: |
| 467 | generic_call( |
| 468 | evm, |
| 469 | GenericCall( |
| 470 | gas=message_call_gas.sub_call, |
| 471 | value=value, |
| 472 | caller=evm.message.current_target, |
| 473 | to=to, |
| 474 | code_address=code_address, |
| 475 | should_transfer_value=True, |
| 476 | is_staticcall=False, |
| 477 | memory_input_start_position=memory_input_start_position, |
| 478 | memory_input_size=memory_input_size, |
| 479 | memory_output_start_position=memory_output_start_position, |
| 480 | memory_output_size=memory_output_size, |
| 481 | ), |
| 482 | ) |
| 483 | |
| 484 | # PROGRAM COUNTER |
| 485 | evm.pc += Uint(1) |
selfdestruct ¶
Halt execution and register account for later deletion.
Parameters
evm : The current EVM frame.
def selfdestruct(evm: Evm) -> None:
| 489 | <snip> |
|---|---|
| 498 | # STACK |
| 499 | beneficiary = to_address_masked(pop(evm.stack)) |
| 500 | |
| 501 | # GAS |
| 502 | gas_cost = GasCosts.OPCODE_SELFDESTRUCT_BASE |
| 503 | if beneficiary not in evm.accessed_addresses: |
| 504 | evm.accessed_addresses.add(beneficiary) |
| 505 | gas_cost += GasCosts.COLD_ACCOUNT_ACCESS |
| 506 | |
| 507 | if ( |
| 508 | not is_account_alive(evm.message.tx_env.state, beneficiary) |
| 509 | and get_account( |
| 510 | evm.message.tx_env.state, evm.message.current_target |
| 511 | ).balance |
| 512 | != 0 |
| 513 | ): |
| 514 | gas_cost += GasCosts.OPCODE_SELFDESTRUCT_NEW_ACCOUNT |
| 515 | |
| 516 | charge_gas(evm, gas_cost) |
| 517 | if evm.message.is_static: |
| 518 | raise WriteInStaticContext |
| 519 | |
| 520 | originator = evm.message.current_target |
| 521 | beneficiary_balance = get_account( |
| 522 | evm.message.tx_env.state, beneficiary |
| 523 | ).balance |
| 524 | originator_balance = get_account( |
| 525 | evm.message.tx_env.state, originator |
| 526 | ).balance |
| 527 | |
| 528 | # First Transfer to beneficiary |
| 529 | set_account_balance( |
| 530 | evm.message.tx_env.state, |
| 531 | beneficiary, |
| 532 | beneficiary_balance + originator_balance, |
| 533 | ) |
| 534 | # Next, Zero the balance of the address being deleted (must come after |
| 535 | # sending to beneficiary in case the contract named itself as the |
| 536 | # beneficiary). |
| 537 | set_account_balance(evm.message.tx_env.state, originator, U256(0)) |
| 538 | |
| 539 | # register account for deletion |
| 540 | evm.accounts_to_delete.add(originator) |
| 541 | |
| 542 | # mark beneficiary as touched |
| 543 | if account_exists_and_is_empty(evm.message.tx_env.state, beneficiary): |
| 544 | evm.touched_accounts.add(beneficiary) |
| 545 | |
| 546 | # HALT the execution |
| 547 | evm.running = False |
| 548 | |
| 549 | # PROGRAM COUNTER |
| 550 | pass |
delegatecall ¶
Message-call into an account.
Parameters
evm : The current EVM frame.
def delegatecall(evm: Evm) -> None:
| 554 | <snip> |
|---|---|
| 563 | # STACK |
| 564 | gas = Uint(pop(evm.stack)) |
| 565 | code_address = to_address_masked(pop(evm.stack)) |
| 566 | memory_input_start_position = pop(evm.stack) |
| 567 | memory_input_size = pop(evm.stack) |
| 568 | memory_output_start_position = pop(evm.stack) |
| 569 | memory_output_size = pop(evm.stack) |
| 570 | |
| 571 | # GAS |
| 572 | extend_memory = calculate_gas_extend_memory( |
| 573 | evm.memory, |
| 574 | [ |
| 575 | (memory_input_start_position, memory_input_size), |
| 576 | (memory_output_start_position, memory_output_size), |
| 577 | ], |
| 578 | ) |
| 579 | |
| 580 | if code_address in evm.accessed_addresses: |
| 581 | access_gas_cost = GasCosts.WARM_ACCESS |
| 582 | else: |
| 583 | evm.accessed_addresses.add(code_address) |
| 584 | access_gas_cost = GasCosts.COLD_ACCOUNT_ACCESS |
| 585 | |
| 586 | message_call_gas = calculate_message_call_gas( |
| 587 | U256(0), gas, Uint(evm.gas_left), extend_memory.cost, access_gas_cost |
| 587 | U256(0), |
| 588 | gas, |
| 589 | Uint(evm.gas_left), |
| 590 | extend_memory.cost, |
| 591 | access_gas_cost, |
| 592 | ) |
| 593 | charge_gas(evm, message_call_gas.cost + extend_memory.cost) |
| 594 | |
| 595 | # OPERATION |
| 596 | evm.memory += b"\x00" * extend_memory.expand_by |
| 597 | generic_call( |
| 598 | evm, |
| 599 | GenericCall( |
| 600 | gas=message_call_gas.sub_call, |
| 601 | value=evm.message.value, |
| 602 | caller=evm.message.caller, |
| 603 | to=evm.message.current_target, |
| 604 | code_address=code_address, |
| 605 | should_transfer_value=False, |
| 606 | is_staticcall=False, |
| 607 | memory_input_start_position=memory_input_start_position, |
| 608 | memory_input_size=memory_input_size, |
| 609 | memory_output_start_position=memory_output_start_position, |
| 610 | memory_output_size=memory_output_size, |
| 611 | ), |
| 612 | ) |
| 613 | |
| 614 | # PROGRAM COUNTER |
| 615 | evm.pc += Uint(1) |
staticcall ¶
Message-call into an account.
Parameters
evm : The current EVM frame.
def staticcall(evm: Evm) -> None:
| 619 | <snip> |
|---|---|
| 628 | # STACK |
| 629 | gas = Uint(pop(evm.stack)) |
| 630 | to = to_address_masked(pop(evm.stack)) |
| 631 | memory_input_start_position = pop(evm.stack) |
| 632 | memory_input_size = pop(evm.stack) |
| 633 | memory_output_start_position = pop(evm.stack) |
| 634 | memory_output_size = pop(evm.stack) |
| 635 | |
| 636 | # GAS |
| 637 | extend_memory = calculate_gas_extend_memory( |
| 638 | evm.memory, |
| 639 | [ |
| 640 | (memory_input_start_position, memory_input_size), |
| 641 | (memory_output_start_position, memory_output_size), |
| 642 | ], |
| 643 | ) |
| 644 | |
| 645 | if to in evm.accessed_addresses: |
| 646 | access_gas_cost = GasCosts.WARM_ACCESS |
| 647 | else: |
| 648 | evm.accessed_addresses.add(to) |
| 649 | access_gas_cost = GasCosts.COLD_ACCOUNT_ACCESS |
| 650 | |
| 651 | code_address = to |
| 652 | |
| 653 | message_call_gas = calculate_message_call_gas( |
| 654 | U256(0), |
| 655 | gas, |
| 656 | Uint(evm.gas_left), |
| 657 | extend_memory.cost, |
| 658 | access_gas_cost, |
| 659 | ) |
| 660 | charge_gas(evm, message_call_gas.cost + extend_memory.cost) |
| 661 | |
| 662 | # OPERATION |
| 663 | evm.memory += b"\x00" * extend_memory.expand_by |
| 664 | generic_call( |
| 665 | evm, |
| 666 | GenericCall( |
| 667 | gas=message_call_gas.sub_call, |
| 668 | value=U256(0), |
| 669 | caller=evm.message.current_target, |
| 670 | to=to, |
| 671 | code_address=code_address, |
| 672 | should_transfer_value=True, |
| 673 | is_staticcall=True, |
| 674 | memory_input_start_position=memory_input_start_position, |
| 675 | memory_input_size=memory_input_size, |
| 676 | memory_output_start_position=memory_output_start_position, |
| 677 | memory_output_size=memory_output_size, |
| 678 | ), |
| 679 | ) |
| 680 | |
| 681 | # PROGRAM COUNTER |
| 682 | evm.pc += Uint(1) |
revert ¶
Stop execution and revert state changes, without consuming all provided gas and also has the ability to return a reason.
Parameters
evm : The current EVM frame.
def revert(evm: Evm) -> None:
| 686 | <snip> |
|---|---|
| 696 | # STACK |
| 697 | memory_start_index = pop(evm.stack) |
| 698 | size = pop(evm.stack) |
| 699 | |
| 700 | # GAS |
| 701 | extend_memory = calculate_gas_extend_memory( |
| 702 | evm.memory, [(memory_start_index, size)] |
| 703 | ) |
| 704 | |
| 705 | charge_gas(evm, extend_memory.cost) |
| 706 | |
| 707 | # OPERATION |
| 708 | evm.memory += b"\x00" * extend_memory.expand_by |
| 709 | output = memory_read_bytes(evm.memory, memory_start_index, size) |
| 710 | evm.output = Bytes(output) |
| 711 | raise Revert |
| 712 | |
| 713 | # PROGRAM COUNTER |
| 714 | # no-op |