alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust
https://alloy.rs
Apache License 2.0
764 stars 139 forks source link

feat: rlp encoding for logs with generic event data #553

Closed prestwich closed 6 months ago

prestwich commented 6 months ago

closes #544

Motivation

Allow rlp encoding of logs after their data has been ABI decoded.

Solution

Add a set of methods and a blanket Encode implementation for Log<T> where for<'a> &'a T: Into<LogData>,

Note that this change does not allow decoding, as that would require embedding the ABI error into the RLP error decode impl

PR Checklist

gakonst commented 6 months ago

@Rjected ptal

prestwich commented 6 months ago

cc @DaniPopes what's up with the tests?

DaniPopes commented 6 months ago

You can update them by running with env TRYBUILD=overwrite, make sure to be on the latest nightly (and with -Zthreads=1 if you overwrite it)

Rjected commented 6 months ago

this also needs to be rebased

prestwich commented 6 months ago

clippy issue seems to have been introduced by merge of main. why?

Please do not merge until we know why this is the case

Rjected commented 6 months ago

clippy issue seems to have been introduced by merge of main. why?

Please do not merge until we know why this is the case

the new nightly clippy doesnt like things that are never constructed, including in tests

onbjerg commented 6 months ago

hmm unsure, was this struct ever used? doing

git grep "StructProp" (git rev-list --all)

yields nothing except changelog and the struct def itself

weird that it wouldn't be caught before this?

edit: not weird given dan comment

prestwich commented 6 months ago

the new nightly clippy doesnt like things that are never constructed, including in tests

why are we using nightly clippy? didnt we decide that was a mistake with ethers as it introduced unstable lints and situations like this where CI breaks for no reason?

prestwich commented 6 months ago

CI is unrelated.

DaniPopes commented 6 months ago

This breaks RLP encoding for Log<LogData> (the default). Fixed in #573.