2/5
_Follow along with this video:_ --- We're going to take a look at how this function in the [**evm.codes playground**](https://www.evm.codes/playground), and there's actually a convenient method, build into Huff, that allows us to retrieve the runtime bytecode of our compiled contract! ``` huffc src/horseStoreV1/HorseStore.huff --bin-runtime 5f3560e01c63cdfead2e1461000f575b ``` Paste the returned runtime bytecode into the evm.codes playground and let's step through what's happening with our contract. ::image{src='/formal-verification-1/21-jumpdest/jumpdest-1.png' style='width: 75%; height: auto;'} By adding the runtime bytecode to the playground, we're presented with almost exactly what we wrote in Huff, converted to pure op codes. Something that's going to stand out is the `JUMPDEST` code. To understand this op code, let's take one step back. In the previous lesson we'd set `updateJump` as a pointer to our program counter of `SET_NUMBER_OF_HORSES()`. This is only partially true. When a `JUMP` or `JUMPI` op code is executed, it requires a stack input of a `valid jump destination`. Huff's syntax allows us to define `updateJump` as a new `valid jump destination` before our `JUMPI` operation is executed. ```js updateJump: SET_NUMBER_OF_HORSES(); // sets the compiled location of the SET_NUMBER_OF_HORSES macro as a valid jump destination. ``` So, looking again at our playground: - Op Codes 1-4 - isolating `function selector` from received `call data` - PUSH4 - Pushes our known `function selector` to the stack - EQ - Compares our isolated `function selector` to our known selector and returns 0/1 - PUSH2 - Adds our jump destination to the stack - JUMPI - Jumps to our destination if the value returned by EQ is anything other than 0 - JUMPDEST - An empty stack at our jump destination ::image{src='/formal-verification-1/21-jumpdest/jumpdest-2.png' style='width: 75%; height: auto;'} Currently of course, nothing is going to happen after we jump to our new destination. We haven't added any logic to our macro yet. I encourage you to experiment in the playground before moving on. What's left on our stack after stepping through the code? What happens if we provide call data that doesn't start with our expected `function selector`? Answer these questions, and I'll see you in the next lesson!
A detailed guide to the jumpdest opcode - This lesson dives into the jumpdest opcode, its functionality, and how it's used in conjunction with jump and jumpi. The lesson also illustrates real-world application by compiling and running a Huff contract.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Solidity Developer
Assembly and Formal VerificationDuration: 30min
Duration: 4h 38min
Duration: 3h 57min
Duration: 1h 56min
Course Overview
About the course
Assembly
Writing smart contracts using Huff and Yul
Ethereum Virtual Machine OPCodes
Formal verification testing
Smart contract invariant testing
Halmos, Certora, Kontrol
Security researcher
$49,999 - $120,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Guest lecturers:
Josselin Feist
Head of Blockchain at Trail of Bits
Last updated on January 17, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar