Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc/trace): wrong calculate of block ommer rewards #8767

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jun 12, 2024

In the current implementation of trace_block rpc, we return block base reward as block reward, and the uncle inclusion rewards as uncle reward.

But in OpenEthereum/Erigon's implementation, they return block base + uncle inclusion as block reward, and each uncle reward as uncle reward, so the actual uncle rewards were missed.

IMHO, we should keep the same as oe/erigon, because the results will be more inaccurate, similar to etherscan's.

Eg the reward of https://etherscan.io/block/1378035

image

Reth's response:

{
    "jsonrpc": "2.0",
    "result": [
        {
            "action": {
                "author": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
                "rewardType": "block",
                "value": "0x4563918244f40000" // 5ETH
            },
            "blockHash": "0xd6940190d24aa1c2e8aa70fb2847aba6c4461679753a7546daf79e6295a9e1e2",
            "blockNumber": 1378035,
            "subtraces": 0,
            "traceAddress": [],
            "type": "reward"
        },
        {
            "action": {
                "author": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
                "rewardType": "uncle",
                "value": "0x22b1c8c1227a000" // 0.15625ETH
            },
            "blockHash": "0xd6940190d24aa1c2e8aa70fb2847aba6c4461679753a7546daf79e6295a9e1e2",
            "blockNumber": 1378035,
            "subtraces": 0,
            "traceAddress": [],
            "type": "reward"
        }
    ],
    "id": "reth"
}

Erigon's response

{
    "jsonrpc": "2.0",
    "id": "erigon",
    "result": [
        {
            "action": {
                "author": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
                "rewardType": "block",
                "value": "0x478eae0e571ba000" // 5.15625ETH
            },
            "blockHash": "0xd6940190d24aa1c2e8aa70fb2847aba6c4461679753a7546daf79e6295a9e1e2",
            "blockNumber": 1378035,
            "result": null,
            "subtraces": 0,
            "traceAddress": [],
            "type": "reward"
        },
        {
            "action": {
                "author": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
                "rewardType": "uncle",
                "value": "0x3cb71f51fc558000" // 4.375ETH
            },
            "blockHash": "0xd6940190d24aa1c2e8aa70fb2847aba6c4461679753a7546daf79e6295a9e1e2",
            "blockNumber": 1378035,
            "result": null,
            "subtraces": 0,
            "traceAddress": [],
            "type": "reward"
        }
    ]
}

Ref https://github.com/ledgerwatch/erigon/blob/b4c9f22923cd7156cd26be91a8a83b131eb3cc73/consensus/ethash/consensus.go#L624-L668

@jsvisa jsvisa requested review from mattsse and Rjected as code owners June 12, 2024 05:31
jsvisa added 2 commits June 12, 2024 13:40
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
@shekhirin shekhirin added C-bug An unexpected or incorrect behavior A-rpc Related to the RPC implementation labels Jun 12, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@mattsse mattsse added this pull request to the merge queue Jun 12, 2024
Merged via the queue into paradigmxyz:main with commit e9a7691 Jun 12, 2024
29 checks passed
@jsvisa jsvisa deleted the trace-reward branch June 12, 2024 15:01
emhane pushed a commit that referenced this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants