Skip to content

2xic/tiny-evm-language

Repository files navigation

Bytecode is the way Photo credit: @high_byte

Preface

This compiler is kinda wack as it was more a golfing exercise and reason to play with Zig. I put more love into my C compiler.

Goal

I just wanted to create a simple golfing language that solves dropper CTF challenge from paradigm.xyz and also a reason to play with zig. The best solutions requires pre-computation, but that isn't what we are trying to do here. The point is not to create the best solution, but create a golfing solution.

See docs for some example programs.

Solution on Dropper Score
Tiny evm language 955188
Naive solc 970992

See benchmark or run it yourself ./run_dropper_benchmark.sh

Todos

These todo's will likely never happen, you want a good evm language ? Use huff.

  1. Code generation
    1. Nested functions call doesn't really work (the fallthrough logic is not optimal)
    2. If conditional jump destination can sometimes generate bad / invalid JUMPs.
    3. Validation / padding of PUSH argument values.
  2. Zig code can likely be made more modular.

Install (Ubuntu)

snap install zig --classic --beta

Build

zig build --summary all

Run

./zig-out/bin/cli [path] 

Test

Note that we don't have any real unit tests

zig build test

We have some compiler tests

./e2e_test.sh

About

VERY SMALL EVM LANGUAGE. GAS GOLFING ONLY, NO PRODUCTION!!

Topics

Resources

Stars

Watchers

Forks