-
Notifications
You must be signed in to change notification settings - Fork 157
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
base: main
Are you sure you want to change the base?
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.
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
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
value: vec![ | ||
226, 71, 32, 244, 92, 183, 79, 45, 85, 241, 222, 235, 182, 9, 143, 80, 241, 11, | ||
81, 29, 171, 138, 125, 71, 196, 129, 154, 8, 220, 208, 184, 149, | ||
] |
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.
It'd be great to document where those test vectors come from.
Summary of changes
Changes introduced in this pull request:
Filecoin.EthGetLogs
This PR introduces a new flag/configuration setting (
enable_event_caching
) to retain events in the Tipset cache.If neither the RPC API nor the methods related to events are used, a value of false can be passed.
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist