Alert Source Discuss
🚧 Stagnant Standards Track: Interface

EIP-3041: 向 `eth_getBlockByHash` 添加 `baseFee`

Authors Abdelhamid Bakhta (@abdelhamidbakhta)
Created 2020-10-13
Discussion Link https://ethereum-magicians.org/t/eip-3041-add-basefee-in-eth-getblockbyhash-response/4825
Requires EIP-1474, EIP-1559

简单总结

eth_getBlockByHash RPC 端点响应添加 basefee 字段。

摘要

eth_getBlockByHash JSON-RPC 请求的 result 对象添加 baseFee 属性。此属性将包含 EIP-1559 分叉后任何区块的基本费用值。

动机

EIP-1559 在协议中引入了每 gas 的基本费用。 此值作为区块头结构中的一个新字段在共识下维护。 用户可能需要给定区块的基本费用值。基本费用值对于更准确地进行 gas 价格预测非常重要。

规范

eth_getBlockByHash

描述

返回由哈希指定的区块的信息。 此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之前,必须不包含 baseFee 字段。 此端点返回的每个区块,如果其区块号等于或晚于 EIP-1559 分叉区块,必须包含 baseFee 字段。

参数

参数保持不变。

返回

有关 eth_getBlockByHash 的完整规范,请参见 EIP-1474。 为包含基本费用的区块头(EIP-1559 分叉区块之后)向 result 对象添加一个新的 JSON 字段。

  • {Quantity} baseFee - 此区块的基本费用

示例

# Request
curl -X POST --data '{
    "id": 1559,
    "jsonrpc": "2.0",
    "method": "eth_getBlockByHash",
    "params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]
}' <url>

# Response
{
    "id": 1559,
    "jsonrpc": "2.0",
    "result": {
        "difficulty": "0x027f07",
        "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "baseFee": "0x7"
        "gasLimit": "0x9f759",
        "gasUsed": "0x9f759",
        "hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
        "logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
        "miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
        "nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
        "number": "0x1b4",
        "parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "size":  "0x027f07",
        "stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
        "timestamp": "0x54e34e8e"
        "totalDifficulty":  "0x027f07",
        "transactions": []
        "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
        "uncles": []
    }
}

理由

添加单个参数而不是引入一个全新的端点是最简单的更改,也最容易集成。 为了向后兼容,我们决定不在 pre-1559 区块的响应中包含基本费用。

向后兼容性

向后兼容。与 EIP-1559 分叉区块之前的区块相关的调用将在响应中省略基本费用字段。

安全考虑

添加的字段 (baseFee) 仅提供信息,不会引入技术安全问题。

版权

CC0 下放弃版权及相关权利。

Citation

Please cite this document as:

Abdelhamid Bakhta (@abdelhamidbakhta), "EIP-3041: 向 `eth_getBlockByHash` 添加 `baseFee` [DRAFT]," Ethereum Improvement Proposals, no. 3041, October 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-3041.