Alert Source Discuss
🚧 Stagnant Standards Track: Interface

EIP-3045: 向 `eth_getUncleByBlockHashAndIndex` 添加 `baseFee`

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

简单总结

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

摘要

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

动机

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

规范

eth_getUncleByBlockHashAndIndex

描述

返回由区块哈希和叔块索引位置指定的叔块的信息。 此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之前,必须不包含 baseFee 字段。 此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之上或之后,必须包含 baseFee 字段。

参数

参数保持不变。

返回

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

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

示例

# Request
curl -X POST --data '{
    "id": 1559,
    "jsonrpc": "2.0",
    "method": "eth_getUncleByBlockHashAndIndex",
    "params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"]
}' <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-3045: 向 `eth_getUncleByBlockHashAndIndex` 添加 `baseFee` [DRAFT]," Ethereum Improvement Proposals, no. 3045, October 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-3045.