Skip to content

feat(l1): tokamak proven execution — phase 0-1.3 foundation#2

Open
cd4761 wants to merge 92 commits intomainfrom
feat/tokamak-proven-execution
Open

feat(l1): tokamak proven execution — phase 0-1.3 foundation#2
cd4761 wants to merge 92 commits intomainfrom
feat/tokamak-proven-execution

Conversation

@cd4761
Copy link
Member

@cd4761 cd4761 commented Feb 23, 2026

Summary

Tokamak Ethereum Client의 Phase 0 ~ Phase 1.3 + Phase 2 기반 작업입니다.

  • Phase 0: ethrex fork 결정(DECISION.md), 비전/아키텍처 문서, Volkov R6 리뷰(7.5 PROCEED)
  • Phase 1.1: 아키텍처 분석(LEVM, modification points), skeleton crates(tokamak-jit, tokamak-debugger), feature flags, Volkov R8-R10 리뷰(8.25 PROCEED)
  • Phase 1.2: Feature flag 분할(tokamak-jit/debugger/l2), pr-tokamak.yaml CI 워크플로우, fork CI 조정
  • Phase 1.3: OpcodeTimings accessor methods(reset, raw_totals, raw_counts), tokamak-bench crate(runner/report/regression), pr-tokamak-bench.yaml CI
  • Phase 2: tokamak-jit compiler infrastructure (adapter, compiler, backend, validation), JIT LEVM infra modules (analyzer, cache, counter, dispatch, types)

주요 변경

영역 내용
신규 crate tokamak-bench, tokamak-jit, tokamak-debugger (skeleton)
CI pr-tokamak.yaml, pr-tokamak-bench.yaml
LEVM 확장 timings.rs — reset/raw accessor methods
LEVM JIT infra crates/vm/levm/src/jit/ — types, analyzer, counter, cache, dispatch
tokamak-jit adapter, compiler, backend, validation, error modules
문서 docs/tokamak/ 전체 (DECISION, architecture, features, vision)
격리 전략 Hybrid (feature flag ~30줄 + 신규 crate 3개)

검증 결과 (로컬)

  • cargo build --release -p tokamak-bench — OK
  • cargo test -p tokamak-bench — 11 tests pass
  • cargo test -p tokamak-jit — 7 tests pass
  • cargo check --features tokamak — OK
  • cargo clippy --features tokamak -- -D warnings — OK
  • cargo clippy --workspace --features l2,l2-sql -- -D warnings — OK

Test plan

  • pr-tokamak.yaml Quality Gate 통과
  • pr-tokamak-bench.yaml Benchmark PR 통과
  • cargo check --features tokamak 통과
  • cargo test -p tokamak-bench -p tokamak-jit 전체 통과
  • 기존 workspace 테스트에 regression 없음
  • Feature flag 미활성 시 기존 코드 영향 없음 확인

Complete Phase 0 analysis: evaluate ethrex, Reth, from-scratch, and
revm-only options via weighted decision matrix. ethrex fork selected
(score 4.85/5) for its custom LEVM, ZK-native architecture, Hook
system, and manageable 133K-line codebase.

Includes vision, competitive landscape, feature specs, team discussion
summaries, Volkov review history, and branch strategy.
- Rebalance decision matrix to ethrex vs Reth binary comparison;
  move "from scratch" and "revm only" to appendix
- Adjust Reth scores: ZK 1→2 (Zeth exists), manageability 2→3
  (modular arch acknowledged), sync 5→4 for ethrex (less battle-tested)
- Add EXIT criteria with 4 elements: metric, deadline, action, owner
- Add Tier S PoC section: perf_opcode_timings build verification
  and code path analysis
- Add JIT technical barriers (dynamic jumps, revmc reference)
- Fix weighted sum arithmetic (Reth 2.85→2.80)
Record completed work: DECISION.md creation, Volkov R6 review (6.5/10),
three mandatory fixes (matrix rebalance, EXIT criteria, Tier S PoC),
Reth/Zeth/ExEx research findings, and next steps for Phase 1.1.
- DECISION.md: DRAFT → FINAL
- Replace human staffing model with AI Agent development model
- Add bus factor policy (Kevin as interim decision-maker)
- Replace staffing risks with agent-specific risks
- Remove Senior Rust 2명 EXIT criterion
- Add 11 custom commands (.claude/commands/):
  - Development: /rust, /evm, /jit, /debugger, /l2
  - Verification: /quality-gate, /safety-review, /diff-test
  - Operations: /rebase-upstream, /phase, /bench
- Volkov R8: 7.5/10 PROCEED achieved
Architecture analysis documents:
- OVERVIEW.md: 25+2 crate dependency graph, node startup flow, CI inventory
- LEVM.md: VM struct, execution flow, dual-dispatch loop, hook system
- MODIFICATION-POINTS.md: 5 modification points, hybrid isolation strategy
- PHASE-1-1.md: Phase 1.1 execution plan with success criteria

Phase 1.1 infrastructure:
- Skeleton crates: tokamak-jit, tokamak-bench, tokamak-debugger
- Feature flag: `tokamak` propagation chain (cmd → vm → levm)
- Workspace registration for 3 new crates
- Fix OpcodeTimings: remove false min/max claim, document 4 actual fields
- Fix CallFrame: caller→msg_sender, Bytes→Code, return_data→output/sub_return_data
- Fix opcode table: describe const fn chaining pattern accurately
- Label all pseudocode snippets consistently (JIT, debugger, L2 hook)
- Plan feature flag split: tokamak → tokamak-jit/debugger/l2
- Add JIT-VM interface complexity analysis (5 challenges)
- Add failure scenarios & mitigations table (5 scenarios)
- Record build results: 5m53s clean, 718 tests passed
- Fix line count ~133K → ~103K (verified via wc -l)
- Add tokamak feature to OVERVIEW.md feature tables
Split monolithic `tokamak` feature into 3 independent features
(tokamak-jit, tokamak-debugger, tokamak-l2) with umbrella re-export.
Add pr-tokamak.yaml CI workflow for quality-gate and format checks.
Update snapsync action default image to tokamak-network/ethrex.
Document sync architecture, Hive test matrix, and success criteria.
Add structured benchmark infrastructure to tokamak-bench crate:
- timings.rs: reset(), raw_totals(), raw_counts() accessors
- tokamak-bench: types, runner, report, regression modules + CLI binary
- CI workflow: pr-tokamak-bench.yaml (bench PR vs base, post comparison)
- 11 unit tests covering regression detection, JSON roundtrip, reporting
Feature unification causes these modules to be compiled during L2
workspace clippy. Add targeted allows for arithmetic_side_effects,
as_conversions, expect_used, and unsafe_code lints.
Add the core JIT tiered compilation modules that were missing from
the branch: execution counter, code cache dispatch, types, and
module declaration. These provide the lightweight in-process
infrastructure gated behind the tokamak-jit feature flag.
- tokamak-jit: compiler, backend, adapter, validation, error modules
- JIT backend CI job with LLVM 18 in pr-tokamak.yaml
- jit_bench module in tokamak-bench for interpreter vs JIT comparison
- Phase 2 architecture documentation
- Updated HANDOFF with current status
@github-actions
Copy link

🤖 Kimi Code Review

⚠️ Review failed: KIMI_API_KEY secret is not set


Automated review by Kimi (Moonshot AI)

@gemini-code-assist
Copy link

Summary of Changes

Hello @cd4761, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 Tokamak 이더리움 클라이언트의 기반을 다지는 중요한 진전을 나타냅니다. JIT EVM, 연속 벤치마킹, 타임-트래블 디버거와 같은 핵심 기능을 위한 아키텍처적 토대를 마련하는 데 중점을 두었습니다. 이를 위해 새로운 크레이트와 CI 워크플로우를 도입하고, 기존 LEVM(Lambda EVM)에 JIT 관련 인프라를 통합하며, 프로젝트의 방향과 구현 세부 사항을 명확히 하는 광범위한 문서를 추가했습니다. 이 작업은 향후 Tokamak 클라이언트의 성능, 검증 가능성 및 디버깅 용이성을 향상시키기 위한 초석이 될 것입니다.

