eth
eth is a no_std-first Rust workspace for Ethereum execution-layer protocol
building blocks.
The project target is a production-ready Ethereum crate at 1.0.0, reached
through small releases with explicit security, conformance, and dependency
evidence. The first implementation work is intentionally conservative:
explicit domains, bounded decode policy, stable crate boundaries, and security
documentation before RPC, signer, REVM, Reth, or P2P adapters become real
dependencies.
Current Status
Status: v0.43.0 adds explicit bounded native EVM state access.
The optional evm-core feature now exposes dependency-free no_std word, stack,
memory, opcode, program-counter, fork, gas schedule, opcode-table, host-state,
warm/cold access, and bounded interpreter domains for hard-capped basic
stack/control-flow bytecode plus explicit state reads without admitting REVM or
another execution backend.
Implemented now:
- Rust workspace pinned to stable
1.96.1. - MSRV policy for Rust
1.90.0through1.96.1. no_stdfacade and focused first-party crates.- Explicit primitive domains for chain, block, gas, nonce, timestamp, address, hash, wei, and transaction type values.
- Constant-time equality composition for fixed-width hash and wei values.
- Bounded decode limits plus stateful cumulative allocation, item, and proof-node accounting.
- Canonical RLP scalar, list, and integer decoding plus no-allocation canonical encoding helpers.
- No-allocation primitive RLP encode and exact-decode helpers for chain, block, gas, nonce, timestamp, address, hash, and wei values.
- EIP-2718 transaction envelope shell classification for typed and legacy transaction bytes.
- Unvalidated legacy transaction field decoding for nonce, gas price, gas limit, to/create, value, input, and signature words.
- Unvalidated EIP-2930 access-list transaction field decoding, including bounded borrowed access-list entry and storage-key iteration.
- Unvalidated EIP-1559 dynamic-fee transaction field decoding for max priority fee, max fee, gas limit, destination/create, value, calldata, access list, and signature words.
- Unvalidated EIP-4844 blob transaction field decoding for blob fee, required call target, blob versioned hash list, calldata, access list, and signature words.
- Unvalidated EIP-7702 set-code transaction field decoding for destination, calldata, access list, authorization list, and signature words.
- No-allocation canonical transaction envelope encoding for admitted unvalidated legacy, EIP-2930, EIP-1559, EIP-4844, and EIP-7702 transaction domains.
- Explicit caller-provided
ChainSpec,ForkSpec,Hardfork, andValidationContextAPIs for fork activation selection, including fail-closed checks for duplicate forks, wrong-chain entries, and non-monotonic fork or activation ordering. - Unvalidated execution block header decoding for legacy, London, Shanghai,
Cancun, and Prague field sets, plus block header hashing through the Keccak
trait boundary and a distinct
BlockHashdomain newtype. - Unvalidated legacy and EIP-2718 typed receipt decoding, including status/root policy, 256-byte logs bloom, borrowed log entries, topics, and data.
- Unvalidated EIP-4895 withdrawal-list decoding, including global withdrawal indexes, validator indexes, recipient addresses, and nonzero Gwei amounts.
- Bounded syntactic MPT node decoding for branch, extension, and leaf nodes, including compact-path validation, eager inline child shape checks, and cumulative proof-node byte/count accounting.
- Transaction and receipt MPT inclusion proof verification at
rlp(transaction_index)over the caller-provided Keccak-256 trait boundary, with distinct transaction and receipt root domains. - Account and storage MPT inclusion proof verification at
keccak256(address)andkeccak256(slot_key)over the caller-provided Keccak-256 trait boundary, with distinct account and storage root domains. - Proof-gated transaction typestate transitions for decoded, canonical, fork-validated, and sender-recovered state tokens.
- Replay-domain validation for legacy EIP-155 and typed transaction chain IDs before sender recovery results are accepted.
- Canonical transaction signing-preimage encoding and signing-hash helpers for legacy EIP-155, EIP-2930, EIP-1559, EIP-4844, and EIP-7702 decoded transaction domains.
- EIP-7702 authorization tuple signing-hash and signer recovery helpers, kept separate from transaction signing hashes with explicit domain newtypes.
- EIP-7702 set-code transaction validity gate for Prague/Pectra fork context, non-empty authorization lists, fee order, caller-computed gas policy, and caller-provided authority account-state checks. Per-authorization failures are counted as skipped tuples instead of rejecting the whole transaction.
- Optional
evmfeature exposing explicit no-std execution environment, transaction input, state snapshot, result report, and hard-ceiling gas-estimation policy types without admitting an EVM backend. - Optional
evm-corefeature exposing first-party no_std EVM word, stack, memory, opcode, program-counter, fork, gas schedule, opcode-table, host-state traits, warm/cold access tracking, and basic bounded interpreter domains with bytecode, step, gas, and state-access ceilings as the native execution foundation. - Digest-level secp256k1 sender recovery through a caller-provided backend boundary, with low-s rejection, Ethereum y-parity policy, and caller-provided Keccak-256 public-key hashing.
- Decoded transaction signature validation helpers that combine replay-domain checks, signing hashes, low-s/y-parity policy, sender recovery, and optional expected-sender comparison.
- External raw mainnet transaction KATs for EIP-2930, EIP-1559, EIP-4844, and EIP-7702 sender recovery.
- EIP-712 domain-safety checks for required
chainIdandverifyingContractfields, plus a domain-gated sender recovery helper. - No-allocation EIP-712 typed-data encoder for caller-provided schemas and
borrowed values, including
encodeType,encodeData,hashStruct, domain separator construction, and typed-data signing digest construction. - Optional
eip712-jsonparser boundary for JSON-RPC typed-data payloads with duplicate-key rejection, explicit parser limits, and no default dependency impact. - Optional
keccak-tinysoftware backend using reviewedtiny-keccak, disabled by default and covered by Keccak-256 KATs. - Core dependency independence audit covering default
subtle, optionalk256,tiny-keccak,serde,serde_json, andsanitizationpaths, and dev/referencealloy-rlpusage. - Runtime dependency policy gate proving reference crates and optional backend/parser crates do not enter the default facade graph.
- Optional parser and sanitization policy gate proving
serde,serde_json,eth-valkyoth-sanitization, andsanitizationenter only through explicit opt-in features. - Public
RlpEncode/RlpDecodetraits and derive macros for reviewed simple structs, with bounded decode and trybuild compile-fail coverage. - Caller-provided Keccak-256 trait boundary with no default hash implementation dependency.
- RLP fuzz harness with committed hex seed corpus and crash reproduction docs.
- Stable error codes, messages, categories, and formatting for codec, protocol, fork, feature, resource, and verification failures.
- Optional sanitization and derive support crates outside the default feature set.
- MIT OR Apache-2.0 license.
- Security, modularity, supply-chain, implementation, and release planning docs.
- Local check, release-gate, dependency-policy, SBOM, and pentest evidence.
- Safe upstream advisory checking for REVM and official Ethereum source drift.
- Independent support-crate release planning for crates.io push limits.
- Pinned official Ethereum source revisions plus a reproducible external
reference-store sync process for
/home/eldryoth/Work/test/eth. - Execution fixture harness for pinned
ethereum/testsRLPTests, with a pass/fail report and explicit unsupported fixture list. - Differential structural RLP harness against
alloy-rlp, with accumulated mismatch reporting.
Not implemented yet:
- No RPC transport.
- No signer or local key storage.
- No stateful or production-valid EVM execution adapter.
- No Reth or P2P integration.
- No block parser yet.
- No ABI/contract helper surface yet; scheduled for
v0.47.0throughv0.55.0. - No consensus/Engine API support yet; scheduled for
v0.56.0throughv0.62.0. - No P2P, txpool, sync, mining, builder, or validator-adjacent boundary yet;
scheduled for
v0.63.0throughv0.69.0.
Trust Dashboard
| Area | Status |
|---|---|
| License | MIT OR Apache-2.0 |
| MSRV | Rust 1.90.0 |
| Pinned toolchain | Rust 1.96.1 |
| Default target | no_std |
| Default runtime dependencies | protocol-core support crates plus reviewed subtle exception |
| Optional hardening dependencies | sanitization and proc-macro tooling behind opt-in crates/features |
| Unsafe policy | first-party crates use #![forbid(unsafe_code)] |
| Default features | protocol-core only |
| Network/signing defaults | none |
| Release evidence | local gates, cargo-deny, cargo-audit, SBOM, pentest report |
| Formal verification | Kani harness planned for v0.71.0 as extra assurance |
| Crate versions | tracked in docs/CRATE_VERSION_MATRIX.md |
| 1.0 target | serious production-ready Ethereum execution-layer toolkit |
Install
[]
= "0.43.0"
For optional sanitization support:
[]
= { = "0.43.0", = ["sanitization"] }
Features
| Feature | Default | Purpose |
|---|---|---|
std |
no | Enables std support in admitted core crates. |
evm |
no | Explicit no_std EVM execution environment, snapshot, result, and bounded gas-estimation boundary. |
evm-core |
no | Dependency-free native EVM core domains, gas-metered basic opcode execution, and explicit bounded state-access traits. |
rpc |
no | Future explicit RPC trust-policy boundary. |
eip712-json |
no | Enables the optional std JSON-RPC EIP-712 typed-data parser boundary. |
keccak-tiny |
no | Enables the optional reviewed tiny-keccak software backend. |
secp256k1-k256 |
no | Enables the optional reviewed k256 sender-recovery adapter. |
sanitization |
no | Re-exports optional secret sanitization bridge APIs. |
signer |
no | Future signer isolation boundary. |
reth |
no | Future Reth integration boundary. |
testkit |
no | Test fixtures, conformance helpers, and adversarial inputs. |
Default builds do not enable networking, signing, local key storage, Reth, P2P,
REVM, or concrete production EVM execution. The optional evm and evm-core
features provide boundary and native core execution primitives only.
Optional reviewed software Keccak backend:
[]
= { = "0.43.0", = ["keccak-tiny"] }
use ;
let digest = hash_one;
assert_eq!;
Optional reviewed secp256k1 recovery adapter:
[]
= { = "0.43.0", = ["secp256k1-k256"] }
Optional bounded EVM gas-estimation boundary:
[]
= { = "0.43.0", = ["evm"] }
use DecodeLimits;
use ;
use ;
use ;
;
let context = ValidationContext ;
let block = BlockExecutionContext ;
let limits = DecodeLimits ;
let environment = match try_new ;
let transaction = match decode ;
let snapshot = Snapshot;
let execution = new;
let policy = match try_new ;
let request = match try_new ;
let report = match request.report ;
assert_eq!;
# Ok::
Optional native EVM core domains:
[]
= { = "0.43.0", = ["evm-core"] }
State access uses explicit host-state traits and caller-provided fixed-capacity
warm/cold access sets. The current state-access gas model is admitted only for
EvmFork::LONDON and later; pre-Berlin historical state schedules fail closed
until a fork-specific schedule is implemented.
use ;
let mut stack = try_new?;
stack.push?;
let table = try_new?;
let add = table.instruction?;
assert_eq!;
let mut memory = ;
let mut execution = try_new?;
let report = execution.run?;
assert_eq!;
assert_eq!;
# Ok::
Primitive Domains
Use explicit Ethereum domains instead of unqualified integers and byte arrays:
use ;
let chain = new;
let block = new;
let gas = new;
let nonce = new;
let address = from;
let hash = B256from;
let value = from_u128;
let tx_type = try_new_typed;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Primitive domains bridge directly to the bounded codec without allocation:
use DecodeLimits;
use ;
let limits = DecodeLimits ;
let chain = new;
let mut encoded_chain = ;
let written = chain.encode_rlp?;
assert_eq!;
assert_eq!;
let value = from_u128;
let mut encoded_value = ;
let written = value.encode_rlp?;
assert_eq!;
assert_eq!;
let address = from;
let mut encoded_address = ;
let written = address.encode_rlp?;
assert_eq!;
assert_eq!;
# Ok::
Transaction Decode
Transaction decoders return explicitly unvalidated borrowed field models. They classify and bound wire data, but do not validate signatures from the full transaction, check account state, or prove fork validity:
use DecodeLimits;
use ;
use ;
let dynamic_fee_tx = ;
let limits = DecodeLimits ;
let tx = decode_dynamic_fee_transaction?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
let mut encoded = ;
let written = encode_dynamic_fee_transaction?;
assert_eq!;
# Ok::
Replay Domain Checks
Replay-domain helpers reject wrong-chain transactions before sender recovery results are trusted:
use DecodeLimits;
use ChainId;
use decode_dynamic_fee_transaction;
use ;
let dynamic_fee_tx = ;
let limits = DecodeLimits ;
let tx = decode_dynamic_fee_transaction?;
require_dynamic_fee_replay_domain?;
assert_eq!;
# Ok::
Transaction Signing Hashes
Decoded transaction domains can be converted into canonical signing hashes without admitting a default hash backend:
use Keccak256;
use B256;
use decode_dynamic_fee_transaction;
use dynamic_fee_transaction_signing_hash;
use DecodeLimits;
let dynamic_fee_tx = ;
let limits = DecodeLimits ;
let tx = decode_dynamic_fee_transaction?;
let mut scratch = ;
let signing_hash = dynamic_fee_transaction_signing_hash?;
assert_eq!;
# Ok::
The example hasher is illustrative only. Production hashers must compute
Ethereum Keccak-256. For full decoded transaction signature validation, use
validate_transaction_signature or the type-specific validation helpers so
replay-domain checks, signing-hash construction, low-s/y-parity policy, sender
recovery, and optional expected-sender comparison are applied together. Callers
that reuse the scratch buffer across multiple in-flight transactions should
zero it after hashing before reusing or releasing it.
EIP-7702 authorization tuples use a separate signing-hash domain:
use Keccak256;
use ;
use ;
use set_code_authorization_signing_hash;
let mut chain_id = ;
if let Some = chain_id.last_mut
let authorization = SetCodeAuthorization ;
let mut scratch = ;
let authorization_hash = set_code_authorization_signing_hash?;
assert_eq!;
# Ok::
EIP-712 Typed Data
EIP-712 signing paths can build the structured-data digest from reviewed borrowed type descriptors and values without adding a concrete Keccak backend to the default graph:
use Keccak256;
use ;
use ;
let types = ;
let values = ;
let domain = Eip712DomainData ;
let mut scratch = ;
let _digest = ?;
#
# ;
#
# Ok::
JSON-RPC typed-data parsing is available only through the opt-in
eip712-json feature. It uses explicit parser limits, rejects duplicate JSON
object keys, and still relies on a caller-provided Keccak backend.
use ;
let json = r#"{
"types": {"Permit": [{"name": "owner", "type": "address"}]},
"primaryType": "Permit",
"domain": {"chainId": 1},
"message": {"owner": "0x1111111111111111111111111111111111111111"}
}"#;
let mut scratch = ;
let _digest = ?;
# Ok::
Sender Recovery
Sender recovery operates on an already constructed Ethereum signing digest. Transaction callers should prefer the signing-hash helpers above over hand-built transaction digests, then recover the sender with an admitted Keccak-256 backend:
use Keccak256;
use B256;
use SignatureYParity;
use ;
;
let digest = B256from;
let signature = from_parts;
let _result = recover_sender_from_digest_with_backend;
The recovery layer rejects malformed scalar values, high-s signatures, and
non-Ethereum recovery IDs. The example hasher above is illustrative only and
does not compute a real digest. Production hashers must implement Ethereum
Keccak-256, not FIPS SHA3-256, and should be checked with
eth::hash::verify_empty_digest_with before being wired into
recover_sender_from_digest_with_backend. A wrong secp256k1 or Keccak backend
produces a wrong sender address silently; there is no runtime cross-check. A
successful recovered address is still not a full transaction-validity proof.
Constant-Time Composition
B256::ct_eq and Wei::ct_eq return subtle::Choice so compound checks can
use & and | without short-circuiting:
use B256;
let block_hash = B256from;
let expected_block_hash = B256from;
let receipts_root = B256from;
let expected_receipts_root = B256from;
let valid = block_hash.ct_eq
& receipts_root.ct_eq;
assert!;
Convert Choice to bool only at the final trust boundary.
Keccak Boundary
eth defines a no_std Keccak-256 trait boundary and intentionally does not
ship a default hashing backend yet:
use ;
use B256;
let digest = hash_one;
assert_eq!;
Implementations must compute Ethereum Keccak-256, not FIPS SHA3-256. See
docs/keccak-boundary.md for the dependency
decision and future backend admission checklist.
Stable Errors
Error values expose stable codes, messages, and categories. They do not carry input bytes, keys, signatures, or other secret-bearing payloads:
use ;
let error = AllocationExceeded;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Decode Budgets
Every future untrusted decoder is required to use explicit limits. Use
DecodeAccumulator when more than one allocation can occur:
use ;
let limits = DecodeLimits ;
assert_eq!;
let mut budget = limits.accumulator;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
RLP Codec
The RLP codec admits canonical byte-string scalars, lists, and Ethereum integers with exact consumption. Decoders require explicit limits; encoders are buffer-based and do not allocate:
use ;
let limits = DecodeLimits ;
let scalar = decode_rlp_scalar?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
let mut encoded = ;
let written = encode_decoded_scalar?;
assert_eq!;
assert_eq!;
assert_eq!;
assert!;
let list = decode_rlp_list?;
assert_eq!;
assert_eq!;
let mut items = list.items;
let first = items.next.transpose?.and_then;
let second = items.next.transpose?.and_then;
assert!;
assert!;
let mut scalar_output = ;
assert_eq!;
assert_eq!;
let list_payload = ;
let mut list_output = ;
assert_eq!;
assert_eq!;
# Ok::
The RLP parser surface has cargo-fuzz targets and committed seed fixtures. See
docs/fuzzing.md for seed materialization, target scope, and
crash reproduction.
Withdrawals
EIP-4895 withdrawal lists decode into an explicitly unvalidated borrowed model.
The decoder checks canonical RLP shape, uint64 indexes, 20-byte recipient
addresses, and nonzero Gwei amounts, but it does not prove header
withdrawals_root membership or state-balance application:
use DecodeLimits;
use decode_withdrawals;
let limits = DecodeLimits ;
let raw = ;
let withdrawals = decode_withdrawals?;
let mut entries = withdrawals.entries;
let first = entries.next.transpose?.ok_or?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert!;
# Ok::
MPT Nodes
The verifier crate decodes Merkle Patricia Trie node shape without computing a root. Branch nodes must contain sixteen child references plus one scalar value; extension and leaf nodes must contain a compact hex-prefix path plus a child reference or scalar value:
use DecodeLimits;
use ;
let limits = DecodeLimits ;
let raw_leaf = ;
let node = decode_mpt_node?;
if let Leaf = node else
let branch = ;
let branch = decode_mpt_node?;
if let Branch = branch else
# Ok::
Transaction and receipt inclusion proofs can be checked against trusted trie
roots. The verifier derives the key as rlp(transaction_index), hashes proof
nodes through the caller-provided Keccak boundary, and compares the included
value byte-for-byte:
use DecodeLimits;
use TinyKeccak256;
use B256;
use ;
let limits = DecodeLimits ;
# let trusted_root = B256from_bytes;
# let encoded_transaction = ;
# let proof_nodes: = ;
let root = from_b256;
let result = verify_transaction_inclusion;
assert!;
Account and storage proof APIs derive keys as keccak256(address) and
keccak256(slot_key), then compare the encoded account or storage value
byte-for-byte. They do not decode account fields, prove that a storage root
belongs to a specific account, or interpret the storage scalar. See
docs/mpt-nodes.md.
Transaction Envelopes
The protocol crate can classify the outer transaction envelope without decoding or validating transaction fields:
use DecodeLimits;
use ;
let limits = DecodeLimits ;
let envelope = decode_transaction_envelope?;
assert!;
if let Typed = envelope
# Ok::
Typed payloads can be classified first, then decoded with the matching transaction decoder. Legacy transactions can also be decoded into an explicitly unvalidated field model:
use DecodeLimits;
use ;
let limits = DecodeLimits ;
let raw = ;
let tx = decode_legacy_transaction?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
The decoded value is not chain-valid, signature-valid, sender-recovered, or
fork-valid. It is only a bounded, canonical field parse. Use
eip155_chain_id instead of subtracting directly from the raw v signature
word; reserved ChainId(0) maps to None.
Optional Sanitization
The main facade stays small by default. Applications that handle local secret material can opt into the sanitization bridge:
use ;
let mut key = from_array;
key.secure_sanitize;
assert!;
For derive macros, depend on the support crate directly:
[]
= { = "0.7", = ["derive"] }
Public RLP encode/decode derives live in eth-valkyoth-derive:
[]
= "0.17"
= "0.17"
The derive surface is intentionally conservative. It supports reviewed structs
only, rejects generics/enums/unions, requires DecodeLimits for decode, and
keeps skipped fields explicit with #[eth_rlp(skip, default, reason = "...")].
Workspace Shape
Most users should depend on the facade crate, eth. The support crates are
published separately so implementation boundaries stay small, no_std
friendly, and independently testable.
| Crate | Default | Purpose |
|---|---|---|
eth |
yes | Facade crate over stable protocol-core crates. |
eth-valkyoth-primitives |
yes | Chain, fork, block, gas, nonce, address, hash, wei, and bounded value types. |
eth-valkyoth-codec |
yes | Bounded exact-consumption wire codec policy. |
eth-valkyoth-hash |
yes | Keccak-256 trait boundary for caller-provided hash implementations. |
eth-valkyoth-protocol |
yes | Fork-aware validation states and protocol context. |
eth-valkyoth-verify |
yes | Verification boundaries for signatures, proofs, replay domains, and EIP-712 typed-data hashing. |
eth-valkyoth-sanitization |
no | Optional bridge to the sanitization crate for secret-bearing Ethereum data. |
eth-valkyoth-derive |
no | Optional sanitization and RLP derive macros. |
eth-valkyoth-evm |
no | Explicit no_std EVM execution boundary; no backend admitted yet. |
eth-valkyoth-evm-core |
no | Dependency-free native EVM core domains plus gas-metered basic bounded opcode execution and explicit host-state reads; no calls/creates yet. |
eth-valkyoth-rpc |
no | Future explicit RPC trust-policy boundary. |
eth-valkyoth-signer |
no | Future signer isolation boundary. |
eth-valkyoth-reth |
no | Future Reth integration boundary. |
eth-valkyoth-testkit |
no | Test fixtures, conformance helpers, and adversarial inputs. |
Rust Version Support
The minimum supported Rust version is Rust 1.90.0. New deployments should use
the pinned stable Rust 1.96.1 until the toolchain policy is updated.
Compatibility evidence for 0.43.0:
| Rust | Local Evidence |
|---|---|
1.90.0 |
cargo check --workspace --all-features |
1.91.0 |
cargo check --workspace --all-features |
1.92.0 |
cargo check --workspace --all-features |
1.93.0 |
cargo check --workspace --all-features |
1.94.0 |
cargo check --workspace --all-features |
1.95.0 |
cargo check --workspace --all-features |
1.96.0 |
cargo check --workspace --all-features |
1.96.1 |
full release gate |
Checks
For dependency-policy checks, install cargo-deny and cargo-audit, then run:
Documentation
- Implementation Plan
- Release Plan
- Block Headers
- Receipts
- Withdrawals
- Keccak Boundary
- Transaction Signing Hashes
- Transaction Signature Validation
- k256 Dependency Admission
- Fuzzing
- Scope
- Threat Model
- Spec Matrix
- Spec Source Policy
- GitHub Security Settings
- Secret Handling Policy
- Modularity Policy
- Supply-Chain Security
- Unsafe Policy
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.