fvictorio / evm-puzzles

A collection of EVM puzzles
806 stars 158 forks source link

EVM Puzzles Walkthrough #5

Open 0xKitsune opened 2 years ago

0xKitsune commented 2 years ago

First off, thanks for making such an awesome set of challenges, they have been a ton of fun!

While I was going through each challenge, there were parts where I thought, "how does this opcode actually work under the hood" which was followed by a few nights of exploring the yellow paper, stack overflow posts and various other rabbit holes to find the answers. I thought that creating a walkthrough would help others that are newer to the EVM learn some of the EVM nuances related to these puzzles. I am still adding additions to the explanation on puzzle #8 but thought I would make a PR to see if you had any thoughts, edits or comments. I am open to all feedback and would love to have something like this integrated into the repo! I would be happy to make any additions that you think would be helpful or clarify anything that is currently in the walkthrough.

I am looking forward to hearing your thoughts.

viraj124 commented 2 years ago

@0xKitsune in the last puzzle walkthrough how come CODESIZE becomes equal to 1b ?

0xKitsune commented 2 years ago

You can know that CODESIZE equates to 1b (or 27 in decimal form) in puzzle #10 because the CODESIZE opcode returns the size of the current environment that the code is running. It's basically just counting the amount of bytes in the sequence.

For more info on how this works, you can check out the explanation for puzzle #2 as well as the explanation from evm.codes.

Here is an example of puzzle #10 running in an evm codes playground, where you can see it produces 1b. Lmk if you have any other questions feel free to dm me on twitter.

larrettgee commented 3 weeks ago

Getting back into EVM Opcodes & this walkthrough has been immensely helpful :) Thanks!