Highlights

  • Tokamak 클라이언트 기반 마련: ethrex 포크 결정, 비전 및 아키텍처 문서화, Volkov 리뷰를 통한 초기 단계 승인 등 Tokamak 이더리움 클라이언트의 기반 작업이 완료되었습니다.
  • 아키텍처 분석 및 스켈레톤 크레이트 추가: LEVM 아키텍처 분석을 통해 tokamak-jit, tokamak-debugger 스켈레톤 크레이트가 추가되었고, 초기 기능 플래그 설정 및 Volkov 리뷰를 통과했습니다.
  • 기능 플래그 분할 및 CI 워크플로우 개선: 모놀리식 tokamak 기능 플래그가 tokamak-jit, tokamak-debugger, tokamak-l2로 분할되었으며, pr-tokamak.yaml CI 워크플로우가 추가되고 포크 CI 설정이 조정되었습니다.
  • 연속 벤치마킹 인프라 구축: OpcodeTimingsreset, raw_totals, raw_counts 접근자 메서드가 추가되었고, tokamak-bench 크레이트(러너, 리포트, 회귀 분석) 및 pr-tokamak-bench.yaml CI가 구현되었습니다.
  • JIT EVM 인프라 초기 구현: tokamak-jit 컴파일러 인프라(어댑터, 컴파일러, 백엔드, 유효성 검사)와 LEVM JIT 인프라 모듈(분석기, 캐시, 카운터, 디스패치, 타입)이 추가되었습니다.
  • 새로운 크레이트 추가: tokamak-bench, tokamak-jit, tokamak-debugger 세 가지 새로운 크레이트가 워크스페이스에 추가되었습니다.
  • LEVM JIT 인프라 모듈: crates/vm/levm/src/jit/ 경로에 JIT 컴파일을 위한 분석기, 캐시, 카운터, 디스패치, 타입 모듈이 추가되었습니다.
  • 광범위한 문서화: docs/tokamak/ 디렉토리에 DECISION, 아키텍처, 기능, 비전 등 Tokamak 프로젝트 관련 광범위한 문서가 추가되었습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .claude/commands/bench.md
    • 벤치마크 러너에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/debugger.md
    • 타임-트래블 디버거에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/diff-test.md
    • 차등 테스트에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/evm.md
    • EVM 전문가에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/jit.md
    • JIT 컴파일러 개발자에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/l2.md
    • L2 Hook 개발자에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/phase.md
    • 단계 관리에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/quality-gate.md
    • 품질 게이트에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/rebase-upstream.md
    • 업스트림 리베이스에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/rust.md
    • Rust 전문가 개발자에 대한 새로운 명령 문서가 추가되었습니다.
  • .claude/commands/safety-review.md
    • 안전성 검토에 대한 새로운 명령 문서가 추가되었습니다.
  • .github/actions/snapsync-run/action.yml
    • 기본 ethrex Docker 이미지 저장소가 업데이트되었습니다.
  • Cargo.lock
    • alloy-primitives 종속성 버전이 업데이트되었고, inkwell, llvm-sys, regex-lite, revm-*, revmc-* 패키지가 추가되었습니다.
  • Cargo.toml
    • tokamak-jit, tokamak-bench, tokamak-debugger가 워크스페이스 멤버로 추가되었습니다.
  • cmd/ethrex/Cargo.toml
    • tokamak-jit, tokamak-debugger, tokamak-l2, tokamak 기능 플래그가 추가되었습니다.
  • crates/tokamak-bench/Cargo.toml
    • Tokamak 벤치마크를 위한 새로운 크레이트가 추가되었습니다.
  • crates/tokamak-bench/src/bin/runner.rs
    • Tokamak 벤치마크를 위한 메인 CLI 러너가 추가되었습니다.
  • crates/tokamak-bench/src/jit_bench.rs
    • JIT 벤치마크 결과 구조와 인터프리터 기준선 측정 로직이 추가되었습니다.
  • crates/tokamak-bench/src/lib.rs
    • jit_bench, regression, report, runner, types 모듈 선언이 추가되었습니다.
  • crates/tokamak-bench/src/regression.rs
    • 벤치마크 스위트 비교 및 회귀 감지 로직이 추가되었습니다.
  • crates/tokamak-bench/src/report.rs
    • JSON 직렬화/역직렬화 및 마크다운 보고서 생성 함수가 추가되었습니다.
  • crates/tokamak-bench/src/types.rs
    • 벤치마크 스위트, 결과, opcode 항목 및 회귀 보고서를 위한 데이터 구조가 추가되었습니다.
  • crates/tokamak-debugger/Cargo.toml
    • Tokamak 디버거를 위한 새로운 크레이트가 추가되었습니다.
  • crates/tokamak-debugger/src/lib.rs
    • Tokamak 타임-트래블 디버거를 위한 플레이스홀더 파일이 추가되었습니다.
  • crates/vm/Cargo.toml
    • tokamak-jit, tokamak-debugger, tokamak-l2, tokamak 기능 플래그가 추가되었습니다.
  • crates/vm/levm/Cargo.toml
    • tokamak-jit, tokamak-debugger, tokamak-l2, tokamak 기능 플래그가 추가되었습니다.
  • crates/vm/levm/src/jit/analyzer.rs
    • JIT 컴파일을 위한 바이트코드 분석 로직이 추가되었습니다.
  • crates/vm/levm/src/jit/cache.rs
    • 컴파일된 함수 포인터를 저장하기 위한 JIT 코드 캐시가 추가되었습니다.
  • crates/vm/levm/src/jit/counter.rs
    • JIT 컴파일 티어링을 위한 실행 카운터가 추가되었습니다.
  • crates/vm/levm/src/jit/dispatch.rs
    • JIT 디스패치 로직 및 전역 상태 관리가 추가되었습니다.
  • crates/vm/levm/src/jit/mod.rs
    • JIT 컴파일 인프라를 위한 모듈 선언이 추가되었습니다.
  • crates/vm/levm/src/jit/types.rs
    • JIT 컴파일 시스템을 위한 핵심 데이터 구조가 추가되었습니다.
  • crates/vm/levm/src/lib.rs
    • jit 모듈이 조건부로 추가되었습니다.
  • crates/vm/levm/src/precompiles.rs
    • #[allow(clippy::expect_used)] 속성이 추가되었습니다.
  • crates/vm/levm/src/timings.rs
    • OpcodeTimingsPrecompilesTimingsreset, raw_totals, raw_counts 메서드가 추가되었고, clippy 허용 규칙이 추가되었습니다.
  • crates/vm/levm/src/vm.rs
    • JIT_STATE 지연 정적 변수와 run_execution 루프에 JIT 디스패치 로직이 추가되었습니다.
  • crates/vm/tokamak-jit/Cargo.toml
    • Tokamak JIT 컴파일러를 위한 새로운 크레이트가 revmc 종속성과 함께 추가되었습니다.
  • crates/vm/tokamak-jit/src/adapter.rs
    • LEVM 상태를 revmc/revm 타입 모델로 연결하기 위한 어댑터 계층이 추가되었습니다.
  • crates/vm/tokamak-jit/src/backend.rs
    • EVM 바이트코드 컴파일 및 캐싱을 위한 고수준 JIT 백엔드가 추가되었습니다.
  • crates/vm/tokamak-jit/src/compiler.rs
    • EVM 바이트코드 컴파일을 위한 revmc/LLVM 컴파일러 래퍼가 추가되었습니다.
  • crates/vm/tokamak-jit/src/error.rs
    • JIT 컴파일을 위한 오류 타입이 추가되었습니다.
  • crates/vm/tokamak-jit/src/lib.rs
    • Tokamak JIT 컴파일러를 위한 모듈 선언 및 재내보내기가 추가되었습니다.
  • crates/vm/tokamak-jit/src/tests/fibonacci.rs
    • JIT 컴파일러를 위한 피보나치 PoC 테스트가 추가되었습니다.
  • crates/vm/tokamak-jit/src/tests/mod.rs
    • JIT 테스트를 위한 모듈 선언이 추가되었습니다.
  • crates/vm/tokamak-jit/src/validation.rs
    • JIT 및 인터프리터 결과 비교를 위한 유효성 검사 로직이 추가되었습니다.
  • docs/tokamak/DECISION.md
    • Tokamak EL 클라이언트 기반으로 ethrex를 포크하기 위한 결정 문서가 추가되었습니다.
  • docs/tokamak/README.md
    • Tokamak 이더리움 클라이언트의 비전과 기능을 설명하는 README 문서가 추가되었습니다.
  • docs/tokamak/architecture/LEVM.md
    • LEVM 아키텍처에 대한 심층 분석 문서가 추가되었습니다.
  • docs/tokamak/architecture/MODIFICATION-POINTS.md
    • Tokamak 수정 지점 및 격리 전략을 상세히 설명하는 문서가 추가되었습니다.
  • docs/tokamak/architecture/OVERVIEW.md
    • ethrex 아키텍처 개요 문서가 추가되었습니다.
  • docs/tokamak/architecture/PHASE-1-1.md
    • Phase 1.1: 포크 및 환경 설정에 대한 문서가 추가되었습니다.
  • docs/tokamak/architecture/PHASE-1-2.md
    • Phase 1.2: 동기화 및 Hive + CI 인프라에 대한 문서가 추가되었습니다.
  • docs/tokamak/architecture/PHASE-1-3.md
    • Phase 1.3: 벤치마킹 기반에 대한 문서가 추가되었습니다.
  • docs/tokamak/architecture/PHASE-2.md
    • Phase 2: JIT 기반 (revmc 통합)에 대한 문서가 추가되었습니다.
  • docs/tokamak/branch-strategy.md
    • Tokamak ethrex 브랜치 전략을 설명하는 문서가 추가되었습니다.
  • docs/tokamak/context/competitive-landscape.md
    • 이더리움 EL 클라이언트의 경쟁 환경을 분석하는 문서가 추가되었습니다.
  • docs/tokamak/context/open-questions.md
    • 미해결 질문 및 듀얼-트랙 전략을 다루는 문서가 추가되었습니다.
  • docs/tokamak/context/team-discussion-summary.md
    • 팀 토론 요약 문서가 추가되었습니다.
  • docs/tokamak/context/volkov-reviews.md
    • Volkov의 검토 이력 문서가 추가되었습니다.
  • docs/tokamak/features/01-time-travel-debugger.md
    • 타임-트래블 디버거 기능 문서가 추가되었습니다.
  • docs/tokamak/features/02-continuous-benchmarking.md
    • 연속 벤치마킹 기능 문서가 추가되었습니다.
  • docs/tokamak/features/03-jit-compiled-evm.md
    • JIT-컴파일된 EVM 기능 문서가 추가되었습니다.
  • docs/tokamak/scaffold/HANDOFF.md
    • Tokamak 이더리움 클라이언트 핸드오프 문서가 추가되었습니다.
  • docs/tokamak/slack-post.md
    • 통합 비전을 위한 Slack 게시물 초안이 추가되었습니다.
  • docs/tokamak/slack-short.md
    • 요약된 Slack 게시물 초안이 추가되었습니다.
  • docs/tokamak/vision.md
    • Tokamak 이더리움 클라이언트의 통합 비전 문서가 추가되었습니다.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/pr-tokamak-bench.yaml
    • .github/workflows/pr-tokamak.yaml
Activity
  • Phase 0 작업(ethrex 포크 결정, 비전/아키텍처 문서화, Volkov R6 검토)이 완료되었습니다.
  • Phase 1.1 작업(아키텍처 분석, 스켈레톤 크레이트, 기능 플래그, Volkov R8-R10 검토)이 완료되었습니다.
  • Phase 1.2 작업(기능 플래그 분할, pr-tokamak.yaml CI 워크플로우, 포크 CI 조정)이 완료되었습니다.
  • Phase 1.3 작업(OpcodeTimings 접근자 메서드, tokamak-bench 크레이트, pr-tokamak-bench.yaml CI)이 완료되었습니다.
  • Phase 2 작업(JIT 컴파일러 인프라 및 LEVM JIT 인프라 모듈)이 완료되었습니다.
  • tokamak-benchtokamak-jit에 대한 로컬 검증 테스트가 통과되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 Tokamak Ethereum 클라이언트의 기반을 마련하는 중요한 작업입니다. JIT 컴파일, 벤치마킹, 디버깅을 위한 새로운 크레이트(tokamak-jit, tokamak-bench, tokamak-debugger)를 도입하고, 기존 ethrex-levm에 JIT 인프라와 벤치마킹을 위한 접근자 메소드를 추가했습니다. 또한, 기능별로 분리된 tokamak-* 피처 플래그와 CI 워크플로우를 설정하여 프로젝트의 구조를 체계적으로 잡았습니다. 전반적으로 코드 품질이 높고, 아키텍처에 대한 깊은 고민이 엿보입니다. 몇 가지 유지보수성 및 잠재적 메모리 누수와 관련된 개선점을 제안했지만, 이는 이 훌륭한 기반 작업의 가치를 훼손하지 않습니다.

