-
Notifications
You must be signed in to change notification settings - Fork 160
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
feat(rpc) Implement Filecoin.EthGetLogs
#4780
Conversation
@LesnyRumcajs added a few unit tests to cover the most intricated functions |
#[derive(Clone, Debug)] | ||
pub enum StampedEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add some docs on the public items such as this StampedEvent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
src/shim/executor.rs
Outdated
amt.for_each(|_, event| { | ||
events.push(event.clone().into()); | ||
Ok(()) | ||
})?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't for_each
deprecated in favour of iter()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just remove this. It's deadcode anyway.
src/state_manager/mod.rs
Outdated
enable_event_caching: if enable_event_caching { | ||
EventCache::Cached | ||
} else { | ||
EventCache::NotCached | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design idea - I wonder if we can make the code more straightforward by injecting an trait object of EventCache
. It would be instantiated at the start of the program to either an implementation without cache or with a cache. This way, throughout the code, you wouldn't need to check if the caching is enabled or not - you'd write to it but whether it would actually happen would be completely transparent.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent idea! In the future we'll likely have:
- No cache (e.g., a node without RPC)
- Cache Events in tipset state cache
- Use sidecar indexer to retrieve Events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to store events in a dedicated cache (with a dedicated size), avoiding the need to store unnecessary None
values in the SM tipset state cache when events are not in use. This also prevents polluting the SM cache and avoids potential performance slowdowns.
As for injecting an trait object, I think it would add some complexity compared to using an enum
at this stage. Let's consider that for a future PR, or once we have an indexer in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing, we can remove the --enable-event-caching
flag now.
fn match_key(key: &str) -> Option<usize> { | ||
match key.get(0..2) { | ||
Some("t1") => Some(0), | ||
Some("t2") => Some(1), | ||
Some("t3") => Some(2), | ||
Some("t4") => Some(3), | ||
_ => None, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work on mainnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. "t1"
, "t2"
, etc, all refer to topics. Those are hardcoded keys: https://github.com/filecoin-project/builtin-actors/blob/master/actors/evm/src/interpreter/instructions/log_event.rs#L15
Summary of changes
Changes introduced in this pull request:
Filecoin.EthGetLogs
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist