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

Abierto
#1,493 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
blockchain

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C++
Estrellas
979
Forks
340
Merge medio
12 h 16 min
PR fusionados (30 d)
25

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ipsilon/evmone

Todos los issues de ipsilon/evmone

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.