-
Notifications
You must be signed in to change notification settings - Fork 275
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] Incorrect safety invariant #1722
Comments
this is still present in |
@DaniPopes Yes, any idea on how to address this? Bad working solution would be to do clone, but it will be slow, obviously. I think it's possible to use https://github.com/google/zerocopy to do the job (as both types have the same type fields), wdyt? |
I think we can avoid the wrapper type altogether seeing that Bytes48 and Blob are just type aliases to FixedBytes, so the SSZ derive should work on the main type directly. |
Component
rpc
What version of Alloy are you on?
v0.7.0/master
Operating System
None
Describe the bug
Safety invariant in the unwrap function is incorrect
alloy/crates/rpc-types-engine/src/payload.rs
Line 476 in 67576f9
Structs
alloy/crates/rpc-types-engine/src/payload.rs
Line 460 in 67576f9
alloy/crates/rpc-types-engine/src/payload.rs
Line 449 in 67576f9
Rust repr does not guarantee that this structs would have the same memory layout (https://doc.rust-lang.org/nomicon/repr-rust.html).
Also transmute highlights that it should not be used with Rust repr
https://doc.rust-lang.org/nomicon/transmutes.html
To fix the problem we could either change unwrap or add repr(C) to structs (but we will need to align them manually)
wrap_ref have similar issue too, but it's not easy to fix this as the operation itself is not safe (only with repr(C) ) so it's up to discussion
The text was updated successfully, but these errors were encountered: