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

fix: use u128 for calc data fee result #757

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

Rjected
Copy link
Collaborator

@Rjected Rjected commented Sep 28, 2023

A hive test runs with these parameters:

self.block.get_blob_gasprice = Some(136505023684851)
self.tx.get_total_blob_gas = 524288

multiply to get data fee
data fee returned: 16227713636554506240
data fee SHOULD be 71567945857683161088

The data fee overflowed in this case, causing an invalid state root in the test. This fixes the calc_data_fee method to compute a u128.

@@ -424,10 +424,10 @@ impl Env {
///
/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
#[inline]
pub fn calc_data_fee(&self) -> Option<u64> {
pub fn calc_data_fee(&self) -> Option<u128> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn calc_data_fee(&self) -> Option<u128> {
pub fn calc_data_fee(&self) -> Option<U256> {

revm balance is represented as U256 so it would be good to return same type.

self.block
.get_blob_gasprice()
.map(|blob_gas_price| blob_gas_price * self.tx.get_total_blob_gas())
.map(|blob_gas_price| blob_gas_price as u128 * self.tx.get_total_blob_gas() as u128)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.map(|blob_gas_price| blob_gas_price as u128 * self.tx.get_total_blob_gas() as u128)
.map(|blob_gas_price| U256::from(blob_gas_price).saturating_mul(U256::from(self.tx.get_total_blob_gas()))

@rakita rakita merged commit ea0d8d8 into bluealloy:main Sep 28, 2023
8 checks passed
@Rjected Rjected mentioned this pull request Sep 28, 2023
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.

3 participants