ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.79k stars 20.23k forks source link

feeHistory returns one more entry for baseFeePerGas than the indicated range #24669

Closed seaona closed 2 years ago

seaona commented 2 years ago

System information

Geth version: the one that Infura is using atm OS & Version: Linux

Expected behaviour

When making a request to eth_feeHistory and passing a value of "0x5" for the blockCount, I expect to get baseFeePerGas, gasUsedRatio and reward for these indicated block range.

Actual behaviour

However, on the baseFeePerGas I get one more entry than expected (6), meanwhile, on the gasUsedRatio and reward I am getting 5.

{
    "jsonrpc": "2.0",
    "id": 1154511320665004,
    "result": {
        "baseFeePerGas": [
            "0xd",
            "0xd",
            "0xe",
            "0xe",
            "0xf",
            "0xf"
        ],
        "gasUsedRatio": [
            0.3050173513495279,
            0.5518528666666667,
            0.21957763333333333,
            0.5059045491255545,
            0.3485550253180236
        ],
        "oldestBlock": "0x9fbee6",
        "reward": [
            [
                "0x3b9aca42",
                "0x59682f00",
                "0x59682f00"
            ],
            [
                "0x3b9aca42",
                "0x59682f00",
                "0x9502f900"
            ],
            [
                "0x3b9aca34",
                "0x3b9aca42",
                "0x59682ef2"
            ],
            [
                "0x3b9aca35",
                "0x3b9aca35",
                "0x3b9aca35"
            ],
            [
                "0x3b9aca43",
                "0x59682f00",
                "0x59682f00"
            ]
        ]
    }
}

I am not sure if this is actually a bug, or is it the expected behaviour. If so, to which block is the extra entry referring to?

Steps to reproduce the behaviour

  1. Make an RPC call to eth_feeHistory
  2. Indicate the range of blocks (i.e. 0x5) and the rest of arguments
  3. Send the request

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

rjl493456442 commented 2 years ago

Check the spec here , the additional one more baseFee is expected.

baseFeePerGas: An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.

Danyalkasiri commented 2 years ago

Hi,thank you,I hope you're great and you're bored ľm bored ĺm sorry l answered late. 🥰💖

در تاریخ دوشنبه ۱۱ آوریل ۲۰۲۲،‏ ۰۷:۳۰ rjl493456442 @.***> نوشت:

Check the spec here https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/execution-apis/assembled-spec/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=false&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false , the additional one more baseFee is expected.

baseFeePerGas: An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.

— Reply to this email directly, view it on GitHub https://github.com/ethereum/go-ethereum/issues/24669#issuecomment-1094491828, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYF5KXDXWX64WQ544WBLSUDVEOITXANCNFSM5S425M2A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

seaona commented 2 years ago

ohh I see, thank you very much @rjl493456442