Comment on lines 42 to 50
// SAFETY: The compiled function pointer is stored in CompiledCode
// which is kept alive in the CodeCache. The LLVM JIT memory backing
// the function is not freed (no `free_function` call in PoC).
#[expect(unsafe_code)]
let f: EvmCompilerFn = unsafe {
compiler
.jit(&hash_hex, bytecode, SpecId::CANCUN)
.map_err(|e| JitError::CompilationFailed(format!("{e}")))?
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

안전성 주석에 "no free_function call in PoC"라고 언급되어 있는데, 이는 컴파일된 코드가 메모리에서 해제되지 않아 메모리 누수가 발생할 수 있음을 시사합니다. PoC 단계에서는 괜찮을 수 있지만, 프로덕션 환경에서는 반드시 해결해야 할 문제입니다. 향후 JIT 코드 캐시에서 엔트리가 제거될 때 (예: LRU 정책에 의해) 컴파일된 함수 메모리도 함께 해제하는 메커니즘을 설계해야 합니다. revmc가 컴파일된 함수를 해제하는 API를 제공하는지 확인하고, 이를 CodeCacheinvalidateDrop 구현과 연동하는 것을 고려해야 합니다.

Comment on lines +1 to +5
#![allow(
clippy::arithmetic_side_effects,
clippy::as_conversions,
clippy::type_complexity
)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

파일 전체에 대해 중요한 clippy lint(특히 arithmetic_side_effectsas_conversions)를 비활성화하는 것은 잠재적인 버그를 숨길 수 있어 위험합니다. 이 PR에서 추가된 코드는 이 lint들을 발생시키지 않는 것으로 보입니다. 기존 코드의 특정 부분에서 lint가 발생한다면, 해당 라인이나 함수에만 #[allow(...)]를 적용하여 범위를 좁히는 것이 더 안전합니다. 예를 들어, info 함수 내의 count as f64 변환이 원인이라면 해당 표현식에만 lint를 허용하는 것이 좋습니다.

@github-actions
Copy link

Tokamak Benchmark Results: Baseline

No baseline benchmark found on the base branch.
This PR establishes the initial benchmark baseline.

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Benchmark Results Comparison

No significant difference was registered for any benchmark run.

Detailed Results

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
main_revm_BubbleSort 2.945 ± 0.021 2.915 2.981 1.06 ± 0.01
main_levm_BubbleSort 2.770 ± 0.015 2.736 2.790 1.00
pr_revm_BubbleSort 2.992 ± 0.061 2.943 3.152 1.08 ± 0.02
pr_levm_BubbleSort 2.862 ± 0.279 2.753 3.653 1.03 ± 0.10

