Compute gas with uint32

未关闭
#1,719 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
28/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
cpp
领域
blockchain

调研方向

Start from the gas fields listed in the issue: gas_left in the interpreter and Result/TermResult, StateGas in lib/evmone/state_gas.hpp, and the evmc_message / evmc_result ABI fields. Read how the interpreter currently uses a signed subtract-and-compare-to-zero check, and TX_MAX_GAS_LIMIT in test/state/transaction.hpp. Done means a coherent uint32 (or documented ABI) plan for those counters, not a drive-by type swap.

由索引模型根据 Issue 内容生成。

描述

optimization

Every gas counter in evmone is int64_t, but all per-transaction gas quantities fit in 32 bits.

EIP-7825 caps a transaction's gas limit at TX_MAX_GAS_LIMIT = 2^24 (MAX_TX_GAS_LIMIT, test/state/transaction.hpp), and block gas limits are far below 2^32. A pending EIP-8037 change would additionally cap tx.gas itself at 2^32-1, so the whole two-dimensional budget stays inside an unsigned 32-bit integer.

Candidates:

  • gas_left threaded through the interpreter and Result / TermResult
  • StateGas::left and StateGas::spilled (lib/evmone/state_gas.hpp)
  • evmc_message::gas, evmc_message::state_gas
  • evmc_result::gas_left, gas_refund, state_gas_left, state_gas_spilled

Two things to settle first:

  • The interpreter relies on gas going negative ((gas_left -= cost) < 0). An unsigned counter needs a borrow-based check instead, e.g. __builtin_usub_overflow.
  • The evmc_* fields are public ABI, so changing them is a breaking change.
主要语言
C++
星标
979
派生
340
平均合并
12 小时 16 分钟
30 天内合并 PR
25

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ipsilon/evmone 的其他 Issue

查看 ipsilon/evmone 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。