statetest: BLOCKHASH range check breaks when currentNumber > 2^63-1
メンテナーはふだん 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), soISZEROis0. - evmone-statetest returns
0x0for the same in-range lookup, soISZEROis1.
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
BLOCKHASHpushes non-zero. - evmone trace shows
BLOCKHASHpushes0x0.
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:currentNumberparsed viafrom_json<int64_t>.test/state/block.hpp:BlockInfo::numberisint64_t.lib/evmone/instructions.hppblockhash():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-1lookups aboveINT64_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 ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ipsilon/evmone のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 56/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
audit-reference-check
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
schrodinger/pymol-open-source#532 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
xlnt-community/xlnt#174 ·
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
sleepyviper1213/redis#30 ·