Skip to content

omerfirmak/zevm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

194 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zevm

An alpha EVM implementation in Zig, using threaded code dispatch for opcode execution. Osaka-compliant.

Requirements

  • Zig 0.15.2

Building

zig build

Running tests

Run unit tests:

zig build test

Run the full state test suite after fetching the fixture archive and extracting it:

zig build state-tests

Run a single fixture file:

zig build state-tests -Dstate-test=/path/to/fixture.json

Usage

The entry point for executing a transaction is EVM.init followed by EVM.process. You need to provide a Message (transaction parameters), a Context (block parameters), and a State (account/storage world state).

See example/main.zig for a working end-to-end example (zig build example to run it).

CommittedState

The EVM reads account balances, storage slots, and contract code through a CommittedState interface. Consumers provide their own implementation to back these reads with a real database, in-memory map, or anything else.

A CommittedState must be a struct exposing the same methods as the default implementation (evm/empty_committed_state.zig). See example/committed_state.zig for a working example.

Using zevm as a dependency

Add zevm to your build.zig.zon:

.zevm = .{
    .url = "git+https://github.com/omerfirmak/zevm.git#<commit>",
    .hash = "<hash>",
},

Then in your build.zig, pass your custom CommittedState source file when declaring the dependency:

const zevm_dep = b.dependency("zevm", .{
    .target = target,
    .optimize = optimize,
    .committed_state = b.path("src/my_committed_state.zig"),
});

exe.root_module.addImport("zevm", zevm_dep.module("zevm"));

If you omit .committed_state, the built-in empty implementation is used (returns zeros for everything).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages