Alert Source Discuss
🚧 Stagnant Standards Track: Interface

EIP-3044: 将 `baseFee` 添加到 `eth_getBlockByNumber`

Authors Abdelhamid Bakhta (@abdelhamidbakhta)
Created 2020-10-14
Discussion Link https://ethereum-magicians.org/t/eip-3044-add-basefee-to-eth-getblockbynumber/4828
Requires EIP-1474, EIP-1559

简单总结

将 basefee 字段添加到 eth_getBlockByNumber RPC 端点响应。

摘要

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

动机

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

规范

eth_getBlockByNumber

描述

返回由编号指定的区块的信息。 此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之前,则不得包含 baseFee 字段。 此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之上或之后,则必须包含 baseFee 字段。

参数

参数保持不变。

返回值

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

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

示例

# Request
curl -X POST --data '{
    "id": 1559,
    "jsonrpc": "2.0",
    "method": "eth_getBlockByNumber",
    "params":["latest", 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": []
    }
}

理由

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

向后兼容性

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

安全注意事项

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

版权

版权及相关权利通过 CC0 放弃。

Citation

Please cite this document as:

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