# Ethereum - ZisK v0.15.0 - AIR Cost Reth and Ethrex
This document contains an analysis of ZisK AIR-costs of Reth and Ethrex guest programs.
This was done by an [integration](https://github.com/eth-act/zkevm-benchmark-workload/pull/259) of `ziskemu` AIR-cost analyzer into [zkevm-benchmark-workload](https://github.com/eth-act/zkevm-benchmark-workload), plus proper cycle-scoping in [ere-guests](https://github.com/eth-act/ere-guests) and custom forks in Ethrex and Reth only for adding deeper marks than present int [ere-guests](https://github.com/eth-act/ere-guests/blob/main/crates/stateless-validator-ethrex/src/guest.rs#L86-L88) in relevant code sections.
AIR-costs are significantly better performance proxies than zkVM cycles, since cycles do not represent fair costs when zkVMs precompiles are used.
In the following sections, we show the guest programs internal costs analyzed in 500 consecutive mainnet blocks (block nums [23533500, 23533999]).
When `ZONE_1 (XX%, YYYY)` is shown this means:
- `ZONE_1` the name of the logic being measured.
- `XX%` the relative cost of this section compared to the total run cost.
- `YYYY` nominal cost of the section -- useful to compare between guest programs.
Both Reth and Ethrex ASCII diagrams show the execution order of block execution.
## Reth
Guest program structure:
```
Total avg. cost: 51.1B
┌────────────────────────────────────────────┐
│ READ_INPUT (0.8%, 407.0M) │
│ DESERIALIZE_INPUT (3.0%, 1.6B) │
└────────────────┬───────────────────────────┘
▼
┌──────────────────────────────────────────────────────┐
│ EIP-8025 (8.2%) │
│ ├ NEW_PAYLOAD_REQUEST_ROOT (7.5%, 3.8B) │
│ ├ MISC_PREPARATION (0.0%, 5.6M) │
│ └ NEW_PAYLOAD_REQUEST_TO_BLOCK (0.7%, 373.2M) │
└────────────────────────┬─────────────────────────────┘
▼
┌──────────────────────────────────────────────────────┐
│ STF (86.7%, 44.4B) │
│ ├ RECOVER_PUBLIC_KEYS (1.5%, 742.0M) │
│ ├ VALIDATE_ANCESTOR_HEADERS (0.0%, 6.9M) │
│ ├ VALIDATE_BLOCK_CONSENSUS (0.7%, 352.2M) │
│ ├ VALIDATE_ACCOUNT_TRIE (31.6%, 16.0B) │
│ ├ EXECUTE_BLOCK (40.8%, 21.2B) │
│ ├ POST_VALIDATION_CHECKS (1.8%, 939.8M) │
│ └ COMPUTE_POST_STATE_ROOT (10.3%, 5.2B) │
└────────────────────────┬─────────────────────────────┘
▼
┌────────────────────────────────────────────┐
│ SERIALIZE_OUTPUT (0.0%, 97.8K) │
│ WRITE_OUTPUT (0.0%, 42.1K) │
└────────────────────────────────────────────┘
```
Notes:
- The Reth guest program uses Risc0 MPT. In `VALIDATE_ACCOUNT_TRIE` it verifies the **account** trie before any EVM execution. Storage tries are checked **on first access** during EVM execution, so their check is part of `EXECUTE_BLOCK` costs.
To understand better the variability of costs per scope:

Notes:
- `validate_ancestor_headers` variability makes sense since depending on existing `BLOCKHASH` executions in the block, this forces to include between 1 to 256 ancestor headers.
## Ethrex
Guest program structure:
```
Total avg. cost: 58.9B
┌────────────────────────────────────────────┐
│ READ_INPUT (0.9%, 504.7M) │
│ DESERIALIZE_INPUT (18.7%, 10.9B) │
└────────────────┬───────────────────────────┘
▼
┌──────────────────────────────────────────────────────┐
│ EIP-8025 (7.6%) │
│ ├ NEW_PAYLOAD_REQUEST_ROOT (6.5%, 3.8B) │
│ ├ MISC_PREPARATION (0.0%, 212.7K) │
│ └ NEW_PAYLOAD_REQUEST_TO_BLOCK (1.1%, 614.8M) │
└────────────────────────┬─────────────────────────────┘
▼
┌──────────────────────────────────────────────────────┐
│ STF (72.1%, 42.8B) │
│ ├ PRE_STATE_INIT (25.5%, 15.0B) │
│ ├ ANCESTOR_VALIDATION (0.0%, 8.5M) │
│ ├ VALIDATE_BLOCK_CONSENSUS (0.0%, 206.0K) │
│ ├ SETUP_EVM (0.0%, 6.2K) │
│ ├ EXECUTE_BLOCK (33.0%, 19.8B) │
│ ├ GET_STATE_TRANSITIONS (0.3%, 192.1M) │
│ ├ APPLY_ACCOUNT_UPDATES (6.4%, 3.8B) │
│ ├ POST_VALIDATION_CHECKS (2.1%, 1.3B) │
│ └ POST_STATE_ROOT_CALCULATION (4.8%, 2.7B) │
└────────────────────────┬─────────────────────────────┘
▼
┌────────────────────────────────────────────┐
│ SERIALIZE_OUTPUT (0.0%, 49.8K) │
│ SHA256_OUTPUT_BYTES (0.0%, 117.0K) │
│ WRITE_OUTPUT (0.0%, 42.1K) │
└────────────────────────────────────────────┘
```
Notes:
- Note the high `DESERIALIZE_INPUT` cost compared to Reth. Ethrex uses `rkyv` for input deserialization compared to `bincode` in Reth.
- The `EIP-8025` zone looks very similar with Reth (in nominal cost). This makes sense, since they share most of the implementation in `ere-guests` (I [wrote that in Rust](https://github.com/eth-act/ere-guests/pull/7), so in `ere-guests` both leverage the impl). Most dominant factor in this zone is the `NewPayloadRequest` hash tree root calculation for public inputs (expected).
- `POST_STATE_ROOT_CALCULATION`, in nominal terms, is 1.75x faster in Ethrex than Reth.
- As mentioned in the _Reth_ section, comparing pre-state validation is complicated, since Reth checks part of pre-state during EVM execution and not fully before.
To understand better the variability of costs per scope:

Notes:
- `ancestor_validation` variability has the same explanation done for Reth.