Skip to content
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

use unionlabs::hash::H256 in evm-storage-verifier #3363

Closed
benluelo opened this issue Dec 11, 2024 · 0 comments · Fixed by #3377
Closed

use unionlabs::hash::H256 in evm-storage-verifier #3363

benluelo opened this issue Dec 11, 2024 · 0 comments · Fixed by #3377
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@benluelo
Copy link
Contributor

benluelo commented Dec 11, 2024

remove primitive-types usage in this crate and use the types from unionlabs instead: https://github.com/unionlabs/union/blob/main/lib/evm-storage-verifier/Cargo.toml#L12

this should be a pretty trivial swap, since unionlabs::hash::Hash implements rlp encoding:

impl<E: Encoding, const BYTES: usize> rlp::Decodable for Hash<BYTES, E> {
fn decode(rlp: &rlp::Rlp) -> Result<Self, rlp::DecoderError> {
rlp.decoder()
.decode_value(|bytes| match bytes.len().cmp(&BYTES) {
core::cmp::Ordering::Less => Err(::rlp::DecoderError::RlpIsTooShort),
core::cmp::Ordering::Greater => Err(::rlp::DecoderError::RlpIsTooBig),
core::cmp::Ordering::Equal => {
Ok(Self::new(bytes.try_into().expect("size is checked; qed;")))
}
})
}
}
// TODO: Feature gate rlp across the crate
// #[cfg(feature = "rlp")]
impl<E: Encoding, const BYTES: usize> rlp::Encodable for Hash<BYTES, E> {
fn rlp_append(&self, s: &mut ::rlp::RlpStream) {
s.encoder().encode_value(self.as_ref());
}
}

@benluelo benluelo added C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Dec 11, 2024
benluelo added a commit that referenced this issue Dec 14, 2024
Fixes #3363

Since Unionlabs::Hash::H256 is already implemented, this refactors the
codes that uses primitive_types::H256 to our own one.

Additionally ,this PR implements AsMut to hash.rs as Hasher need AsMut
trait to be resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
1 participant