Skip to content

Conversation

felixnorden
Copy link
Collaborator

No description provided.

let journal = Journal::abi_decode(&info.journal.bytes)?;
assert_eq!(
from_wormhole_address(journal.emitterContract),
from_wormhole_address(journal.emitterContract).unwrap_or(Address::ZERO),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to unwrap or expect here. This is a silent failure otherwise

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger, will revise!

}

/// Converts a Wormhole format B256 address to an Ethereum Address.
pub fn from_wormhole_address_align(wormhole_addr: B256) -> Result<Address, String> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove the pub and possibly put this inside the tests module as this is the only place it is used

Comment on lines +92 to +98
let (prefix, ints, suffix) = unsafe { garbage_bytes.align_to::<u32>() };
if prefix.iter().any(|&b| b != 0)
|| ints.iter().any(|&i| i != 0)
|| suffix.iter().any(|&b| b != 0)
{
return Err(String::from("Malformed wormhole address"));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels weird and not idiomatic to me. Not totally clear what this function is for

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the alternative function I was talking about from a "performance" perspective as the recommendation to check multiple bytes being zero was to align them into a larger data structure when doing research.

With 12 bytes, we have 3 u32 values, reducing the # of checks by a factor of 4 per cycle. If we think this isn't idiomatic/valuable to save on the cycles, we'll just remove it!

@felixnorden felixnorden marked this pull request as ready for review September 25, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants