Skip to content

Conversation

FabijanC
Copy link
Contributor

@FabijanC FabijanC commented May 13, 2025

Usage related changes

Development related changes

Checklist:

  • Checked out the contribution guidelines
  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/clippy_check.sh
  • No unused dependencies - ./scripts/check_unused_deps.sh
  • No spelling errors - ./scripts/check_spelling.sh
  • Performed code self-review
  • Rebased to the latest commit of the target branch (or merged it into my branch)
    • Once you make the PR reviewable, please avoid force-pushing
  • Updated the docs if needed - ./website/README.md
  • Linked the issues resolvable by this PR - linking info
  • Updated the tests if needed; all passing - execution info

Summary by CodeRabbit

  • New Features

    • Simplified gas price configuration by consolidating multiple gas price parameters into three unified fields: l1_gas_price, l1_data_gas_price, and l2_gas_price.
  • Refactor

    • Updated all CLI flags, environment variables, API schemas, and configuration files to use the new unified gas price fields.
    • Adjusted test setups and helper utilities to align with the new gas price representation.
  • Documentation

    • Revised API schema documentation to reflect the consolidated gas price fields and removed references to deprecated parameters.

Copy link

coderabbitai bot commented May 13, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This change refactors the handling of gas price parameters throughout the codebase. It consolidates previously separate gas price fields—distinguished by "wei" and "fri" units for L1 gas price, L1 data gas price, and L2 gas price—into three unified fields: l1_gas_price, l1_data_gas_price, and l2_gas_price, all denominated in FRI units. The update affects configuration structs, CLI argument parsing, block and transaction logic, test setups, and API schemas. Methods and data structures are updated to use the new unified fields, and related test cases, documentation, and API definitions are modified to match the new naming and structure. No changes to control flow or error handling are introduced.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@FabijanC FabijanC changed the title Rename gas price parameters - only strk/fri Breaking: Rename gas price parameters - only strk/fri May 13, 2025
@FabijanC
Copy link
Contributor Author

@coderabbitai review

Copy link

coderabbitai bot commented May 13, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 0

🧹 Nitpick comments (3)
crates/starknet-devnet-types/src/rpc/gas_modification.rs (1)

36-36: TODO for GasPriceVector converter

There's a TODO comment about implementing a converter to GasPriceVector. Consider creating a ticket to track this work item to ensure it doesn't get forgotten in future development.

crates/starknet-devnet-core/src/starknet/mod.rs (2)

100-104: Clarify the intent behind DUMMY_GAS_PRICE_VECTOR

NonzeroGasPrice::MIN translates to “1 FRI/WEI”. That non-zero value will propagate to every place where an ETH-denominated gas price is requested (e.g. l1_gas_price(&FeeType::Eth) in restart_pending_block). In practice this may:

  1. Produce non-intuitive results (fees of 1 wei on ETH paths) when callers expect ETH prices to be irrelevant or zero.
  2. Leak into user-facing RPC responses, which could be confusing for tooling that assumes ETH fees are not supported.

Please double-check whether we really want ETH prices to be hard-coded to 1. Alternatives:

-const DUMMY_GAS_PRICE_VECTOR: GasPriceVector = GasPriceVector {
-    l1_gas_price: NonzeroGasPrice::MIN,
-    l1_data_gas_price: NonzeroGasPrice::MIN,
-    l2_gas_price: NonzeroGasPrice::MIN,
-};
+/// A placeholder ETH‐price vector.  
+/// Using `u128::MAX` makes it obvious that ETH prices are unsupported and
+/// prevents accidental fee under-estimation.
+const DUMMY_GAS_PRICE_VECTOR: GasPriceVector = GasPriceVector {
+    l1_gas_price: NonzeroGasPrice::new(u128::MAX),
+    l1_data_gas_price: NonzeroGasPrice::new(u128::MAX),
+    l2_gas_price: NonzeroGasPrice::new(u128::MAX),
+};

Or make ETH prices Option<NonzeroGasPrice> and return None where ETH is not supported.


493-504: Factor out duplicated gas-price mapping logic

set_block_context_gas re-creates a GasPrices struct that is almost identical to the one built in init_block_context. The only moving part is the GasModification container. Consider extracting a helper such as:

fn gas_prices_from(gas: &GasModification) -> GasPrices {}

and re-use it from both places. This eliminates duplication and guarantees that future changes (e.g. a new field in GasPriceVector) cannot drift out of sync.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 180dc4d and e60a062.

📒 Files selected for processing (16)
  • crates/starknet-devnet-core/src/blocks/mod.rs (3 hunks)
  • crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs (0 hunks)
  • crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs (1 hunks)
  • crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (0 hunks)
  • crates/starknet-devnet-core/src/starknet/mod.rs (16 hunks)
  • crates/starknet-devnet-core/src/starknet/starknet_config.rs (2 hunks)
  • crates/starknet-devnet-core/src/state/state_diff.rs (1 hunks)
  • crates/starknet-devnet-types/src/rpc/block.rs (0 hunks)
  • crates/starknet-devnet-types/src/rpc/gas_modification.rs (1 hunks)
  • crates/starknet-devnet/src/cli.rs (3 hunks)
  • tests/integration/common/utils.rs (2 hunks)
  • tests/integration/general_integration_tests.rs (2 hunks)
  • tests/integration/test_gas_modification.rs (7 hunks)
  • tests/integration/test_restart.rs (3 hunks)
  • tests/integration/test_simulate_transactions.rs (2 hunks)
  • website/static/devnet_api.json (4 hunks)
