mds1 / evm-diff

Diff EVM-compatible chains in a friendly format
https://evmdiff.com
MIT License
278 stars 27 forks source link

feat: add Opcode diffs (bounty: 300 OP 🔴) #6

Closed mds1 closed 1 year ago

mds1 commented 1 year ago

This issue is eligible for a 300 OP bounty. Read CONTRIBUTING.md to learn how to qualify.

This is basically a version of https://www.evm.codes/ for each chain.

Each opcode should include all information shown by evm codes. Specifically:

The data for each chain should live in src/chains/[chainName]/vm/opcodes.ts. Alternatively, if that file gets too big, the path can be src/chains/[chainName]/vm/opcodes/[group].ts, where group matches the Ethereum execution-specs file names here. In the case where it's split up across multiple files in an opcodes folder, include an index.ts file that exports the final opcodes list.

The component to render the diff of opcodes should live in src/components/diff/DiffOpcodes.tsx. Two opcodes should be considered equal if every item in the above bulleted list matches, i.e. JSON.stringify(a) === JSON.stringify(b). If there any any differences, they should not be considered equal

To keep PRs small and easy to review, let's split this up into two PRs:

Suggested type to define in src/chains/types.ts:

type OpcodeParam = {
  name: string;
  description: string;
};

export type Opcode = {
  number: number;
  name: string;
  minGas: number;
  description: string;
  input: OpcodeParam[];
  output: OpcodeParam[];
  // Gas computation can get complex, so I'm not sure of the best way to
  // represent this. If it's hard, this can be left out for now and we can
  // create a separate issue to track.
  gasComputation: TODO;
  errorCases: string[];
  notes: string[];
  references: string[];
};

// This type already exists and we're adding the `opcodes` field.
export type Chain = {
  metadata: Metadata;
  precompiles: (Precompile | Predeploy)[];
  opcodes: Opcode[];
};
leovct commented 1 year ago

hi @mds1, happy to start working on the PR to add the first mainnet opcodes :)

mds1 commented 1 year ago

Awesome thanks @leovct!