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

eth/tracers: do system contract processing prior to parallel-tracing #30520

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

easyfold
Copy link
Contributor

@easyfold easyfold commented Sep 27, 2024

Description

debug_traceBlockByNumber may return incorrect result on some blocks, with JS tracers.
This PR tries to fix it.

traceBlockParallel does not apply ProcessBeaconBlockRoot and ProcessParentBlockHash before executing block's transactions, which may cause some transactions trace to report unexpected reverted errors.

Case

request

{
    "method": "debug_traceBlockByNumber",
    "params": [
        "0x128c38d",
        {
            "tracer": "callTracerLegacy"
        }
    ],
    "id": 1,
    "jsonrpc": "2.0"
}

In response, tx 0x8236b9e4749102df80e43130d7df505cb7e9b3036c2fa8759867b5fbbf837370 would show "error": "execution reverted", that's wrong.

{
            "txHash": "0x8236b9e4749102df80e43130d7df505cb7e9b3036c2fa8759867b5fbbf837370",
            "result": {
                "type": "CALL",
                "from": "0xb4f1e5db68512f06d378b5e02e7ebbe7d2c705ef",
                "to": "0x5c44f2d7545fdd7a2a91513286aac71194d0f5d7",
                "value": "0x0",
                "gas": "0x7045",
                "gasUsed": "0x66c6",
                "input": "0x00",
                "output": "0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000016600000000000000000000000000000000000000000000000000000000000000",
                "error": "execution reverted",
                "calls": [
                    {
                        "type": "CALL",
                        "from": "0x5c44f2d7545fdd7a2a91513286aac71194d0f5d7",
                        "to": "0x000f3df6d732807ef1319fb7b8bb8522d0beac02",
                        "value": "0x0",
                        "gas": "0x127a",
                        "gasUsed": "0x89c",
                        "input": "0x0000000000000000000000000000000000000000000000000000000065f5cc67",
                        "error": "execution reverted"
                    }
                ]
            }
        }

Expected result

{
            "txHash": "0x8236b9e4749102df80e43130d7df505cb7e9b3036c2fa8759867b5fbbf837370",
            "result": {
                "from": "0xb4f1e5db68512f06d378b5e02e7ebbe7d2c705ef",
                "gas": "0x7045",
                "gasUsed": "0x6eea",
                "to": "0x5c44f2d7545fdd7a2a91513286aac71194d0f5d7",
                "input": "0x00",
                "calls": [
                    {
                        "from": "0x5c44f2d7545fdd7a2a91513286aac71194d0f5d7",
                        "gas": "0x127a",
                        "gasUsed": "0x10e0",
                        "to": "0x000f3df6d732807ef1319fb7b8bb8522d0beac02",
                        "input": "0x0000000000000000000000000000000000000000000000000000000065f5cc67",
                        "output": "0x210595812d9b27c3ca7e0e1b5ac186733110293e2d207a44e3416a7af3f48226",
                        "value": "0x0",
                        "type": "CALL"
                    }
                ],
                "value": "0x0",
                "type": "CALL"
            }
        }

@easyfold easyfold requested a review from s1na as a code owner September 27, 2024 08:24
Copy link
Contributor

@jwasinger jwasinger left a comment

Choose a reason for hiding this comment

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

Looks okay from a glance (but I'll defer to @s1na to give thumbs up on this). One thing that stands out is that we repeat this exact same logic in multiple places across this file, and it ought to be deduplicated into it's own function.

@karalabe
Copy link
Member

Please add a meaningful comment as to why the code you just added is needed and for this PR description what was broken and how it was fixed. There's no info about anything, just "here's some code that fixes something somehow, maybe"

@easyfold
Copy link
Contributor Author

Please add a meaningful comment as to why the code you just added is needed and for this PR description what was broken and how it was fixed. There's no info about anything, just "here's some code that fixes something somehow, maybe"

@karalabe Sorry for that. I have maked it more clear.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman changed the title eth/tracers: fix trace block parallel eth/tracers: do system contract processing prior to parallel-tracing Oct 2, 2024
@holiman holiman added this to the 1.14.12 milestone Oct 2, 2024
@holiman
Copy link
Contributor

holiman commented Oct 8, 2024

@s1na PTAL as a codeowner

Copy link
Contributor

@s1na s1na left a comment

Choose a reason for hiding this comment

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

LGTM

@s1na s1na merged commit 7942a6b into ethereum:master Oct 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants