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 API: Trace block rewards in the Ethereum JSON-RPC trace_block output #11633

Open
Stebalien opened this issue Feb 20, 2024 · 3 comments
Open

Comments

@Stebalien
Copy link
Member

At the moment, we skip the "rewards" messages but Ethereum clients will generally include a special trace with type "reward".

@parva-jain
Copy link

I would like to work on this issue.
@Stebalien, it would be great if you could describe more about the issue and give some guidance on proceeding to solve it.
Thanks!!

@Stebalien
Copy link
Member Author

Lotus has two ways of tracing block execution:

  1. Native Filecoin traces. These are produced by the FVM as it executes blocks and are consumed by native Filecoin tooling.
  2. Ethereum-style traces. These are produced by translating native Filecoin traces into something Ethereum native tools can consume. E.g., trace_block.

The translation is a bit tricky because Filecoin is quite different from Ethereum. For example, a Filecoin trace actually traces messages from a set of blocks called a tipset while an Ethereum trace would only trace a single block. We handle this specific case by "pretending" that this set of blocks is actually a single block.

Now, onto what we need to do here...

Right now, the only "actions" we trace are calls and contract creations.

The goal here is to include block rewards in these traces. These would show up as separate top-level EthTraceBlock elements in the trace but the action (EthTraceBlock.EthTrace.Action) would have to be a new type modeled after, e.g., Erigon's RewardTraceAction type (importantly, it needs to serialize to JSON the same way so existing tools can consume this information).

The easiest way to get the rewards is to pull them out of the Filecoin trace. If you look at the code for EthTraceBlock, you'll see that we skip messages "from" the system actor. These messages are "implicit" messages that perform chain maintenance operations. One of these operations is rewarding the producer of the block. So, instead of simply skipping all messages from the system actor, you'd need to:

  1. Check if it's a message to the "reward" actor.
  2. If so, follow the trace of that message to find a sub-call transferring funds to the block miner.
  3. Record that fund transfer as a "reward" action in the Ethereum-style trace.

@Stebalien
Copy link
Member Author

Now that I've written all this out... this is maybe not the best place to get started unless you have a significant amount of experience with either Filecoin or Ethereum internals. If you don't have a lot of experience with the internals of either, it'll be a bit difficult to get a foothold on this issue (I'm going to remove the "good first issue" tag, that was a bit sloppy on my part).

@Stebalien Stebalien removed the good first issue Good for newcomers label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🐱 Todo
Status: 🖊 Planning
Development

No branches or pull requests

2 participants