💤 Files with no reviewable changes (3)
  • crates/starknet-devnet-core/src/starknet/add_deploy_account_transaction.rs
  • crates/starknet-devnet-types/src/rpc/block.rs
  • crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/integration/test_simulate_transactions.rs (1)
tests/integration/common/utils.rs (4)
  • assert_contains (648-657)
  • declare_v3_deploy_v3 (278-300)
  • felt_to_u128 (440-443)
  • get_deployable_account_signer (47-52)
🔇 Additional comments (39)
crates/starknet-devnet-core/src/state/state_diff.rs (1)

269-273: Approved: Simplified gas price configuration.

The test has been updated to use the consolidated gas price fields (l1_gas_price, l1_data_gas_price, l2_gas_price) instead of the previous separate wei/fri fields. This change aligns with the broader refactoring of gas price handling across the codebase.

tests/integration/test_simulate_transactions.rs (2)

31-31: Added utility function import correctly.

The felt_to_u128 utility function has been properly imported from the common utils module to support the gas price extraction refactoring.


459-463: Improved gas price extraction with standardized conversion.

The code now uses the felt_to_u128 utility function to directly convert the gas price from Felt to u128, replacing the previous manual conversion approach. This simplifies the code and makes it more maintainable.

tests/integration/common/utils.rs (2)

445-448: Good addition: New utility function for consistent Felt-to-u64 conversion.

This helper function follows the same pattern as the existing felt_to_u128 function, providing a consistent approach for conversions from Felt values to native integer types. The implementation correctly extracts the first 8 bytes in little-endian order.


637-643: Improved code maintainability with helper functions.

The implementation now uses the helper functions felt_to_u64 and felt_to_u128 for type conversions, making the code more consistent and easier to maintain. This approach standardizes the conversion of Felt values to their respective integer types throughout the codebase.

crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs (1)

430-433: Consolidated gas price fields in test setup.

The test setup has been updated to use the three consolidated gas price fields instead of six separate ones, aligning with the broader refactoring of gas price handling across the codebase. This makes the test more consistent with the rest of the implementation.

tests/integration/test_restart.rs (3)

119-119: Variable renaming follows the new gas price structure

The variable renaming from expected_data_gas_price to expected_l1_data_gas_price and the corresponding assertion update properly align with the consolidated gas price parameter structure being implemented across the codebase.

Also applies to: 122-122


125-130: CLI argument flags updated to match new naming pattern

The command line arguments have been properly updated to use the new consolidated gas price flags (--l1-gas-price, --l1-data-gas-price, --l2-gas-price) instead of the previous -fri suffix variants. This ensures consistent naming across the API.


156-156: Updated assertion fields to match new field names

The test assertions have been correctly updated to use the new field name l1_data_gas_price to ensure the gas price estimates maintain correct values before and after restart.

Also applies to: 166-166

tests/integration/general_integration_tests.rs (2)

39-43: Configuration structure updated for gas prices but contains unrelated change

The JSON configuration object correctly incorporates the consolidated gas price fields (l1_gas_price, l1_data_gas_price, l2_gas_price). However, I notice the start_time value changed from what was likely 4 to 3, which seems unrelated to the gas price parameter renaming described in the PR objectives.

Is the change to start_time intended as part of this PR? Since the PR is described as only renaming gas price parameters, this change appears to be unrelated to the stated objective.


72-77: CLI arguments properly updated to use new gas price parameter names

The CLI arguments passed to the background devnet instance correctly use the new consolidated gas price flags, ensuring consistency with the rest of the codebase changes.

crates/starknet-devnet-core/src/blocks/mod.rs (2)

5-5: Import statements updated to include necessary types

The imports were correctly updated to include GasPrice from starknet_api::block and GasModification from starknet_types::rpc::gas_modification, which are necessary for the new method implementation.

Also applies to: 15-15


398-405: Well-implemented gas modification method

The new apply_gas_modification method provides a clean way to update the block header's gas price fields from a GasModification instance. This properly centralizes the logic for updating gas prices and supports the broader refactoring of gas price handling throughout the codebase.

The implementation correctly maps the consolidated gas price fields to the appropriate fields in the block header, using the proper type conversions.

crates/starknet-devnet-core/src/starknet/starknet_config.rs (2)

109-112: Configuration fields consolidated for cleaner API

The six separate gas price fields have been consolidated into three clearly named fields: l1_gas_price, l1_data_gas_price, and l2_gas_price. This makes the configuration more intuitive and reduces redundancy.


155-157: Default implementation correctly updated for consolidated fields

The default implementation has been properly updated to initialize the new consolidated gas price fields using the appropriate constants, ensuring backward compatibility with existing code.

tests/integration/test_gas_modification.rs (10)

9-9: Import updated to match the new gas price handling

The import has been simplified since we now only use Felt and StarknetError from starknet_rs_core::types, which aligns with the gas price field consolidation.


21-21: Removed unused import

The felt_to_u128 helper is no longer needed since we're working directly with u128 values for gas prices instead of converting between types.


169-176: Gas price parameters renamed to match new convention

The gas price parameters in the JSON request are now using the unified naming scheme (l1_gas_price, l1_data_gas_price, l2_gas_price) instead of separate wei/fri fields. This correctly aligns with the new API schema.


240-242: Simplified gas price type handling

Gas prices are now directly converted to u128 from their constants, which simplifies the code by removing the nested type conversions previously needed with the dual wei/fri representation.


247-249: Consistent use of price_in_fri accessor

The test correctly maintains the use of the .price_in_fri accessor when checking block gas prices, which ensures compatibility with the block structure while using the new unified field names.

Also applies to: 266-268, 273-275, 279-281, 297-299


251-258: Gas price variable names updated for clarity

Variable names have been updated to clearly indicate they represent FRI prices, making the code more readable and consistent with the new unified field names.


283-291: Consistent naming pattern in second update test

The second update test case follows the same naming pattern as the first, maintaining consistency throughout the test file.


345-346: Simplified gas price JSON structure

The gas price JSON now uses the simplified structure with just one field for L2 gas price, which aligns with the new API schema and makes the test more focused.


354-361: Consistent block gas price assertions

The assertions for block gas prices correctly use the .price_in_fri accessor when checking against the default values, maintaining compatibility with existing block structures.


395-399: Final gas price JSON uses unified field names

The expected final gas price JSON correctly uses the unified field names, which ensures consistency with the new API schema and makes the test more robust.

crates/starknet-devnet-types/src/rpc/gas_modification.rs (3)

8-11: Consolidated gas price fields in GasModificationRequest

The GasModificationRequest struct now uses the unified gas price field names (l1_gas_price, l1_data_gas_price, l2_gas_price) instead of separate wei/fri fields. This simplifies the API and makes it more consistent.


17-19: Consolidated gas price fields in GasModification

Similarly, the GasModification struct has been updated to use the unified gas price field names, ensuring consistency across the codebase.


24-32: Updated update method to use new field names

The update method has been refactored to use the new unified field names, maintaining the same functionality while simplifying the code.

website/static/devnet_api.json (4)

387-398: API parameters updated to use unified gas price fields

The devnet_setGasPrice method parameters now use the unified gas price field names (l1_gas_price, l1_data_gas_price, l2_gas_price), all described as being in FRI units. This simplifies the API and makes it more intuitive.


411-425: API result schema updated to match new field names

The result schema for devnet_setGasPrice has been updated to match the new unified field names, ensuring consistency between request and response structures.


736-747: Config API schema updated with unified gas price fields

The devnet_getConfig response schema now uses the unified gas price field names, ensuring consistency across the API.


790-793: Required fields in config updated to match new naming

The list of required fields in the config API response has been updated to use the new unified field names, maintaining API contract integrity.

crates/starknet-devnet/src/cli.rs (5)

116-121: CLI argument renamed to l1_gas_price

The CLI argument has been renamed from gas_price_fri to l1_gas_price, which better describes its purpose and aligns with the new unified field naming convention.


123-128: CLI argument renamed to l1_data_gas_price

Similarly, the data gas price CLI argument has been renamed from data_gas_price_fri to l1_data_gas_price, maintaining consistency with the new naming scheme.


130-135: L2 gas price CLI argument preserved

The L2 gas price CLI argument name was already correct and has been preserved, ensuring compatibility with existing scripts and documentation.


224-226: Updated config struct assignment to use new field names

The to_config method now uses the new unified field names when creating the StarknetConfig struct, completing the CLI argument renaming.


550-552: Test environment variables updated to match new CLI flags

The test environment variables have been updated to use the new unified field names, ensuring that the tests properly verify CLI and environment variable equivalence.

crates/starknet-devnet-core/src/starknet/mod.rs (2)

541-584: Verify price_in_wei values after the refactor

restart_pending_block populates price_in_wei using
block_context.block_info().gas_prices.l1_gas_price(&FeeType::Eth).
Since ETH gas-price vectors are now the dummy constant, every new pending
block advertises price_in_wei = 1.

If any downstream component still interprets that field literally (e.g.
wallets showing “gas price 1 wei”), the UX may degrade. Please confirm
that the ETH side of GasPricePerToken is either ignored or explicitly
documented as a placeholder.


315-316: 👍 Nice use of apply_gas_modification

Switching the block-header update to the dedicated helper keeps the block
generation paths consistent and removes bespoke gas mutations from the
call sites. Good job!

Also applies to: 340-341

@FabijanC
Copy link
Contributor Author

Looks like -wei prices might be necessary after all: L1->L2 messages require them, as discussed on Slack.

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.

Gas price CLI params should be renamed
1 participant