Improve predeclaration/predeployment startup log#734
Conversation
WalkthroughThis pull request removes unnecessary whitespace in the constants file and introduces a new field, Changes
Sequence Diagram(s)sequenceDiagram
participant Main
participant Logger
participant MetadataFn
Main->>Logger: Start logging predeployed accounts
Logger->>MetadataFn: Call get_account_metadata(class_hash)
MetadataFn-->>Logger: Return metadata string ("OpenZeppelin 0.5.1"/"OpenZeppelin 0.20.0"/"Custom")
Logger->>Main: Print account details with metadata
Suggested reviewers
Poem
✨ Finishing Touches
🪧 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 (
|
|
@CodeRabbit how do I make you stop writing poems? Haven't I configured the .github/coderabbit.yaml file with |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 2493 @FabijanC You're right - I can see that you've correctly configured
@FabijanC I can see that you've correctly configured This discrepancy could be due to a few reasons:
Here are some suggestions to resolve this:
Would you like me to help you make any changes to the configuration file? |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (1)
212-216: Updated Account::new parameters to use new KeyPair structure.The code now correctly uses the
dummy_key_pair()function instead of separatedummy_felt()calls, aligning with the new Account initialization pattern. The additional "Custom" parameter appears to be for specifying the account class type or origin.Consider adding a brief comment explaining what the "Custom" string parameter represents, as its purpose isn't immediately clear from the context.
crates/starknet-devnet-core/src/state/state_diff.rs (1)
284-292: Updated Account::new parameters to use new KeyPair structure.The code now correctly uses the
dummy_key_pair()function instead of separatedummy_felt()calls, which provides better encapsulation and makes the code more readable.Consider adding a brief comment explaining what the "Custom" string parameter represents, as its purpose isn't immediately clear from the context.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
crates/starknet-devnet-core/src/account.rs(6 hunks)crates/starknet-devnet-core/src/contract_class_choice.rs(3 hunks)crates/starknet-devnet-core/src/predeployed_accounts.rs(2 hunks)crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs(2 hunks)crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs(2 hunks)crates/starknet-devnet-core/src/starknet/mod.rs(2 hunks)crates/starknet-devnet-core/src/state/state_diff.rs(2 hunks)crates/starknet-devnet-core/src/utils.rs(2 hunks)crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs(1 hunks)crates/starknet-devnet/src/main.rs(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- crates/starknet-devnet/src/main.rs
- crates/starknet-devnet-core/src/contract_class_choice.rs
🧰 Additional context used
🧬 Code Definitions (4)
crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (1)
crates/starknet-devnet-core/src/utils.rs (2)
cairo_0_account_without_validations(185-190)dummy_key_pair(222-224)
crates/starknet-devnet-core/src/state/state_diff.rs (1)
crates/starknet-devnet-core/src/utils.rs (2)
dummy_felt(100-102)dummy_key_pair(222-224)
crates/starknet-devnet-core/src/starknet/mod.rs (1)
crates/starknet-devnet-core/src/utils.rs (2)
dummy_felt(100-102)dummy_key_pair(222-224)
crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs (1)
crates/starknet-devnet-core/src/utils.rs (4)
cairo_0_account_without_validations(185-190)dummy_contract_address(117-119)dummy_felt(100-102)dummy_key_pair(222-224)
🔇 Additional comments (17)
crates/starknet-devnet-core/src/utils.rs (1)
222-224: Well-designed utility function for test key pairs.The new
dummy_key_pair()function provides a clean abstraction for creating test key pairs, which helps maintain consistency across tests. The implementation reuses the existingdummy_felt()function to generate both public and private keys.crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs (1)
54-55: Correctly updated account key access pattern.The code has been properly updated to reflect the new encapsulation of keys in a
KeyPairstruct, maintaining the correct behavior while improving the code organization.crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs (1)
69-69: Appropriately updated import for new key pair utility.Updated import to use the new
dummy_key_pairfunction instead of directly usingdummy_felt.crates/starknet-devnet-core/src/state/state_diff.rs (1)
206-207: Updated import list to include dummy_key_pair.The imports now correctly include the new
dummy_key_pairutility function.crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs (2)
102-102: Code import updated to support KeyPair refactoring.The import has been updated to include the
dummy_key_pairutility function, which supports the encapsulation of public and private keys in the newKeyPairstruct.
496-498: Account creation updated to use KeyPair and include class metadata.The
Account::newcall has been updated to use the newdummy_key_pair()function instead of individualdummy_felt()calls, and now includes the "Custom" string as class metadata, which supports the improved logging objectives.crates/starknet-devnet-core/src/starknet/mod.rs (2)
1546-1546: Import updated to support KeyPair refactoring.The import has been updated to include the
dummy_key_pairutility function, which aligns with the overall encapsulation of public and private keys in theKeyPairstruct.
1570-1573: Account initialization updated to use KeyPair and include class metadata.The
Account::newmethod call has been updated to use thedummy_key_pair()function and include the "Custom" string parameter for class metadata, consistent with the updated constructor signature and the PR objective of improving startup logging.crates/starknet-devnet-core/src/account.rs (7)
36-39: Better encapsulation through the new KeyPair struct.The introduction of the
KeyPairstruct improves code organization by encapsulating related fields (public and private keys) into a single structure, which is a good design practice.
42-51: Account struct updated to use KeyPair and include class metadata.The
Accountstruct has been modified to use the newKeyPairtype for keys and now includes aclass_metadatafield of type&'static str. This enhances the structure and supports the PR objective of improving logging for contract metadata.
58-78: new_chargeable method updated to use KeyPair struct.The method now initializes the
keysfield with aKeyPairinstance containing the public and private keys, and sets theclass_metadatafield from theAccountClassWrapper. This is consistent with the structural changes and supports improved logging.
81-101: new method signature updated to accept KeyPair and class_metadata.The
Account::newmethod has been updated to accept aKeyPairparameter and aclass_metadataparameter, which is consistent with the changes to theAccountstruct and supports the PR's objective of improving logging.
136-136: Updated field access to use KeyPair structure.The code now accesses the public key through
self.keys.public_key, consistent with the newKeyPairencapsulation.
231-231: Updated test imports to include KeyPair.The test imports have been updated to include the
KeyPairstruct, which is necessary for the test code to work with the updatedAccountimplementation.
327-330: Test setup updated to use KeyPair and include class metadata.The test setup now creates a
KeyPairwith public and private keys and includes the "Dummy account" string as class metadata, maintaining consistency with the updatedAccountconstructor.crates/starknet-devnet-core/src/predeployed_accounts.rs (2)
7-7: Updated import to include KeyPair.The import has been updated to include the
KeyPairstruct from theaccountmodule, necessary for the changes in account generation.
67-69: Account generation updated to use KeyPair and include class metadata.The
Account::newcall now creates aKeyPairwith the generated public key and private key, and includes the "Custom" string as class metadata. This is consistent with the PR's objective of improving predeclaration/predeployment startup logs.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/starknet-devnet-core/src/account.rs (1)
47-47: Consider future flexibility for metadataThe
class_metadatafield uses a&'static strwhich restricts it to compile-time string literals. This works well for the current usage but might limit flexibility if dynamic metadata is needed in the future.Consider whether a owned
Stringtype might provide more flexibility for future requirements, though this would introduce a slight performance overhead.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
crates/starknet-devnet-core/src/account.rs(6 hunks)crates/starknet-devnet-core/src/predeployed_accounts.rs(2 hunks)crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs(2 hunks)crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs(2 hunks)crates/starknet-devnet-core/src/starknet/mod.rs(2 hunks)crates/starknet-devnet-core/src/state/state_diff.rs(2 hunks)crates/starknet-devnet-core/src/utils.rs(2 hunks)crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs(1 hunks)crates/starknet-devnet/src/main.rs(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/starknet-devnet-core/src/state/state_diff.rs
- crates/starknet-devnet-core/src/starknet/mod.rs
- crates/starknet-devnet-core/src/starknet/add_l1_handler_transaction.rs
- crates/starknet-devnet-server/src/api/http/endpoints/accounts.rs
- crates/starknet-devnet/src/main.rs
- crates/starknet-devnet-core/src/utils.rs
- crates/starknet-devnet-core/src/starknet/add_invoke_transaction.rs
- crates/starknet-devnet-core/src/predeployed_accounts.rs
🧰 Additional context used
🧬 Code Definitions (1)
crates/starknet-devnet-core/src/account.rs (5)
crates/starknet-devnet-core/src/state/state_diff.rs (1)
from(126-176)crates/starknet-devnet-core/src/starknet/mod.rs (1)
new(160-294)crates/starknet-devnet-core/src/predeployed_accounts.rs (1)
new(22-35)crates/starknet-devnet-core/src/state/state_readers.rs (1)
new(26-28)crates/starknet-devnet-core/src/utils.rs (1)
dummy_felt(100-102)
🔇 Additional comments (6)
crates/starknet-devnet-core/src/account.rs (6)
35-39: Good addition of KeyPair struct to encapsulate related fieldsThis is a positive refactoring that groups related fields (public and private keys) into a cohesive structure, improving code organization and readability.
41-51: Clean encapsulation of keys and addition of metadataThe Account struct has been improved by:
- Replacing individual key fields with the KeyPair structure
- Adding class_metadata to track producer/version information
These changes align well with the PR objectives to enhance logging for contract metadata.
58-59: Good extraction and handling of class_metadata in new_chargeableThe implementation properly extracts the class_metadata from the AccountClassWrapper and initializes the KeyPair structure. This maintains existing functionality while adding the new metadata field.
Also applies to: 64-75
81-101: Well-structured parameter updates in the new methodThe Account::new method has been properly updated to:
- Accept a KeyPair instead of separate key fields
- Include the new class_metadata parameter
- Use keys.public_key for address computation
The changes maintain backward compatibility while adding new functionality.
119-140: Correctly updated usage of public_key via KeyPairThe simulate_constructor method now correctly accesses the public key through the KeyPair struct.
231-231: Tests properly updated to use KeyPairThe test code has been updated to use the new KeyPair struct, maintaining test coverage and ensuring the refactoring doesn't break existing functionality.
Also applies to: 327-327
* Abstract public+private key as KeyPair: reduce number of fn args
* [skip ci] * feat: add private key parameter in loading l1 contract * replace dummy private key * update docs for postman load contract * add incorrect private key tests * formatting changes * Improve predeclaration/predeployment startup log (#734) * Abstract public+private key as KeyPair: reduce number of fn args * fix tests revert anvil changes * update incorrect test assert code --------- Co-authored-by: FabijanC <fc@spaceshard.io>
* [skip ci] * feat: add private key parameter in loading l1 contract * replace dummy private key * update docs for postman load contract * add incorrect private key tests * formatting changes * Improve predeclaration/predeployment startup log (#734) * Abstract public+private key as KeyPair: reduce number of fn args * fix tests revert anvil changes * update incorrect test assert code --------- Co-authored-by: FabijanC <fc@spaceshard.io>
Usage related changes
Development related changes
KeyPairstruct to reduce number of args in some functionsChecklist:
./scripts/format.sh./scripts/clippy_check.sh./scripts/check_unused_deps.sh./scripts/check_spelling.sh./website/README.mdSummary by CodeRabbit
Summary by CodeRabbit
New Features
Tests
Chores