Closed leovct closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
evm-diff | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 14, 2023 2:14am |
It should be in a pretty good state now @mds1 :)
Description
First PR of the
Opcode diffs
issue (Resolves #6)The
Opcode
type is quite similar to the one suggested in the issue. The only changes I made were to add two new fields. One calledexamples
, which is quite similar to the example field of evm.codes and aplaygroundLink
field which redirects to the evm.codes/playground link of evm.codes. I also created aVariable
type instead of theOpcodeParam
type suggested in order to re-use this type in the context of gas computation.For the gas computation, I chose to represent it as simple as possible with a
name
, adescription
, an algebraicexpression
and somevariables
. I took inspiration from this good old repository.To keep this PR simple, I only added a few opcodes such as
add
,blockhash
,number
andmstore
. You might ask why these specific opcodes and that's a great question. First, theadd
opcode is simple and doesn't require a dynamic computation as opposed to themstore
opcode. Second, thenumber
opcode has a different meaning on the mainnet chain and L2 chains such as arbitrum or optimism while theblockhash
opcode is the same on all chains (just likeadd
andmstore
opcodes). I went with these opcodes because they cover different configuration cases which shows the possibilities of the type system I've used here.Each opcode is defined in its own file to separate things clearly between each opcode. These opcodes live in group folders, matching the Ethereum execution-specs folder names. To better illustrate, here is the structure of the
src/chains/mainnet/vm
folder.Some opcodes are exactly the same on L1 and L2 chains so to prevent us from copy-pasting opcode configurations, I defined the mainnet opcodes under
src/chains/mainnet/vm/opcodes
and reused these opcodes to define arbitrum and optimism opcodes. It means that we only need to write the configuration of the opcodes that are different such asnumber
(as well as mainnet opcodes of course), e.g.src/chains/arbitrum/vm/opcodes/block/number.ts
.Test