paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.9k stars 1.14k forks source link

use full qualified reth_codecs:: path + syntax when deriving reth_codecs::Compact #11862

Open mattsse opened 1 day ago

mattsse commented 1 day ago

Describe the feature

currently we expect that Compact trait is in scope:

https://github.com/paradigmxyz/reth/blob/bc43613be35f316304f7ce4a2225855ac26b5923/crates/storage/codecs/derive/src/compact/generator.rs#L34-L36

hence we have a bunch of these:

https://github.com/paradigmxyz/reth/blob/bc43613be35f316304f7ce4a2225855ac26b5923/crates/primitives/src/receipt.rs#L13-L14

we can get rid of this by using the fully qualified path and syntax in the code we generate.

we also need a new attribute so that we can use this in the reth_codes crate itself, e.g.:

https://github.com/paradigmxyz/reth/blob/bc43613be35f316304f7ce4a2225855ac26b5923/crates/storage/codecs/src/alloy/transaction/legacy.rs#L6-L9

this should be similar to serde crate attribute

https://serde.rs/container-attrs.html#crate

so that we can use in the quote!

let reth_codecs = reth_codecs_path(); // TODO needs to check for `crate` attribute
quote!{
 impl #reth_codes::Compact ...

}

This task is done if we can remove all feature gated use reth_codecs::Compact imports

https://github.com/paradigmxyz/reth/pull/11863 has some wip and can be taken over

Additional context

No response

aroralanuk commented 1 day ago

Can I take this one?