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: calculate l1 gas consumed #257

Merged
merged 1 commit into from
May 20, 2024
Merged

Conversation

yoavGrs
Copy link
Contributor

@yoavGrs yoavGrs commented May 19, 2024

This change is Reviewable

@yoavGrs yoavGrs requested a review from ShahakShama May 19, 2024 11:11
@yoavGrs yoavGrs self-assigned this May 19, 2024
Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @yoavGrs)

a discussion (no related file):
Where is the connection to the block hash? It should have changed from this PR. Is it not connected yet?



src/block_hash/receipt_commitment.rs line 17 at r1 (raw file):

pub fn calculate_receipt_commitment<H: HashFunction>(
    transactions_receipt: &[TransactionReceipt],
    l1_data_gas_wei_price: GasPrice,

Why wei? IIRC It depends on the transaction. If it's a v3 transaction you should put fri here


src/block_hash/receipt_commitment.rs line 82 at r1 (raw file):

// L1 gas consumed (In the current RPC:
//      L1 gas consumed for calldata + L1 gas consumed for steps and builtins.
//      Calculated as: total L1 gas consumed - L1 data gas consumed for blob),

total L1 gas consumed is L1 gas consumed. Data gas is not gas
You can write here (actual_fee - actual_l1_data_gas_fee) / l1_gas_price

@yoavGrs yoavGrs force-pushed the yoav/block_hash/l1_gas_consumed branch 2 times, most recently from eb045b3 to d4f5e94 Compare May 19, 2024 14:09
Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @yoavGrs)


src/block_hash/receipt_commitment.rs line 112 at r2 (raw file):

}

fn get_price_by_version(

This is a useful function. Add a TODO to move it to transaction.rs and make it public


src/block_hash/receipt_commitment_test.rs line 45 at r2 (raw file):

    };
    let l1_data_gas_price =
        GasPricePerToken { price_in_fri: GasPrice(456), price_in_wei: GasPrice(456) };

Make the prices different to check that you're calling the correct price.
You can have two prices, one with fri = x, wei = y for the v2 transaction, and one with fri = y, wei = z for the v3 transaction

@yoavGrs yoavGrs force-pushed the yoav/block_hash/l1_gas_consumed branch from d4f5e94 to 7564068 Compare May 20, 2024 08:16
Copy link
Contributor Author

@yoavGrs yoavGrs left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @ShahakShama)

a discussion (no related file):

Previously, ShahakShama wrote…

Where is the connection to the block hash? It should have changed from this PR. Is it not connected yet?

Right, I will update the block hash (251, 248) after this PR.


Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @yoavGrs)

@yoavGrs yoavGrs force-pushed the yoav/block_hash/l1_gas_consumed branch from 7564068 to 977151a Compare May 20, 2024 10:44
@yoavGrs yoavGrs merged commit 64dd7ca into main May 20, 2024
6 checks passed
@yoavGrs yoavGrs deleted the yoav/block_hash/l1_gas_consumed branch May 20, 2024 10:48
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