smlxl / evm.codes

Source for evm.codes an Ethereum Virtual Machine Opcodes Interactive Reference
https://evm.codes/
MIT License
728 stars 135 forks source link

CALLDATACOPY #204

Closed veridelisi closed 1 year ago

veridelisi commented 1 year ago

Hi I think you need to change "CALLDATACOPY sample".

CALLDATA adress must be as follows 0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE

input 1 must be PUSH1 2 PUSH1 30 PUSH1 0 CALLDATACOPY

input 2 must be PUSH1 1 PUSH1 0 PUSH1 0 CALLDATACOPY

Sincerely VeriDelisi

peroket commented 1 year ago

Hello thank you for your feedback :-) Can you explain what is the problem and how your proposal is a solution to it? I must admit, I fail to understand what you are proposing.

veridelisi commented 1 year ago

Hi peroket

Opcodes, 37, CALLDATACOPY page, you use Calldata as 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF And you use input 2 as (0,31,8)

sample

Problem is that:

User cant understand what is going on with this Calldata and input 2's variables because your calldata is filling with F.

My advice is

you use call data as "0xCCFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAABBCCDDEE" and you use input 2 as (1,0,0) and input 1 as (2,30,0)

peroket commented 1 year ago

So this is for clarity, understood, thank you :-) Feel free to do the change yourself, otherwise I will do it later.

jonahcui commented 1 year ago

I have changed the code, and the page has been changed as below:

CleanShot 2023-01-12 at 11 51 00@2x

But I still need to post the pr. If you like it, I will post it.

The code is here: https://github.com/jonahcui/evm.codes/tree/204-change-example-of-calldatacopy

peroket commented 1 year ago

Can we keep the inputs closer to the original ones, maybe? The important things to show, I think, is that it writes for the given length (not overwriting the rest), and that reading out of bounds makes it write 0s. So making the first write bigger than the second, and making the second read out of bounds but not overwriting the whole memory we just wrote, I think it shows well the behaviour :-) Plus the change in the input to make it more clear which bytes are copied, and this is perfect :-)