-
Notifications
You must be signed in to change notification settings - Fork 117
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
[Bug] Log
doesn't allow implementation of traits for non-default generic parameter
#544
Comments
without capturing log encoding semantics in primitives, how would you design |
My proposal would be: trait ExecutionLogData {
fn topics(&self) -> &[B256];
fn data(&self) -> &Bytes;
} This should provide you with all of the information to implement the current implementations of |
The goal of parameterizing over the data is to allow replacing it with deserialized versions and dropping the serialized version. So this might work for something like |
Yeah, a simple |
it needs a bit more complexity, as it would require RLP coding which is fallible. so it migh be something more like:
|
Component
primitives
What version of Alloy are you on?
0.6.3
Operating System
Linux
Describe the bug
The
Log
generic uses a default type= LogData
. This means that for any traits that are implemented forLog
, the traits are only implemented forLog::<LogData>
. Given that Rust does not allow implementation of external traits on external types, this prohibits people from implementing traits on theLog
type when using a locally definedCustomLogData
.E.g. when trying to
impl alloy_rlp::Encodable for LogData<CustomLogData>
this would fail with the compiler error:To solve this, the trait implementations in https://github.com/alloy-rs/core/blob/main/crates/primitives/src/log.rs#L120 should be generic; e.g.
impl<LogDataT: SomeTrait> alloy_rlp::Encodable for Log<LogDataT> { .. }
.The text was updated successfully, but these errors were encountered: