statetest: BLOCKHASH range check breaks when currentNumber > 2^63-1

オープン
#1,493 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
blockchain

調査の方向性

Start by reading lib/evmone/instructions.hpp around blockhash(), then trace how test/utils/statetest_loader.cpp and test/state/block.hpp represent the current block number. Run the provided reproducer with build/debug/bin/evmone-statetest; done means its post-state root matches the geth result for this high-number Cancun test.

索引モデルが issue の本文から書いたものです。

説明

Summary

evmone-statetest diverges from geth on a valid Cancun state test when env.currentNumber is above INT64_MAX.

The test executes BLOCKHASH(currentNumber - 1) and then stores ISZERO(result).

  • geth returns non-zero BLOCKHASH (in-range lookup), so ISZERO is 0.
  • evmone-statetest returns 0x0 for the same in-range lookup, so ISZERO is 1.

This produces different post-state roots.

Reproducer

files/case12-statetest-blockhash-highnum/blockhash_highnum_state_test.json

Commands
# geth: passes
~/go/bin/evm statetest --statetest.fork Cancun files/case12-statetest-blockhash-highnum/blockhash_highnum_state_test.json

# evmone: fails
build/debug/bin/evmone-statetest files/case12-statetest-blockhash-highnum/blockhash_highnum_state_test.json

Observed:

  • geth state root: 0x27ebe6aaf81779a3f3516512f8bdd8d543be038c26b9bba4bba5d85cce73f02f (PASS)
  • evmone state root: 0x48e2b3fe41a421a38716c88d2e14ad390b55ff6301db7d3b24079e55dc01e768 (FAIL)
Trace difference

For the same bytecode (0x6780000000000000ff401560005500):

  • geth trace shows BLOCKHASH pushes non-zero.
  • evmone trace shows BLOCKHASH pushes 0x0.
Likely root cause

The statetest path stores block numbers as signed 64-bit and BLOCKHASH range checks with signed bounds:

  • test/utils/statetest_loader.cpp: currentNumber parsed via from_json<int64_t>.
  • test/state/block.hpp: BlockInfo::number is int64_t.
  • lib/evmone/instructions.hpp blockhash():
    • upper_bound = state.get_tx_context().block_number (signed)
    • lower_bound = std::max(upper_bound - 256, 0)
    • n = static_cast<int64_t>(number)
    • signed comparison path rejects what should be valid currentNumber-1 lookups above INT64_MAX.

The EVM BLOCKHASH semantics are based on unsigned block numbers modulo 2^256 on stack values, with recent-256 window check relative to the current block number. Using signed block numbers in this path causes incorrect behavior for values above 2^63-1.

主要言語
C++
スター
979
フォーク
340
平均マージ
12時間 16分
マージ済み PR(30日)
25

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ipsilon/evmone のほかの issue

ipsilon/evmone の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。