Benchmark Results: ERC20Approval

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Approval 980.6 ± 14.0 967.3 1011.9 1.00
main_levm_ERC20Approval 1053.7 ± 10.6 1039.2 1071.6 1.07 ± 0.02
pr_revm_ERC20Approval 982.7 ± 6.5 974.8 994.3 1.00 ± 0.02
pr_levm_ERC20Approval 1048.9 ± 10.7 1039.6 1075.8 1.07 ± 0.02

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 135.2 ± 2.2 132.5 138.9 1.01 ± 0.02
main_levm_ERC20Mint 159.8 ± 2.3 157.2 163.6 1.19 ± 0.02
pr_revm_ERC20Mint 134.4 ± 1.2 133.2 137.3 1.00
pr_levm_ERC20Mint 160.8 ± 2.9 157.1 164.9 1.20 ± 0.02

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 236.6 ± 5.7 232.2 251.6 1.01 ± 0.03
main_levm_ERC20Transfer 273.1 ± 6.2 268.4 289.9 1.17 ± 0.03
pr_revm_ERC20Transfer 234.0 ± 2.1 231.2 237.2 1.00
pr_levm_ERC20Transfer 274.3 ± 11.9 265.5 306.0 1.17 ± 0.05

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 229.9 ± 1.0 228.0 231.5 1.00
main_levm_Factorial 265.8 ± 6.1 261.3 277.7 1.16 ± 0.03
pr_revm_Factorial 233.2 ± 2.6 230.3 239.2 1.01 ± 0.01
pr_levm_Factorial 265.4 ± 1.9 263.2 268.0 1.15 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.763 ± 0.040 1.694 1.810 1.03 ± 0.07
main_levm_FactorialRecursive 9.946 ± 0.082 9.784 10.063 5.83 ± 0.40
pr_revm_FactorialRecursive 1.706 ± 0.116 1.402 1.804 1.00
pr_levm_FactorialRecursive 9.870 ± 0.088 9.769 10.054 5.79 ± 0.40

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 211.4 ± 0.7 210.2 212.8 1.00
main_levm_Fibonacci 240.0 ± 4.5 236.1 250.1 1.14 ± 0.02
pr_revm_Fibonacci 213.6 ± 1.3 212.1 216.9 1.01 ± 0.01
pr_levm_Fibonacci 237.2 ± 0.9 235.1 238.5 1.12 ± 0.01

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 884.3 ± 12.8 864.0 909.1 1.21 ± 0.03
main_levm_FibonacciRecursive 731.5 ± 14.1 710.9 754.0 1.00
pr_revm_FibonacciRecursive 903.0 ± 11.7 886.9 929.2 1.23 ± 0.03
pr_levm_FibonacciRecursive 735.5 ± 5.0 728.4 744.2 1.01 ± 0.02

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.6 ± 0.1 8.5 8.8 1.00
main_levm_ManyHashes 10.1 ± 0.1 9.9 10.3 1.17 ± 0.02
pr_revm_ManyHashes 8.6 ± 0.1 8.4 8.9 1.01 ± 0.02
pr_levm_ManyHashes 10.2 ± 0.2 10.0 10.6 1.19 ± 0.03

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 267.8 ± 1.3 266.2 270.4 1.19 ± 0.02
main_levm_MstoreBench 225.8 ± 3.6 222.4 231.8 1.00
pr_revm_MstoreBench 272.0 ± 10.9 266.0 301.0 1.20 ± 0.05
pr_levm_MstoreBench 227.5 ± 5.7 222.3 240.9 1.01 ± 0.03

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 296.0 ± 2.1 294.1 301.3 1.00
main_levm_Push 297.6 ± 3.2 292.1 303.1 1.01 ± 0.01
pr_revm_Push 296.1 ± 3.0 294.0 303.8 1.00 ± 0.01
pr_levm_Push 306.4 ± 13.2 296.8 341.8 1.04 ± 0.05

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 171.0 ± 5.1 164.3 181.9 1.55 ± 0.05
main_levm_SstoreBench_no_opt 110.6 ± 1.7 108.8 113.2 1.00
pr_revm_SstoreBench_no_opt 172.2 ± 6.5 165.2 189.3 1.56 ± 0.06
pr_levm_SstoreBench_no_opt 112.2 ± 4.2 109.2 123.2 1.01 ± 0.04

Add Phase 3 JIT execution wiring so JIT-compiled bytecode actually
runs through the VM dispatch instead of only being compiled.

Key changes:
- JitBackend trait in dispatch.rs for dependency inversion (LEVM
  defines interface, tokamak-jit implements)
- LevmHost: revm Host v14.0 implementation backed by LEVM state
  (GeneralizedDatabase, Substate, Environment)
- Execution bridge: builds revm Interpreter, wraps state in LevmHost,
  transmutes CompiledCode to EvmCompilerFn, maps result to JitOutcome
- vm.rs wiring: try_jit_dispatch() && execute_jit() before interpreter
  loop, with fallback on failure
- register_jit_backend() for startup registration
- E2E tests: fibonacci JIT execution + JIT vs interpreter validation
  (behind revmc-backend feature, requires LLVM 21)
Close 7 gaps preventing production use of the JIT system:

- 4A: Propagate is_static from CallFrame to revm Interpreter
- 4B: Sync gas refunds after JIT execution, pass storage_original_values
  through JIT chain for correct SSTORE original vs present value
- 4C: Add LRU eviction to CodeCache (VecDeque + max_entries)
- 4D: Auto-compile when execution counter hits threshold, add compile()
  to JitBackend trait and backend() accessor to JitState
- 4E: Detect CALL/CREATE/DELEGATECALL/STATICCALL opcodes in analyzer,
  skip JIT compilation for contracts with external calls
- 4F: Skip JIT when tracer is active, add JitMetrics with atomic
  counters, log fallback events via eprintln
…compilation, and validation

Phase 5 addresses three remaining JIT gaps:

5A — Multi-fork support: Cache key changed from H256 to (H256, Fork) so the
same bytecode compiled at different forks gets separate cache entries.
fork_to_spec_id() adapter added. Hardcoded SpecId::CANCUN removed from
compiler, execution, and host — all now use the environment's fork.

5B — Background async compilation: New CompilerThread with std::sync::mpsc
channel and a single background thread. On threshold hit, vm.rs tries
request_compilation() first (non-blocking); falls back to synchronous
compile if no thread is registered. register_jit_backend() now also
starts the background compiler thread.

5C — Validation mode wiring: JitConfig.max_validation_runs (default 3)
gates logging to first N executions per (hash, fork). JitState tracks
validation_counts and logs [JIT-VALIDATE] with gas_used and output_len
for offline comparison. Full dual-execution deferred to Phase 6.
M1: CompilerThread now implements Drop — drops sender to signal
    shutdown, then joins the background thread. Panics are caught
    and logged (no silent swallowing). Fields changed to Option
    for take-on-drop pattern.

M2: SELFDESTRUCT (0xFF) added to has_external_calls detection in
    analyzer.rs. Bytecodes containing SELFDESTRUCT are now skipped
    by the JIT compiler, preventing the incomplete Host::selfdestruct
    (missing balance transfer) from being exercised.

