Skip to content

Conversation

@TropicalDog17
Copy link
Contributor

@TropicalDog17 TropicalDog17 commented Jun 11, 2024

Description

Change the type of the number parameter in the block_hash methods of Host and Database from U256 to u64.

Closes #1423

\cc @rakita @DaniPopes

fn block_hash(&mut self, number: u64) -> Option<B256> {
let block_number = as_usize_saturated!(self.env().block.number);
let requested_number = as_usize_saturated!(number);
let requested_number = number as usize;
Copy link
Member

Choose a reason for hiding this comment

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

This can panic. We should use usize::try_from(number).unwrap_or(usize::MAX);

Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

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

cool change. One edge case pending

@TropicalDog17
Copy link
Contributor Author

@rakita thanks for your review, I've refactored accordingly.

@TropicalDog17 TropicalDog17 requested a review from rakita June 11, 2024 11:13
@TropicalDog17 TropicalDog17 force-pushed the tuan/refactor-blockhash branch from cf48fd3 to 4d3faae Compare June 11, 2024 11:14
Copy link
Member

@rakita rakita left a comment

Choose a reason for hiding this comment

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

lgtm

@DaniPopes DaniPopes changed the title refactor: replace U256 to u64 in EIP-2935 BLOCKHASH refactor: replace U256 with u64 in BLOCKHASH Jun 12, 2024
@rakita rakita merged commit 784a065 into bluealloy:main Jun 21, 2024
This was referenced Jun 28, 2024
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.

Don't use U256 operation in EIP-2935 BLOCKHASH

3 participants