Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "eot"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
authors = ["alake"]
license = "MIT"
description = "EVM Opcode Table - Rust implementation of EVM opcodes for all Ethereum forks"
description = "EVM opcodes library for all Ethereum forks, with complete fork inheritance, validation, and metadata"
documentation = "https://docs.rs/eot"
homepage = "https://github.com/g4titanx/eot"
repository = "https://github.com/g4titanx/eot"
Expand Down
132 changes: 7 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,16 @@
# EOT - EVM Opcode Table
# eot - EVM Opcode Table

A Rust implementation of EVM opcodes for all Ethereum forks, with complete fork inheritance, validation, and metadata.
EVM opcodes library for all Ethereum forks, with complete fork inheritance, validation, and metadata

[![Crates.io](https://img.shields.io/crates/v/eot.svg)](https://crates.io/crates/eot)
[![Documentation](https://docs.rs/eot/badge.svg)](https://docs.rs/eot)
[![Build Status](https://github.com/g4titanx/eot/workflows/CI/badge.svg)](https://github.com/g4titanx/eot/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Quick start
## What can it do?
`eot` is an EVM opcode table library that provides complete opcode metadata, fork inheritance, and validation for all Ethereum hard forks from Frontier to Cancun. It offers both a unified interface for simple opcode lookup and fork-specific implementations that accurately reflect the evolution of the EVM instruction set. You can query opcode properties like gas costs, stack behavior, and descriptions, check opcode availability across different forks, validate bytecode sequences, and build EVM analysis tools with confidence that the data matches each fork's specifications exactly.

Add this to your `Cargo.toml`:

```toml
[dependencies]
eot = "0.1"
```

Basic usage:

```rust
use eot::{Cancun, OpCode, Fork};

// Use the latest fork (Cancun)
let tload = Cancun::TLOAD;
println!("Gas cost: {}", tload.gas_cost()); // 100
println!("Introduced in: {:?}", tload.introduced_in()); // Fork::Cancun
println!("EIP: {:?}", tload.eip()); // Some(1153)

// Check if an opcode exists in a fork
if Cancun::has_opcode(0x5c) {
println!("TLOAD exists in Cancun!");
}

// Get all opcodes for a fork
let all_opcodes = Cancun::all_opcodes();
println!("Cancun has {} opcodes", all_opcodes.len());

// Convert between opcode and byte value
let byte_val: u8 = tload.into(); // 0x5c
let back_to_opcode = Cancun::from(byte_val);
assert_eq!(tload, back_to_opcode);
```

## Architecture

### Smart Fork System

Instead of manually copying opcodes between forks, we use automatic inheritance:

```
Frontier (Base) → Homestead → Byzantium → Constantinople → Istanbul → Berlin → London → Shanghai → Cancun
```

Each fork automatically includes all opcodes from previous forks plus its own additions.

### Rich Metadata

Every opcode includes complete information:

```rust
use eot::{Cancun, OpCode};

let tload = Cancun::TLOAD;
let metadata = tload.metadata();

assert_eq!(metadata.opcode, 0x5c);
assert_eq!(metadata.name, "TLOAD");
assert_eq!(metadata.gas_cost, 100);
assert_eq!(metadata.stack_inputs, 1);
assert_eq!(metadata.stack_outputs, 1);
assert_eq!(metadata.introduced_in, Fork::Cancun);
assert_eq!(metadata.group, Group::StackMemoryStorageFlow);
assert_eq!(metadata.eip, Some(1153));
```

### Other Features

```rust
use eot::{Cancun, traits::OpcodeExt};

// State modification analysis
let sstore = Cancun::SSTORE;
println!("Modifies state: {}", sstore.modifies_state()); // true
println!("Can revert: {}", sstore.can_revert()); // false

// Push opcode analysis
let push1 = Cancun::PUSH1;
println!("Is push opcode: {}", push1.is_push()); // true
println!("Push size: {:?}", push1.push_size()); // Some(1)

// Stack depth requirements
let dup5 = Cancun::DUP5;
println!("Min stack depth: {}", dup5.min_stack_depth()); // 5

// Opcode groups
let add = Cancun::ADD;
println!("Group: {:?}", add.group()); // Group::StopArithmetic
```
See the `examples/` directory for practical demonstrations of opcode queries, fork compatibility checking, and gas analysis workflows.

## Supported Forks

Expand All @@ -112,32 +26,6 @@ println!("Group: {:?}", add.group()); // Group::StopArithmetic
| Shanghai | 17,034,870 | Apr 2023 | `PUSH0` | ✅ |
| Cancun | 19,426,587 | Mar 2024 | `TLOAD`, `TSTORE`, `MCOPY`, `BLOBHASH`, `BLOBBASEFEE` | ✅ |

## Building the Project

### Prerequisites
- Rust 1.70+ (for proper trait support)
- Python 3.8+ (for code generation, optional)

### Building

```bash
git clone https://github.com/g4titanx/eot
cd eot
cargo bb && cargo tt
```

### Regenerating Fork Files (Optional)

If you need to modify opcode data:

```bash
# Run the Python generator
python3 generate_forks.py

# Then rebuild
cargo build
```

## Contributing

1. **Adding a new fork**:
Expand All @@ -163,15 +51,9 @@ cargo build
Then:
```bash
python3 generate_forks.py
cargo test
cargo tt
```

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Acknowledgments

- clearloop for [evm-opcodes](https://crates.io/crates/evm-opcodes)
- Ethereum Foundation for EVM specification
- EIP authors for comprehensive opcode documentation
- [clearloop](github.com/clearloop) for [evm-opcodes](https://crates.io/crates/evm-opcodes)
Loading
Loading