M3: Negative gas refund cast fixed in execution.rs. Previously
    `refunded as u64` would wrap negative i64 (EIP-3529) to a huge
    u64. Now uses `u64::try_from(refunded)` — negative values are
    silently ignored (already reflected in gas remaining).

M4: Documented fork assumption in counter.rs and vm.rs. Counter is
    keyed by bytecode hash only (not fork). Safe because forks don't
    change during a node's runtime; cache miss on new fork falls back
    to interpreter.
Update roadmap and status to reflect B-1 completion: negative refund
bug fix, 11 gas alignment tests, upstream revmc constant documented.
Advance execution order to Week 3 (C-1 + C-2 → B-3).
Add compare_jit() for detecting JIT speedup regressions between PR and
base branch (20% threshold). New JitCompare CLI subcommand, JIT
regression report types, and markdown output.

Add 3 CI jobs to pr-tokamak-bench.yaml: jit-bench-pr, jit-bench-main,
compare-jit-results with PR comment integration. LLVM 21 jobs use
continue-on-error until C-2 provisioning is complete.

10 new tests covering regression/improvement detection, edge cases
(missing scenario, None speedup, multi-scenario), and report output.
Update roadmap, status, and execution order. Phase 9 now ~50% complete.
Feature lambdaclass#10 Continuous Benchmarking advances to ~50%. Next: C-2 (LLVM
provisioning) and B-3 (EIP-7928 BAL recording).
Extract inline LLVM 21 installation into .github/actions/install-llvm/
composite action. Includes llvm-dev and libpolly-dev packages (fixes
Polly linking issue). Update pr-tokamak.yaml and pr-tokamak-bench.yaml
to use the new action, removing continue-on-error workaround.
…hs (B-3)

Implement Block Access List (BAL) recording in the JIT execution path
so that storage reads/writes are tracked identically to the interpreter.

- Record storage reads in sload_skip_cold_load() via bal_recorder
- Record implicit reads + conditional writes in sstore_skip_cold_load()
- Remove 4 TODO comments, replace with architectural notes
- Add 5 differential tests (JIT vs interpreter BAL comparison)
- Apply cargo fmt to tokamak-jit crate
…fallback (D-2)

Add explicit handling for oversized bytecodes (> 24576 bytes, EIP-170)
that cannot be JIT-compiled by revmc/LLVM. Previously, compilation
would fail silently with repeated cache lookups on every call frame.

Changes:
- Add negative cache (oversized_hashes FxHashSet) to JitState for
  O(1) skip of known-oversized bytecodes
- Add early size gate in VM dispatch at compilation threshold,
  preventing compilation attempts before they reach the backend
- Add belt-and-suspenders size check in background compiler thread
- Return interpreter-only benchmark results instead of silently
  dropping oversized scenarios (Push/MstoreBench/SstoreBench)
- 4 unit tests for oversized cache + 3 integration tests (revmc-gated)
…:is_bytecode_oversized()

Replace 4 inline `len > max_bytecode_size` comparisons with a single
method on JitConfig. Also update STATUS.md with D-2 completion details.
… pipeline (D-3)

Same-length PUSH+PUSH+OP → single wider PUSH replacement preserving
bytecode offsets (JUMP targets, basic blocks unchanged). Supports
ADD, SUB, MUL, AND, OR, XOR with SUB wrapping edge case handling.

- optimizer.rs: detect_patterns() scan + optimize() constant folding
- Pipeline integration between analyze_bytecode() and compile()
- 37 unit tests + 5 integration tests (42 total for D-3)
… sync verification

- Replace hardcoded lambdaclass/ethrex with ${GITHUB_REPOSITORY} in
  snapsync-run action so assertoor can fetch the syncing-check config
  from the correct fork (tokamak-network/ethrex)
- Change default build_profile from release to release-with-debug-assertions
  so state trie validation (debug_assert!) fires during sync verification
ethrex-sync self-hosted runner is not available on tokamak-network fork.
Use GitHub-hosted ubuntu-latest runner with Kurtosis installed via apt.
Remove engine-restart job (only needed for persistent self-hosted runner).
Hoodi snap sync on GitHub-hosted runner did not complete within 1h.
Both EL and CL remained unsynced for the entire duration (run #22395022810).
…etion

- Overall completion 45-50% → 55-60%
- JIT feature 75% → 80%, test count 58 → 104
- Remove "Opcode fusion, constant folding" from Remaining
- Add D-3 to Recently Completed (Phase D) section
- Update codebase line counts (8,743 → 9,657)
- Update In Progress: next is E-1 or A-2
…level recording (E-1)

LEVM hook infrastructure:
- OpcodeRecorder trait in debugger_hook.rs (feature-gated tokamak-debugger)
- Stack::peek() for non-destructive stack inspection
- Per-opcode callback in interpreter_loop (before advance_pc)

tokamak-debugger crate:
- DebugRecorder captures opcode, PC, gas, depth, stack top-N, memory size
- ReplayEngine with record(), forward(), backward(), goto() navigation
- ReplayTrace + StepRecord + ReplayConfig data types
- DebuggerError with VM and StepOutOfRange variants

14 tests: basic replay (4), navigation (5), gas tracking (3), nested calls (2)
@cd4761
Copy link
Member Author

cd4761 commented Feb 25, 2026

E-1: Time-Travel TX Replay Engine — Complete

Commit: 03affff7c

Added

  • LEVM Hook: OpcodeRecorder trait + per-opcode callback in interpreter_loop (feature-gated tokamak-debugger)
  • Stack::peek(): Non-destructive stack inspection for recording
  • tokamak-debugger crate: ReplayEngine with record(), forward(), backward(), goto() navigation
  • Data types: StepRecord (opcode, PC, gas, depth, stack top-N, memory size, code address), ReplayTrace, ReplayConfig

Verification

  • 14 tests passing: basic replay (4), navigation (5), gas tracking (3), nested calls (2)
  • Clippy clean with and without tokamak-debugger feature
  • Fresh-context verification passed

Next: E-2 (Debugger CLI)

Hoodi snap sync passed in 1h48m35s (run 22404315946):
- assertoor synced-check: EL + CL both synced
- release-with-debug-assertions profile (state trie debug_assert enabled)
- ubuntu-latest runner with Kurtosis + Lighthouse v8.0.1

Phase A (Production Foundation) is now 100% complete (A-1 through A-4).
Phase 1.2 criteria 9/9 ALL PASS.
… debugger (E-2)

Add a REPL-based debugger CLI on top of the E-1 replay engine, gated
behind the `cli` feature flag. Supports 13 commands: step, step-back,
continue, reverse-continue, break, delete, goto, info, stack, list,
breakpoints, help, quit.

New files:
- src/bin/debugger.rs — binary entry point (clap)
- src/cli/mod.rs — Args, InputMode, run(), DB setup
- src/cli/commands.rs — Command enum, parse(), execute()
- src/cli/formatter.rs — step/info/stack/breakpoints display
- src/cli/repl.rs — rustyline REPL loop
- src/tests/cli_tests.rs — 27 tests (parsing, formatter, execution)

Usage: cargo run -p tokamak-debugger --features cli -- bytecode --code 600360040100
Add `debug_timeTravel` RPC method that replays a transaction at opcode
granularity and returns a window of execution steps for time-travel
debugging over JSON-RPC.

- Extract `prepare_state_for_tx()` from `trace_transaction_calls()` in
  blockchain/tracing.rs for reuse by the debugger endpoint
- Add `Evm::setup_env_for_tx()` wrapper in vm/tracing.rs
- Change `LEVM::setup_env` visibility to pub(crate)
- Add serde Serialize derives to StepRecord, ReplayTrace, ReplayConfig
- Add `opcode_name()` method to StepRecord
- Feature-gate behind `tokamak-debugger` in ethrex-rpc
- 10 tests: 6 RPC handler + 4 serde round-trip
Add `cross-client` CLI subcommand that compares ethrex execution
performance against Geth and Reth using eth_call with state overrides.

- ethrex runs in-process (reuses existing runner), external clients
  via JSON-RPC eth_call with bytecode injected at state override address
- New cross_client module: types.rs, runner.rs, report.rs
- Markdown report with ethrex as 1.00x baseline, ratio per client
- Feature-gated behind `cross-client` (reqwest, tokio, url deps)
- 18 tests covering serialization, parsing, reporting
…on (F-4)

Add cargo-fuzz harnesses, property-based tests, and unsafe code audit
documentation for the JIT compiler.

- 3 fuzz targets: analyzer, optimizer, differential (standalone crate)
- 4 proptest property tests: never-panics, bounds, length-preserving,
  convergence (optimizer is NOT single-pass idempotent)
- SAFETY_AUDIT.md cataloging all 9 unsafe blocks with risk assessment
- Update ROADMAP and STATUS docs to reflect E-3, F-1, F-4 completion
- Rewrite fuzz_differential.rs for actual JIT vs interpreter comparison:
  generate random EVM bytecode, execute on both paths, compare status/gas/output
- Add tokamak-jit as optional dep, wire revmc-backend feature properly
- Fallback to interpreter determinism check when LLVM unavailable
- Add DASHBOARD-SPEC.md for F-2 public dashboard (clients.tokamak.network):
  no-backend architecture, 6 pages, 4-phase implementation plan
Astro + React islands + Recharts + Tailwind static site at dashboard/.
Fetches benchmark JSON from CI artifacts and displays:
- Landing page with metric cards and benchmark table
- Historical trends page with scenario selector and CI error bands

Includes:
- 16 TypeScript interfaces mirroring Rust bench types
- Zod schemas with commit hash, timestamp, and path validation
- Path traversal protection in fetch layer
- 11 React components (MetricCard, StatusBadge, BenchTable, TrendChart, etc.)
- rebuild-index.py script for CI data pipeline
- publish-dashboard CI job in pr-tokamak-bench.yaml
- 62 JS/TS tests (Vitest) + 9 Python tests (unittest)
… flag (F-3)

- TokamakFeeConfig + JitPolicy types (crates/common)
- TokamakL2Hook wrapping L2Hook via composition (crates/vm/levm)
- VMType::TokamakL2 variant + hook dispatch + Evm constructors
- BlockchainType::TokamakL2 + 5 match arm updates (blockchain.rs)
- --tokamak-l2 CLI flag with env var support
- Feature propagation across 6 Cargo.toml files
- P256Verify precompile extended via is_l2_type() helper
- 7 unit tests (4 fee config serde + 3 hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants