Skip to content

refactor(events): restructure filecoin and eth events. - #7608

Draft
akaladarshi wants to merge 3 commits into
mainfrom
akaladarshi/eth-events-refactor
Draft

akaladarshi wants to merge 3 commits into
mainfrom
akaladarshi/eth-events-refactor

Conversation

@akaladarshi

Copy link
Copy Markdown
Contributor

Summary of changes

Changes introduced in this pull request:

  • TipsetEvents allows collection of all the event produce in a single tipset.
  • BlockLogs holds all the EthLog produced by each message in a block.
  • This is just a first draft of the restructuring once verified by the team will push the stacked PR's on top of it which will have full on integration of the changes.
    • Basically idea here is to introduced separate structures for the Filecoin Events, Ethereum Logs and allow all the API's to directly use whatever structure they want for the events and logs instead of calling individual functions, in proceess makes collection of events/logs easier since filecoin doesn't really store the events at the block level.

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • This pull request is based on an issue that a maintainer has accepted (see Before Opening a Pull Request).
  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

…om them

A tipset's events are collected once, numbered in message order, with each
emitter resolved synchronously against the post-execution state. The block
logs bloom is a fold over the Ethereum projection, so the second emitter
resolver and event shaper in bloom.rs are gone.
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@LesnyRumcajs LesnyRumcajs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The direction seems sound, I also don't love our sprawl of free functions but they're often the most optimal ones (hello C). Couple of things to think about before going forward with this:

  1. It doesn't seem to me lots of this logic should live under rpc/methods/eth; more like src/eth/*. Ideally, rpc/* would contain logic that is strictly there for RPC handling. As you mentioned, tipset events are a chain-level artifact.
  2. Performance - it seems to me that there might be a lot of redundant work with building those structs. We'd need A LOT of care not to introduce a regression in affected methods.
  3. Error handling - it's also unclear to me whether this design preserves error handling logic.

In general, it'd be worth having a broader discussion with multiple alternatives so that we can have a consensus why a given one is the best one.

Also, as a broader refactoring on user-critical logic, this would need first a good coverage net (not sure what's the % at the moment); refer to Working Effectively with Legacy Code from Michael Feathers. I really wouldn't like to have regressions for the sake of nicer (subjectively) code. At the same time, if refactoring could open vistas for improved performance, I'm convinced everyone would be on board with that.

A good first step in doing some refactoring would be just moving things around (without ANY logic changes); I already mentioned it elsewhere, but the chain logic should be minimal in rpc/*. Afterwards, with proper coverage on high-level methods we could tinker around if it makes sense.

use fvm_ipld_encoding::IPLD_RAW;

/// The Ethereum logs of one tipset, grouped by message, in tipset order.
pub struct BlockLogs {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub struct BlockLogs {
pub struct EthBlockLogs {

This is longer but arguably more descriptive.

Comment on lines +23 to +30
/// Collects the logs of an executed tipset.
pub fn collect(
state_manager: &StateManager,
tipset: &Tipset,
executed: &ExecutedTipset,
) -> anyhow::Result<Self> {
Self::from_events(&TipsetEvents::collect(state_manager, tipset, executed))
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's a bit awkward as an associated function - seems like there should be a method on TipsetEvents to convert to BlockLogs instead.


impl TipsetEvents {
/// Collects the events of an executed tipset.
pub fn collect(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn collect(
pub fn from_tipset(

Comment on lines +59 to +60
tipset: &Tipset,
executed: &ExecutedTipset,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

having both tipset and executed to pass is a bit awkward; ExecutedTipsetseems more likeTipsetExecutionResult`. I understand it's what we have at the moment, but it's not an ideal name.


/// Global cache first, then the finality-deep state (cached globally when reorg-stable),
/// then the post-execution state, the only one holding an actor created in this tipset.
fn resolve_uncached(&self, emitter: ActorID) -> Option<Address> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we have this logic somewhere already?

This branch has not been deployed

No deployments
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.

2 participants