Created
July 26, 2022 18:24
-
-
Save CJ42/c4e64f1f79e59335c8cb4643992c55fa to your computer and use it in GitHub Desktop.
Show the changes of execution context by the EVM when calling external contract (Fresh instance of Memory obtained)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; ... | |
| 057 SLOAD ; load the value for `target` state variable from storage | |
| ; ... | |
| ; more stack manipulation | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| 109 PUSH4 82692679 ; 1. load the function selector of doSomething() | |
| 114 PUSH1 40 | |
| 116 MLOAD ; 2. load the free memory pointer | |
| 117 DUP2 | |
| 118 PUSH4 ffffffff | |
| 123 AND | |
| 124 PUSH1 e0 ; 3.1 push 224 (0x0e) on the stack | |
| 126 SHL ; 3.2 shift the functin selector of doSomething() left by 224 bits, so to prepare the calldata to be sent to the Target contract | |
| 127 DUP2 | |
| 128 MSTORE ; 4. store the calldata to be sent to the Target contract in memory, at memory location pointed to by the free memory pointer | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| 145 EXTCODESIZE ; get the size of the code of the Target address, to ensure it is a contract | |
| 146 ISZERO ; if the codesize at Target address is zero, then the address is not a contract, so we will stop execution later | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| ; ... | |
| 157 POP | |
| 158 GAS | |
| 159 CALL ; 5. make the external call to the Target contract, with the calldata to be sent to it (`doSomething()`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment