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

refactor: replace U256 with u64 in BLOCKHASH #1505

Merged
merged 3 commits into from
Jun 21, 2024

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

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.

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
25 checks passed
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