Update starknet-rs; default minting to FRI; use only tx v3 in integration tests#722
Update starknet-rs; default minting to FRI; use only tx v3 in integration tests#722FabijanC merged 89 commits intostarknet-0.13.4from
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request upgrades several dependency versions and removes a deprecated dependency from the Cargo configuration. In the core library, the error handling logic has been refactored to introduce new error types and remove legacy stack trace structures. The public interface has been simplified by removing the stack trace module while enhancing error conversion methods. The API endpoints and JSON RPC error responses now directly utilize the new error types. In addition, a wide array of integration tests have been updated to migrate from older transaction methods (v1/v2) to version 3 methods, adjust gas fee parameters from WEI to FRI, and update contract addresses and endpoint constants. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Starknet
participant ErrorHandler
Client->>Starknet: Initiate transaction call
Starknet->>Starknet: Process transaction (v3 method)
alt Transaction Fails
Starknet->>ErrorHandler: Wrap error into ContractExecutionError
ErrorHandler-->>Starknet: Return detailed error
Starknet-->>Client: Send error response (with encoded details)
else Transaction Succeeds
Starknet-->>Client: Return successful transaction result
end
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| #[arg(help = "Specify the gas price in fri per L1 gas unit;")] | ||
| gas_price_fri: NonZeroU128, | ||
|
|
||
| // TODO perhaps make this affect only fri and remove -fri flags |
There was a problem hiding this comment.
We can deal with this later, in a separate PR
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (8)
crates/starknet-devnet-types/src/rpc/transactions.rs (1)
373-378: Minor struct initialization style.Wrapping
l1_data_gasin an inline block is fine, though slightly inconsistent with adjacent fields. Consider inlining for uniformity or keep if it enhances clarity.crates/starknet-devnet/src/cli.rs (1)
132-132: Consider documenting the rationale behind this TODO comment.The TODO comment suggests a potential plan to simplify the CLI by making the gas price flags affect only FRI and removing redundant
-friflags. While the comment itself provides some context, it would be helpful to add more details about why this change is being considered and what the expected benefits would be.- // TODO perhaps make this affect only fri and remove -fri flags + // TODO: Consider making gas price flags affect only FRI and remove redundant -fri flags + // Rationale: Since we're moving to STRK as the primary currency, simplifying to a single + // set of price flags would improve usability and reduce confusion.crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (1)
317-321: Improved error handling for contract execution errorsThe error handling has been refactored to directly use ContractExecutionError instead of wrapping errors in ErrorStack. This provides more structured and informative error responses to API clients.
Consider using a more descriptive error message in the catch-all case to help with debugging:
-Err(e) => Err(ApiError::ContractError(ContractExecutionError::Message(e.to_string()))), +Err(e) => Err(ApiError::ContractError(ContractExecutionError::Message(format!("Contract call failed: {}", e)))),tests/integration/test_gas_modification.rs (1)
135-136: Zero L1 gas and fixed overall fee.
The test assertsl1_gasis zero yet expects a large overall fee. Confirm these values reflect your default pricing logic.If
l1_gasis always zero, consider clarifying that scenario or removing extraneous checks.crates/starknet-devnet-core/src/error.rs (2)
193-203: Definition ofInnerContractExecutionError.
Bundling address, class hash, selector, and return data is a solid approach to provide detailed error context. Consider adding a brief doc comment on each field for clarity.
232-326: Unwrapping error stacks in(ErrorStack, String)conversion.
The recursive unrolling ofErrorStackinto nested frames is a thorough approach.
- The helper function
format_erroris a neat utility for combining messages.- Skipping VM frames unless at the end can streamline messages, but consider adding a quick note in the code about the rationale (since skipping frames might hide some context).
tests/integration/test_old_state.rs (1)
50-63: Check for robust error handling.
While.await.unwrap()is acceptable in test code, consider adding descriptive error messages for easier debugging. Otherwise, the logic for using.execute_v3is correct.tests/integration/test_fork.rs (1)
145-146: Fix spelling in doc comment.
Minor spelling nit: “declaraiton” → “declaration”.-/// Using a fork of a real network because Devnet no longer accepts Cairo 0 class declaraiton +/// Using a fork of a real network because Devnet no longer accepts Cairo 0 class declaration
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (43)
Cargo.toml(1 hunks)crates/starknet-devnet-core/Cargo.toml(0 hunks)crates/starknet-devnet-core/src/error.rs(4 hunks)crates/starknet-devnet-core/src/lib.rs(0 hunks)crates/starknet-devnet-core/src/stack_trace.rs(0 hunks)crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs(2 hunks)crates/starknet-devnet-core/src/starknet/estimations.rs(3 hunks)crates/starknet-devnet-core/src/starknet/mod.rs(8 hunks)crates/starknet-devnet-server/src/api/http/endpoints/mint_token.rs(1 hunks)crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs(5 hunks)crates/starknet-devnet-server/src/api/json_rpc/error.rs(6 hunks)crates/starknet-devnet-types/src/rpc/transactions.rs(7 hunks)crates/starknet-devnet/src/cli.rs(1 hunks)tests/integration/common/background_devnet.rs(3 hunks)tests/integration/common/constants.rs(1 hunks)tests/integration/common/fees.rs(1 hunks)tests/integration/common/utils.rs(11 hunks)tests/integration/get_transaction_by_hash.rs(6 hunks)tests/integration/get_transaction_receipt_by_hash.rs(11 hunks)tests/integration/lib.rs(0 hunks)tests/integration/test_abort_blocks.rs(2 hunks)tests/integration/test_account_impersonation.rs(3 hunks)tests/integration/test_account_selection.rs(4 hunks)tests/integration/test_advancing_time.rs(2 hunks)tests/integration/test_blocks_generation.rs(5 hunks)tests/integration/test_call.rs(5 hunks)tests/integration/test_dump_and_load.rs(7 hunks)tests/integration/test_estimate_fee.rs(24 hunks)tests/integration/test_estimate_message_fee.rs(2 hunks)tests/integration/test_fork.rs(7 hunks)tests/integration/test_gas_modification.rs(9 hunks)tests/integration/test_get_class.rs(3 hunks)tests/integration/test_get_events.rs(3 hunks)tests/integration/test_messaging.rs(18 hunks)tests/integration/test_minting.rs(1 hunks)tests/integration/test_old_state.rs(9 hunks)tests/integration/test_restart.rs(5 hunks)tests/integration/test_simulate_transactions.rs(34 hunks)tests/integration/test_subscription_to_events.rs(1 hunks)tests/integration/test_subscription_to_tx_status.rs(1 hunks)tests/integration/test_trace.rs(9 hunks)tests/integration/test_transaction_handling.rs(3 hunks)tests/integration/test_v3_transactions.rs(7 hunks)
💤 Files with no reviewable changes (4)
- tests/integration/lib.rs
- crates/starknet-devnet-core/Cargo.toml
- crates/starknet-devnet-core/src/lib.rs
- crates/starknet-devnet-core/src/stack_trace.rs
🧰 Additional context used
🧬 Code Definitions (16)
crates/starknet-devnet-core/src/starknet/estimations.rs (1)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)
tests/integration/test_call.rs (3)
crates/starknet-devnet-server/src/test_utils.rs (1)
assert_contains(12-21)tests/integration/common/utils.rs (4)
declare_v3_deploy_v3(272-294)deploy_v3(249-269)extract_message_error(468-473)extract_nested_error(476-481)tests/integration/common/background_devnet.rs (1)
spawn_with_additional_args(132-165)
tests/integration/test_account_selection.rs (3)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)crates/starknet-devnet-core/src/account.rs (1)
new(72-91)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v3.rs (1)
from(23-25)
tests/integration/test_old_state.rs (1)
tests/integration/common/utils.rs (4)
extract_message_error(468-473)extract_nested_error(476-481)from(602-617)from(621-645)
tests/integration/test_estimate_fee.rs (8)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-types/src/rpc/transactions.rs (4)
from(346-352)from(398-426)new(127-129)new(359-385)crates/starknet-devnet-core/src/state/state_diff.rs (1)
from(126-176)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v3.rs (1)
from(23-25)crates/starknet-devnet-types/src/rpc/estimate_message_fee.rs (1)
new(35-37)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_deploy_account_transaction_v1.rs (1)
new(20-40)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v2.rs (1)
new(22-42)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_invoke_transaction_v1.rs (1)
new(18-36)
crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (12)
crates/starknet-devnet-types/src/rpc/contract_class.rs (8)
try_from(81-86)try_from(91-96)try_from(102-118)try_from(124-167)try_from(218-226)try_from(232-281)serde_json(315-315)serde_json(469-469)crates/starknet-devnet-types/src/rpc/contract_class/deprecated/rpc_contract_class.rs (1)
try_from(90-93)crates/starknet-devnet-types/src/rpc/contract_class/deprecated/json_contract_class.rs (2)
try_from(221-233)try_from(239-242)crates/starknet-devnet-types/src/rpc/transactions/l1_handler_transaction.rs (1)
try_from(117-135)crates/starknet-devnet-server/src/rpc_core/request.rs (2)
try_from(34-36)try_from(42-56)crates/starknet-devnet-types/src/patricia_key.rs (3)
try_from(57-59)try_from(65-67)try_from(73-75)crates/starknet-devnet-server/src/api/json_rpc/mod.rs (4)
serde_json(987-987)serde_json(1149-1149)serde_json(1575-1575)serde_json(1579-1579)tests/integration/common/utils.rs (1)
serde_json(69-69)crates/starknet-devnet-types/src/utils.rs (1)
serde_json(103-103)crates/starknet-devnet-types/src/rpc/contract_class/deprecated/abi_entry.rs (2)
serde_json(110-110)serde_json(128-128)crates/starknet-devnet-server/src/api/json_rpc/spec_reader/mod.rs (1)
serde_json(277-277)crates/starknet-devnet-server/src/api/json_rpc/models.rs (1)
serde_json(292-292)
tests/integration/test_fork.rs (3)
crates/starknet-devnet-core/src/account.rs (1)
new(72-91)crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)tests/integration/common/utils.rs (1)
new(233-238)
tests/integration/get_transaction_by_hash.rs (1)
tests/integration/common/utils.rs (3)
assert_tx_successful(99-110)get_deployable_account_signer(48-53)get_simple_contract_in_sierra_and_compiled_class_hash(95-97)
tests/integration/test_simulate_transactions.rs (7)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_deploy_account_transaction_v1.rs (1)
new(20-40)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v2.rs (1)
new(22-42)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_invoke_transaction_v1.rs (1)
new(18-36)crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-core/src/state/state_diff.rs (1)
from(126-176)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v3.rs (1)
from(23-25)
crates/starknet-devnet-types/src/rpc/transactions.rs (4)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-types/src/rpc/transaction_receipt.rs (1)
from(84-90)tests/integration/common/utils.rs (2)
from(602-617)from(621-645)crates/starknet-devnet-types/src/rpc/transactions/broadcasted_declare_transaction_v3.rs (1)
from(23-25)
tests/integration/test_gas_modification.rs (7)
crates/starknet-devnet-core/src/starknet/mod.rs (2)
new(160-294)pending_block(574-576)crates/starknet-devnet-types/src/rpc/transactions.rs (4)
new(127-129)new(359-385)from(346-352)from(398-426)crates/starknet-devnet-core/src/account.rs (1)
new(72-91)crates/starknet-devnet-types/src/rpc/transactions/declare_transaction_v3.rs (1)
new(33-48)crates/starknet-devnet-types/src/rpc/transactions/deploy_account_transaction_v3.rs (2)
new(36-54)from(66-82)crates/starknet-devnet-types/src/rpc/transactions/invoke_transaction_v3.rs (2)
new(32-46)from(54-70)tests/integration/common/fees.rs (1)
assert_difference_if_validation(24-66)
tests/integration/test_v3_transactions.rs (6)
tests/integration/common/utils.rs (4)
assert_tx_successful(99-110)from(602-617)from(621-645)new(233-238)crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-types/src/rpc/transactions.rs (4)
from(346-352)from(398-426)new(127-129)new(359-385)crates/starknet-devnet-core/src/starknet/mod.rs (2)
estimate_fee(763-776)new(160-294)tests/integration/common/reqwest_client.rs (1)
new(19-21)crates/starknet-devnet-server/src/test_utils.rs (1)
assert_contains(12-21)
tests/integration/test_trace.rs (2)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)
tests/integration/test_messaging.rs (5)
tests/integration/common/utils.rs (4)
get_messaging_lib_in_sierra_and_compiled_class_hash(78-81)new(233-238)from(602-617)from(621-645)crates/starknet-devnet-types/src/rpc/transactions.rs (4)
new(127-129)new(359-385)from(346-352)from(398-426)crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)crates/starknet-devnet-server/src/test_utils.rs (1)
assert_contains(12-21)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)
tests/integration/common/utils.rs (1)
crates/starknet-devnet-core/src/error.rs (10)
from(82-84)from(114-136)from(140-149)from(153-173)from(215-217)from(224-229)from(233-325)from(329-374)from(412-489)from(620-660)
🔇 Additional comments (260)
tests/integration/test_advancing_time.rs (2)
67-67: Switch todeclare_v3looks correct.This aligns with the updated transaction version usage. Ensure all references and calls in the test suite remain consistent with the
declare_v3method.
76-76: Migration todeploy_v3is consistent with the new workflow.The updated method call is appropriate for version 3 deployments. Ensure that any downstream references or usage of deployment logic also aligns with this change.
tests/integration/common/fees.rs (2)
52-52: Confirm that allowing equality for L1 gas is intended.Switching from
>to>=could permit cases where both traces report the same L1 gas usage. Verify whether this is the intended behavior or if strict inequality was expected.
62-62: Requiring strictly more L2 gas may cause edge cases.Replacing
>=with>tightens the condition for L2 gas usage. Confirm that there's no scenario where equal L2 gas usage should be accepted.crates/starknet-devnet-types/src/rpc/transactions.rs (9)
16-18: New imports for resource bounds are appropriate.These additions (
AllResourceBounds,Fee,GasVectorComputationMode,Tip, andValidResourceBounds) seem consistent with the updated logic for resource management.
21-22: Imported mapping and statuses align with new usage.Introducing
ResourceBounds,ResourceBoundsMapping, and transaction status types is consistent with the expanded functionality in resource and execution result handling.
347-350: RefinedGasVectorComputationModematching logic.Mapping
ValidResourceBounds::L1Gas(_)toNoL2GasandAllResources(_)toAllis consistent with a clear distinction between single vs. multi-resource usage. Double-check whether partial combinations (e.g., only L1 data gas) are handled elsewhere or implicitly treated as “all resources.”
399-424: Review match logic for partial resource bounds.This block interprets
(l1_gas_max_amount, l2_gas_max_amount, l1_data_gas_max_amount)to determine whether we haveAllResourcesor onlyL1Gas. Verify that cases like “l1_data_gas only” or “l1_data_gas + l2_gas, but no l1_gas” are intentionally treated asAllResources.
440-448: Validate conditional checks in resource-bound matching.Adding these match arms clarifies which combinations of
(l1_gas, l2_gas, l1_data_gas)are acceptable. Confirm your fallback ensures correct allowance when onlyl1_data_gasorl2_gasis nonzero.
1013-1019: Optional trace fields improve clarity.Conditionally serializing
validate_invocation,fee_transfer_invocation, andstate_diffis a good approach to keep JSON responses smaller. No issues found.
1026-1031: Optional fields inDeclareTransactionTrace.Skipping serialization when fields are none is consistent with the pattern in other traces. Looks good.
1038-1045: Flexible deployment trace structure.The optional constructor and fee transfer details allow partial traces without bloating responses. No concerns here.
1053-1054: L1 handler trace now optionally includes state diff.This preserves consistency with other transaction traces and avoids empty structures. Implementation looks correct.
tests/integration/test_minting.rs (1)
78-78: Test updated to reflect new default unit.This test adjustment properly reflects the change in default fee unit from WEI to FRI. The test now correctly expects "FRI" in the response when no unit is specified in the request.
tests/integration/test_subscription_to_tx_status.rs (1)
24-24:Details
❓ Verification inconclusive
Updated expected transaction hash due to fee unit change.
The transaction hash has been updated to reflect the new expected value when using FRI as the default unit. This is a necessary change since the transaction hash depends on the transaction details, which now include FRI instead of WEI.
Run the following script to verify this is the correct transaction hash for the first mint operation:
🏁 Script executed:
#!/bin/bash # Start a fresh devnet instance and check the first mint transaction hash # to verify the expected hash is correct PORT=5050 # Start devnet in background starknet-devnet --port $PORT & DEVNET_PID=$! # Give devnet time to start sleep 2 # Perform the first mint operation MINT_RESULT=$(curl -s -X POST "http://127.0.0.1:$PORT/mint" \ -H "Content-Type: application/json" \ -d '{"address":"0x1","amount":10}') # Extract the transaction hash TX_HASH=$(echo $MINT_RESULT | jq -r '.tx_hash') echo "Actual transaction hash: $TX_HASH" echo "Expected transaction hash: 0xf33a338433016ad79716afb01599f70ce7f03cdf5acda0137095c8407a2c0b" # Clean up kill $DEVNET_PIDLength of output: 716
Updated Transaction Hash Verification: Manual Confirmation Required
The updated expected transaction hash is correctly set to account for the fee unit change from WEI to FRI. However, our verification script failed to produce any output because the
starknet-devnetcommand was not found in the current environment. Please ensure that thestarknet-devnettool is installed and available, then re-run the script or manually verify that the first mint transaction hash indeed matches the expected value:
- Expected hash:
0xf33a338433016ad79716afb01599f70ce7f03cdf5acda0137095c8407a2c0bOnce verified, you can approve the change confidently.
tests/integration/test_subscription_to_events.rs (1)
59-61: Great migration from fee calculation to explicit gas parameters!The code now specifies explicit gas values for different layers (L1, L1 data, L2) instead of calculating them, which aligns with the migration from Wei to Fri (ETH to STRK) mentioned in the PR objectives.
tests/integration/test_estimate_message_fee.rs (2)
33-33: Good simplification of declaration code with new transaction versionThe code now uses a more concise approach for declaring classes with the v3 transaction format, which aligns with the updated dependencies.
66-67: Appropriate update to gas consumption assertionsThe test now correctly checks separate L1 and L2 gas consumption values instead of a single aggregated value, providing more granular verification.
tests/integration/test_abort_blocks.rs (2)
149-149: Successfully migrated fee unit from Wei to FriUpdated balance retrieval to use FeeUnit::Fri instead of FeeUnit::Wei, which aligns with the PR objective of switching from ETH to STRK as the currency.
Also applies to: 156-156, 162-162
249-249: Correctly updated fee unit in pending block testUpdated both pending and latest balance checks to use FeeUnit::Fri, maintaining consistency with the currency migration from Wei to Fri.
Also applies to: 256-256
Cargo.toml (1)
83-87:Details
❓ Verification inconclusive
Successfully upgraded Starknet dependencies to version 0.13.x
Updated all Starknet-related dependencies to their latest versions, which is consistent with the PR title "Starknet-0.13.4-snrs". This upgrade likely provides new features, bug fixes, and improved compatibility with the latest Starknet protocol.
🏁 Script executed:
#!/bin/bash # Check for any compatibility issues between the updated dependencies grep -r "starknet-rs-" --include="*.rs" . | grep -v "use" | grep -v "extern crate" | head -20Length of output: 91
Starknet Dependency Upgrade Verified – Manual Compatibility Check Recommended
The upgrade in the Cargo.toml correctly updates most Starknet dependencies to version 0.13.x in line with the PR title "Starknet-0.13.4-snrs". Note that
starknet-rs-signersremains at version 0.11.0, which could be intentional if a 0.13.x release isn’t available for that package.The automated grep check for compatibility issues produced no matches. This may either indicate that no direct compatibility issues exist or that the search approach doesn’t capture all usage scenarios. It’s advisable to manually verify the integration points where these dependencies are employed.
- Confirm that the version pinning for
starknet-rs-signersis deliberate.- Verify that the usage of each Starknet dependency across the codebase remains compatible with these versions.
Please perform a manual review of the affected code areas to ensure overall compatibility.
tests/integration/test_account_impersonation.rs (3)
200-200: Updated from execute_v1 to execute_v3 for transaction simulationThis is part of the Starknet 0.13.4 migration to use execute_v3, which now uses FRI as the default unit (instead of WEI) with STRK as the currency.
230-230: Updated from declare_v2 to declare_v3 for contract declarationThe declaration process has been migrated to use the v3 API. The change is consistent with the removal of max_fee parameter that was previously required in v2 declarations, now that the gas currency has changed to STRK (FRI units).
253-253: Updated from execute_v1 to execute_v3 for transaction invocationThe execution method has been upgraded to v3, aligning with the Starknet 0.13.4 changes where FRI is now the default unit and STRK is the currency.
tests/integration/test_get_class.rs (3)
60-61: Updated from declare_v2 to declare_v3 for contract declarationThe declaration method has been upgraded to use v3, removing the need for max_fee parameter that was previously required in v2. This change aligns with the Starknet 0.13.4 migration to use FRI as the default unit.
111-112: Updated from declare_v2 to declare_v3 in blocks-on-demand testSimilar to the previous change, the declaration API has been updated to v3, removing the max_fee parameter. This is consistent with the migration to FRI units across all transaction-related methods.
181-182: Updated from declare_v2 to declare_v3 in block abortion testThe contract declaration method has been updated to v3, consistent with the other changes in this file and across the codebase. The upgrade to v3 methods supports the new fee structure using FRI units for STRK currency.
tests/integration/test_get_events.rs (5)
19-19: Changed predeployed_account to be mutableThe variable is now declared as mutable to support setting the block ID conditionally based on the block_on_demand parameter.
27-29: Added conditional block ID setting for block-on-demand modeAdded support for block-on-demand mode by setting the block ID to Pending when required. This ensures transactions can be queued properly in this mode.
This change was previously commented on in a review. The reviewer suggested minimizing conditional logic in tests and recommended specifying gas_bounds in declarations instead. Has this approach been discussed and agreed upon by the team?
35-37: Updated from declare_v2 to declare_v3 for contract declarationThe declaration API has been updated to v3, removing the max_fee parameter. This change is consistent with the Starknet 0.13.4 migration to use FRI as the default unit.
50-50: Updated from deploy_v1 to deploy_v3 for contract deploymentThe deployment method has been upgraded to v3, aligning with other transaction-related method updates. The new API uses FRI units and no longer requires explicit max_fee specification.
75-76: Updated from execute_v1 to execute_v3 for transaction executionThe execution method has been upgraded to v3, consistent with other changes across the codebase. This supports the new fee structure using FRI units for STRK currency.
crates/starknet-devnet-server/src/api/json_rpc/endpoints.rs (4)
1-1: Added ContractExecutionError to importsAdded ContractExecutionError to the imports to support the refactored error handling throughout the file.
339-343: Streamlined error handling for transaction execution errors in simulationThe error handling has been simplified to directly pass the execution_error to the ApiError, removing the need for error stacks and improving the clarity of error responses.
358-360: Enhanced error handling for message fee estimationUpdated the error handling to directly use ContractExecutionError, aligning with the refactored error handling approach throughout the file.
469-473: Improved error handling for transaction simulationThe error handling for simulation has been updated to directly use ContractExecutionError, consistent with other error handling changes in the file. This provides a more structured approach to error reporting.
crates/starknet-devnet-core/src/starknet/estimations.rs (3)
16-16: Import update for the new error handling approach.The import now explicitly brings in
ContractExecutionErrorfrom the error module, reflecting the transition fromErrorStackto a more structured error representation.
82-91: Error handling improved with stronger typing.The error handling has been refactored to use the more structured
ContractExecutionErrortype instead of relying on generic error stacks. This enhances type safety and improves error clarity for API consumers.
134-152: Consider removing the TODO comment as suggested in previous feedback.The implementation now uses a structured match pattern for handling different types of revert errors, which is more maintainable than the previous approach. However, there's a TODO comment about users preferring structured errors that could be removed since you're now providing structured errors with
ContractExecutionError.Also, as pointed out in a previous review, the
revert_error_stringparameter could potentially be omitted as it could be handled within theFromconverter forContractExecutionError.- // TODO Users would probably prefer a structured error, but according to the RPC spec, a - // string is allowed. We should improve this for non Execution error - let revert_error_string = revert_error.to_string(); match revert_error { blockifier::transaction::objects::RevertError::Execution(error_stack) => { - return Err(Error::ContractExecutionError(ContractExecutionError::from(( - error_stack, - revert_error_string, - )))); + return Err(Error::ContractExecutionError(ContractExecutionError::from(error_stack))); } blockifier::transaction::objects::RevertError::PostExecution(fee_check_error) => { return Err(fee_check_error.into()); } };crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (2)
62-63: Added constant import for error handling enhancement.The new constant import will be used to verify error messages in test cases, which improves test coverage and error handling validation.
136-158: Improved error validation in test cases with structured errors.The error handling has been refactored to use the more structured
ContractExecutionError::Nestedtype instead of accessing error frames directly. This change improves error handling by:
- Using strongly typed error structures
- Validating specific fields of the error (selector, contract_address)
- Adding a check for the proper error encoded string
This approach makes the tests more robust and better aligned with the new error handling model.
tests/integration/common/constants.rs (1)
85-89:Details
❓ Verification inconclusive
Updated RPC endpoints to v0_8.
The integration test endpoints have been updated from v0_7 to v0_8, which likely aligns with the API changes in the Starknet protocol. Ensure that the functionality is compatible with these newer endpoints.
🏁 Script executed:
#!/bin/bash # Verify test endpoints are accessible echo "Checking if the updated endpoints are accessible..." curl -s --head "${INTEGRATION_SEPOLIA_HTTP_URL}" | head -n 1 curl -s --head "${MAINNET_URL}" | head -n 1 curl -s --head "${MAINNET_HTTPS_URL}" | head -n 1 echo "Looking for any other references to v0_7 that might need to be updated..." rg -F 'v0_7' --type rustLength of output: 390
Verify that the updated RPC endpoints are indeed reachable.
The constants intests/integration/common/constants.rsnow correctly reference v0_8 endpoints, and a preliminary check for lingeringv0_7references returned no results. However, the automated shell script did not display endpoint accessibility results—likely because the constant values weren’t picked up by the shell environment. Please manually verify that the following endpoints are reachable and return the expected responses:
INTEGRATION_SEPOLIA_HTTP_URLMAINNET_URLMAINNET_HTTPS_URLOnce manual checks confirm that these endpoints are operational, we can fully approve this change.
crates/starknet-devnet-server/src/api/json_rpc/error.rs (6)
1-2: Updated imports for enhanced JSON serialization.The imports have been updated to use
serde_json::jsonmacro directly and to importContractExecutionErrorfrom starknet_core, aligning with the new error handling approach throughout the codebase.
31-33: Simplified error model with structured error types.The error variants now use
ContractExecutionErrordirectly instead of the legacyErrorStack, which provides more structured and typesafe error handling. This change aligns with the broader error handling improvements in the codebase.
106-112: Enhanced error response structure for contract errors.The error response format has been improved to directly include the
contract_execution_errorin the JSON payload, making it easier for API consumers to process and understand the errors.
113-120: Consistent error handling for transaction execution errors.Similar to the contract error changes, the transaction execution error response now includes the structured
execution_errordirectly in the JSON data.
357-368: Updated test cases to use the new error structure.The test cases have been properly updated to use the new
ContractExecutionError::Messagetype and to verify the corresponding JSON structure in the error response.
373-389: Refactored transaction execution error tests.The transaction execution error test cases have been updated to use the new error structure, ensuring that the serialization of errors works as expected.
tests/integration/test_blocks_generation.rs (7)
286-292: Initialize account with caution.
Creating a mutableSingleOwnerAccountwith the newExecutionEncoding::Newmode can be appropriate if you consistently use the new transaction format across your codebase.
293-293: Ensure correct block context.
predeployed_account.set_block_id(BlockId::Tag(BlockTag::Pending))will route subsequent operations to the pending block. Verify this is intentional if you rely on pending-state updates.
304-304: Migrate to the new declaration version.
Using.declare_v3aligns with newer protocol requirements. Ensure other references to older declaration methods are updated for consistency.
370-377: New account initialization with pending block context.
Creating a mutable account and setting the block ID to pending is consistent with your on-demand block generation approach. Confirm that this interacts well with any subsequent block creation calls.
383-383: Updated declare_v3 usage.
Looks good for version 3 declarations. Check that configuration for theArcreference is properly tested if concurrency is relevant.
397-397: Deploy with the new method.
deploy_v3is the recommended approach in newer APIs. Ensure the constructor arguments and fee structure remain valid underdeploy_v3.
422-422: Switch to execute_v3.
Upgrading toexecute_v3closes the gap with the new fee model. If you have downstream code parsing older transaction formats, verify it is fully updated.tests/integration/test_transaction_handling.rs (3)
38-44: Refine customized gas limits.
Using.l1_gas(0), .l1_data_gas(1000), .l2_gas(5e7 as u64)offers more granular control. Be sure these bounds match your testing scenarios and won’t trigger unintended insufficient resource errors.
72-75: Validate CASM hash correctness.
Declaring with a dummy CASM hash is expected to fail if mismatched. This test correctly covers that scenario.
105-112: Granular gas parameters in execute_v3.
Specifying separate parameters for L1 gas, L1 data gas, and L2 gas is recommended for modern transaction flows. Confirm that the specified amounts align with your devnet configuration.tests/integration/test_gas_modification.rs (16)
73-79: Adopt version 3 declare with zero resource bounds.
Declaring the contract with.declare_v3(...).l1_gas(0).l1_data_gas_price(0)...is valid for testing minimal gas scenarios. Just ensure it doesn’t conflict with any actual cost modeling.
85-85: Establish zero resource bounds JSON.
Definingzero_boundswithmax_amountandmax_price_per_unitset to 0 is consistent with a baseline scenario.
96-101: Upgrade simulation to version "0x3".
The addition of"resource_bounds"clarifies max L1/L2 resource usage, important for detailed fee calculations.
105-109: Add optional fields for tipping and paymaster data.
Including"tip": "0x0","paymaster_data": [], "account_deployment_data": [], and data availability modes ensures the transaction object remains spec-compliant.
159-162: Check fee variation with SKIP_VALIDATE.
Ensuring different flags yield different overall fees is important. The numeric values look correct, but watch out for future protocol changes that might alter these values.
170-172: Introduce new Fri prices.
Defining distinct FRI prices for L1 gas, data gas, and L2 gas is consistent with the devnet’s advanced fee model.
174-179: Set updated gas prices.
Storing newgas_price_wei,gas_price_fri, etc. in JSON is a direct approach for test coverage.
193-199: Validate fee estimation with revised FRI gas prices.
Asserting the new gas-related fields in the response ensures that updated FRI prices are recognized.
205-211: Fee estimates after skipping validation.
Correctly identifies the difference in overall_fee for skipped vs. unskipped validation. The numeric changes appear correct.
217-217: Check skip fee invocation toggle.
should_skip_fee_invocationremains a faithful check for fee invocation differences.
248-255: Initialize default data and L2 gas prices.
Mapping them to the same initial values as Wei is appropriate if you want the initial Fri settings to match the default.
261-263: Validate default resource prices in genesis block.
Confirminglatest_block.l1_gas_priceremains the default indicates no user override occurred.
380-383: Check pending block L1 gas price.
Ensures that updated or default resource pricing is applied to the pending block.
385-390: Check pending block L1 data gas price.
Similar verification for data gas; ensures consistency in resource pricing logic.
392-396: Check pending block L2 gas price.
Validates L2 gas usage aligns with your new or default FRI configuration.
400-403: Retry after adjusting L2 gas price.
Raisingl2_gasto avoidInsufficientAccountBalanceerrors is valid. This final declare with.declare_v3confirms the new gas pricing is effective.tests/integration/test_account_selection.rs (5)
15-15: Network URL constant updated to SepoliaThe constant for network URL has been changed from
MAINNET_URLtoINTEGRATION_SEPOLIA_HTTP_URL, aligning with the migration to using Sepolia testnet instead of Mainnet for integration testing.
127-127: Network URL constant updated in fork configurationThe fork network URL was updated to use Sepolia testnet, which is consistent with the import change on line 15.
179-179: Updated to deploy_v3 methodThe deployment method has been updated from
deploy_v1todeploy_v3as part of the migration to newer API versions.
197-197: Updated to execute_v3 methodThe execution method has been updated from
execute_v1toexecute_v3as part of the migration to newer API versions.
167-173:Details
✅ Verification successful
Upgraded to declare_v3 with gas estimation parameters
The code has been migrated from
declare_v2todeclare_v3with additional gas estimation multiplier parameters. The multiplier values are set to 1.0 (no effect), which appears to be added for API compatibility.
🏁 Script executed:
#!/bin/bash # Check if there are other examples of these multipliers in the codebase rg -A 1 "gas_estimate_multiplier\(1\.0\)" --type rustLength of output: 778
Action: Verified usage of gas estimation multipliers across integration tests
The migration to
declare_v3with additional gas estimation multiplier parameters has been confirmed. Thegas_estimate_multiplier(1.0)andgas_price_estimate_multiplier(1.0)are consistently applied in other integration tests (e.g.,tests/integration/test_estimate_fee.rsandtests/integration/get_transaction_by_hash.rs), indicating that these parameters are intentionally set to 1.0 for API compatibility without impacting gas calculations.tests/integration/get_transaction_receipt_by_hash.rs (9)
7-9: Updated imports to support new transaction typesAdded new import types related to transaction finality status and execution results to support the enhanced transaction receipt validation.
36-37: Upgraded to declare_v3 methodUpdated from
declare_v2todeclare_v3as part of the migration to the newer API version.
61-62: Updated to deploy_v3 with gas estimation multiplierThe deployment method has been updated to use
deploy_v3with a gas estimation multiplier of 1.0. The multiplier doesn't affect calculations but maintains consistency with the API.
63-64: Improved fee estimation approachThe fee estimation has been updated to directly call
estimate_fee()on the deployment object, which is a cleaner approach than the previous implementation.
87-95: Upgraded to execute_v3 methodExecution method has been updated from
execute_v1toexecute_v3as part of the migration to the newer API version.
106-107: Added finality status assertionNew assertion checks that the transaction finality status is
AcceptedOnL2, enhancing the validation of transaction receipts.
141-148: Added explicit gas parameter configurationAdded specific gas parameters (l1_gas, l1_data_gas, l2_gas) for deployment, providing finer control over gas usage for the transaction.
167-170: Enhanced execution resource validationAdded assertions to verify that consumed gas does not exceed specified limits for l1_gas, l1_data_gas, and l2_gas, improving test robustness.
202-208: Improved transaction fee handlingUpdated from using a single max fee to specific gas parameters for different gas types (l1, l2, data), providing more granular control over transaction costs.
tests/integration/test_v3_transactions.rs (14)
10-10: Removed NonZeroFelt from importsThe
NonZeroFelttype has been removed from imports, likely because it's no longer needed with the new gas handling approach.
22-23: Added LocalFee to importsAdded
LocalFeeto the imports, which is used for more structured handling of gas parameters in the updated code.
100-100: Updated to execute_v3 methodExecution method has been updated to use
execute_v3as part of the migration to the newer API version.
235-235: Improved fee handling with LocalFee structUpdated fee estimation to use the structured
LocalFeetype, providing better organization of gas parameters.
239-245: Enhanced declaration with specific gas parametersUpdated the declaration to use specific gas parameters for different gas types instead of a single max fee, allowing for more precise control.
328-330: Structured gas parameter handling with LocalFeeReplaced the previous fee calculation with the
LocalFeestruct, which provides a more organized approach to handling different gas parameters.
332-337: Updated gas testing scenariosImproved test cases for gas units and prices, including edge cases like zero values and combinations of insufficient gas units and prices.
341-349: Enhanced declaration configuration with granular gas parametersUpdated declaration configuration to use specific gas parameters for different gas types, allowing for more precise control in testing.
350-352: Updated error handling for insufficient resourcesError handling has been updated to check for
InsufficientResourcesForValidateinstead ofInsufficientMaxFee, reflecting changes in how transaction validation works in the newer API.
357-364: Enhanced account deployment with granular gas parametersUpdated account deployment to use specific gas parameters for different gas types, providing more precise control over gas usage.
365-369: Updated error handling for insufficient resources in account deploymentError handling has been updated to check for
InsufficientResourcesForValidateinstead of a previous error type, aligning with the new validation approach.
374-381: Enhanced execution configuration with granular gas parametersUpdated execution configuration to use specific gas parameters for different gas types, allowing for more precise control in testing.
394-394: Updated error message assertionError message assertion has been updated to check for "Insufficient max L2Gas" instead of a previous message, reflecting changes in error handling.
400-403: Updated error handling for execution with insufficient resourcesError handling has been updated to check for
InsufficientResourcesForValidateinstead of a previous error type, maintaining consistency with other error handling changes.tests/integration/get_transaction_by_hash.rs (8)
11-13: Updated constants importChanged the imported constant from
CAIRO_0_ACCOUNT_CONTRACT_HASHtoCAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH, indicating a migration to newer contract versions.
20-20: Updated test function name for v3 APIFunction name updated from
get_declare_v2_transaction_by_hash_happy_pathtoget_declare_v3_transaction_by_hash_happy_pathto reflect the API version change.
36-37: Upgraded to declare_v3 methodUpdated from
declare_v2todeclare_v3as part of the migration to the newer API version.
52-53: Updated contract hash to newer versionChanged the contract hash from
CAIRO_0_ACCOUNT_CONTRACT_HASHtoCAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH, indicating a migration to newer contract versions.
61-61: Updated to deploy_v3 with gas estimation multiplierThe deployment method has been updated to use
deploy_v3with a gas estimation multiplier of 1.0, which maintains API compatibility.Was this multiplier added on purpose? Since it's set to 1.0 (no multiplication effect), it appears to be for API compatibility, but if it's intended to affect gas calculations, a different value might be needed.
63-63: Simplified fee estimation approachUpdated fee estimation to directly call the method on the deployment object, providing a cleaner approach.
74-74: Updated test function name for v3 APIFunction name updated from
get_invoke_v1_transaction_by_hash_happy_pathtoget_invoke_v3_transaction_by_hash_happy_pathto reflect the API version change.
87-95: Upgraded to execute_v3 methodExecution method has been updated from
execute_v1toexecute_v3as part of the migration to the newer API version.tests/integration/common/background_devnet.rs (3)
29-29: New constant reference for STRK.
Good replacement of the old ETH constant withSTRK_ERC20_CONTRACT_ADDRESS. This aligns with the PR objective of switching from ETH to STRK.
256-256: Updated contract address to STRK.
Changingcontract_addresstoSTRK_ERC20_CONTRACT_ADDRESSis consistent with the switch to STRK. Ensure that any leftover references to the old address have also been updated.
223-226: 💡 Verification agent🧩 Analysis chain
Confirm consistent usage of
FRIwhen minting.
The newly introduced doc comment and theFeeUnit::Fricall correctly indicate that minting uses FRI units. Verify that no other minting calls are still using Wei to avoid confusion.
🏁 Script executed:
#!/bin/bash # Checking for any references to `mint(` calls using Wei or another unit rg -A 2 "mint\(" | rg "FeeUnit::Wei"Length of output: 36
I'll run an additional search to double-check for any references to
FeeUnit::Weiacross the repository.If the output of this command returns nothing, it confirms that there are no remaining minting calls using Wei; minting now consistently uses FRI (via
FeeUnit::Fri). Please verify the command output to ensure that no results are returned.FRI Minting Usage Confirmed
• Verified that mint calls only useFeeUnit::Fri, ensuring consistency in using FRI.
• No other minting calls using Wei were detected.
🏁 Script executed:
#!/bin/bash # Perform a repository-wide search to look for any usage of FeeUnit::Wei rg "FeeUnit::Wei"Length of output: 1363
Consistent FeeUnit Usage Required in Minting Tests
The mint function intests/integration/common/background_devnet.rsnow correctly usesFeeUnit::Fri; however, a repository-wide search revealed that at least one mint call in tests (e.g., intests/integration/test_account_selection.rs) still usesFeeUnit::Wei. Please review these test cases and update them to use FRI—or if the difference is intentional, clearly document why minting in tests differs from production usage.
- Confirm that all minting operations (especially in test files) use
FeeUnit::Frito maintain consistency.- For cases where
FeeUnit::Weiis still used (e.g., mint calls intest_account_selection.rs), either update to FRI or add clarifying documentation.tests/integration/test_restart.rs (4)
13-13: Switching import to STRK.
ReplacingETH_ERC20_CONTRACT_ADDRESSwithSTRK_ERC20_CONTRACT_ADDRESSlooks correct.
61-61: Using STRK in storage retrieval.
Retrieving storage fromSTRK_ERC20_CONTRACT_ADDRESSnow matches the new token. This aligns well with the rest of the changes.
91-93: Increased mint amount and new account deployment method.
Switching to.deploy_v3(...)with explicit gas parameters and using1e21as the mint amount is consistent with the new testing logic. Verify that tests still pass under high minted values.
118-169: Expanded gas price checks for multiple gas types.
Your changes now test distinct L1, L2, and data gas prices and confirm they persist through restarts. This is a comprehensive approach enabling targeted verification of each type of gas price. Good job ensuring they're distinct and verifying them before and after the restart.crates/starknet-devnet-core/src/error.rs (8)
1-1: Imported stack-trace helper methods.
The addition ofgen_tx_execution_error_traceandErrorStackSegmentimport sets up for rich error handling.
21-26: IntroducingContractExecutionErrorfields inErrorenum.
The new enum variants provide clear separation between normal contract errors (ContractExecutionError) and simulation-specific errors (ContractExecutionErrorInSimulation). This refactor should improve maintainability.
134-134: Delegating unhandled execution errors toContractExecutionError.
ForwardingTransactionExecutionErrortoContractExecutionErrorensures consistent error representation across the codebase.
205-212: Top-levelContractExecutionErrorenum.
Having a central enum with a nested variant + message variant allows a robust recursive structure of contract call failures.
214-218: From conversion.
This pattern is helpful for quickly wrapping simple error strings. Good job keeping it minimal.
220-230: From transformation.
Usinggen_tx_execution_error_traceto build a stack trace before conversion is an excellent way to keep error details consistent without duplicating logic.
328-374: Collecting failed calls inimpl From<&CallInfo> for ContractExecutionError.
Iterating over recursively nestedCallInfostructures to identify failures is well-structured. Nicely done ensuring that each error is reflected in the final recursive error.
377-663: New test module for error handling.
The thorough set of test code here effectively validates the conversion logic from stack traces and call infos into structured error objects. Ensuring that each error frame is reflected in the output will greatly reduce debugging overhead in the future.tests/integration/test_old_state.rs (12)
3-6: No major concerns about new imports.
The newly imported constants and types are used consistently throughout the file.
10-12: Imported v3 transaction types.
Using version 3 transaction types and related structures is consistent with the broader changes in this PR. No issues found.
98-98: Switched default fee unit toFri.
This aligns with the PR objective of updating the default unit to FRI. Implementation looks correct.
114-116: Doc comment addition.
Adding a doc comment clarifies the purpose of the test regarding revert scenarios.
144-151: Using.declare_v3.
The shift to.declare_v3with.send().await.unwrap()fits the new transaction model. Just ensure that any dependent code calls match this method’s updated signature.
155-169: Building a query call with resource bounds.
EncapsulatingBroadcastedInvokeTransactionV3creation in this closure is neat. No concerns regarding the test setup.
175-179: Zeroed resource bounds for testing.
Providing zero resource bounds effectively verifies error and behavior in edge cases. Looks appropriate for test coverage.
190-204: Utilizing default devnet constants in simulation.
ApplyingDEVNET_DEFAULT_L1_GAS_PRICE,DEVNET_DEFAULT_L1_DATA_GAS_PRICE, andDEVNET_DEFAULT_L2_GAS_PRICEhelps maintain consistent configuration across tests.
209-210: Constructing a dynamic error message.
Usingto_fixed_hex_string()for the class hash is a clear and readable approach.
213-214: Comment block only.
No changes to functionality; skipping additional remarks.
218-240: Nested error verification.
Thoroughly checks multi-level call failures withextract_nested_errorandextract_message_error. Implementation looks solid.
247-249: Revert reason matches expected error.
Ensuring the revert’s reason ends with the expected message completes the test’s objective properly.tests/integration/test_call.rs (9)
1-1: New import forassert_contains.
No issues found; the usage aligns with other test utilities.
3-5: New imports fromstarknet_rs_core.
Bringing inContractErrorDataand related types is consistent with the nested error handling approach.
11-12: Added Cairo 1 contract paths.
Introducing constants for Cairo 1 contracts supports new test scenarios. No concerns.
15-15: Imported utility functions.
declare_v3_deploy_v3,deploy_v3,extract_message_error, andextract_nested_errorusage aligns with the new error extraction flow.
67-72: EntrypointNotFound handling for Cairo 0 contract.
This match statement ensures the appropriate error is raised. Correct approach for verifying non-existent entry points.
77-82: Spawning devnet with Cairo 0 account class.
Specifying--account-classextends coverage for older contract types. Looks fine for integration tests.
100-106: EntrypointNotFound handling for Cairo 1 contract.
Again verifying proper error for a non-existent method. Implementation as expected.
127-127: Deploying a second contract withdeploy_v3.
Straightforward usage. No issues flagged.
145-163: Nested revert error checks.
Demonstrates correct usage ofextract_nested_errorandextract_message_errorfor multi-level panic verification.tests/integration/common/utils.rs (16)
19-22: Added references to new types.
No issues found. These imports are needed for the new resource-bounded transactions.
23-24: ImportingUdcUniqueSettings.
Integrates custom deployment settings fordeploy_v3. Implementation looks consistent.
35-37: IntroducingUDC_CONTRACT_ADDRESS.
Used by the universal deployer contract references. No concerns.
247-249: Newdeploy_v3function.
Provides a clearer, versioned approach to contract deployment. Implementation is concise and appropriate for test usage.
308-310: Specifying only L1 gas (repeat concern).
This mirrors a previous remark from past reviews: consider whether you also need to specify L2 gas or data gas here.
319-321: Only L1 gas usage once more.
Reiterating the possibility that additional gas parameters might be required.
348-350: Again only L1 gas.
Same observation applies, referencing the past question about broader gas parameter coverage.
359-361: Continuing with L1 gas specification only.
Likewise, verify if L2 gas constraints are needed for these tests.
389-390:deploy_v3(salt)usage.
Standard flow, no new concerns.
392-392: Minting withu128::MAX.
Large mint amount appears intentional for stress or overflow testing. No issues.
414-415: Argent accountdeploy_v3(salt).
Effects are analogous to otherdeploy_v3calls. Looks correct.
417-417: Minting maximum tokens again.
Repeats the stress test approach. No concerns.
467-473:extract_message_error.
Clean helper function for extracting the top-level message. Panics on unexpected variants, suitable for test code.
475-481:extract_nested_error.
Complements the message extraction by handling nested errors. Useful for in-depth debugging.
591-619: DefiningLocalFeestruct.
A neat way to store multiple gas parameters and map them toResourceBoundsMapping. No issues found.
620-646: Conversion fromFeeEstimatetoLocalFee.
Unwrapping byte slices may panic on malformed data, but this is likely acceptable for test scenarios. Implementation otherwise correct.tests/integration/test_fork.rs (1)
139-139: Looks consistent with the new FRI usage.
This change aligns with the PR’s objective of using FRI as the default fee unit.tests/integration/test_estimate_fee.rs (47)
4-4: New import for ENTRYPOINT_NOT_FOUND_ERROR_ENCODED.
It’s used later for error validation and looks correct.
11-13: Additional imports for extended transaction types.
References toResourceBoundsMapping,TransactionExecutionErrorData, etc. are properly used below.
18-18: HttpTransport import recognized.
Allows correct instantiation of the JSON RPC client.
29-29: Added imports for local test utilities and LocalFee.
These utility imports appear correct and used for test coverage.Also applies to: 31-31
36-38: Fee summation logic looks correct.
Summingl1_data_gas_consumed,l2_gas_consumed, andl1_gas_consumedmultiplied by their prices is logically consistent.
62-62: Using deploy_v3 with gas multipliers.
Declaringdeploymentand setting multipliers to 1.0 for a straightforward test scenario.Also applies to: 65-67
77-78: LocalFee approach for fee estimation.
Creating a LocalFee from the estimate before testing insufficient resource bounds is well structured.
80-83: Testing insufficient resource bounds on deploy_v3.
Calling.l1_data_gas(...),.l1_gas(...), and.l2_gas(...)efficiently checks error handling.
89-89: Capturing InsufficientResourcesForValidate error.
Appropriate error handling for resource-bound failures.
95-97: Increased gas multipliers to ensure success.
This addresses the insufficient fee scenario in a straightforward manner.
122-122: Deploying v3 account for invalid class hash.
The call structure todeploy_v3(salt)is consistent with the updated approach.
124-133: Validating TransactionExecutionError for undeclared class.
The assertion confirms that the correct error is produced when class hash is missing.
140-140: Introduce estimate_fee_of_declare_v3 test function.
A direct test for the new declare transaction version.
164-167: Setting gas estimation multipliers on declare_v3.
Ensures consistent resource usage across repeated calls.
176-177: Using LocalFee before testing resource bounds.
Makes the subsequent insufficient gas scenario more natural to handle.
179-183: Applying insufficient resource bounds on declare_v3.
Helps confirm correct error handling mechanisms.
188-188: InsufficientResourcesForValidate error check.
Matches the expected Starknet error outcome.
195-199: Ensuring success via resource multiplier.
Increasing.l1_gas,.l1_data_gas, and.l2_gasby 1.1 is a valid approach.
226-227: Declaring V3 contract with zero nonce.
Reflects consistent usage of the updated transaction version.
254-254: Estimating fee for an invoke V3 call.
Demonstrates the new approach of calculating fees in invoke scenarios.
264-264: Comment clarifies insufficient resource bounds test.
Good to maintain clarity on the test purpose.
266-268: Gas multipliers intentionally set below 1.0.
Simulates the underfunded transaction path.
279-279: Asserting “Insufficient max L2Gas” reversion.
Accurately checks the correct error message.
283-292: Sufficient resource bounds for successful invoke.
Ensures the transaction goes through with a higher gas allocation.
319-319: Declaring panicking contract.
No concerns; logic is in line with the newly introduced test scenario.
333-333: Deploying panicking contract with deploy_v3.
Matches the approach used elsewhere in this file.
339-339: Assigning custom panic reason.
Useful for verifying correct retrieval of panic messages.
342-342: Passing the panic reason in calldata.
Ensures the correct fail path test for contract invocation.
345-346: Executing V3 call for the panic scenario.
Correct approach to validate error extraction.
355-355: Indexing transaction at zero.
Consistent with typical test flows for the first transaction in a batch.
361-364: Layered error extraction approach.
Effectively drills down to the final panic message.
410-410: Setting expected version for query.
Properly referencing the offset plus 3.
417-417: Estimation toggles query behavior.
Ensures no side effects but still calculates the fee.
423-423: Function to broadcast invoke V3 for final fee estimation.
Neatly encapsulates the preparation logic into a helper function.
434-435: Execution prepared but fee line commented out.
Likely intentional for demonstration or debugging of the resource bounds.
437-437: Resource consumption and prices set to zero.
This is presumably a test scenario to confirm minimal bounds.Also applies to: 439-439, 441-441, 443-443, 445-445, 447-447
454-462: Chain method calls to set every resource bound to zero.
Demonstrates complete manual control over transaction resources.
467-492: Constructing a BroadcastedInvokeTransactionV3 with zero resource bounds.
Correctly populates all fields, includingpaymaster_dataandnonce_data_availability_mode.
523-528: Passing zero bounds on a declare_v3 transaction.
Maintains consistency with the test logic used for the invoke scenario.
541-562: Combining a Declare V3 with an Invoke broadcast for fee estimation.
Tests multi-transaction fee estimation thoroughly.
606-606: First broadcasted_invoke_v3_for_estimation call.
Ensures partial transaction set is properly tested.
620-620: Second broadcasted_invoke_v3_for_estimation call.
Valid test coverage for subsequent transactions in the batch.
642-642: Confirming transaction_index == 1.
Ensures we identify the second transaction as the failing one.
643-645: Error message matches ENTRYPOINT_NOT_FOUND_ERROR_ENCODED.
Precisely corresponds to the newly imported constant.
675-675: Setting l1_data_gas bound to zero.
Maintains the pattern established in these tests.
700-713: Building BroadcastedDeclareTransactionV3 in a multi-tx scenario.
All fields are correctly set for a query transaction.
714-717: Adding the second broadcasted transaction as an Invoke V3.
Confirms a multi-transaction estimate flow with repeated resource bounds usage.crates/starknet-devnet-core/src/starknet/mod.rs (5)
76-76: Updated error handling imports.The import has been updated to include the
ContractExecutionErrortype from theerrormodule, indicating a restructuring of the error handling system.
145-150: Enhanced gas price management in block initialization.The
next_block_gasstructure has been expanded to include STRK-related gas price fields (gas_price_frianddata_gas_price_fri), completing the gas price tracking capabilities for both WEI and FRI currencies.
327-334: Added L2 gas price configuration to pending block.The L2 gas price values for both WEI and FRI are now explicitly set in the pending block header, ensuring complete gas price information is available for transactions.
739-748: Simplified error handling in contract calls.The error handling logic in the
callmethod has been streamlined. The function now directly wraps execution errors in aContractExecutionError, eliminating the need for intermediate error trace generation throughgen_tx_execution_error_trace.
750-755: Improved specific error handling for contract execution failures.The error handling for failed contract executions has been enhanced to distinguish between
EntrypointNotFounderrors and generalContractExecutionErrorcases, providing more precise error reporting to clients.tests/integration/test_trace.rs (12)
3-5: Updated imports to use STRK ERC20 contract address.The import has been changed to use
STRK_ERC20_CONTRACT_ADDRESSinstead ofETH_ERC20_CONTRACT_ADDRESS, reflecting the transition from WEI to FRI as the default fee token.
14-14: Added utility import for selector name resolution.The
get_selector_from_nameutility has been imported to generate function selectors in a standardized way, improving code readability and reducing potential for errors.
23-24: Updated test constants to use Felt type and increased amount.The
DUMMY_ADDRESSconstant has been changed from a numeric value to aFelttype with a hex value, andDUMMY_AMOUNThas been increased from 1 to 456, providing more realistic test values.
32-51: Enhanced mint invocation assertions to match updated implementation.The test has been updated to verify the exact structure of mint transaction calldata, checking for:
- The STRK ERC20 contract address instead of ETH
- The correct selector for "transfer" function
- The proper structure of calldata arguments including amount representation
This ensures the tests correctly validate the updated implementation.
55-57: Updated fee transfer assertion to use STRK contract.The fee transfer assertion now verifies that transfers use the STRK ERC20 contract address instead of ETH, aligning with the protocol's switch to STRK as the primary fee token.
59-61: Added execution resources validation to trace test.New assertions verify the correct gas usage pattern:
- L1 gas should be zero
- L1 data gas should be positive
- L2 gas should be positive
This ensures the gas computation model is working as expected.
118-122: Migrated to V3 transaction declaration with explicit gas parameters.The test now uses
declare_v3instead of an earlier version, with explicit parameters for:
- L1 gas (set to 0)
- L1 data gas (set to 1000)
- L2 gas (set to 10^8)
This update aligns with the protocol's evolution to more granular gas handling.
149-150: Updated fee transfer check to use STRK contract.The test now verifies that the fee transfer in the declaration trace uses the STRK ERC20 contract address, consistent with the switch from ETH to STRK as the primary fee token.
174-178: Migrated contract declaration to V3 with explicit gas parameters.Similar to other declaration updates, this test now uses
declare_v3with explicit L1 gas, L1 data gas, and L2 gas parameters, ensuring compatibility with the updated transaction structure.
187-191: Updated contract deployment to use V3 with explicit gas parameters.The test now uses
deploy_v3with explicit gas parameters for all three gas types, matching the updated contract deployment interface and gas handling model.
239-246: Updated account deployment to use V3 with explicit parameters.The account deployment test now:
- Uses
deploy_v3with explicit gas parameters- Sets a nonce value
- Mints STRK to the new account before deployment
- Captures the deployment result in a more structured way
These changes reflect the updated account deployment workflow and requirements.
271-272: Updated fee transfer assertion in deployment trace.The test now verifies that the fee transfer in the deployment account trace uses the STRK ERC20 contract address, aligning with the switch to STRK as the primary fee token.
tests/integration/test_simulate_transactions.rs (16)
5-16: Importing STRK constants and Broadcasted structures*
These added imports fromstarknet_core::constantsand theBroadcasted*transaction variants align well with the upgraded API usage (v3 transactions, STRK token, etc.). No issues found.
26-28: Updated references to CAIRO_1 constants
These lines add or rename constants for Cairo 1 contract paths and related variables. Everything appears consistent with the new naming scheme.
33-35: Added references to new utility methods and LocalFee
Introducingget_flattened_sierra_contract_and_casm_hashandLocalFeeis consistent with the v3 fee approach. Implementation details for these utilities aren’t shown here, but usage seems coherent.
39-114: Refactored simulate_declare_v3 function
- Switching to
.declare_v3(...)withLocalFeeusage, resource bounds, and setting gas parameters (lines 57–65) follows the new fee model. This ensures better granularity but verify all call sites are updated for signature consistency.- Adding simulation flags (
SKIP_FEE_CHARGE, etc.) in lines 101–109 is correct for test scenarios.- Resource bounds mapping in lines 89–94 looks fine, but ensure large or edge values are handled gracefully.
Overall, this function is well-structured and properly tests the new v3 transaction flow.
123-146: simulate_deploy_account with v3 deployment support
- Declaring an account factory for Cairo 1 (line 123) is consistent with the new approach; ensure older references to v1/v2 deployments are fully removed or migrated.
- Gathering fee estimates (lines 133–134) and applying
.l1_gas(...),.l2_gas(...), etc. (lines 138–143) aligns with the new LocalFee config.- Checking the updated contract address matches
STRK_ERC20_CONTRACT_ADDRESS(line 194) reaffirms the switch to STRK for fee token usage.Implementation looks sound.
Also applies to: 194-194
238-360: simulate_invoke_v3 improvements
- Using
.execute_v3(...)andLocalFeefor gas configuration (lines 280–283) ensures uniform handling of L1/L2 gas.- Manually setting
nonce(line 280) to handle sequential transactions is okay for test environments. Confirm other test methods remain consistent with the new nonce approach.- Resource bounds in lines 303–315 match the pattern in
simulate_deploy_account.No issues detected.
392-426: Query version logic (simulate with query offsets)
- Checking version behavior with
.execute_v3plus verifying resource bounds usage (lines 395–402) is correct.- The non-trivial offset
QUERY_VERSION_OFFSET + Felt::THREE(line 388) is presumably tested here for boundary conditions.Implementation looks correct for mocking version behaviors.
431-492: simulate_of_panicking_invoke
- This test specifically checks for revert reasons (lines 487–488) when a contract panics. Good coverage for failure scenarios.
- The direct usage of
json_rpc_client.get_block_with_tx_hashes(...)to fetchgas_pricefrom the latest block (lines 455–468) could be combined with standardestimate_feecalls for consistency, but it’s still acceptable for advanced tests.No major concerns.
495-582: simulate_of_multiple_txs with a failing transaction
- Broadcasting multiple v3 transactions (lines 542–568) and verifying that a revert in one transaction doesn’t break the entire simulation is crucial. The logic is valid.
- The partial revert check (lines 576–580) is well-structured.
Looks good.
585-620: test_simulation_of_multiple_txs_should_return_index_of_first_failing_transaction
- The custom
transaction_indexerror field (line 668–672) is a neat way to identify the failing transaction.- Confirm that indexing logic in external code is consistent with this test’s expectations.
Implementation is straightforward; no issues found.
677-718: simulate_with_max_fee_exceeding_account_balance_returns_error
- Lines 694–704 intentionally set extremely high gas amounts to trigger insufficient balance. This thoroughly tests fee-check logic.
- The fallback scenario
.simulate(false, true)skipping fee transfer is verified.Implementation aligns with the new fee-charging model.
721-887: simulate_v3_with_skip_fee_charge_deploy_account_declare_deploy_via_invoke
This end-to-end test covering (1) deploy account, (2) declare, (3) invoke, all with skip-fee logic, is a solid integration scenario. The code is quite extensive but appears logically consistent with the new approach.
890-942: simulate_invoke_v3_with_fee_just_below_estimated
- Good demonstration (lines 927–933) of a carefully chosen
l2_gasjust under the estimate to cause an “Insufficient” revert.- This ensures accurate boundary testing for resource limits.
Code is correct and thorough in testing partial coverage of gas.
945-1071: simulate_invoke_declare_deploy_account_with_zero/bad gas settings
- Zero or partial gas config is tested (lines 992–1071) which is critical for edge cases.
- The uniform error “Insufficient resources” (lines 1062–1067) is appropriate.
No issues found.
1086-1123: simulate_invoke_v3_with_failing_execution
Verifies revert trace capturing (lines 1107–1115). This is consistent with other panic tests.
870-917: withdrawing_should_incur_l1_gas_cost
- The fee estimation check (lines 889–893) ensures L1/L2 resource usage is non-zero.
- The final transaction revert on insufficient L1Gas (lines 910–915) is a valid negative test scenario.
Implementation of gas checks looks correct.
tests/integration/test_messaging.rs (10)
43-46: New constants for dummy addresses and message opcode
Replacing string-based addresses withFeltto unify type usage is a good move for consistency. No direct issues.
48-49: Comment clarifications for reliance on whitelisted L1 address
This clarifies address usage differs from older Cairo 0 contracts. No concerns.
51-66: Refactored withdraw function to return Result
- Lines 58–59 switch the function to return a
Result<InvokeTransactionResult, AccountError<...>>, making error handling more explicit.- Using
.execute_v3(invoke_calls).send()(line 65) is consistent with the new v3 flow.This is a solid improvement for error transparency.
81-89: Updated increase_balance with L1/L2 gas parameters
Explicitly setting.l1_gas(0),.l2_gas(5e7), etc. ensures correct limit testing. This is beneficial for coverage.
183-212: assert_withdrawn helper function
- Verifies the user’s balance is zero (line 190) and checks the dry-run postman output includes the expected message payload (lines 193–203).
- The usage of
MESSAGE_WITHDRAW_OPCODE, user, amountensures no confusion with the older approach.Implementation is well-structured.
215-231: can_send_message_to_l1
- Using the new dummy L1 address and
withdrawcall (line 229) to produce an L2→L1 message is logically correct.- Verifying the final
assert_withdrawn(line 230) ensures thorough coverage.All logic is consistent with the updated approach.
254-275: can_send_message_to_l1_from_library_syscall
- The call to
withdraw_from_lib(...)(line 263) reuses similar v3 patterns, now referencinglib_sierra_class_hash.- The final
assert_withdrawnensures the message is properly recognized.No issues noted.
355-366: can_consume_from_l2
SettingDUMMY_L1_ADDRESS(line 361) and withdrawing with v3 calls (line 364) looks correct. Ensuring zero balances (line 365) is good final verification.
507-507: test_dumping_of_non_rpc_requests (partial changes)
These lines (507,509,511–514) are not directly relevant to messaging logic but clarify the mint call’s new signature (json!({ "address": address, "amount": mint_amount, "unit": unit })). Confirm the updated approach is consistent across all calls.Also applies to: 509-509, 511-514
870-917: withdrawing_should_incur_l1_gas_cost in messaging tests
(Note: This line range also appears in the prior file, but within test_messaging.rs snippet it’s line 869–917? Possibly an artifact. If referencing the final snippet lines 869–917 in test_messaging.rs:)No changed lines are shown here beyond the snippet boundary. If you intended lines 869–917 in this file, no code is visible in the snippet. If an overlap occurred, please verify the changes are properly tested for L1 gas usage in the messaging context.
tests/integration/test_dump_and_load.rs (7)
83-85: Switched to FeeUnit::Fri
Changing balance queries to useFeeUnit::Fri(line 83) presumably reflects the minted STRK usage. Ensure all relevant calls also adoptFriconsistently across tests to avoid mismatched currency units.
373-414: dump_load_endpoints_transaction_and_state_after_load_is_valid
- The code retrieves balance with
get_balance_latest(..., FeeUnit::Fri)(line 404) to ensure loaded state is correct.- Checking transaction validity after load (lines 408–413) is an excellent integration step.
No concerns.
247-265: declare_deploy with v3 transactions
- Lines 247–251 show calls to
.declare_v3(...).l1_data_gas(...)etc. verifying new usage.- The subsequent
.deploy_v3(...)block (lines 261–265) is consistent with the updated deploy approach.Implementation is straightforward.
407-413: Verifying loaded mint transaction
- Checking the minted transaction after load ensures the devnet state matches prior run.
- The
InvokeTransaction::V3pattern is correct.Looks good.
505-517: test_dumping_of_non_rpc_requests
Although primarily a coverage for non-RPC calls, lines 507 and onward demonstrate the updated “mint + create_block + abort_block” flow. The final dump then replays the correct disk state. Good thorough test.
546-548: Loaded balance check
The assertion at line 547 verifies that the minted balance (in Wei or Fri) is persisted properly after a dump/load cycle. No issues.
563-569: Dumping after restart
Ensures that on reload (line 566), no leftover data is incorrectly dumped. The check at line 569 for empty output is correct.
…et-devnet into starknet-0.13.4-snrs
Usage related changes
devnet_mintanddevnet_getAccountBalancechanged to FRI (i.e. currency changed to STRK).Development related changes
Checklist:
./scripts/format.sh./scripts/clippy_check.sh./scripts/check_unused_deps.sh./scripts/check_spelling.sh./website/README.mdSummary by CodeRabbit
Chores
Refactor