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): include block rewards in trace_filter rpc #8868

Merged
merged 15 commits into from
Jun 18, 2024

Conversation

jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jun 16, 2024

the block rewards were missed in the result of trace_filter, which will affect the blocks before the merge, so add them into the result if some.

btw: if we know one block of the block-range is passed ttd, then no need to extract the following blocks anymore, but the results were handled in an async way, how can we break it? pseudo code as below:

for block in blocks:
    if block.is_passed_ttd():
        break
    reward_traces.extend(extract_block_reward_traces(block))

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.

thanks, a few suggestions

crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
@emhane emhane added the A-rpc Related to the RPC implementation label Jun 17, 2024
This reverts commit 559353614f4f04dd431fc0ed0ad6b4aad2116415.

Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
@jsvisa jsvisa force-pushed the trace-filter-missing-rewards branch from 793aa90 to 6c5cabe Compare June 18, 2024 04:04
@jsvisa jsvisa requested a review from gakonst as a code owner June 18, 2024 04:04
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
Signed-off-by: jsvisa <[email protected]>
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.

a few more suggestions

crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/trace.rs Outdated Show resolved Hide resolved
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.

ty, I removed the additional is_paris_active check and moved this into the calculate_base_block_reward function

one thing I'm unsure about is the trace filter response, because now all reward traces are appended at the end
is that expected or should this rather be [[block, rewards], [block, rewards] ]?

if so we should change this

@jsvisa
Copy link
Contributor Author

jsvisa commented Jun 18, 2024

one thing I'm unsure about is the trace filter response, because now all reward traces are appended at the end
is that expected or should this rather be [[block, rewards], [block, rewards] ]?

yeah, the current response differs to erigon's, but I think this isn't a big issue, as they are all in the same array, the sequence may not matter that much, and we can use block_number + tx hash + traceAddress to identify the single trace.

ergion's response for block `0x16E35F:0x16E360`
{
  "jsonrpc": "2.0",
  "id": 67,
  "result": [
    {
      "action": {
        "author": "0x4bb96091ee9d802ed039c4d1a5f6216f90f81b01",
        "rewardType": "block",
        "value": "0x4563918244f40000"
      },
      "blockHash": "0x27cc6d1022bd28ac1106505dafb86ad0167f11e473f6d14b7edc81752e06825d",
      "blockNumber": 1499999,
      "result": null,
      "subtraces": 0,
      "traceAddress": [],
      "type": "reward"
    },
    {
      "action": {
        "from": "0x1699333a4e46093e15a94b4a213b88eb8a963834",
        "callType": "call",
        "gas": "0x0",
        "input": "0x",
        "to": "0x9d1e424358fa3376e995976e92437e0fb449e159",
        "value": "0x42d24f8401fb3800"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [],
      "transactionHash": "0xbe03790872e51ef0ffe1b5d741bdaa09b4e158a579f721da0725ace53b55b87f",
      "transactionPosition": 0,
      "type": "call"
    },
    {
      "action": {
        "from": "0x9e21ef129618e859f081c8be4bcf114c5b2c750d",
        "callType": "call",
        "gas": "0x203a0",
        "input": "0x",
        "to": "0x81018aced0c4e67312a7beecc8b28edf1ad0ffd7",
        "value": "0xa688906bd8b00000"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [],
      "transactionHash": "0x4f004c80d2431cacb0a9334eef97782f8d33b6e42577e914430e4038508d86aa",
      "transactionPosition": 1,
      "type": "call"
    },
    {
      "action": {
        "from": "0x0c0f71f46f1f8f6beb301cc55a7e7ba55e8604f3",
        "callType": "call",
        "gas": "0x1e0d3",
        "input": "0x",
        "to": "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
        "value": "0xde0b6b3a7640000"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x5a33",
        "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
      },
      "subtraces": 1,
      "traceAddress": [],
      "transactionHash": "0x85621a86874614a218da822ef990a9c543ee1b25c678269644e0df956ba7b9df",
      "transactionPosition": 2,
      "type": "call"
    },
    {
      "action": {
        "from": "0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
        "callType": "call",
        "gas": "0x15893",
        "input": "0x",
        "to": "0x807640a13483f8ac783c557fcdf27be11ea4ac7a",
        "value": "0x0"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x13f9",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [
        0
      ],
      "transactionHash": "0x85621a86874614a218da822ef990a9c543ee1b25c678269644e0df956ba7b9df",
      "transactionPosition": 2,
      "type": "call"
    },
    {
      "action": {
        "from": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
        "callType": "call",
        "gas": "0x10d88",
        "input": "0x",
        "to": "0x1f4402bb2e1217cfb49a125d3893b32034fa738d",
        "value": "0xdf09389de9692f0"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [],
      "transactionHash": "0x9a5f3beacbc8a4d6409007c680fb509570d94101b5a7fc9943a8ef22d7e8f40d",
      "transactionPosition": 3,
      "type": "call"
    },
    {
      "action": {
        "from": "0xcd88e0e0c455345833ce31c5452c1c37f4b4c438",
        "callType": "call",
        "gas": "0x0",
        "input": "0x",
        "to": "0xe315990a56899c575e03cbbc18f6ae3f117a7459",
        "value": "0x72356ac309800"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": {
        "gasUsed": "0x0",
        "output": "0x"
      },
      "subtraces": 0,
      "traceAddress": [],
      "transactionHash": "0x5788e90d4a85d91673f8863614294e03a80724f6f503cd3f5005bab4552e74b5",
      "transactionPosition": 4,
      "type": "call"
    },
    {
      "action": {
        "author": "0x2a65aca4d5fc5b5c859090a6c34d164135398226",
        "rewardType": "block",
        "value": "0x478eae0e571ba000"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": null,
      "subtraces": 0,
      "traceAddress": [],
      "type": "reward"
    },
    {
      "action": {
        "author": "0x68795c4aa09d6f4ed3e5deddf8c2ad3049a601da",
        "rewardType": "uncle",
        "value": "0x340aad21b3b70000"
      },
      "blockHash": "0x83952d392f9b0059eea94b10d1a095eefb1943ea91595a16c6698757127d4e1c",
      "blockNumber": 1500000,
      "result": null,
      "subtraces": 0,
      "traceAddress": [],
      "type": "reward"
    }
  ]
}

@mattsse
Copy link
Collaborator

mattsse commented Jun 18, 2024

sg!
tysm for this!

@mattsse mattsse enabled auto-merge June 18, 2024 18:25
@mattsse mattsse added this pull request to the merge queue Jun 18, 2024
Merged via the queue into paradigmxyz:main with commit 7bfc604 Jun 18, 2024
30 checks passed
@jsvisa jsvisa deleted the trace-filter-missing-rewards branch June 18, 2024 23:35
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants