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

feat(katana): add l1 data price info in header #2547

Merged
merged 3 commits into from
Oct 16, 2024
Merged

feat(katana): add l1 data price info in header #2547

merged 3 commits into from
Oct 16, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 16, 2024

fully resolves #2539

ref #2545

the values in the new fields are mostly dumb values rn bcs we arent sampling anything from the L1. so the next todo to make these changes correct, is to create a gas oracle that samples the actual values from the l1.

similar to #2543, the database format for Header is changed. considering we already bumped the db version in #2543, we can keep using the same version and defer bumping it again once this commit is included in a release.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new fields for Layer 1 data availability and gas prices across various components, enhancing transaction processing and data management.
    • Added support for L1DataAvailabilityMode, improving the handling of gas prices in block production and execution.
  • Bug Fixes

    • Updated references to gas prices in multiple locations to ensure consistency with the new structure.
  • Documentation

    • Enhanced documentation for block-related structures to reflect changes in gas pricing and data availability fields.

@kariy kariy changed the title Add l1 data info in block header feat(katana): add l1 data price info in header Oct 16, 2024
Copy link

coderabbitai bot commented Oct 16, 2024

Walkthrough

Ohayo! This pull request introduces significant updates to the Backend struct and related components across multiple files. Key changes include the addition of new fields for managing Layer 1 data availability modes and gas prices, specifically l1_da_mode, l1_gas_prices, and l1_data_gas_prices. The updates ensure that these fields are correctly populated and utilized throughout the blockchain processing and RPC interactions, enhancing the overall structure and functionality of the codebase.

Changes

File Path Change Summary
crates/katana/core/src/backend/mod.rs Added import for L1DataAvailabilityMode, updated PartialHeader to include l1_da_mode, l1_data_gas_prices, and replaced gas_prices with l1_gas_prices.
crates/katana/core/src/backend/storage.rs Updated new_from_forked method to derive genesis block properties from forked_block, including gas prices and block header fields.
crates/katana/core/src/service/block_producer.rs Modified do_mine method to include l1_da_mode and l1_data_gas_prices in block header construction.
crates/katana/executor/src/implementation/blockifier/mod.rs Updated fill_block_env_from_header to access gas prices from header.l1_gas_prices and updated block_env method to include l1_data_gas_prices.
crates/katana/executor/tests/executor.rs Renamed gas_prices to l1_gas_prices in assertions within test_executor_with_valid_blocks_impl.
crates/katana/executor/tests/fixtures/mod.rs Added import for L1DataAvailabilityMode, updated valid_blocks fixture to include new fields in PartialHeader.
crates/katana/primitives/src/block.rs Enhanced PartialHeader and Header structs with l1_gas_prices, l1_data_gas_prices, and l1_da_mode.
crates/katana/primitives/src/chain_spec.rs Added fields l1_da_mode, l1_gas_prices, and l1_data_gas_prices to Header struct.
crates/katana/primitives/src/da/mod.rs Introduced public export for L1DataAvailabilityMode.
crates/katana/primitives/src/env.rs Added public field l1_data_gas_prices to BlockEnv struct.
crates/katana/rpc/rpc-types/src/block.rs Updated several block-related structures to retrieve l1_gas_prices and l1_data_gas_prices.
crates/katana/rpc/rpc/src/starknet/read.rs Modified StarknetApiServer to include l1_gas_prices and l1_data_gas_prices, updated PartialHeader struct.
crates/katana/storage/provider/src/providers/db/mod.rs Updated block_env_at to return l1_data_gas_prices in BlockEnv.
crates/katana/storage/provider/src/providers/fork/mod.rs Updated block_env_at to return l1_data_gas_prices in BlockEnv.
crates/katana/storage/provider/src/providers/in_memory/mod.rs Updated block_env_at to return l1_data_gas_prices in BlockEnv.
crates/katana/storage/provider/tests/block.rs Adjusted tests to populate l1_gas_prices and l1_data_gas_prices from the block header.
crates/saya/provider/src/rpc/mod.rs Updated fetch_block to include l1_gas_prices, l1_data_gas_prices, and l1_da_mode in SealedHeader.

Assessment against linked issues

Objective Addressed Explanation
Ensure correct L1 data gas prices are returned (Issue #2539)
Ensure the correct version of Starknet is returned (Issue #2539) The version mismatch issue is not addressed.

Possibly related PRs

Suggested reviewers

  • glihm

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Outside diff range and nitpick comments (4)
crates/katana/primitives/src/env.rs (1)

14-15: Ohayo! LGTM, sensei! The addition of L1 data gas prices is spot on.

The new l1_data_gas_prices field in the BlockEnv struct is a great addition that aligns perfectly with the PR objectives. It's consistent with the existing structure and will help address the discrepancies in gas price data.

Consider adding a brief doc comment above the new field to explain its purpose, similar to the other fields in the struct. For example:

/// The L1 data gas prices at this particular block.
pub l1_data_gas_prices: GasPrices,

This will help maintain consistency in documentation and provide clarity for future developers, sensei.

crates/katana/executor/src/implementation/blockifier/mod.rs (2)

105-107: Ohayo, gas price handling looks good, sensei!

The change to use header.l1_gas_prices aligns well with the PR objective of correcting the gas price data. Good job on using NonZeroU128 with a fallback to ensure the gas price is never zero.

Consider extracting the fallback value 1 to a named constant for better readability and maintainability. For example:

const FALLBACK_GAS_PRICE: u128 = 1;
// ...
NonZeroU128::new(header.l1_gas_prices.eth).unwrap_or(NonZeroU128::new(FALLBACK_GAS_PRICE).unwrap());

242-245: Ohayo, sensei! Nice addition of L1 data gas prices!

The new l1_data_gas_prices field in the BlockEnv struct provides a more comprehensive view of the gas prices, aligning well with the PR objective. This enhancement will help address the discrepancies in gas price data.

For consistency with the l1_gas_prices field above, consider using a similar structure:

l1_data_gas_prices: KatanaGasPrices {
    eth: self.block_context.block_info().gas_prices.eth_l1_data_gas_price.get(),
    strk: self.block_context.block_info().gas_prices.strk_l1_data_gas_price.get(),
},

This approach ensures that we're using the get() method on NonZeroU128, maintaining consistency with how l1_gas_prices is handled.

crates/katana/core/src/backend/storage.rs (1)

161-161: Address the TODO: Remove gas price from genesis

There's a TODO comment indicating that the gas price should be removed from the genesis block. Removing it could simplify the genesis configuration and prevent redundant data.

Would you like me to help implement this change or open a new GitHub issue to track this task?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9fdd351 and b3b2c98.

⛔ Files ignored due to path filters (2)
  • spawn-and-move-db.tar.gz is excluded by !**/*.gz
  • types-test-db.tar.gz is excluded by !**/*.gz
📒 Files selected for processing (17)
  • crates/katana/core/src/backend/mod.rs (2 hunks)
  • crates/katana/core/src/backend/storage.rs (3 hunks)
  • crates/katana/core/src/service/block_producer.rs (3 hunks)
  • crates/katana/executor/src/implementation/blockifier/mod.rs (2 hunks)
  • crates/katana/executor/tests/executor.rs (3 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/primitives/src/block.rs (4 hunks)
  • crates/katana/primitives/src/chain_spec.rs (5 hunks)
  • crates/katana/primitives/src/da/mod.rs (1 hunks)
  • crates/katana/primitives/src/env.rs (1 hunks)
  • crates/katana/rpc/rpc-types/src/block.rs (11 hunks)
  • crates/katana/rpc/rpc/src/starknet/read.rs (4 hunks)
  • crates/katana/storage/provider/src/providers/db/mod.rs (1 hunks)
  • crates/katana/storage/provider/src/providers/fork/mod.rs (1 hunks)
  • crates/katana/storage/provider/src/providers/in_memory/mod.rs (1 hunks)
  • crates/katana/storage/provider/tests/block.rs (2 hunks)
  • crates/saya/provider/src/rpc/mod.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (54)
crates/katana/primitives/src/da/mod.rs (1)

7-7: Ohayo, sensei! This change looks great!

The addition of pub use ::starknet::core::types::L1DataAvailabilityMode; is a solid move. It makes the L1DataAvailabilityMode type readily available from this module, which aligns perfectly with our goal of addressing L1 data availability issues mentioned in the PR objectives.

This change will make it easier for other parts of the codebase to work with L1 data availability modes, potentially simplifying the implementation of the required changes for correct StarkNet version and gas price data.

crates/katana/executor/src/implementation/blockifier/mod.rs (1)

Line range hint 1-300: Ohayo, sensei! Overall changes look solid!

The modifications in this file are well-aligned with the PR objectives of resolving discrepancies in StarkNet version and gas price data. The changes to gas price handling and the addition of L1 data gas prices in the block environment contribute to a more accurate and comprehensive representation of the blockchain state.

To further improve the code:

  1. Consider adding comments explaining the significance of the new l1_data_gas_prices field and how it differs from l1_gas_prices.
  2. Update any relevant documentation or comments that might reference the old gas price structure.
  3. Ensure that these changes are consistently applied across other related files in the codebase.
crates/katana/executor/tests/executor.rs (4)

51-51: Ohayo! LGTM, sensei! This change aligns perfectly with our mission.

The update from gas_prices to l1_gas_prices is spot on. It ensures we're accurately asserting the L1 data gas prices in our block environment, which is crucial for addressing those pesky discrepancies mentioned in issue #2539. Nice work!


130-130: Ohayo again, sensei! Consistency is key, and you've nailed it!

Excellent job maintaining the l1_gas_prices update here for the second block assertion. This consistent change across the test implementation ensures we're thoroughly validating the L1 data gas prices throughout the execution process. Keep up the great work!


177-177: Ohayo once more, sensei! You've achieved the trifecta of awesomeness!

Fantastic job completing the l1_gas_prices update trifecta with this change for the third block assertion. Your thorough implementation ensures we're validating the L1 data gas prices consistently across all three blocks. This level of detail is exactly what we need to squash those gas price discrepancies. You're a true coding ninja!


Line range hint 51-177: Ohayo, sensei! Let's wrap this up with a bow of wisdom!

Your changes to the test_executor_with_valid_blocks_impl function are spot on! By consistently updating gas_prices to l1_gas_prices across all three block assertions, you've ensured that our test suite accurately validates the L1 data gas prices. This aligns perfectly with our mission to resolve the discrepancies mentioned in issue #2539.

These updates make our test implementation more robust and reflective of the actual block structure. Great job on improving the accuracy and reliability of our testing process!

Is there anything else you'd like me to look at, sensei?

crates/katana/storage/provider/tests/block.rs (2)

129-130: Ohayo! LGTM, sensei! These changes align perfectly with our L1 data mission.

The addition of l1_gas_prices and l1_data_gas_prices to the BlockEnv structure ensures that our tests now cover the new L1 gas price fields. This modification is in line with the PR objectives to include L1 data info in the block header. Great job on keeping our tests up-to-date!


235-236: Ohayo again, sensei! Excellent work on maintaining consistency!

The addition of l1_gas_prices and l1_data_gas_prices to the BlockEnv structure in the insert_block_empty_test_impl function mirrors the changes made in the insert_block_test_impl function. This consistency ensures that both empty and non-empty block tests cover the new L1 gas price fields. Your attention to detail in keeping our test implementations aligned is commendable!

crates/katana/storage/provider/src/providers/in_memory/mod.rs (1)

573-574: Ohayo, sensei! LGTM: Enhanced block environment data

The addition of l1_data_gas_prices alongside the existing l1_gas_prices in the BlockEnv struct is a great improvement. This change aligns perfectly with the PR objectives to address discrepancies in gas price data when fetching block information.

crates/katana/storage/provider/src/providers/fork/mod.rs (2)

579-580: Ohayo! New L1 gas price fields added to BlockEnv, sensei!

The addition of l1_gas_prices and l1_data_gas_prices to the BlockEnv struct aligns well with the PR objectives. This change should help resolve the discrepancies in gas price data when fetching block information from Katana, as mentioned in issue #2539.


579-580: Verify BlockEnv usage in the codebase, sensei!

The changes to BlockEnv look good, but we should ensure that any code using this struct is updated to handle the new l1_gas_prices and l1_data_gas_prices fields.

Let's run a quick check to find any potential usage of BlockEnv that might need updating:

✅ Verification successful

ohayo sensei!

I've thoroughly checked the usage of BlockEnv across the codebase, including the new l1_gas_prices and l1_data_gas_prices fields. Everything looks good and properly handled.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find potential usage of BlockEnv that might need updating

# Search for BlockEnv usage
echo "Searching for BlockEnv usage:"
rg --type rust "BlockEnv" -C 3

# Search for l1_gas_prices usage
echo "\nSearching for l1_gas_prices usage:"
rg --type rust "l1_gas_prices" -C 3

# Search for l1_data_gas_prices usage
echo "\nSearching for l1_data_gas_prices usage:"
rg --type rust "l1_data_gas_prices" -C 3

Length of output: 88041

crates/katana/core/src/backend/mod.rs (4)

8-8: Ohayo sensei! Import of L1DataAvailabilityMode is appropriate

The addition of use katana_primitives::da::L1DataAvailabilityMode; correctly introduces the L1DataAvailabilityMode enum needed for specifying the data availability mode in the block header.


72-72: Ohayo sensei! Adding l1_da_mode to PartialHeader

The l1_da_mode field has been added to the PartialHeader and initialized with L1DataAvailabilityMode::Calldata. This ensures that the block header accurately reflects the L1 data availability mode, addressing the discrepancies noted in issue #2539.


73-76: Ohayo sensei! Updating gas_prices to l1_gas_prices

The gas_prices field has been updated to l1_gas_prices in the PartialHeader, correctly associating gas prices with Layer 1. This change aligns with the PR objectives to return accurate L1 gas price data when querying block information.


77-80: Ohayo sensei! Including l1_data_gas_prices in PartialHeader

The new field l1_data_gas_prices is added to the PartialHeader and initialized with values from block_env.l1_data_gas_prices. This addition ensures that L1 data gas prices are accurately included in the block header, resolving the inconsistencies highlighted in issue #2539.

crates/saya/provider/src/rpc/mod.rs (1)

104-104: Ohayo sensei! The addition of l1_da_mode is correctly implemented

The new field l1_da_mode is appropriately assigned from block.l1_da_mode, aligning with the PR objectives.

crates/katana/primitives/src/block.rs (4)

50-52: Ohayo, sensei! The additions to PartialHeader are well-integrated

The new fields l1_gas_prices, l1_data_gas_prices, and l1_da_mode have been correctly added to the PartialHeader struct. This enhancement aligns with the objective of incorporating L1-specific gas pricing and data availability modes.


84-87: Ohayo, sensei! The additions to Header are appropriate

The fields l1_gas_prices, l1_data_gas_prices, and l1_da_mode have been properly added to the Header struct, ensuring consistency with PartialHeader and enhancing the block header's functionality.


89-102: Verify the default values in Header::default

Ohayo, sensei! Please ensure that the default values set in the Default implementation of Header are suitable for your application's context, especially:

  • l1_gas_prices: GasPrices::default()
  • l1_data_gas_prices: GasPrices::default()
  • l1_da_mode: L1DataAvailabilityMode::Calldata

114-116: Ohayo, sensei! The updates in Header::new are consistent

The new fields are correctly initialized from PartialHeader in the Header::new method. This ensures that all necessary data is accurately transferred and maintained.

crates/katana/executor/tests/fixtures/mod.rs (1)

13-13: Ohayo sensei! The import of L1DataAvailabilityMode is correctly added.

crates/katana/core/src/backend/storage.rs (4)

152-152: Parsing StarkNet version correctly

The code accurately parses the starknet_version from the forked_block and assigns it to the chain's protocol version.


155-159: Verify the impact of updating genesis block properties

Ohayo sensei! Updating the genesis block properties to match the forked block ensures consistency with the source chain. However, this could have implications on chain integrity and future behavior. Please verify that this change aligns with the intended design.

Would you like assistance in assessing the potential impact of these updates?


181-185: Ensure correct initialization of L1 data gas prices and DA mode

The code updates the block header with l1_data_gas_prices and l1_da_mode from the forked_block, which is essential for accurate block processing.

Please verify that these fields are correctly utilized in downstream processes.


218-218: Importing L1DataAvailabilityMode for proper type usage

Ohayo sensei! The addition of the import for L1DataAvailabilityMode ensures that the code can reference the DA mode enum without issues.

crates/katana/rpc/rpc/src/starknet/read.rs (6)

4-4: Ohayo, sensei! Added necessary import for L1DataAvailabilityMode

The import of L1DataAvailabilityMode from katana_primitives::da is appropriate for its usage in the code.


87-89: Ohayo, sensei! Correctly updated PartialHeader with new L1 data fields

Adding l1_da_mode, l1_data_gas_prices, and l1_gas_prices to PartialHeader enhances the block header with necessary L1 data information as per the PR objectives.


174-175: Ohayo, sensei! Consider borrowing instead of cloning

Same as lines 83-84.


178-180: Ohayo, sensei! Correctly updated PartialHeader with new L1 data fields

Same as lines 87-89.


234-235: Ohayo, sensei! Consider borrowing instead of cloning

Same as lines 83-84.


238-240: Ohayo, sensei! Correctly updated PartialHeader with new L1 data fields

Same as lines 87-89.

crates/katana/primitives/src/chain_spec.rs (5)

5-5: Ohayo, sensei! The import of L1DataAvailabilityMode looks good.


60-62: Ohayo, sensei! Adding the new fields l1_da_mode, l1_gas_prices, and l1_data_gas_prices to the header is appropriate.


222-222: Ohayo, sensei! The import of L1DataAvailabilityMode in the test module is correct.


349-351: Ohayo, sensei! Updating the expected block header with the new fields ensures the tests remain accurate.


367-372: Ohayo, sensei! Asserting the new header fields in tests is a thorough approach.

crates/katana/core/src/service/block_producer.rs (2)

14-14: Ohayo, sensei! Good inclusion of L1DataAvailabilityMode.

The import at line 14 is necessary for specifying the data availability mode in the block header.


585-588: Ohayo, sensei! Excellent update to the block header.

Including l1_da_mode, l1_gas_prices, and l1_data_gas_prices in the block header ensures that the block accurately reflects the L1 data availability mode and gas prices.

crates/katana/rpc/rpc-types/src/block.rs (16)

23-25: Ohayo sensei! Correctly initialized l1_gas_price in BlockWithTxs.

The l1_gas_price is accurately constructed using block.header.l1_gas_prices.eth and strk, ensuring precise gas price handling.


27-29: Ohayo sensei! Properly set up l1_data_gas_price in BlockWithTxs.

The l1_data_gas_price is correctly initialized with values from block.header.l1_data_gas_prices.eth and strk.


50-51: Ohayo sensei! Updated l1_da_mode to reflect header data.

Setting l1_da_mode to block.header.l1_da_mode ensures the data availability mode aligns with the actual block header.


66-67: Ohayo sensei! Initialized l1_gas_price correctly in PendingBlockWithTxs.

The l1_gas_price is properly set using header.l1_gas_prices.eth and strk, maintaining consistency with the header information.


105-107: Ohayo sensei! Correct l1_gas_price initialization in BlockWithTxHashes.

The values are accurately derived from block.header.l1_gas_prices, ensuring accurate gas pricing.


109-111: Ohayo sensei! Properly initialized l1_data_gas_price in BlockWithTxHashes.

Using block.header.l1_data_gas_prices.eth and strk ensures correct data gas pricing.


129-130: Ohayo sensei! Updated l1_da_mode and included l1_data_gas_price.

Setting l1_da_mode to block.header.l1_da_mode and properly initializing l1_data_gas_price enhances consistency.


142-144: Ohayo sensei! Correctly set l1_gas_price in PendingBlockWithTxHashes.

The initialization from header.l1_gas_prices is accurate, ensuring consistency in pending blocks.


146-148: Ohayo sensei! Proper l1_data_gas_price initialization in PendingBlockWithTxHashes.

Values are correctly assigned from header.l1_data_gas_prices, reflecting accurate pricing.


158-159: Ohayo sensei! Updated l1_da_mode in pending block with hashes.

Using header.l1_da_mode ensures the data availability mode is up-to-date with header data.


198-200: Ohayo sensei! Correct l1_gas_price setup in BlockWithReceipts.

The gas prices are accurately initialized from header.l1_gas_prices, ensuring proper receipt handling.


202-204: Ohayo sensei! Initialized l1_data_gas_price in BlockWithReceipts.

Values from header.l1_data_gas_prices are correctly used, maintaining consistency.


227-227: Ohayo sensei! Included l1_data_gas_price in block receipts.

Adding l1_data_gas_price ensures comprehensive gas pricing information in the block.


245-247: Ohayo sensei! Properly set l1_gas_price in PendingBlockWithReceipts.

Initialization from header.l1_gas_prices ensures accurate gas pricing in pending receipts.


249-251: Ohayo sensei! Correct l1_data_gas_price initialization in pending receipts.

Using header.l1_data_gas_prices maintains consistency in data gas pricing.


269-270: Ohayo sensei! Updated l1_da_mode in PendingBlockWithReceipts.

Setting l1_da_mode to header.l1_da_mode ensures alignment with the header's data availability mode.

crates/saya/provider/src/rpc/mod.rs Show resolved Hide resolved
crates/saya/provider/src/rpc/mod.rs Show resolved Hide resolved
crates/katana/primitives/src/block.rs Show resolved Hide resolved
Comment on lines +111 to +113
l1_gas_prices: gas_prices.clone(),
l1_data_gas_prices: gas_prices.clone(),
l1_da_mode: L1DataAvailabilityMode::Calldata,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ohayo sensei! Consider refactoring repeated initialization of PartialHeader fields

The fields l1_gas_prices, l1_data_gas_prices, and l1_da_mode are initialized with the same values in each ExecutableBlock. To enhance maintainability and reduce code duplication, consider abstracting these common initializations into a helper function or a shared method.

Also applies to: 161-163, 194-196

Comment on lines +177 to +179
// we dont update the `l1_gas_price` bcs its already done when we set the `gas_prices` in
// genesis. this flow is kinda flawed, we should probably refactor it out of the
// genesis.
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor gas price handling out of genesis

Ohayo sensei! The comments suggest that the current flow for gas price handling is flawed and may benefit from refactoring. Moving gas price initialization out of the genesis block could improve code clarity and maintainability.

Consider abstracting gas price configuration into a dedicated function or module.

crates/katana/core/src/backend/storage.rs Show resolved Hide resolved
crates/katana/core/src/backend/storage.rs Show resolved Hide resolved
crates/katana/rpc/rpc/src/starknet/read.rs Show resolved Hide resolved
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 47.18310% with 75 lines in your changes missing coverage. Please review.

Project coverage is 69.42%. Comparing base (9fdd351) to head (9f582b0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/rpc/rpc-types/src/block.rs 19.56% 37 Missing ⚠️
crates/katana/core/src/backend/storage.rs 13.04% 20 Missing ⚠️
crates/katana/rpc/rpc/src/starknet/read.rs 33.33% 10 Missing ⚠️
crates/saya/provider/src/rpc/mod.rs 0.00% 6 Missing ⚠️
crates/katana/primitives/src/block.rs 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2547      +/-   ##
==========================================
- Coverage   69.44%   69.42%   -0.02%     
==========================================
  Files         388      388              
  Lines       49881    49953      +72     
==========================================
+ Hits        34640    34682      +42     
- Misses      15241    15271      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kariy kariy merged commit f9a559f into main Oct 16, 2024
13 of 15 checks passed
@kariy kariy deleted the katana/header branch October 16, 2024 18:22
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.

Wrong version of starknet in katana and gas price
1 participant