EVM Puzzle 1
I recently discovered that the EVM Puzzle series is an excellent set of challenges to test our understanding of EVM opcodes. The puzzles can be found at this link: https://github.com/fvictorio/evm-puzzles. In this blog post, we will focus on solving the first puzzle.
1 | ############ |
According to the requirements of the puzzle, we need to jump to the target program counter (PC), which is located at address 08, the JUMPDEST opcode.
Here is the explanation of CALLVALUE:
Stack output
value
: the value of the current call in wei.
And here is the explanation of JUMP:
The program counter (PC) is a byte offset in the deployed code. It indicates which instruction will be executed next. When an ADD is executed, for example, the PC is incremented by 1, since the instruction is 1 byte. The PUSH instructions are bigger than one byte, and so will increment the counter accordingly.
The JUMP instruction alters the program counter, thus breaking the linear path of the execution to another point in the deployed code. It is used to implement functionalities like functions.
Stack input
counter
: byte offset in the deployed code where execution will continue from. Must be a JUMPDEST instruction.
Therefore, the target value that JUMP jumps to is our input, and the target address is 08. We simply input 8.
1 | Puzzle solved! |