EIP-3046: 在 `eth_getUncleByBlockNumberAndIndex` 中添加 `baseFee`
Authors | Abdelhamid Bakhta (@abdelhamidbakhta) |
---|---|
Created | 2020-10-14 |
Discussion Link | https://ethereum-magicians.org/t/add-basefee-to-eth-getunclebyblocknumberandindex/4830 |
Requires | EIP-1474, EIP-1559 |
简单总结
向 eth_getUncleByBlockNumberAndIndex
RPC 终点响应添加 basefee 字段。
摘要
向 eth_getUncleByBlockNumberAndIndex
JSON-RPC 请求的 result
对象添加 baseFee
属性。此属性将包含 EIP-1559 分叉后任何区块的基本费用值。
动机
EIP-1559 在协议中引入了每 gas 的基本费用。 此值作为区块头结构中的一个新字段,在共识下维护。 用户可能需要给定区块的基本费用值。基本费用值对于更准确地进行 gas 价格预测非常重要。
规范
eth_getUncleByBlockNumberAndIndex
描述
返回由区块号和叔块索引位置指定的叔块的信息。
此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之前,不得包含 baseFee
字段。
此端点返回的每个区块,如果其区块号在 EIP-1559 分叉区块之上或之后,必须包含 baseFee
字段。
参数
参数保持不变。
返回值
有关 eth_getUncleByBlockNumberAndIndex
的完整规范,请参见 EIP-1474。
向包含基本费用的区块头(EIP-1559 分叉区块之后)的 result
对象添加一个新的 JSON 字段。
- {
Quantity
}baseFee
- 此区块的基本费用
示例
# Request
curl -X POST --data '{
"id": 1559,
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockNumberAndIndex",
"params":["latest", "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": []
}
}
原理
添加单个参数而不是引入一个全新的端点是最简单的更改,也最容易集成。 为了向后兼容,我们决定不在 1559 之前的区块的响应中包含基本费用。
向后兼容性
向后兼容。与 EIP-1559 分叉区块之前的区块相关的调用将在响应中省略基本费用字段。
安全考虑
添加的字段 (baseFee
) 仅提供信息,不会引入技术安全问题。
版权
版权和相关权利通过 CC0 放弃。
Citation
Please cite this document as:
Abdelhamid Bakhta (@abdelhamidbakhta), "EIP-3046: 在 `eth_getUncleByBlockNumberAndIndex` 中添加 `baseFee` [DRAFT]," Ethereum Improvement Proposals, no. 3046, October 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-3046.