Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

katana: update default predeployed accounts #2524

Merged
merged 18 commits into from
Oct 14, 2024
Merged

Conversation

kariy
Copy link
Member

@kariy kariy commented Oct 12, 2024

ref #2498 #2405

  • update the default predeployed account class implementation to OZ 0.17.0 account preset
  • rename class constants

is it required to change the account implementation because the version we're using doesn't support transaction version > 1 as seen below:

https://github.com/OpenZeppelin/cairo-contracts/blob/6ab91b5cf57d6a7d02f2d5c5abfc7b5712bc8e47/src/account/account.cairo#L75C1-L77C14

technically v3 support is later added in OZ 0.8.1. so going all the way to 0.17.0 may seem exaggerated, but 0.8.1 is ~8 months old now so better to just use the latest compatible version. tbh i dont exactly know how different 0.17.0 is compared to 0.8.1.

Breaking

class hash of the account class has changed due to different impl, meaning the generated account addresses have also changed. need to make sure that places where we hardcode the default account addresses are changed accordingly

Fix

this commit fix the error mentioned by the comment below dojoengine/sequencer@d6951f2

Summary by CodeRabbit

  • New Features

    • Updated account address across multiple configurations for improved accuracy.
  • Bug Fixes

    • Renamed constants related to account and contract classes for clarity and consistency.
    • Modified StarkNet method parameters for enhanced functionality.
    • Adjusted paths for compiled contracts to ensure correct file references.

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

🧹 Outside diff range and nitpick comments (14)
crates/katana/contracts/Makefile (3)

1-8: Ohayo! Variable definitions look good, sensei!

The variable definitions are clear and well-structured. They align nicely with the PR objectives to update the default predeployed account implementation. Great job on using CONTRACT_CLASS_SUFFIX for easy future modifications!

Consider adding a brief comment explaining the purpose of ORIGINAL_CLASS_NAME and CLASS_NAME for improved clarity:

 ORIGINAL_CLASS_NAME := katana_account_Account$(CONTRACT_CLASS_SUFFIX)
+# The desired output filename for the default account contract
 CLASS_NAME := default_account.json

10-12: Ohayo! Build rule looks solid, sensei!

The build rule is well-structured and aligns perfectly with the PR objectives. It correctly uses scarb for building and handles the file renaming as expected.

To make the build process more robust, consider adding a mkdir command to ensure the BUILD_DIR exists:

 $(BUILD_DIR): ./account/src/*
+	mkdir -p $(BUILD_DIR)
 	scarb build -p katana_account
 	mv target/dev/$(ORIGINAL_CLASS_NAME) $(BUILD_DIR)/$(CLASS_NAME)

This change will prevent potential errors if the build directory doesn't exist.


1-14: Ohayo! Overall, excellent work on this Makefile, sensei!

This new Makefile effectively supports the PR objectives by setting up a clear build process for the updated default predeployed account implementation. The variable definitions and build rule are well-structured and should work as intended.

The introduction of this Makefile will streamline the build process for the Katana project, making it easier to manage and update the default account contract. Great job on improving the project's build infrastructure!

As the project grows, consider expanding this Makefile to include additional targets for cleaning build artifacts, running tests, or other common development tasks. This will further enhance the development workflow for the Katana project.

examples/spawn-and-move/README.md (1)

51-54: Ohayo! Great work, sensei!

The contract address has been successfully updated in both the command and the example output. These changes maintain consistency with the new implementation.

To further improve clarity, consider adding a comment explaining that this new address represents the updated default predeployed account. This would help readers understand the significance of the change.

crates/katana/contracts/messaging/cairo/Makefile (1)

Line range hint 1-43: Ohayo, sensei! Overall, the changes look good, but let's consider the broader impact.

The updates to ACCOUNT_L2_ADDR and ACCOUNT_L3_ADDR are consistent with the PR objectives to update the default predeployed account class implementation. However, there are a few points to consider:

  1. These changes will affect both L2 and L3 layers of the messaging system.
  2. As mentioned in the PR objectives, this is a breaking change that will alter the generated account addresses.
  3. The identical addresses for L2 and L3 might need explanation to prevent confusion.

To ensure a smooth transition:

  1. Verify that all hardcoded default account addresses have been updated throughout the codebase.
  2. Consider adding comments explaining the reason for the identical L2 and L3 addresses.
  3. Update any documentation or tests that rely on the old addresses.
  4. Prepare a migration guide for users who might be affected by this breaking change.

Would you like assistance in creating a migration guide or updating related documentation, sensei?

crates/katana/storage/provider/tests/class.rs (1)

66-68: Ohayo! The changes look great, sensei!

The test case has been updated to use the new constant names, which is consistent with the changes in the implementation. This ensures that the tests accurately reflect the new structure.

For improved readability, consider adding a blank line between each test case entry in the vector. This would make it easier to distinguish between different test cases at a glance.

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

114-114: Ohayo again, sensei! LGTM with a small suggestion.

The usage of the renamed constant DEFAULT_LEGACY_ERC20_CASM is correct and aligns with the updated import statement. This change ensures that the test fixtures are using the latest version of the predeployed account class implementation.

For consistency, consider updating the usage of DEFAULT_LEGACY_UDC_CASM in a similar manner elsewhere in the function (not visible in the provided diff).


Ohayo, sensei! I found some issues that need your attention:

  • Old constant names still present: Instances of DEFAULT_LEGACY_ERC20_CONTRACT_CASM and DEFAULT_LEGACY_UDC_CONTRACT_CASM were found in crates/katana/primitives/src/genesis/constant.rs. These need to be updated or removed to maintain consistency.

  • Hardcoded account addresses detected: Numerous hardcoded account addresses across multiple files could lead to potential bugs or inconsistencies. It's recommended to refactor these to use defined constants or configuration settings.

🔗 Analysis chain

Line range hint 1-214: Ohayo, sensei! Overall assessment: Changes look good!

The updates in this file are minimal and focused on renaming constants related to the legacy ERC20 and UDC contracts. These changes align well with the PR objectives of updating the default predeployed account class implementation. The modifications contribute to maintaining consistency across the codebase and reflect the use of the latest OpenZeppelin account preset.

However, it's important to note that these changes might have broader implications:

  1. As mentioned in the PR objectives, this update introduces a breaking change due to the alteration of the account class hash.
  2. The generated account addresses will change as a result of this update.

To ensure all necessary updates have been made, please run the following script to check for any remaining occurrences of the old constant names or hardcoded account addresses that might need updating:

This script will help identify any locations where updates might be necessary due to the breaking changes introduced by this PR.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for old constant names and potentially outdated account addresses

# Search for old constant names
echo "Searching for old constant names:"
rg --type rust "DEFAULT_LEGACY_ERC20_CONTRACT_CASM|DEFAULT_LEGACY_UDC_CONTRACT_CASM"

# Search for potentially hardcoded account addresses
# Note: This might produce false positives, manual review is recommended
echo "Searching for potential hardcoded account addresses:"
rg --type rust "0x[a-fA-F0-9]{1,64}"

Length of output: 84557

crates/katana/primitives/src/genesis/allocation.rs (1)

13-13: Ohayo, sensei! The constant renaming looks good, but let's add a comment for clarity.

The change from DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH to DEFAULT_ACCOUNT_CLASS_HASH aligns with the PR objectives and makes the name more concise. However, to maintain clarity about its origin, consider adding a comment:

/// Default account class hash from OpenZeppelin contracts v0.17.0
use super::constant::DEFAULT_ACCOUNT_CLASS_HASH;

This will help future developers understand the constant's source without needing to dig through the PR history.

crates/katana/primitives/src/conversion/rpc.rs (3)

278-278: Ohayo, sensei! LGTM on the constant renaming.

The renaming from DEFAULT_OZ_ACCOUNT_CONTRACT to DEFAULT_ACCOUNT_CLASS aligns well with the PR objectives. It's a more generic name that doesn't tie the constant to OpenZeppelin specifically, which is good for future flexibility.

Consider adding a brief comment above the constant to explain its purpose and the reason for the generic name, especially if it's used in multiple places throughout the codebase.


304-306: Ohayo once more, sensei! The test update looks good.

The test flattened_sierra_class_to_compiled_class has been correctly updated to use the new DEFAULT_ACCOUNT_CLASS constant, which is consistent with the earlier renaming.

While the current test checks if the conversion is successful, consider enhancing it to verify some properties of the resulting compiled class. For example:

let sierra = DEFAULT_ACCOUNT_CLASS.clone().flatten().unwrap();
let (class_hash, compiled_class_hash, compiled_class) = super::flattened_sierra_to_compiled_class(&sierra).unwrap();

assert!(!class_hash.is_zero(), "Class hash should not be zero");
assert!(!compiled_class_hash.is_zero(), "Compiled class hash should not be zero");
assert!(matches!(compiled_class, CompiledClass::Class(_)), "Compiled class should be of type Class");

This would provide more comprehensive validation of the conversion process.


Line range hint 1-307: Ohayo, sensei! Overall, the changes in this file look solid.

The updates in this file align well with the PR objectives:

  1. The constant renaming from DEFAULT_OZ_ACCOUNT_CONTRACT to DEFAULT_ACCOUNT_CLASS provides more flexibility and generalization.
  2. The file path update in the test reflects the reorganization of contract build artifacts.
  3. The test update is consistent with the constant renaming.

These changes contribute to the overall goal of updating the default predeployed account class implementation. The modifications are minimal and focused, which is good for maintainability.

As the project evolves, consider:

  1. Documenting the purpose and usage of DEFAULT_ACCOUNT_CLASS for future developers.
  2. Implementing a more robust test suite for the flattened_sierra_to_compiled_class function to ensure its reliability across different scenarios.
  3. If not already in place, consider adding a CI check to ensure consistency of file paths across the project, especially for critical files like account.json.
crates/katana/node-bindings/src/lib.rs (1)

Line range hint 517-532: Ohayo, sensei! Nice work on improving JSON log parsing!

The changes look good and improve the robustness of the code. The use of serde_json::from_str for parsing JSON logs is a solid choice. However, we could make a small optimization to avoid parsing the same line twice in some cases.

Consider using serde_json::from_str::<JsonLog<RpcAddr>>(&line) result in both if conditions to avoid parsing the same line twice:

-if let Ok(log) = serde_json::from_str::<JsonLog<RpcAddr>>(&line) {
+let parse_result = serde_json::from_str::<JsonLog<RpcAddr>>(&line);
+if let Ok(log) = parse_result {
     debug_assert!(log.fields.message.contains(RPC_ADDR_LOG_SUBSTR));
     port = log.fields.other.addr.port();
     // We can safely break here as we don't need any information after the rpc
     // address
     break;
 }
 // Parse all logs as generic logs
-else if let Ok(info) = serde_json::from_str::<JsonLog>(&line) {
+else if let Ok(info) = parse_result.map(|log: JsonLog<RpcAddr>| JsonLog::from(log)) {
     // Check if this log is a katana startup info log
     if let Ok(info) = KatanaInfo::try_from(info.fields.message) {
         // ... (rest of the code remains the same)
     }
 }

This change will slightly improve performance by avoiding redundant parsing.

crates/katana/rpc/rpc/tests/starknet.rs (1)

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

The update to use DEFAULT_ACCOUNT_CLASS_HASH instead of DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH is the main change in this file. This aligns perfectly with the PR objectives to update the default predeployed account class implementation.

The minimal nature of the changes suggests a low risk of introducing new issues. However, it's worth noting that this change might affect the generated account addresses, as mentioned in the PR objectives.

Consider adding a comment near the usage of DEFAULT_ACCOUNT_CLASS_HASH to remind developers about the potential impact on generated account addresses. This could help prevent confusion in the future.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9b47e7c and b931486.

📒 Files selected for processing (35)
  • bin/sozo/src/commands/options/account/controller.rs (1 hunks)
  • bin/sozo/tests/test_data/policies.json (1 hunks)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-world/src/metadata_test.rs (1 hunks)
  • crates/katana/contracts/Makefile (1 hunks)
  • crates/katana/contracts/messaging/cairo/Makefile (2 hunks)
  • crates/katana/contracts/messaging/cairo/account_l2.json (1 hunks)
  • crates/katana/contracts/messaging/cairo/account_l3.json (1 hunks)
  • crates/katana/contracts/messaging/l3.messaging.json (1 hunks)
  • crates/katana/contracts/messaging/solidity/Makefile (1 hunks)
  • crates/katana/controller/src/lib.rs (4 hunks)
  • crates/katana/core/src/backend/storage.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/tests/executor.rs (5 hunks)
  • crates/katana/executor/tests/fixtures/contract.json (1 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (2 hunks)
  • crates/katana/node-bindings/src/json.rs (1 hunks)
  • crates/katana/node-bindings/src/lib.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/primitives/src/genesis/allocation.rs (2 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (13 hunks)
  • crates/katana/primitives/src/genesis/mod.rs (14 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (2 hunks)
  • crates/katana/rpc/rpc/tests/test_data/erc20.json (1 hunks)
  • crates/katana/storage/provider/test-data/simple_account.sierra.json (1 hunks)
  • crates/katana/storage/provider/tests/class.rs (3 hunks)
  • crates/katana/storage/provider/tests/fixtures.rs (2 hunks)
  • crates/torii/types-test/dojo_dev.toml (1 hunks)
  • examples/rpc/starknet/starknet_getClassAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassHashAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getNonce.hurl (1 hunks)
  • examples/spawn-and-move/README.md (2 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
  • examples/spawn-and-move/dojo_release.toml (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • bin/sozo/tests/test_data/policies.json
  • crates/katana/executor/tests/fixtures/contract.json
  • crates/katana/node-bindings/src/json.rs
  • crates/katana/rpc/rpc/tests/test_data/erc20.json
  • crates/katana/storage/provider/test-data/simple_account.sierra.json
🧰 Additional context used
🔇 Additional comments (72)
examples/rpc/starknet/starknet_getClassAt.hurl (1)

8-8: Ohayo! The class hash update looks good, sensei!

The change to the class hash is consistent with the PR objectives to update the default predeployed account class implementation. This aligns perfectly with the breaking change mentioned in the PR summary.

Just a friendly reminder, sensei! Since this is a breaking change, we should verify that all other occurrences of the old class hash have been updated. Let's run a quick check:

If this search returns any results, we might need to update those instances as well.

✅ Verification successful

Ohayo, sensei!

The previous search didn't yield any results, but to ensure we've thoroughly checked for any lingering instances of the old class hash, let's run an additional verification:


Ohayo, sensei!

Fantastic news 🎉! We've thoroughly checked and found no remaining instances of the old class hash. Everything looks clean and up-to-date.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining instances of the old class hash
old_hash="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
rg "$old_hash"

Length of output: 147


Script:

#!/bin/bash
# Description: Recursively search for any remaining instances of the old class hash using grep
old_hash="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
grep -r "$old_hash" .

Length of output: 154

examples/rpc/starknet/starknet_getClassHashAt.hurl (2)

8-8: Ohayo! The contract address update looks good, sensei!

The change from the old address to 0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba aligns perfectly with our PR objectives. It reflects the update to the default predeployed account class implementation using the OpenZeppelin version 0.17.0 account preset.


16-16: Ohayo! The assertion remains solid, sensei!

The unchanged assertion jsonpath "$.result" matches /^0x[A-Fa-f0-9]+$/ is still perfectly valid for our new implementation. It correctly verifies that the result is a hexadecimal string starting with "0x", which is exactly what we want.

examples/rpc/starknet/starknet_getNonce.hurl (1)

8-8: Ohayo! The address update looks good, sensei!

The change aligns perfectly with our mission to update the default predeployed account addresses. Great job on keeping our examples up-to-date!

Just a friendly reminder, this change is part of a breaking update. Let's make sure we've caught all instances of this address across our codebase. Here's a quick check we can run:

If this returns any results, we might need to update those instances too!

crates/katana/contracts/messaging/l3.messaging.json (1)

5-5: Ohayo! The sender_address update looks good, sensei!

The change aligns with the PR objectives of updating the default predeployed accounts to use the OpenZeppelin version 0.17.0 account preset. This update is crucial for supporting transaction versions greater than 1.

However, we should verify if this is the only place where the address needs to be updated. Let's run a quick check:

This script will help us identify any other files that might need updating, sensei. Remember, this is a breaking change, so we need to be thorough!

✅ Verification successful

**Ohayo, sensei! The sender_address update has been verified successfully. No occurrences of the old address were found elsewhere, and the new address is correctly used in the expected files. **

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other occurrences of the old address in the codebase

OLD_ADDRESS="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
NEW_ADDRESS="0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

echo "Searching for occurrences of the old address:"
rg "$OLD_ADDRESS"

echo "Searching for occurrences of the new address:"
rg "$NEW_ADDRESS"

Length of output: 3790

crates/katana/contracts/messaging/cairo/account_l2.json (1)

12-12: Ohayo, sensei! The address update looks good!

The change aligns with the PR objectives to update the default predeployed account class implementation. However, please remember that this is a breaking change.

To ensure consistency, let's verify if this new address is used correctly across the codebase:

Please review the results of this script to ensure that all necessary updates have been made consistently across the codebase.

✅ Verification successful

Ohayo, sensei! The address update has been successfully verified!

All instances of the old address have been removed, and the new address is consistently used across the codebase. Great job on ensuring the change is comprehensive and aligns with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of the old address and verify the usage of the new address.

# Test 1: Search for any remaining instances of the old address
echo "Checking for any remaining instances of the old address:"
rg --type-not json "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

# Test 2: Verify the usage of the new address
echo "Verifying the usage of the new address:"
rg --type-not json "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 3131

crates/katana/contracts/messaging/cairo/account_l3.json (3)

12-12: Ohayo! The address update looks good, sensei!

The change to the address field aligns with the PR objectives of updating the default predeployed account class implementation to use OpenZeppelin version 0.17.0. This update is crucial for supporting higher transaction versions.


Line range hint 2-2: Ohayo! Should we update the version field, sensei?

The version field in the JSON is still set to 1. Given that we're updating to OpenZeppelin version 0.17.0, should this version field be updated as well? It might be worth checking if the new OpenZeppelin implementation requires a different version number here.

Let's check if there are any other similar JSON files with a different version number:

#!/bin/bash
# Description: Search for similar JSON files with different version numbers

echo "Ohayo! Searching for similar JSON files with different version numbers:"
fd -e json | xargs jq -r 'select(.version != null) | "\(.version) \(input_filename)"' | sort -u

12-12: Verify the impact of this address change, sensei!

As this is a breaking change affecting the default account addresses, we need to ensure that all hardcoded references to the old address are updated throughout the codebase.

Let's run a quick check to find any remaining instances of the old address:

✅ Verification successful

Ohayo, sensei! It looks like the previous script ran into an error. Let's try a different approach to ensure all instances of the old address are updated throughout the codebase.


Ohayo, sensei! It seems we might have missed some JSON files in our search. Let's make sure we cover all bases and find any lingering instances of the old address.


Ohayo, sensei! My apologies for the hiccup in the last script. Let's give it another go and make sure we catch every instance of that old address, including in JSON files.


All instances of the old address have been successfully updated. No remaining references found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining instances of the old address in the codebase

old_address="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Ohayo! Searching for any remaining instances of the old address:"
rg "$old_address" --type-not json

Length of output: 677


Script:

#!/bin/bash
# Description: Search for any remaining instances of the old address in the codebase

old_address="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Ohayo! Searching for any remaining instances of the old address:"
rg "$old_address" --ignore-file .gitignore

Length of output: 314


Script:

#!/bin/bash
# Description: Search for any remaining instances of the old address in the codebase, including JSON files

old_address="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Ohayo! Searching for any remaining instances of the old address, including JSON files:"
rg "$old_address" --ignore-file .gitignore --type json --type not json

Length of output: 414


Script:

#!/bin/bash
# Description: Search for any remaining instances of the old address in the codebase, including JSON files

old_address="0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Ohayo! Searching for any remaining instances of the old address, including JSON files:"
rg "$old_address" --ignore-file .gitignore

Length of output: 358

crates/benches/contracts/Scarb.toml (1)

20-20: Ohayo! Account address updated as expected, sensei!

The change in the account_address value aligns perfectly with our mission to update the default predeployed accounts. This modification is consistent with the breaking change mentioned in the PR objectives, where we anticipated changes in account addresses due to the new implementation.

Let's make sure this new address is used consistently across the codebase, sensei:

✅ Verification successful

✅ Account address update verified successfully, sensei!

All instances of the old account address have been removed. The new address is consistently used throughout the codebase, ensuring alignment with our PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new account address is used consistently

# Test: Search for both old and new account addresses
echo "Occurrences of the old address:"
rg "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Occurrences of the new address:"
rg "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 3574

examples/spawn-and-move/dojo_dev.toml (1)

15-15: Ohayo! The account address update looks good, sensei!

The change aligns perfectly with our mission to update the default predeployed account. Just a friendly reminder that this is a breaking change, so we'll need to update any hardcoded default account addresses elsewhere in our dojo.

Let's make sure this new address is used consistently across our codebase, sensei:

✅ Verification successful

Ohayo, sensei! 🌸

Great news! The new account address has been consistently updated across all relevant files, and the old address is no longer present. This ensures our configuration remains stable and up-to-date with the latest changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for occurrences of both old and new account addresses

echo "Ohayo! Let's check for the old address:"
rg --type-add 'toml:*.toml' --type toml '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03'

echo "Now, let's look for the new address:"
rg --type-add 'toml:*.toml' --type toml '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba'

Length of output: 891

examples/spawn-and-move/dojo_release.toml (1)

15-15: Ohayo, sensei! The account address update looks good.

The change to the account_address aligns with the PR objectives of updating the default predeployed accounts. This update is part of the breaking change mentioned in the PR summary.

To ensure consistency across the codebase, let's verify the usage of this new address:

Remember, sensei, this is a breaking change. Please ensure that all instances of the old address have been updated, and any hardcoded default account addresses in the codebase or documentation are also updated accordingly.

✅ Verification successful

Ohayo, sensei! Let's refine our search for the account addresses.

It seems rg doesn't recognize the cairo file type. Let's update the script to target .cairo files specifically:

Please run this updated script to ensure all instances of the old address have been replaced with the new one across .toml, .rust, and .cairo files.


Ohayo, sensei! Let's adjust our search to include .cairo files correctly.

It looks like rg doesn't recognize the --extension flag. We'll use the -g "*.cairo" option to target .cairo files properly. Here's the updated script:

Please run this updated script to ensure all instances of the old address have been replaced with the new one across .toml, .rust, and .cairo files.


Ohayo, sensei! It looks like the new account address wasn't found in our previous search. Let's make sure it's correctly set in examples/spawn-and-move/dojo_release.toml.


Ohayo, sensei! The new account address has been successfully updated in examples/spawn-and-move/dojo_release.toml and no instances of the old address remain in the codebase. Everything looks good!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new account address across the codebase.

# Test: Search for the old and new account addresses
echo "Occurrences of the old address:"
rg --type toml --type rust --type cairo "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Occurrences of the new address:"
rg --type toml --type rust --type cairo "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 421


Script:

# 
#!/bin/bash
# Description: Verify the usage of the new account address across the codebase, including .cairo files.

# Test: Search for the old and new account addresses
echo "Occurrences of the old address:"
rg --type toml --type rust --extension cairo "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Occurrences of the new address:"
rg --type toml --type rust --extension cairo "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 1199


Script:

# 
#!/bin/bash
# Description: Verify the usage of the new account address across the codebase, including .cairo files.

# Test: Search for the old and new account addresses
echo "Occurrences of the old address:"
rg --type toml --type rust -g "*.cairo" "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

echo "Occurrences of the new address:"
rg --type toml --type rust -g "*.cairo" "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 361


Script:

# 
#!/bin/bash
# Description: Verify that the new account address is correctly set in dojo_release.toml.

rg "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba" examples/spawn-and-move/dojo_release.toml

Length of output: 198

crates/katana/contracts/messaging/solidity/Makefile (2)

12-12: Ohayo again, sensei! Let's consider the ripple effects of this change.

The update to L2_ACCOUNT may have implications for other parts of the system:

  1. Deployment of messaging contracts might be affected.
  2. Sending and consuming messages could behave differently.
  3. The interaction between L1 and L2 might need adjustment.

To ensure system integrity, please run comprehensive tests, especially focusing on:

#!/bin/bash
# Description: Verify the functionality of key Makefile targets

# Test 1: Deploy messaging contracts
make deploy_messaging_contracts

# Test 2: Send a test message
make send_msg selector_str=test_func payload="[1,2,3]"

# Test 3: Consume a test message
make consume_msg payload="[1,2,3]"

Sensei, please review the output of these commands to confirm that the system functions correctly with the new L2_ACCOUNT address.


12-12: Ohayo, sensei! The L2_ACCOUNT address has been updated.

The L2_ACCOUNT address has been changed from the old value to 0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba. This update aligns with the PR objectives to utilize the OpenZeppelin version 0.17.0 account preset.

To ensure this change is consistent across the project, let's run the following script:

Sensei, please review the script output to ensure the address update is consistent across the project.

✅ Verification successful

Ohayo, sensei! It looks like the previous verification script encountered some issues. Let's try running a corrected script to ensure the L2_ACCOUNT address update is consistent across the project.

Please run the above script and share the output so we can ensure the address update is fully integrated.


Ohayo, sensei! 🎉 Great news! The L2_ACCOUNT address update is consistent across the entire project, and there are no remaining instances of the old address. Everything looks good to go!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the L2_ACCOUNT address update across the project

# Test 1: Check for any remaining instances of the old address
rg '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03'

# Test 2: Verify the new address is used consistently
rg '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba'

Length of output: 439


Script:

#!/bin/bash
# Description: Verify the L2_ACCOUNT address update across the project

# Test 1: Check for any remaining instances of the old address
rg '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03'

# Test 2: Verify the new address is used consistently
rg '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba'

Length of output: 3428

examples/spawn-and-move/README.md (3)

36-38: Ohayo! LGTM, sensei!

The contract address in the comment has been successfully updated to reflect the new implementation. This change aligns perfectly with the PR objectives.


41-41: Ohayo! Excellent update, sensei!

The contract address in the example output has been correctly updated to match the new implementation. This change ensures consistency throughout the documentation.


Line range hint 36-54: Ohayo! Excellent update overall, sensei!

The README has been successfully updated to reflect the new contract address throughout the examples. These changes ensure that the documentation remains accurate and consistent with the latest implementation.

The updates improve the reliability of the guide for users following along, as they now see the correct contract address in all relevant places. This aligns perfectly with the PR objectives of updating the default predeployed account class implementation.

Great job on maintaining the documentation alongside the code changes!

crates/katana/contracts/messaging/cairo/Makefile (2)

43-43: Ohayo again, sensei! LGTM, but let's verify and clarify.

The update to ACCOUNT_L3_ADDR looks good and is consistent with the change to ACCOUNT_L2_ADDR. This aligns with the PR objectives for updating the default predeployed account class implementation.

Let's verify the usage of this new address:

#!/bin/bash
# Description: Verify the usage of the new ACCOUNT_L3_ADDR value

# Test: Search for the old and new address values
echo "Occurrences of the old address for L3:"
rg "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
echo "Occurrences of the new address for L3:"
rg "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Also, sensei, I noticed that ACCOUNT_L2_ADDR and ACCOUNT_L3_ADDR now have the same value. Is this intentional? If so, could you please add a comment explaining why these addresses are identical to prevent any confusion for future developers?


2-2: Ohayo, sensei! LGTM, but let's verify the usage.

The update to ACCOUNT_L2_ADDR looks good and aligns with the PR objectives. This change is part of updating the default predeployed account class implementation.

To ensure consistency, let's verify the usage of this new address throughout the codebase:

✅ Verification successful

Ohayo, sensei! Verified the update to ACCOUNT_L2_ADDR. The old address is no longer present, and the new address is correctly used across the codebase. Everything looks good to go!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new ACCOUNT_L2_ADDR value

# Test: Search for the old and new address values
echo "Occurrences of the old address:"
rg "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
echo "Occurrences of the new address:"
rg "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"

Length of output: 3602

crates/dojo-world/src/metadata_test.rs (1)

65-65: Ohayo, account address update looks good, sensei!

The change aligns perfectly with the PR objectives of updating the default predeployed account class implementation. Great job on keeping the tests up-to-date with the new expected behavior!

A couple of suggestions to make this even better:

  1. Could you verify if all other occurrences of the old address (0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03) have been updated throughout the codebase?
  2. Consider adding a comment explaining the significance of this specific address, perhaps mentioning it's derived from the OpenZeppelin v0.17.0 account preset.

Let's run a quick check to ensure we've caught all instances of the old address:

✅ Verification successful

Ohayo, sensei! Verified that all instances of the old address have been successfully updated to the new address. Great job!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining instances of the old address

# Test: Look for the old address. Expect: No results
rg '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03'

# Test: Confirm the new address is used. Expect: At least one result
rg '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba'

Length of output: 3428

crates/katana/primitives/src/genesis/constant.rs (8)

20-24: Ohayo! Nice work on generalizing the constant name, sensei!

The renaming of OZ_ACCOUNT_CONTRACT_PUBKEY_STORAGE_SLOT to DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT is a good move. It makes the constant more generic and adaptable to different account implementations. This change aligns well with the PR's objective of updating the default predeployed account class.


55-57: Ohayo! Excellent consistency in naming, sensei!

The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH is a good simplification. It removes the redundant "CONTRACT" term, making the constant name more concise while maintaining clarity. This change is consistent with the overall refactoring approach in this PR.


74-77: Ohayo! Nice work on updating the compiled class hash, sensei!

The renaming of DEFAULT_OZ_ACCOUNT_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_ACCOUNT_COMPILED_CLASS_HASH and updating its value is consistent with the previous changes. This update reflects the compiled version of the new default predeployed account class implementation.

This change, along with the updated class hash, ensures that the new account implementation is fully integrated into the system.


Line range hint 1-128: Ohayo! Excellent work on updating the constants and artifact loading, sensei!

Your changes in this file align well with the PR objectives and contribute to a more consistent and up-to-date codebase. Here's a summary of the key updates:

  1. Renamed constants to be more generic and consistent (e.g., removing "OZ" and "CONTRACT" references).
  2. Updated the default account class hash and compiled class hash to reflect the new implementation.
  3. Changed the paths for loading contract artifacts, suggesting a project restructuring.
  4. Updated the parsing function for compiled class artifacts.

These changes, especially the updates to the account class implementation, will have a significant impact on the system. As mentioned earlier, please ensure that any hardcoded default account addresses in the codebase are updated accordingly.

Great job on improving the overall structure and consistency of the constants!


70-73: Ohayo! Excellent update to the account class hash, sensei!

The renaming of DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH to DEFAULT_ACCOUNT_CLASS_HASH and updating its value is a crucial change that aligns perfectly with the PR's objective. This update reflects the new implementation of the default predeployed account class, likely corresponding to the OpenZeppelin version 0.17.0 account preset mentioned in the PR summary.

As noted in the PR objectives, this change will result in different generated account addresses. Please ensure that any hardcoded default account addresses in the codebase are updated accordingly.

#!/bin/bash
# Search for potential hardcoded account addresses that might need updating
rg --type rust "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"

87-94: Ohayo! Good updates to the contract artifact loading, sensei!

The changes to the lazy_static initializations for contract classes look good. You've updated the paths from "../../contracts/compiled/" to "../../../contracts/build/" and changed the parsing function from parse_compiled_class to read_compiled_class_artifact.

These changes suggest a reorganization of the project structure or build process. Could you please verify:

  1. The new paths are correct and the build artifacts are indeed in the "../../../contracts/build/" directory?
  2. The read_compiled_class_artifact function includes any necessary additional logic or error handling compared to the previous parse_compiled_class function?
#!/bin/bash
# Verify the existence of the new build artifacts
ls -l ../../../contracts/build/erc20.json ../../../contracts/build/universal_deployer.json ../../../contracts/build/default_account.json

# Check the implementation of the new parsing function
rg -A 10 "fn read_compiled_class_artifact" crates/katana/primitives/src/genesis/constant.rs

100-102: Ohayo! Nice consistency in updating the controller account artifacts, sensei!

The changes to the lazy_static initializations for the controller account class are consistent with the previous updates. You've updated the paths and file names to reflect the new project structure and possibly a new build process.

To ensure everything is in order:

  1. Could you confirm that the new file names ("controller_CartridgeAccount.contract_class.json") are correct and reflect the intended naming convention?
  2. Please verify that the contents of these new files are as expected and contain the correct controller account implementation.
#!/bin/bash
# Verify the existence and contents of the new controller account artifact
ls -l ../../../contracts/build/controller_CartridgeAccount.contract_class.json
jq '.abi' ../../../contracts/build/controller_CartridgeAccount.contract_class.json

59-61: Ohayo! Good consistency in renaming, sensei, but let's double-check the value.

The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH is consistent with the previous changes and improves clarity.

However, I noticed that the value is now set to DEFAULT_LEGACY_ERC20_CLASS_HASH. Could you please verify if this is intentional? Typically, the compiled class hash and the class hash are different values.

✅ Verification successful

Ohayo, sensei! The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH is consistent and intentional. Assigning it to DEFAULT_LEGACY_ERC20_CLASS_HASH is correct based on the definitions provided.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if the compiled class hash is intentionally set to the same value as the class hash
grep -n "DEFAULT_LEGACY_ERC20_.*_HASH" crates/katana/primitives/src/genesis/constant.rs

Length of output: 863


Script:

#!/bin/bash
# Fetch definitions of DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH and DEFAULT_LEGACY_ERC20_CLASS_HASH
rg -A 2 'pub const DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH' crates/katana/primitives/src/genesis/constant.rs
rg -A 2 'pub const DEFAULT_LEGACY_ERC20_CLASS_HASH' crates/katana/primitives/src/genesis/constant.rs

Length of output: 461

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

10-10: Ohayo! LGTM, sensei!

The import statement has been updated to reflect the renamed constants. This change aligns perfectly with the PR objectives to update the default predeployed account class implementation.


136-139: Ohayo! Nice work, sensei!

The historical test case for block 1 has been correctly updated to use the new constant name DEFAULT_LEGACY_ERC20_CASM. This change maintains consistency with the updated implementation and ensures that historical state testing remains accurate.

crates/katana/storage/provider/tests/fixtures.rs (1)

11-11: Ohayo, sensei! LGTM: Import statement updated correctly.

The import statement has been updated to reflect the renamed constants DEFAULT_LEGACY_ERC20_CASM and DEFAULT_LEGACY_UDC_CASM. This change aligns with the PR objectives and maintains consistency with the updates in the katana_primitives::genesis::constant module.

crates/katana/controller/src/lib.rs (5)

9-9: Ohayo, sensei! Nice update to the constant import.

The change from CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH aligns perfectly with our PR objectives. It's a more concise and clear naming convention. Good job on keeping our codebase tidy!


238-238: Arigato for updating the test, sensei!

Your diligence in updating the test assertion to use CONTROLLER_CLASS_HASH is much appreciated. This change ensures our tests remain in sync with the implementation changes, maintaining the integrity of our test suite.


Line range hint 1-258: Ohayo, sensei! Overall, these changes look sugoi (amazing)!

You've done a great job updating the controller account implementation:

  1. Consistently renamed CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH throughout the file.
  2. Updated the Sierra artifact path, reflecting changes in our build process.
  3. Ensured that tests are updated to maintain integrity.

These changes align perfectly with our PR objectives to update the default predeployed account class implementation.

To ensure everything is in order, could you please:

  1. Confirm that the build process has been updated to output artifacts to the new build directory?
  2. Verify that there are no remaining references to the old constant name in other files?

Here's a script to help with the second point:

#!/bin/bash
# Check for any remaining references to the old constant name
rg "CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH" .

Great work on keeping our codebase clean and up-to-date, sensei!


46-46: Excellent consistency, sensei!

The update to use CONTROLLER_CLASS_HASH here is spot on. It's great to see that you've maintained consistency with the earlier constant change. This ensures that our new controller class hash is correctly used when creating the genesis allocation.

To double-check our work, let's run a quick verification:

✅ Verification successful

Ohayo, sensei!

I've double-checked the usage of CONTROLLER_CLASS_HASH across the codebase, and everything looks consistent and in order. Great job maintaining the integrity of the constant throughout!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent usage of CONTROLLER_CLASS_HASH
rg "CONTROLLER_CLASS_HASH" crates/katana/controller/src/lib.rs

Length of output: 254


76-76: Ohayo! Nice catch on updating the artifact path, sensei.

The change from compiled to build in the CONTROLLER_SIERRA_ARTIFACT path is noted. This likely reflects an update in our build process or directory structure.

Let's make sure this new path is correct:

Also, sensei, could you confirm that our build process has been updated to output artifacts to this new location?

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

15-15: Ohayo, sensei! LGTM on this import change!

The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH aligns perfectly with the PR objectives. It's a more concise name while still clearly conveying its purpose. Nice work on keeping things tidy!


Line range hint 1-299: Ohayo one last time, sensei! Here's a wrap-up of the changes.

The modifications in this file are minimal but important. They consistently rename the DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH, both in the import statement and its usage. These changes align well with the PR objectives of updating the default predeployed account class implementation.

The rest of the file remains unchanged, which is good as it suggests that the impact of this renaming is localized. However, it's worth noting that this change might be part of a larger update across the codebase.

To ensure we haven't missed any instances of the old constant name, let's run a quick check:

#!/bin/bash
# Description: Check for any remaining instances of the old constant name

# Search for any remaining instances of the old constant name
rg --type rust "DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH"

If this search returns any results, we might need to update those instances as well.


199-199: Ohayo again, sensei! This change looks good too!

The usage of DEFAULT_LEGACY_ERC20_CLASS_HASH is consistent with the import change. It's great to see the constant being used correctly in the context of deploying an ERC20 contract.

Just to be extra careful, let's verify that the value of this constant hasn't changed unexpectedly:

✅ Verification successful

Ohayo again, sensei! It looks like the previous search might have had a slight hiccup. Let's try verifying the constant's value with the correct name to ensure everything is in order:


Ohayo again, sensei! It seems we couldn't locate DEFAULT_LEGACY_ERC20_CLASS_HASH or DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH. Let's search for any related ERC20 constants to find the correct one:


Ohayo again, sensei! The usage of DEFAULT_LEGACY_ERC20_CLASS_HASH has been verified and is consistent with its definition. Everything looks good!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the value of DEFAULT_LEGACY_ERC20_CLASS_HASH

# Search for the constant definition
rg --type rust "const DEFAULT_LEGACY_ERC20_CLASS_HASH\s*=\s*" -A 1

Length of output: 57


Script:

#!/bin/bash
# Description: Verify the value of DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH

# Search for the constant definition
rg --type rust "const DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH\s*=\s*" -A 1

Length of output: 77


Script:

#!/bin/bash
# Description: Search for any ERC20 related constants

rg --type rust "const .*ERC20.*\s*=\s*" -A 1

Length of output: 1422

bin/sozo/src/commands/options/account/controller.rs (1)

288-288: Ohayo! Updated user address for test case, sensei.

The change aligns with the PR objectives of updating the default predeployed account class implementation. This new address reflects the breaking change mentioned in the PR summary.

To ensure consistency across the codebase, let's verify if this new address is used in other test files:

✅ Verification successful

Ohayo! Let's get those addresses checked out, sensei.

[/run_scripts]


Ohayo! Verified the update to the user address, sensei.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for occurrences of both old and new addresses in test files

echo "Occurrences of the old address:"
rg --type rust '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03' **/tests/**

echo "Occurrences of the new address:"
rg --type rust '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba' **/tests/**

Length of output: 443


Script:

#!/bin/bash
# Description: Check for occurrences of both old and new addresses in all Rust files

echo "Occurrences of the old address:"
rg --type rust '0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03'

echo "Occurrences of the new address:"
rg --type rust '0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba'

Length of output: 1043

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

142-143: Ohayo! LGTM, sensei! Constants renamed as per PR objectives.

The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_CASM to DEFAULT_LEGACY_ERC20_CASM and DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH is consistent with the PR objectives. These changes improve clarity without altering functionality.


178-178: Ohayo! Nice update, sensei! Assertion aligned with renamed constant.

The assertion has been correctly updated to use the new constant name DEFAULT_LEGACY_ERC20_CLASS_HASH. This change maintains consistency with the earlier renaming in the import statement, ensuring the test case remains valid.


289-290: Ohayo! Excellent consistency, sensei! Assertions updated across test cases.

The assertions in the blockchain_from_db test case have been correctly updated to use the new constant names DEFAULT_LEGACY_ERC20_CLASS_HASH and DEFAULT_LEGACY_ERC20_CASM. These changes maintain consistency with the earlier renaming in the import statement and the blockchain_from_genesis_states test case. The test logic remains unchanged, ensuring the validity of the tests.

Also applies to: 315-316


Line range hint 1-337: Ohayo, sensei! Overall assessment: Changes are on point and consistent.

The modifications in this file primarily involve renaming constants related to the legacy ERC20 contract and updating their usage in test cases. These changes align well with the PR objectives of updating the default predeployed account class implementation. The renaming improves code clarity without altering the underlying functionality or test logic.

Key points:

  1. Constants renamed in import statements (lines 142-143)
  2. Assertions updated in blockchain_from_genesis_states test (line 178)
  3. Assertions updated in blockchain_from_db test (lines 289-290, 315-316)

These changes maintain consistency across the file and ensure that the test cases remain valid. Good job on keeping the codebase clean and up-to-date!

crates/katana/executor/tests/executor.rs (6)

10-11: Ohayo! Nice work on updating the import statements, sensei!

The changes to the constant names improve consistency and clarity. The new DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_LEGACY_ERC20_CLASS_HASH are more descriptive and align better with their purposes.


144-144: Excellent update, sensei! This change is on point!

The assertion now correctly uses the DEFAULT_ACCOUNT_CLASS_HASH, which aligns perfectly with our objective of updating to the new OpenZeppelin account preset. This ensures that our tests accurately reflect the new implementation.


184-184: Ohayo! Nicely done on keeping things consistent, sensei!

The update to use DEFAULT_LEGACY_ERC20_CLASS_HASH in the UDC deployment code maintains consistency with the other constant renames. This ensures that our tests are using the correct class hash for the legacy ERC20 contract deployment.


235-235: Ohayo! Great attention to detail, sensei!

The update to use DEFAULT_LEGACY_ERC20_CLASS_HASH in this assertion is crucial. It ensures that our test accurately verifies the class hash of the deployed ERC20 contract, maintaining consistency with the earlier updates and keeping our test suite robust.


294-295: Ohayo! Excellent work on maintaining consistency, sensei!

The updates to use DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_LEGACY_ERC20_CLASS_HASH in the expected contract deployment map are spot-on. These changes ensure that our tests accurately reflect the expected state after contract deployments, maintaining consistency with the earlier updates and reinforcing the robustness of our test suite.


Line range hint 1-338: Ohayo! Outstanding work on this update, sensei!

Your changes to executor.rs consistently apply the new constant names throughout the test implementation. This update aligns perfectly with our objective of incorporating the new OpenZeppelin account preset. The renamed constants (DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_LEGACY_ERC20_CLASS_HASH) improve clarity and maintain consistency across the entire test suite.

These modifications ensure that our tests accurately reflect the new implementation, particularly in areas such as account deployment, UDC interactions, and state verifications. The careful updates to assertions and expected values demonstrate a thorough approach to maintaining test integrity.

Great job on this comprehensive update! It significantly contributes to the robustness and clarity of our test suite.

crates/katana/node-bindings/src/lib.rs (1)

631-633: Ohayo again, sensei! Good catch on updating the test case!

The modification to use endpoint_url() instead of endpoint() in the can_launch_katana test is a positive change. It ensures that we're testing the method that should be used in production code, which is a great practice.

This change improves the test's accuracy and relevance. Keep up the good work!

crates/katana/rpc/rpc/tests/starknet.rs (2)

17-18: Ohayo! LGTM on the import changes, sensei!

The addition of DEFAULT_ACCOUNT_CLASS_HASH to the imports is spot-on for updating the default predeployed account class implementation. Nice work!


167-167: Ohayo! The account class hash update looks good, sensei!

The change from DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH to DEFAULT_ACCOUNT_CLASS_HASH is in line with the PR objectives. Great job on updating this!

However, let's make sure this change doesn't break anything else in the codebase.

Let's run a quick check to ensure this change doesn't affect other parts of the codebase:

crates/katana/executor/src/implementation/blockifier/state.rs (7)

237-238: Ohayo, sensei! The constants have been correctly updated.

The import of DEFAULT_ACCOUNT_CLASS, DEFAULT_ACCOUNT_CLASS_CASM, DEFAULT_LEGACY_ERC20_CASM, and DEFAULT_LEGACY_UDC_CASM aligns with the updated account implementation.


Line range hint 251-255: Ohayo, sensei! The new_sierra_class function is implemented correctly.

The function properly reads and parses the cairo1_contract.json file to obtain the compiled and flattened Sierra classes. This ensures that the latest contract definitions are used in the tests.


265-266: Ohayo, sensei! Correctly cloning default account classes.

Cloning DEFAULT_ACCOUNT_CLASS and DEFAULT_ACCOUNT_CLASS_CASM ensures that the state provider uses the updated OpenZeppelin account preset as intended.


268-268: Ohayo, sensei! Proper handling of the legacy ERC20 class.

Cloning DEFAULT_LEGACY_ERC20_CASM to legacy_class correctly sets up the legacy class hash for testing purposes.


307-309: Ohayo, sensei! Verification of actual_class is accurate.

The assertion confirms that actual_class matches the expected class after conversion, ensuring the cached state retrieves the correct account class.


311-313: Ohayo, sensei! The actual_legacy_class assertion is correct.

This validates that the legacy class retrieved matches DEFAULT_LEGACY_ERC20_CASM, confirming the integrity of legacy contract handling.


410-412: Ohayo, sensei! Assertions in can_fetch_as_state_provider test are valid.

The tests accurately verify that the state provider fetches the correct classes and class hashes, reflecting the updates to the default account implementation.

crates/katana/primitives/src/genesis/mod.rs (5)

181-181: Public Key Storage Insertion Is Correct

Ohayo sensei! The insertion of the public key into DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT is correctly implemented.


278-278: Update of Default Account Class in Genesis

Ohayo sensei! The GenesisClass for the default account has been updated correctly with the new class hash, CASM, and Sierra class. Excellent work!

Also applies to: 280-282, 579-580


287-287: Controller Class Updates Are Correct

Ohayo sensei! The updates to the controller class constants and their usage are correctly implemented. Good job!

Also applies to: 289-291, 587-600


336-336: Confirm Necessity of Legacy ERC20 Constants in Tests

Ohayo sensei! The test code is still using DEFAULT_LEGACY_ERC20_* constants. Please verify if the tests need to be updated to reflect the new account class implementation, or if retaining the legacy constants is intentional.

Run the following script to find usages of DEFAULT_LEGACY_ERC20_* constants in tests:

#!/bin/bash
# Description: Search for usages of DEFAULT_LEGACY_ERC20_* constants in test modules.

# Expected: Determine if tests need to be updated.

rg --type rust --glob '*_test.rs' 'DEFAULT_LEGACY_ERC20_(CLASS_HASH|CASM|COMPILED_CLASS_HASH)'

Also applies to: 339-340, 525-525


250-250: Verify Usage of Legacy ERC20 Constants

Ohayo sensei! The code continues to use DEFAULT_LEGACY_ERC20_* constants for the fee token configuration. Please verify whether these constants should be updated to match the new account class implementation, or if the legacy constants are still appropriate.

Run the following script to identify where DEFAULT_LEGACY_ERC20_* constants are used:

#!/bin/bash
# Description: Search for usages of DEFAULT_LEGACY_ERC20_* constants.

# Expected: Confirm whether these constants need updating.

rg --type rust 'DEFAULT_LEGACY_ERC20_(CLASS_HASH|CASM|COMPILED_CLASS_HASH)'

Also applies to: 262-262, 265-266, 367-367

crates/katana/primitives/src/genesis/json.rs (7)

29-31: Ensure Consistent Naming of Constants

Ohayo sensei!

The renaming of constants to CONTROLLER_ACCOUNT_CLASS, CONTROLLER_ACCOUNT_CLASS_CASM, and CONTROLLER_CLASS_HASH enhances clarity and maintains consistency with the updated naming conventions. This improves code readability and maintainability.


32-34: Verify Default Account Class Constants

Ohayo sensei!

The inclusion of DEFAULT_ACCOUNT_CLASS, DEFAULT_ACCOUNT_CLASS_CASM, and related constants ensures that the default account classes are correctly referenced throughout the codebase. This aligns with the shift to OpenZeppelin version 0.17.0.


327-331: Confirm Controller Class Insertion Under 'slot' Feature

Ohayo sensei!

The code correctly inserts the CONTROLLER_CLASS_HASH into the classes map when the slot feature is enabled. This ensures that the controller class is available during genesis when required.


843-845: Check Class Assignment in Test Cases

Ohayo sensei!

In this test, the DEFAULT_ACCOUNT_CLASS is being serialized and assigned a class hash of Some(felt!("0xa55")). Please verify that this class hash aligns with the updated OpenZeppelin version 0.17.0 account class. Updating test cases ensures they accurately reflect the current implementation.

Would you like assistance in updating the test cases to match the new account class?


522-527: ⚠️ Potential issue

Update Default Account Class Hash to Match OZ v0.17.0

Ohayo sensei!

The default account class hash DEFAULT_ACCOUNT_CLASS_HASH is used here. Since we're upgrading to OpenZeppelin version 0.17.0, ensure that this constant reflects the new class hash. Using an outdated class hash could lead to unintended behavior.

You can verify the value of DEFAULT_ACCOUNT_CLASS_HASH with the following command:

#!/bin/bash
# Verify DEFAULT_ACCOUNT_CLASS_HASH corresponds to OZ v0.17.0

rg 'const DEFAULT_ACCOUNT_CLASS_HASH' --type rust -A 3

434-438: Ensure Fee Token Class Matches Updated Implementation

Ohayo sensei!

The default fee token class is inserted with DEFAULT_LEGACY_ERC20_CLASS_HASH and associated CASM. To align with the update to OpenZeppelin version 0.17.0, please verify that these constants correspond to the new implementation.

Consider checking the definitions to ensure they reflect the updated class:

#!/bin/bash
# Check the definitions of DEFAULT_LEGACY_ERC20_CLASS_HASH and DEFAULT_LEGACY_ERC20_CASM

rg 'const DEFAULT_LEGACY_ERC20_(CLASS_HASH|CASM)' --type rust -A 5

409-409: Verify Default Fee Token Class Hash

Ohayo sensei!

The default fee token class hash is set to DEFAULT_LEGACY_ERC20_CLASS_HASH. Since we're updating to OpenZeppelin version 0.17.0, please verify that this constant corresponds to the correct class hash for the updated version.

You can run the following command to locate and check the definition of DEFAULT_LEGACY_ERC20_CLASS_HASH:

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

🧹 Outside diff range and nitpick comments (4)
crates/katana/primitives/src/genesis/test-genesis.json (4)

11-27: Ohayo! The feeToken and universalDeployer configs are looking sharp, sensei!

The feeToken configuration is comprehensive and well-structured. For the universalDeployer, consider adding a comment explaining its minimal configuration if it's intentional.

You might want to add a comment like this above the universalDeployer section:

  // Minimal configuration for universalDeployer
  "universalDeployer": {
    ...
  },

28-52: Ohayo! The accounts section is diverse and intriguing, sensei!

The variety of account configurations provides excellent coverage for different testing scenarios. Nice work!

For consistency, consider using the same format for class references across all accounts. For example:

-      "class": "MyClass"
+      "class": "0x80086"  // Assuming this is the correct class hash for MyClass

This change would align with the format used in other accounts and improve overall consistency.


53-71: Ohayo! The contracts section is well-structured and comprehensive, sensei!

The diverse contract configurations provide excellent coverage for various testing scenarios. Kudos on the thorough setup!

To enhance clarity, consider adding comments to explain the purpose of contracts with minimal configuration. For example:

    "0xe29882a1fcba1e7e10cad46212257fea5c752a4f9b1b1ec683c503a2cf5c8a": {
      "balance": "0xD3C21BCECCEDA1000000"
      // Minimal configuration for specific test case
    },

This would help other developers understand the intention behind these minimal configurations.


72-86: Ohayo! The classes section is well-organized and informative, sensei!

The clear definition of classes with their respective JSON file paths is excellent. It provides a solid foundation for the updated predeployed accounts.

Consider the following enhancements for consistency and future-proofing:

  1. Use absolute paths or environment variables for class file locations to ensure consistency across different development environments:
-      "class": "../../../contracts/build/erc20.json",
+      "class": "${CONTRACTS_BUILD_DIR}/erc20.json",
  1. Add class hashes for all entries to maintain consistency:
    {
      "class": "../../../contracts/build/default_account.json",
      "name": "MyClass"
+     "classHash": "0x80086"  // Assuming this is the correct class hash
    }

These changes will improve consistency and make the configuration more robust to future changes in project structure.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b931486 and 9295c68.

📒 Files selected for processing (7)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (14 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis.json (1 hunks)
  • examples/rpc/starknet/starknet_getClass.hurl (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/katana/executor/tests/executor.rs
  • crates/katana/primitives/src/genesis/json.rs
🧰 Additional context used
🔇 Additional comments (8)
crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (3)

1-37: Ohayo! Nice job on the JSON structure, sensei!

The reorganization and consistent formatting of the JSON file make it much easier to read and maintain. Great attention to detail!


7-22: Keeping it clean and consistent, sensei!

The gasPrices, feeToken, universalDeployer, and accounts sections have been nicely reformatted while maintaining their original content. This improves readability without altering functionality. Well done!


24-36: Ohayo! Important updates to the classes array, sensei!

The changes in the classes array reflect a significant update:

  1. Transition from compiled to built contracts (e.g., ../../../contracts/compiled/erc20.json../../../contracts/build/erc20.json).
  2. Addition of default_account.json.
  3. Removal of oz_account_080.json.

These changes align with the PR objectives to update the default predeployed account class implementation. However, please note:

  1. This update may result in different contract addresses, which could be a breaking change.
  2. Ensure that all references to the old compiled contracts are updated throughout the codebase.
  3. Verify that the new default_account.json is compatible with the rest of the system.

To ensure all references are updated, please run:

#!/bin/bash
# Search for any remaining references to compiled contracts
rg --type json "compiled/[^/]+\.json"
crates/katana/primitives/src/genesis/test-genesis.json (1)

2-10: Ohayo! The initial block info looks solid, sensei!

The basic block information and gas prices for both ETH and STRK are well-defined. This setup nicely accommodates the Starknet ecosystem.

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

15-17: Ohayo! LGTM on the import updates, sensei!

The changes in the import statements align well with the PR objectives. The addition of DEFAULT_ACCOUNT_CLASS_HASH supports the update to the default predeployed account class implementation. The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH improves clarity by removing the redundant "CONTRACT" term.


93-94: Ohayo! The sender_address update looks good, sensei!

The change in the sender_address is consistent with the PR objectives, as it was mentioned that generated account addresses would change due to the new implementation.

Could you please confirm that this new address is correctly derived from the updated account class implementation? It would be great to ensure its accuracy.


Line range hint 169-173: Ohayo! Excellent update to DeployAccountTxV1, sensei!

The change to use DEFAULT_ACCOUNT_CLASS_HASH for the class_hash field directly implements the PR objective of updating the default predeployed account class implementation. This switch from a hardcoded value to a constant improves maintainability and reduces the risk of inconsistencies. Well done!


Line range hint 198-211: Ohayo! Nice consistency in using the renamed constant, sensei!

The update to use DEFAULT_LEGACY_ERC20_CLASS_HASH in the ERC20 deployment calldata is consistent with the earlier renaming of the constant in the import statements. This change ensures that the correct, updated constant is used in the ERC20 deployment process. Great attention to detail!

@kariy
Copy link
Member Author

kariy commented Oct 12, 2024

there is an error where the new account class, for some haven't yet discovered reasons, doesn't fail with RunResources has no remaining steps error when on disabled fee mode and the tx max fee is lower than the actual fee needed. no changes on the execution level except for the new class artifact. so unsure what's the reason.

a possible cause could be because the new account is compiled using scarb 2.8.2 while katana is still on cairo 2.7.0. if the casm is compiled from the produced sierra (both has the same sierra version, 1.6.0) then the resultant casm should be the same. havent yet tried compiling the class with cairo 2.7.0.

UPDATE:

ok its not related to the cairo version at all. the amount of steps of the __validate__ of the new account implementation is significantly lower than the current version. so it was able to finish execution, but the at the end of the StatefulValidator::perform_validations flow it does a post verification check - making sure the amount of steps taken within the bounds that the tx can pay (ie tx max fee). hence the different error that we get.

in fee-disabled mode, we should skip this check to be consistent with the expected behaviour.

@kariy kariy force-pushed the katana/update-default-account branch from be530b5 to 3849ac1 Compare October 12, 2024 17:39
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: 7

🧹 Outside diff range and nitpick comments (8)
crates/katana/contracts/account/Scarb.toml (1)

14-14: Ohayo! LGTM, sensei! Adding CASM support is a wise move.

The addition of casm = true to the [[target.starknet-contract]] section is a positive change. This will generate the Compiled Assembly (CASM) format alongside the existing Sierra format, which could help address compatibility issues between different tool versions.

Sensei, this change might help resolve the issue you mentioned about the RunResources has no remaining steps error. By generating both CASM and Sierra formats, we're ensuring broader compatibility across different Cairo and Scarb versions. It's a step towards future-proofing our contract deployment process.

crates/katana/contracts/Scarb.toml (1)

11-13: Ohayo! Ensure thorough testing after dependency changes, sensei.

The dependency updates align with the PR objectives, particularly the use of OpenZeppelin v0.15.1. However, the downgrades of starknet and snforge_std could potentially impact functionality or introduce compatibility issues.

Please ensure comprehensive testing is performed, especially focusing on:

  1. Support for transaction versions greater than 1
  2. Compatibility between the downgraded dependencies
  3. Any potential breaking changes in the project due to these version changes

Additionally, consider documenting the reasons for these specific version choices to aid future maintenance.

crates/katana/contracts/account/src/lib.cairo (1)

Line range hint 2-36: Ohayo sensei! Let's summarize the key changes and their implications.

  1. Version downgrade from v0.17.0 to v0.15.1
  2. Storage struct visibility changed from public to private
  3. All Storage struct fields changed from public to private

These changes significantly alter the accessibility of the Account module's internals. While they promote better encapsulation, they may also break existing code that relies on direct access to these structures.

To ensure a smooth transition:

  1. Thoroughly test all code that interacts with the Account module.
  2. Update documentation to reflect these new access restrictions.
  3. Consider providing a migration guide for any breaking changes.
  4. Implement and test any necessary accessor methods to maintain required functionality.

If you need any assistance with these tasks, please don't hesitate to ask, sensei!

crates/katana/primitives/src/genesis/test-genesis.json (3)

11-21: Ohayo! New feeToken section looks great, sensei!

The addition of the feeToken section is a significant improvement. It provides crucial information for the fee token configuration, which is essential for the updated account implementation.

Consider documenting the purpose and impact of this new section in the project's documentation to ensure other developers understand its importance.


22-27: Ohayo! The universalDeployer section is a great addition, sensei!

This new section provides essential information for the universal deployer configuration, which is crucial for the updated account implementation.

Consider adding a comment or documentation to explain the significance of the 0x10 key in the storage mapping. This will enhance code readability and maintainability.


53-86: Ohayo! The contracts and classes sections look solid, sensei!

The updates to the contracts section and the addition of the classes section are well-aligned with the PR objectives. These changes provide a clear structure for defining contract and class properties.

I noticed that the class definitions now point to the build directory instead of the compiled directory. This change is good, but make sure to update any related documentation or build scripts to reflect this new directory structure.

crates/katana/primitives/src/genesis/constant.rs (1)

Line range hint 1-128: Ohayo, sensei! Let's wrap up this review.

Overall, the changes in this file are well-aligned with the PR objectives. The renaming of constants improves consistency and clarity in the codebase. The updates to class hashes and artifact paths reflect the transition to the new OpenZeppelin account implementation.

However, there are a few points to keep in mind:

  1. The change in DEFAULT_ACCOUNT_CLASS_HASH introduces a breaking change that will affect generated account addresses. Ensure that this impact is well-documented and communicated to users.
  2. The equality between DEFAULT_LEGACY_ERC20_CLASS_HASH and DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH should be verified to ensure it's intentional.
  3. The new artifact paths in the lazy_static initializations should be double-checked to ensure they align with the updated build process.

These changes are significant and may have broader impacts on the system. It's crucial to ensure comprehensive testing is performed, especially around account creation and interaction, to validate the correct functioning with the new implementation.

crates/katana/primitives/src/genesis/json.rs (1)

522-531: Ohayo! The changes look solid, sensei! Just a tiny suggestion.

The renaming and introduction of the new constant DEFAULT_ACCOUNT_COMPILED_CLASS_HASH improve consistency and clarity. Great job!

Consider using a more descriptive name for the e variable in the Entry::Vacant(e) pattern. For example:

-    if let btree_map::Entry::Vacant(e) = classes.entry(DEFAULT_ACCOUNT_CLASS_HASH) {
+    if let btree_map::Entry::Vacant(entry) = classes.entry(DEFAULT_ACCOUNT_CLASS_HASH) {
         // insert default account class to the classes map
-        e.insert(GenesisClass {
+        entry.insert(GenesisClass {
             casm: Arc::new(DEFAULT_ACCOUNT_CLASS_CASM.clone()),
             sierra: Some(Arc::new(DEFAULT_ACCOUNT_CLASS.clone().flatten()?)),
             compiled_class_hash: DEFAULT_ACCOUNT_COMPILED_CLASS_HASH,
         });
     }

This small change could make the code even more readable, sensei!

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 172f45b and 076b985.

⛔ Files ignored due to path filters (1)
  • crates/katana/contracts/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (44)
  • bin/sozo/src/commands/options/account/controller.rs (1 hunks)
  • bin/sozo/tests/test_data/policies.json (1 hunks)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-world/src/metadata_test.rs (1 hunks)
  • crates/katana/contracts/.tool-versions (1 hunks)
  • crates/katana/contracts/Makefile (1 hunks)
  • crates/katana/contracts/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/src/lib.cairo (2 hunks)
  • crates/katana/contracts/messaging/cairo/Makefile (2 hunks)
  • crates/katana/contracts/messaging/cairo/account_l2.json (1 hunks)
  • crates/katana/contracts/messaging/cairo/account_l3.json (1 hunks)
  • crates/katana/contracts/messaging/l3.messaging.json (1 hunks)
  • crates/katana/contracts/messaging/solidity/Makefile (1 hunks)
  • crates/katana/controller/src/lib.rs (4 hunks)
  • crates/katana/core/src/backend/storage.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/contract.json (1 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/node-bindings/src/json.rs (1 hunks)
  • crates/katana/node-bindings/src/lib.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/primitives/src/genesis/allocation.rs (2 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (14 hunks)
  • crates/katana/primitives/src/genesis/mod.rs (14 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis.json (1 hunks)
  • crates/katana/rpc/rpc/src/starknet/write.rs (1 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (2 hunks)
  • crates/katana/rpc/rpc/tests/test_data/erc20.json (1 hunks)
  • crates/katana/storage/provider/test-data/simple_account.sierra.json (1 hunks)
  • crates/katana/storage/provider/tests/class.rs (3 hunks)
  • crates/katana/storage/provider/tests/fixtures.rs (2 hunks)
  • crates/torii/types-test/dojo_dev.toml (1 hunks)
  • examples/rpc/starknet/starknet_getClass.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassHashAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getNonce.hurl (1 hunks)
  • examples/spawn-and-move/README.md (2 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
  • examples/spawn-and-move/dojo_release.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/katana/contracts/.tool-versions
🚧 Files skipped from review as they are similar to previous changes (35)
  • bin/sozo/src/commands/options/account/controller.rs
  • bin/sozo/tests/test_data/policies.json
  • crates/benches/contracts/Scarb.toml
  • crates/dojo-world/src/metadata_test.rs
  • crates/katana/contracts/Makefile
  • crates/katana/contracts/messaging/cairo/Makefile
  • crates/katana/contracts/messaging/cairo/account_l2.json
  • crates/katana/contracts/messaging/cairo/account_l3.json
  • crates/katana/contracts/messaging/l3.messaging.json
  • crates/katana/contracts/messaging/solidity/Makefile
  • crates/katana/controller/src/lib.rs
  • crates/katana/core/src/backend/storage.rs
  • crates/katana/executor/tests/executor.rs
  • crates/katana/executor/tests/fixtures/contract.json
  • crates/katana/executor/tests/fixtures/mod.rs
  • crates/katana/node-bindings/src/json.rs
  • crates/katana/node-bindings/src/lib.rs
  • crates/katana/primitives/src/conversion/rpc.rs
  • crates/katana/primitives/src/genesis/mod.rs
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json
  • crates/katana/rpc/rpc/src/starknet/write.rs
  • crates/katana/rpc/rpc/tests/starknet.rs
  • crates/katana/rpc/rpc/tests/test_data/erc20.json
  • crates/katana/storage/provider/test-data/simple_account.sierra.json
  • crates/katana/storage/provider/tests/class.rs
  • crates/katana/storage/provider/tests/fixtures.rs
  • crates/torii/types-test/dojo_dev.toml
  • examples/rpc/starknet/starknet_getClass.hurl
  • examples/rpc/starknet/starknet_getClassAt.hurl
  • examples/rpc/starknet/starknet_getClassHashAt.hurl
  • examples/rpc/starknet/starknet_getNonce.hurl
  • examples/spawn-and-move/README.md
  • examples/spawn-and-move/dojo_dev.toml
  • examples/spawn-and-move/dojo_release.toml
🧰 Additional context used
🔇 Additional comments (20)
crates/katana/contracts/Scarb.toml (2)

12-12: Ohayo! OpenZeppelin version update looks good, sensei!

The openzeppelin dependency has been updated to v0.15.1 as mentioned in the PR objectives. This should support transaction versions greater than 1, which addresses the main goal of this PR.


13-13: Ohayo! Consider impact of snforge_std downgrade, sensei.

The snforge_std dependency has been downgraded from v0.31.0 to v0.26.0. While this aligns with the overall downgrade pattern, we should verify if this version is compatible with the other changes and doesn't introduce any issues.

crates/katana/contracts/account/src/lib.cairo (1)

2-2: Ohayo sensei! Verify the version downgrade intention.

The version comment has been updated from v0.17.0 to v0.15.1, which appears to be a downgrade. While this aligns with the PR objectives, it's important to ensure this change is intentional and to consider any potential impacts on functionality or compatibility.

Could you please confirm if this downgrade is intentional and if there are any specific reasons for choosing v0.15.1 over v0.17.0? Also, have you considered any potential impacts on the existing codebase?

crates/katana/primitives/src/genesis/test-genesis.json (1)

2-10: Ohayo! Initial configuration looks good, sensei!

The basic configuration for the genesis block is well-structured and contains all the necessary information.

crates/katana/primitives/src/genesis/constant.rs (6)

20-24: Ohayo, sensei! LGTM on this constant rename.

The renaming of OZ_ACCOUNT_CONTRACT_PUBKEY_STORAGE_SLOT to DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT is a good move. It generalizes the constant name, removing the specific reference to OpenZeppelin (OZ) while maintaining its functionality. This change aligns well with the PR's objective of updating the default predeployed account class implementation.


55-57: Ohayo again, sensei! This rename looks good too.

The constant DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH has been simplified to DEFAULT_LEGACY_ERC20_CLASS_HASH. This change maintains consistency in naming conventions across the codebase while removing the redundant "CONTRACT" term. Nice work on keeping things clean and consistent!


70-72: Ohayo, sensei! This update looks significant.

The constant DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH has been renamed to DEFAULT_ACCOUNT_CLASS_HASH, which aligns with the PR's objective of updating the default predeployed account class implementation. The new value (0x06599b8b9b4b4d65da09c8f5bede6046908452fa8e112d6ad4a2f979a5e65bbd) likely corresponds to the updated OpenZeppelin account implementation. This change is crucial as it introduces a breaking change in the account class hash, which will affect generated account addresses.


74-76: Ohayo again, sensei! This change complements the previous one nicely.

The constant DEFAULT_OZ_ACCOUNT_CONTRACT_COMPILED_CLASS_HASH has been renamed to DEFAULT_ACCOUNT_COMPILED_CLASS_HASH, maintaining consistency with the previous rename. The new value (0x0138105ded3d2e4ea1939a0bc106fb80fd8774c9eb89c1890d4aeac88e6a1b27) corresponds to the compiled version of the updated account class. This change is essential for ensuring that the compiled class hash matches the new account implementation.


78-80: Ohayo, sensei! Another clean rename here.

The constant CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH has been simplified to CONTROLLER_CLASS_HASH. This change maintains consistency with the other renames in this PR, removing redundant terms like "ACCOUNT" and "CONTRACT". It's a small change, but it contributes to a more consistent and cleaner codebase. Good job!


87-94: Ohayo, sensei! These lazy_static updates look good, but let's double-check something.

The lazy_static initializations have been updated to use artifacts from the "build" directory instead of "compiled". This change likely reflects updates in the build process or project structure. The new paths for DEFAULT_ACCOUNT_CLASS, DEFAULT_ACCOUNT_CLASS_CASM, CONTROLLER_ACCOUNT_CLASS, and CONTROLLER_ACCOUNT_CLASS_CASM align with the updated account implementation mentioned in the PR objectives.

However, it's important to verify that these new paths are correct and that the build process is updated accordingly.

Also applies to: 100-101

✅ Verification successful

Ohayo, sensei! All the new artifact paths have been verified and are correct. Great work!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the new artifact files
fd -e json -p "contracts/build/(erc20|universal_deployer|default_account|controller_CartridgeAccount).*.json"

Length of output: 335

crates/katana/primitives/src/genesis/allocation.rs (1)

236-236: Ohayo again, sensei! The DevAllocationsGenerator update looks solid.

The change to use DEFAULT_ACCOUNT_CLASS_HASH in the DevAllocationsGenerator::new method is consistent with the constant renaming and aligns with the PR objectives. This ensures that the generator uses the updated account class hash.

crates/katana/executor/src/implementation/blockifier/state.rs (4)

Line range hint 1-557: Ohayo, sensei! Here's a summary of our review journey.

The changes in this file are well-aligned with the PR objectives to update the default predeployed account class implementation. Here's a quick recap:

  1. Constants have been renamed for better clarity.
  2. The contract JSON file path has been updated.
  3. Test functions have been updated to use the new constants.

These changes contribute to improved code readability and maintainability. The verification steps I've suggested will help ensure consistency across the codebase.

Great work on keeping the tests up-to-date with the changes!


265-266: Ohayo once more, sensei! The test updates look solid.

The test functions have been correctly updated to use the new constants, which is crucial for maintaining the integrity of the test suite.

Let's ensure all relevant tests have been updated:

#!/bin/bash
# Search for any remaining occurrences of the old constant names in test files
rg "DEFAULT_OZ_ACCOUNT_CONTRACT_CASM|DEFAULT_LEGACY_ERC20_CONTRACT_CASM" --type rust --glob "**/tests/**"

Also applies to: 268-268, 307-307, 311-311, 410-412


251-251: Ohayo again, sensei! The contract JSON path looks good.

The update to the contract JSON file path is consistent with the changes in the account class implementation.

Let's verify the existence and content of the new JSON file:

#!/bin/bash
# Check if the file exists and display its content
cat crates/katana/contracts/build/cairo1_contract.json

237-238: Ohayo, sensei! LGTM on the constant updates.

The renaming of constants to DEFAULT_ACCOUNT_CLASS_CASM and DEFAULT_LEGACY_ERC20_CASM is more descriptive and aligns well with the PR objectives.

To ensure consistency, let's verify the usage of these new constants across the codebase:

✅ Verification successful

Ohayo, sensei! 🐰

Let's ensure the old constants aren't used elsewhere by searching the entire codebase:


Ohayo, sensei! 🐰

LGTM! The old constants are only present in comments and are not actively used in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining occurrences of the old constant names
rg "DEFAULT_OZ_ACCOUNT_CONTRACT_CASM|DEFAULT_LEGACY_ERC20_CONTRACT_CASM" --type rust

Length of output: 107


Script:

#!/bin/bash
# Search for any remaining occurrences of the old constant names across the entire codebase
rg "DEFAULT_OZ_ACCOUNT_CONTRACT_CASM|DEFAULT_LEGACY_ERC20_CONTRACT_CASM" --type rust

Length of output: 524

crates/katana/primitives/src/genesis/json.rs (5)

29-32: Ohayo! LGTM, sensei! The constant renaming looks great.

The renaming of constants from "CONTRACT" to "CLASS" improves clarity and consistency. It better reflects that these are class-related constants rather than contract-specific ones.


887-895: Ohayo! These changes look great, sensei!

The updates to use the new DEFAULT_ACCOUNT_* constants are consistent with the renaming pattern we've seen throughout the file. This improves code consistency and readability.


806-806: Ohayo! Another path change to verify, sensei.

The path to the universal deployer contract JSON file has been updated. Let's make sure this new path is correct.

#!/bin/bash
# Verify the existence of the universal deployer contract JSON file
if [ -f "../../../contracts/build/universal_deployer.json" ]; then
    echo "The universal deployer contract JSON file exists at the specified path."
else
    echo "Warning: The universal deployer contract JSON file does not exist at the specified path."
fi

811-811: Ohayo! One more path to check, sensei.

The path to the default account contract JSON file has been updated. Let's verify this new path as well.

#!/bin/bash
# Verify the existence of the default account contract JSON file
if [ -f "../../../contracts/build/default_account.json" ]; then
    echo "The default account contract JSON file exists at the specified path."
else
    echo "Warning: The default account contract JSON file does not exist at the specified path."
fi

900-904: Ohayo! Interesting addition here, sensei!

The introduction of the controller class with the "slot" feature looks good. It's well-structured and consistent with the naming conventions used elsewhere in the file.

Could you provide more information about the "slot" feature? It would be helpful to understand:

  1. What does the "slot" feature do?
  2. Are there any specific testing requirements for code under this feature flag?
  3. Is there documentation for this new feature that should be updated?

Also, let's check if this new class is referenced elsewhere in the codebase:

#!/bin/bash
# Search for references to the new controller class
echo "Searching for references to CONTROLLER_CLASS_HASH:"
rg "CONTROLLER_CLASS_HASH" --type rust

echo "\nSearching for references to CONTROLLER_ACCOUNT_CLASS_CASM:"
rg "CONTROLLER_ACCOUNT_CLASS_CASM" --type rust

echo "\nSearching for references to CONTROLLER_ACCOUNT_CLASS:"
rg "CONTROLLER_ACCOUNT_CLASS" --type rust

This will help ensure that the new class is properly integrated into the codebase, sensei.

crates/katana/contracts/Scarb.toml Outdated Show resolved Hide resolved
crates/katana/contracts/account/src/lib.cairo Outdated Show resolved Hide resolved
crates/katana/contracts/account/src/lib.cairo Outdated Show resolved Hide resolved
crates/katana/primitives/src/genesis/json.rs Show resolved Hide resolved
@kariy kariy force-pushed the katana/update-default-account branch from 076b985 to 6bcf4a0 Compare October 13, 2024 03:12
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: 6

🧹 Outside diff range and nitpick comments (2)
crates/katana/primitives/src/genesis/test-genesis.json (1)

53-71: Ohayo, sensei! Let's bring harmony to our contracts!

The expansion of the contracts section is a great improvement. However, there are some inconsistencies in the structure of different contract entries that we should address:

  1. The contract ending with ...2a4f9b1b1ec683c503a2cf5c8a only has a balance field.
  2. Other contracts have additional fields like class and storage.

Consider standardizing the contract entries to ensure consistency across all contracts. This will make the configuration more maintainable and less prone to errors.

Would you like assistance in creating a standardized structure for the contract entries?

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

Line range hint 251-255: Ohayo! The new contract looks good, sensei!

The update to use a new JSON file for the Cairo 1 contract is in line with the PR objectives. This change ensures that the tests are using the latest contract implementation.

Consider adding a comment explaining the purpose of this new contract file, e.g.:

+// Load the latest Cairo 1 contract for testing the updated account implementation
 let json = include_str!("../../../../contracts/build/cairo1_contract.json");
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 076b985 and 6bcf4a0.

⛔ Files ignored due to path filters (1)
  • crates/katana/contracts/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (44)
  • bin/sozo/src/commands/options/account/controller.rs (1 hunks)
  • bin/sozo/tests/test_data/policies.json (1 hunks)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-world/src/metadata_test.rs (1 hunks)
  • crates/katana/contracts/.tool-versions (1 hunks)
  • crates/katana/contracts/Makefile (1 hunks)
  • crates/katana/contracts/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/src/lib.cairo (2 hunks)
  • crates/katana/contracts/messaging/cairo/Makefile (2 hunks)
  • crates/katana/contracts/messaging/cairo/account_l2.json (1 hunks)
  • crates/katana/contracts/messaging/cairo/account_l3.json (1 hunks)
  • crates/katana/contracts/messaging/l3.messaging.json (1 hunks)
  • crates/katana/contracts/messaging/solidity/Makefile (1 hunks)
  • crates/katana/controller/src/lib.rs (4 hunks)
  • crates/katana/core/src/backend/storage.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/contract.json (1 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/node-bindings/src/json.rs (1 hunks)
  • crates/katana/node-bindings/src/lib.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/primitives/src/genesis/allocation.rs (2 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (14 hunks)
  • crates/katana/primitives/src/genesis/mod.rs (14 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis.json (1 hunks)
  • crates/katana/rpc/rpc/src/starknet/write.rs (1 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (2 hunks)
  • crates/katana/rpc/rpc/tests/test_data/erc20.json (1 hunks)
  • crates/katana/storage/provider/test-data/simple_account.sierra.json (1 hunks)
  • crates/katana/storage/provider/tests/class.rs (3 hunks)
  • crates/katana/storage/provider/tests/fixtures.rs (2 hunks)
  • crates/torii/types-test/dojo_dev.toml (1 hunks)
  • examples/rpc/starknet/starknet_getClass.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassHashAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getNonce.hurl (1 hunks)
  • examples/spawn-and-move/README.md (2 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
  • examples/spawn-and-move/dojo_release.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (40)
  • bin/sozo/src/commands/options/account/controller.rs
  • bin/sozo/tests/test_data/policies.json
  • crates/benches/contracts/Scarb.toml
  • crates/dojo-world/src/metadata_test.rs
  • crates/katana/contracts/.tool-versions
  • crates/katana/contracts/Makefile
  • crates/katana/contracts/Scarb.toml
  • crates/katana/contracts/account/Scarb.toml
  • crates/katana/contracts/account/src/lib.cairo
  • crates/katana/contracts/messaging/cairo/Makefile
  • crates/katana/contracts/messaging/cairo/account_l2.json
  • crates/katana/contracts/messaging/cairo/account_l3.json
  • crates/katana/contracts/messaging/l3.messaging.json
  • crates/katana/contracts/messaging/solidity/Makefile
  • crates/katana/controller/src/lib.rs
  • crates/katana/core/src/backend/storage.rs
  • crates/katana/executor/tests/executor.rs
  • crates/katana/executor/tests/fixtures/contract.json
  • crates/katana/executor/tests/fixtures/mod.rs
  • crates/katana/node-bindings/src/json.rs
  • crates/katana/node-bindings/src/lib.rs
  • crates/katana/primitives/src/conversion/rpc.rs
  • crates/katana/primitives/src/genesis/allocation.rs
  • crates/katana/primitives/src/genesis/mod.rs
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json
  • crates/katana/rpc/rpc/src/starknet/write.rs
  • crates/katana/rpc/rpc/tests/starknet.rs
  • crates/katana/rpc/rpc/tests/test_data/erc20.json
  • crates/katana/storage/provider/test-data/simple_account.sierra.json
  • crates/katana/storage/provider/tests/class.rs
  • crates/katana/storage/provider/tests/fixtures.rs
  • crates/torii/types-test/dojo_dev.toml
  • examples/rpc/starknet/starknet_getClass.hurl
  • examples/rpc/starknet/starknet_getClassAt.hurl
  • examples/rpc/starknet/starknet_getClassHashAt.hurl
  • examples/rpc/starknet/starknet_getNonce.hurl
  • examples/spawn-and-move/README.md
  • examples/spawn-and-move/dojo_dev.toml
  • examples/spawn-and-move/dojo_release.toml
🧰 Additional context used
🔇 Additional comments (12)
crates/katana/primitives/src/genesis/test-genesis.json (2)

2-27: Ohayo, sensei! The new sections look promising!

The addition of the feeToken and universalDeployer sections aligns well with the PR objectives of updating default predeployed accounts. The feeToken section provides comprehensive details about the fee token, which is excellent.

However, I'm curious about the universalDeployer section. Could you please provide more information about its purpose and how it relates to the updated account implementation?


72-86: Ohayo, sensei! The new classes section is a welcome addition!

The introduction of the classes section is a great improvement and aligns well with the PR objectives of updating the account implementation. It provides clear references to the class definitions, which will enhance maintainability.

I noticed that some paths have changed from compiled to build directories. For example:

"class": "../../../contracts/build/erc20.json",

Could you please clarify the reason for this change? Has there been an update to the build process or file organization that we should be aware of?

crates/katana/executor/src/implementation/blockifier/state.rs (3)

237-238: Ohayo! LGTM on the constant updates, sensei!

The renaming of constants to more generic names (e.g., DEFAULT_ACCOUNT_CLASS_CASM instead of DEFAULT_OZ_ACCOUNT_CONTRACT_CASM) aligns well with the PR objectives to update the default predeployed account class implementation. This change promotes flexibility and reduces coupling to specific implementations.


307-307: Ohayo! The test assertions are on point, sensei!

The updates to the assertions using the new constant names (DEFAULT_ACCOUNT_CLASS_CASM, DEFAULT_ACCOUNT_CLASS, DEFAULT_LEGACY_ERC20_CASM) are consistent with the earlier changes. These updates ensure that the tests are validating against the correct, updated account implementation.

To ensure the changes haven't introduced any regressions, it would be wise to run the full test suite:

#!/bin/bash
# Run the full test suite
cargo test --all-features

This will help verify that all tests pass with the updated constants and implementations.

Also applies to: 311-311, 410-412


265-266: Ohayo! The state provider setup looks solid, sensei!

The updates to use the new constant names (DEFAULT_ACCOUNT_CLASS, DEFAULT_ACCOUNT_CLASS_CASM, DEFAULT_LEGACY_ERC20_CASM) are consistent with the earlier changes and ensure that the test setup uses the updated account implementation.

To ensure that these changes haven't inadvertently affected other parts of the codebase, let's verify the usage of these constants:

Also applies to: 268-268

✅ Verification successful

Ohayo! The state provider setup looks solid, sensei!

The search results show that all instances of the old constant names (DEFAULT_OZ_ACCOUNT_CONTRACT_CASM, DEFAULT_LEGACY_ERC20_CONTRACT_CASM) are confined to comments within crates/katana/primitives/src/genesis/constant.rs. This confirms that there are no remaining active references, and the updates have been correctly applied.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining uses of the old constant names
rg "DEFAULT_OZ_ACCOUNT_CONTRACT_CASM|DEFAULT_LEGACY_ERC20_CONTRACT_CASM" --type rust

Length of output: 704

crates/katana/primitives/src/genesis/constant.rs (5)

20-23: Ohayo, sensei! Great job generalizing the constant name.

The constant OZ_ACCOUNT_CONTRACT_PUBKEY_STORAGE_SLOT has been renamed to DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT, which enhances the clarity and reusability of the code by removing the specific reference to OpenZeppelin. This makes the codebase more maintainable.


55-60: Ensure the correctness of compiled class hashes.

Assigning DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH might not be intentional. Typically, compiled class hashes should differ from class hashes to uniquely identify compiled entities.

Ohayo once more, sensei! 🐰✨

As previously noted, please verify if assigning the compiled class hash to the class hash is intentional. If not, consider updating DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH with the correct compiled class hash value.


78-79: Renamed CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH.

The constant has been appropriately renamed to reflect a more generalized naming convention. This improves code consistency.


93-94: Consistency in loading default_account.json for Sierra and CASM classes.

Both DEFAULT_ACCOUNT_CLASS and DEFAULT_ACCOUNT_CLASS_CASM are loading from "../../../contracts/build/default_account.json". While this may be intentional, typically, the Sierra class should be loaded from a .sierra.json file and the CASM class from a .casm.json file to distinguish between the different representations.

Ohayo, sensei! Please verify if both references to default_account.json are correct. If different files are intended for Sierra and CASM, consider updating the file names accordingly.


70-76: Updated class hashes for the default account class.

The class hash and compiled class hash for DEFAULT_ACCOUNT_CLASS have been updated. Please ensure that all dependent contracts and references are updated accordingly to prevent any discrepancies at runtime.

To verify the impact of these changes, you can run the following script:

This will help identify any areas that may require updates due to the new class hash values.

✅ Verification successful

All Class Hash Updates Verified

ohayo, sensei! I've verified that DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_ACCOUNT_COMPILED_CLASS_HASH have been consistently updated across the codebase. No discrepancies detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all occurrences of DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_ACCOUNT_COMPILED_CLASS_HASH in the codebase.

rg --type rust "DEFAULT_ACCOUNT_CLASS_HASH|DEFAULT_ACCOUNT_COMPILED_CLASS_HASH" -A 2

Length of output: 10154

crates/katana/primitives/src/genesis/json.rs (2)

29-31: Ohayo, sensei! Constants imported correctly under feature flag

The import of CONTROLLER_ACCOUNT_CLASS, CONTROLLER_ACCOUNT_CLASS_CASM, and CONTROLLER_CLASS_HASH under the #[cfg(feature = "slot")] feature is appropriate and maintains conditional compilation integrity.


327-331: Ohayo, sensei! Proper insertion of controller class into classes map

The insertion of the controller class into the classes map under the #[cfg(feature = "slot")] condition is correctly implemented.

@kariy kariy force-pushed the katana/update-default-account branch from 6bcf4a0 to 4d99a79 Compare October 13, 2024 23:03
@dojoengine dojoengine deleted a comment from coderabbitai bot Oct 13, 2024
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: 5

🧹 Outside diff range and nitpick comments (4)
crates/katana/primitives/src/genesis/test-genesis.json (1)

22-27: Ohayo, sensei! The universalDeployer section is a welcome addition!

The new universalDeployer section is a great addition to the genesis configuration. It provides the necessary information for initializing the universal deployer contract.

To improve clarity, consider adding a comment or documentation explaining the purpose and significance of the universal deployer in the system. This would help other developers understand its role more easily.

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

92-95: Ohayo! Great update on the sender_address, sensei!

The new address aligns with the changes mentioned in the PR summary. The added comment provides valuable context about the address's origin.

Consider enhancing the comment slightly for even more clarity:

- // one of the accounts that is generated by the `genesis` fixture. also one of the
- // accounts generated by katana.
+ // This address represents one of the accounts generated by both the `genesis` fixture
+ // and the Katana framework.

200-200: Ohayo! Nice touch using the constant for the ERC20 class hash, sensei!

The use of DEFAULT_LEGACY_ERC20_CLASS_HASH instead of a hardcoded value is a great improvement. It enhances code maintainability and reduces the risk of errors.

To further improve code readability, consider adding a comment explaining the purpose of this constant in the context of the UDC deployment:

- DEFAULT_LEGACY_ERC20_CLASS_HASH, // class hash
+ DEFAULT_LEGACY_ERC20_CLASS_HASH, // class hash for the ERC20 contract to be deployed
crates/katana/primitives/src/genesis/json.rs (1)

434-438: Ohayo, sensei! The legacy ERC20 constants are now in use.

The switch to using DEFAULT_LEGACY_ERC20_CLASS_HASH, DEFAULT_LEGACY_ERC20_CASM, and DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH appears to be part of a larger refactoring effort. This change is consistent with the previous modification we observed.

Consider updating the documentation or adding comments to explain the rationale behind switching to these legacy ERC20 constants, if not already done elsewhere in the codebase.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6bcf4a0 and 4d99a79.

⛔ Files ignored due to path filters (1)
  • crates/katana/contracts/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (44)
  • bin/sozo/src/commands/options/account/controller.rs (1 hunks)
  • bin/sozo/tests/test_data/policies.json (1 hunks)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-world/src/metadata_test.rs (1 hunks)
  • crates/katana/contracts/.tool-versions (1 hunks)
  • crates/katana/contracts/Makefile (1 hunks)
  • crates/katana/contracts/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/src/lib.cairo (2 hunks)
  • crates/katana/contracts/messaging/cairo/Makefile (2 hunks)
  • crates/katana/contracts/messaging/cairo/account_l2.json (1 hunks)
  • crates/katana/contracts/messaging/cairo/account_l3.json (1 hunks)
  • crates/katana/contracts/messaging/l3.messaging.json (1 hunks)
  • crates/katana/contracts/messaging/solidity/Makefile (1 hunks)
  • crates/katana/controller/src/lib.rs (4 hunks)
  • crates/katana/core/src/backend/storage.rs (4 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/contract.json (1 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/node-bindings/src/json.rs (1 hunks)
  • crates/katana/node-bindings/src/lib.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/primitives/src/genesis/allocation.rs (2 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (14 hunks)
  • crates/katana/primitives/src/genesis/mod.rs (14 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis.json (1 hunks)
  • crates/katana/rpc/rpc/src/starknet/write.rs (1 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (4 hunks)
  • crates/katana/rpc/rpc/tests/test_data/erc20.json (1 hunks)
  • crates/katana/storage/provider/test-data/simple_account.sierra.json (1 hunks)
  • crates/katana/storage/provider/tests/class.rs (3 hunks)
  • crates/katana/storage/provider/tests/fixtures.rs (2 hunks)
  • crates/torii/types-test/dojo_dev.toml (1 hunks)
  • examples/rpc/starknet/starknet_getClass.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassHashAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getNonce.hurl (1 hunks)
  • examples/spawn-and-move/README.md (2 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
  • examples/spawn-and-move/dojo_release.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • crates/katana/core/src/backend/storage.rs
🚧 Files skipped from review as they are similar to previous changes (39)
  • bin/sozo/src/commands/options/account/controller.rs
  • bin/sozo/tests/test_data/policies.json
  • crates/benches/contracts/Scarb.toml
  • crates/dojo-world/src/metadata_test.rs
  • crates/katana/contracts/.tool-versions
  • crates/katana/contracts/Makefile
  • crates/katana/contracts/Scarb.toml
  • crates/katana/contracts/account/Scarb.toml
  • crates/katana/contracts/account/src/lib.cairo
  • crates/katana/contracts/messaging/cairo/Makefile
  • crates/katana/contracts/messaging/cairo/account_l2.json
  • crates/katana/contracts/messaging/cairo/account_l3.json
  • crates/katana/contracts/messaging/l3.messaging.json
  • crates/katana/contracts/messaging/solidity/Makefile
  • crates/katana/controller/src/lib.rs
  • crates/katana/executor/src/implementation/blockifier/state.rs
  • crates/katana/executor/tests/executor.rs
  • crates/katana/executor/tests/fixtures/contract.json
  • crates/katana/node-bindings/src/json.rs
  • crates/katana/node-bindings/src/lib.rs
  • crates/katana/primitives/src/conversion/rpc.rs
  • crates/katana/primitives/src/genesis/allocation.rs
  • crates/katana/primitives/src/genesis/mod.rs
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json
  • crates/katana/rpc/rpc/src/starknet/write.rs
  • crates/katana/rpc/rpc/tests/starknet.rs
  • crates/katana/rpc/rpc/tests/test_data/erc20.json
  • crates/katana/storage/provider/test-data/simple_account.sierra.json
  • crates/katana/storage/provider/tests/class.rs
  • crates/katana/storage/provider/tests/fixtures.rs
  • crates/torii/types-test/dojo_dev.toml
  • examples/rpc/starknet/starknet_getClass.hurl
  • examples/rpc/starknet/starknet_getClassAt.hurl
  • examples/rpc/starknet/starknet_getClassHashAt.hurl
  • examples/rpc/starknet/starknet_getNonce.hurl
  • examples/spawn-and-move/README.md
  • examples/spawn-and-move/dojo_dev.toml
  • examples/spawn-and-move/dojo_release.toml
🧰 Additional context used
🔇 Additional comments (18)
crates/katana/primitives/src/genesis/test-genesis.json (3)

2-10: Ohayo, sensei! The initial block information looks solid!

The configuration for the genesis block's basic information is well-structured and includes all necessary fields. Great job maintaining consistency in this section!


11-21: Ohayo, sensei! Excellent addition of the feeToken configuration!

The new feeToken section is a great enhancement to the genesis configuration. It provides a clear and comprehensive setup for the fee token, including its address, metadata, and initial storage state. This addition will greatly improve the flexibility and clarity of fee handling in the system.


1-86: Ohayo, sensei! Let's wrap up this epic genesis update!

Overall, the changes to the test-genesis.json file are impressive and align well with the PR objectives of updating default predeployed accounts. Here's a summary of the key improvements:

  1. Addition of feeToken and universalDeployer sections, enhancing the configuration capabilities.
  2. Expansion of the accounts and contracts sections with detailed properties.
  3. Introduction of a new classes section, providing clear references to class definitions.

These changes significantly improve the comprehensiveness and flexibility of the genesis block configuration. However, there are a few points to consider:

  1. Standardizing the structure of account and contract entries would improve maintainability.
  2. Clarification on the purpose of the universalDeployer and the changes in class file paths would be helpful.
  3. Ensure all referenced class files exist in the specified locations.

Great work on this update, sensei! With a few minor adjustments, this will be a solid improvement to the Katana framework.

crates/katana/primitives/src/genesis/constant.rs (6)

20-23: Ohayo, sensei! Nice rename for consistency.

The renaming of OZ_ACCOUNT_CONTRACT_PUBKEY_STORAGE_SLOT to DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT aligns well with the PR's objective of updating the default predeployed account class implementation. This change makes the constant more generic and removes the specific reference to OpenZeppelin.


70-76: Ohayo, sensei! These changes align perfectly with our objectives.

The renaming of DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH to DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_OZ_ACCOUNT_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_ACCOUNT_COMPILED_CLASS_HASH is consistent with the PR objectives. The update of the hash values reflects the breaking change mentioned in the PR summary due to the new implementation.

These changes contribute to a more generalized naming convention and update the system to use the new account implementation.


78-79: Ohayo, sensei! Nice simplification of the constant name.

The renaming of CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH is consistent with the other changes in this file. It simplifies the constant name while still clearly conveying its purpose. Good job on maintaining consistency throughout the codebase!


87-94: Ohayo, sensei! These updates look good, but let's verify the new paths.

The changes to the file paths in the include_str! macros and the introduction of read_compiled_class_artifact function suggest a reorganization of the project structure or build process. The addition of DEFAULT_ACCOUNT_CLASS and DEFAULT_ACCOUNT_CLASS_CASM aligns well with the PR objectives.

Could you please confirm that the new paths ("../../../contracts/build/") are correct and that the referenced files exist in these locations?

#!/bin/bash
# Description: Check if the referenced files exist in the new locations
for file in erc20.json universal_deployer.json default_account.json; do
  if [ -f "../../../contracts/build/$file" ]; then
    echo "File $file exists in the new location."
  else
    echo "File $file does not exist in the new location."
  fi
done

100-101: Ohayo, sensei! The controller account class updates look good.

The changes to CONTROLLER_ACCOUNT_CLASS and CONTROLLER_ACCOUNT_CLASS_CASM are consistent with the updates made to other lazy_static! initializations. The use of read_compiled_class_artifact aligns well with the changes made earlier in the file.

Could you please verify that the file "controller_CartridgeAccount.contract_class.json" exists in the new "../../../contracts/build/" directory?

#!/bin/bash
# Description: Check if the controller_CartridgeAccount.contract_class.json file exists in the new location
if [ -f "../../../contracts/build/controller_CartridgeAccount.contract_class.json" ]; then
  echo "File controller_CartridgeAccount.contract_class.json exists in the new location."
else
  echo "File controller_CartridgeAccount.contract_class.json does not exist in the new location."
fi

55-60: Ohayo, sensei! The rename looks good, but let's double-check something.

The renaming of DEFAULT_LEGACY_ERC20_CONTRACT_CLASS_HASH to DEFAULT_LEGACY_ERC20_CLASS_HASH and DEFAULT_LEGACY_ERC20_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH is consistent with the other changes. However, I noticed that DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH is now set to DEFAULT_LEGACY_ERC20_CLASS_HASH.

Could you please verify if this is intentional? Typically, the compiled class hash and the class hash are different values.

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

15-17: Ohayo! Nice work on updating the imports, sensei!

The changes in the import statements align well with the PR objectives. The addition of DEFAULT_ACCOUNT_CLASS_HASH and the renaming of DEFAULT_LEGACY_ERC20_CLASS_HASH improve clarity and consistency in the codebase.


171-171: Ohayo! Excellent update to the account class hash, sensei!

The use of DEFAULT_ACCOUNT_CLASS_HASH for the class_hash field in DeployAccountTxV1 is a significant improvement. This change:

  1. Aligns perfectly with the PR's objective of updating the default predeployed account class.
  2. Enhances code maintainability by using a constant instead of a hardcoded value.
  3. Ensures consistency across the codebase when referring to the default account class hash.

Great job on implementing this crucial update!

crates/katana/primitives/src/genesis/json.rs (7)

327-331: Ohayo, sensei! The constant usage has been updated correctly.

The changes in this segment accurately reflect the new constant names. The logic remains intact, ensuring that the functionality is preserved while improving code clarity.


522-527: Ohayo, sensei! The account class constants have been updated correctly.

The changes in this segment accurately reflect the new constant names for the account class. The logic remains intact, and the updates are consistent with the renaming pattern we observed earlier in the file.


893-895: Ohayo, sensei! The account class constants are consistently updated here as well.

The use of DEFAULT_ACCOUNT_COMPILED_CLASS_HASH, DEFAULT_ACCOUNT_CLASS_CASM, and DEFAULT_ACCOUNT_CLASS in this segment is in line with the renaming pattern we've seen throughout the file. The functionality remains the same, but the code is now more consistent and clear.


900-904: Ohayo, sensei! The controller class constants have been updated consistently.

The use of CONTROLLER_CLASS_HASH, CONTROLLER_ACCOUNT_CLASS_CASM, and CONTROLLER_ACCOUNT_CLASS in this segment aligns perfectly with the renaming pattern we observed earlier in the file. The functionality is preserved while improving the overall consistency of the codebase.


Line range hint 1-1241: Ohayo, sensei! Great job on this refactoring effort!

The changes in this file primarily involve renaming constants and updating their usage throughout the code. Here's a summary of the improvements:

  1. Constants have been renamed to be more descriptive and consistent (e.g., CONTROLLER_ACCOUNT_CONTRACT to CONTROLLER_ACCOUNT_CLASS).
  2. The usage of these constants has been updated consistently throughout the file, including in test cases.
  3. Some constants related to legacy ERC20 functionality have been introduced or updated.

These changes improve code readability and maintain consistency with what appears to be an updated implementation. The logic of the code remains unchanged, reducing the risk of introducing new bugs.

To ensure a smooth transition, please consider the following:

  1. Update any documentation that might reference the old constant names.
  2. Verify that these changes are reflected in any other files that might use these constants.
  3. Consider adding comments explaining the rationale behind switching to legacy ERC20 constants in some places.

Overall, this refactoring enhances the maintainability of the codebase. Excellent work, sensei!


409-409: Ohayo, sensei! Could you clarify this change?

The constant DEFAULT_LEGACY_ERC20_CLASS_HASH is now used instead of what I assume was previously DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH. This change seems different from the renaming pattern observed earlier. Could you please confirm if this is intentional?

Let's check the context of this change:

#!/bin/bash
# Description: Check the context of the DEFAULT_LEGACY_ERC20_CLASS_HASH usage
rg "DEFAULT_LEGACY_ERC20_CLASS_HASH" --type rust -C 5

Line range hint 1101-1132: Ohayo, sensei! The constant updates are consistent throughout the test cases.

The changes in this segment reflect the new constant names we've seen throughout the file. It's great to see that the test cases have been updated to maintain consistency with the production code.

To ensure we haven't missed any instances, let's run a final check for any remaining old constant names:

#!/bin/bash
# Description: Final check for any remaining old constant names
old_constants=(
  "DEFAULT_OZ_ACCOUNT_CONTRACT"
  "DEFAULT_OZ_ACCOUNT_CONTRACT_CASM"
  "DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH"
  "CONTROLLER_ACCOUNT_CONTRACT"
  "CONTROLLER_ACCOUNT_CONTRACT_CASM"
  "CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH"
)

for const in "${old_constants[@]}"; do
  echo "Searching for $const..."
  rg "$const" --type rust
done

Copy link

coderabbitai bot commented Oct 13, 2024

Walkthrough

Ohayo, sensei! This pull request includes updates to an account address across various files, specifically changing the address from 0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03 to 0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba. Additionally, the version of the scarb tool has been downgraded from 2.8.3 to 2.8.2. Various constants and configuration settings related to the account address have also been updated for consistency.

Changes

File(s) Change Summary
bin/sozo/tests/test_data/policies.json Updated account address in method signature.
crates/benches/contracts/Scarb.toml Updated account address in tool environment variable.
crates/katana/contracts/messaging/cairo/Makefile Updated account address variables.
crates/katana/contracts/messaging/cairo/account_l2.json Updated address field in deployment section.
crates/katana/contracts/messaging/cairo/account_l3.json Updated address field in deployment section.
crates/katana/contracts/messaging/solidity/Makefile Updated account address variable.
crates/torii/types-test/dojo_dev.toml Updated account address in environment variable.
examples/spawn-and-move/dojo_dev.toml Updated account address in environment variable.
examples/spawn-and-move/dojo_release.toml Updated account address in environment variable.
crates/katana/contracts/.tool-versions Downgraded version of scarb tool.
bin/sozo/tests/test_data/compiled_contracts/test_contract.json Updated path for compiled contract and modified sierra_program and abi sections.
crates/katana/contracts/messaging/l3.messaging.json Updated sender_address.
crates/katana/node-bindings/src/json.rs Updated example JSON string.
examples/rpc/starknet/starknet_getClassHashAt.hurl Updated method parameter.
examples/rpc/starknet/starknet_getNonce.hurl Updated method parameter.
examples/spawn-and-move/README.md Updated example commands and output values.

Possibly related PRs

  • chore: implement From<BigUint> for address type #2488: The changes in this PR involve the ContractAddress type, which is relevant to the updates made to account addresses in the main PR, particularly in how addresses are constructed and handled.
  • feat: update-erc20-class #2521: This PR introduces a new ERC20 contract that may utilize the updated account addresses from the main PR, especially since it involves contract interactions that could be affected by the address changes.
  • chore(katana-pool): rename error for clarity #2528: While this PR focuses on renaming an error for clarity, it is part of the broader context of transaction handling, which could be indirectly related to the changes in account addresses and their implications in transaction validation.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

Documentation and Community

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (3)
crates/katana/primitives/src/genesis/test-genesis.json (1)

22-27: Ohayo, sensei! The universalDeployer section looks interesting!

The addition of the universalDeployer section is a good improvement. However, it would be helpful to add a comment explaining the purpose and functionality of this universal deployer for other developers who might work on this configuration in the future.

Would you like me to draft a brief comment explaining the universalDeployer's role?

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

251-251: Ensure the file path is valid and portable

Ohayo, sensei! The use of a relative file path in include_str!("../../../../contracts/build/cairo1_contract.json"); might lead to issues if the directory structure changes or when building on different platforms. Consider using an absolute path from the project root or utilizing environment variables to make the path more robust and portable.


311-311: Handle errors when converting legacy classes

Ohayo, sensei! Similarly to the previous comment, in line 311, using .unwrap() can lead to panics if utils::to_class fails. Consider handling the error properly to enhance robustness.

Apply this change:

-utils::to_class(DEFAULT_LEGACY_ERC20_CASM.clone()).unwrap().contract_class()
+utils::to_class(DEFAULT_LEGACY_ERC20_CASM.clone())?.contract_class()

This will ensure consistent error handling throughout the code.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7035d54 and 35dfdb2.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • crates/katana/contracts/Scarb.lock is excluded by !**/*.lock
📒 Files selected for processing (46)
  • bin/sozo/src/commands/options/account/controller.rs (1 hunks)
  • bin/sozo/tests/test_data/policies.json (1 hunks)
  • crates/benches/contracts/Scarb.toml (1 hunks)
  • crates/dojo-world/src/metadata_test.rs (1 hunks)
  • crates/katana/cairo/Cargo.toml (1 hunks)
  • crates/katana/contracts/.tool-versions (1 hunks)
  • crates/katana/contracts/Makefile (1 hunks)
  • crates/katana/contracts/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/Scarb.toml (1 hunks)
  • crates/katana/contracts/account/src/lib.cairo (2 hunks)
  • crates/katana/contracts/messaging/cairo/Makefile (2 hunks)
  • crates/katana/contracts/messaging/cairo/account_l2.json (1 hunks)
  • crates/katana/contracts/messaging/cairo/account_l3.json (1 hunks)
  • crates/katana/contracts/messaging/l3.messaging.json (1 hunks)
  • crates/katana/contracts/messaging/solidity/Makefile (1 hunks)
  • crates/katana/controller/src/lib.rs (4 hunks)
  • crates/katana/core/src/backend/storage.rs (4 hunks)
  • crates/katana/executor/Cargo.toml (1 hunks)
  • crates/katana/executor/src/implementation/blockifier/state.rs (5 hunks)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/contract.json (1 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/node-bindings/src/json.rs (1 hunks)
  • crates/katana/node-bindings/src/lib.rs (2 hunks)
  • crates/katana/primitives/src/conversion/rpc.rs (2 hunks)
  • crates/katana/primitives/src/genesis/allocation.rs (2 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
  • crates/katana/primitives/src/genesis/json.rs (14 hunks)
  • crates/katana/primitives/src/genesis/mod.rs (14 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json (1 hunks)
  • crates/katana/primitives/src/genesis/test-genesis.json (1 hunks)
  • crates/katana/rpc/rpc/src/starknet/write.rs (1 hunks)
  • crates/katana/rpc/rpc/tests/starknet.rs (4 hunks)
  • crates/katana/rpc/rpc/tests/test_data/erc20.json (1 hunks)
  • crates/katana/storage/provider/test-data/simple_account.sierra.json (1 hunks)
  • crates/katana/storage/provider/tests/class.rs (3 hunks)
  • crates/katana/storage/provider/tests/fixtures.rs (2 hunks)
  • crates/torii/types-test/dojo_dev.toml (1 hunks)
  • examples/rpc/starknet/starknet_getClass.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getClassHashAt.hurl (1 hunks)
  • examples/rpc/starknet/starknet_getNonce.hurl (1 hunks)
  • examples/spawn-and-move/README.md (2 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)
  • examples/spawn-and-move/dojo_release.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (40)
  • bin/sozo/src/commands/options/account/controller.rs
  • bin/sozo/tests/test_data/policies.json
  • crates/benches/contracts/Scarb.toml
  • crates/dojo-world/src/metadata_test.rs
  • crates/katana/contracts/.tool-versions
  • crates/katana/contracts/Makefile
  • crates/katana/contracts/Scarb.toml
  • crates/katana/contracts/account/Scarb.toml
  • crates/katana/contracts/account/src/lib.cairo
  • crates/katana/contracts/messaging/cairo/Makefile
  • crates/katana/contracts/messaging/cairo/account_l2.json
  • crates/katana/contracts/messaging/cairo/account_l3.json
  • crates/katana/contracts/messaging/l3.messaging.json
  • crates/katana/contracts/messaging/solidity/Makefile
  • crates/katana/controller/src/lib.rs
  • crates/katana/core/src/backend/storage.rs
  • crates/katana/executor/tests/executor.rs
  • crates/katana/executor/tests/fixtures/contract.json
  • crates/katana/executor/tests/fixtures/mod.rs
  • crates/katana/node-bindings/src/json.rs
  • crates/katana/node-bindings/src/lib.rs
  • crates/katana/primitives/src/conversion/rpc.rs
  • crates/katana/primitives/src/genesis/allocation.rs
  • crates/katana/primitives/src/genesis/constant.rs
  • crates/katana/primitives/src/genesis/test-genesis-with-class.json
  • crates/katana/primitives/src/genesis/test-genesis-with-duplicate-name.json
  • crates/katana/rpc/rpc/src/starknet/write.rs
  • crates/katana/rpc/rpc/tests/starknet.rs
  • crates/katana/rpc/rpc/tests/test_data/erc20.json
  • crates/katana/storage/provider/test-data/simple_account.sierra.json
  • crates/katana/storage/provider/tests/class.rs
  • crates/katana/storage/provider/tests/fixtures.rs
  • crates/torii/types-test/dojo_dev.toml
  • examples/rpc/starknet/starknet_getClass.hurl
  • examples/rpc/starknet/starknet_getClassAt.hurl
  • examples/rpc/starknet/starknet_getClassHashAt.hurl
  • examples/rpc/starknet/starknet_getNonce.hurl
  • examples/spawn-and-move/README.md
  • examples/spawn-and-move/dojo_dev.toml
  • examples/spawn-and-move/dojo_release.toml
🧰 Additional context used
🔇 Additional comments (17)
crates/katana/cairo/Cargo.toml (1)

21-21: Ohayo, sensei! LGTM on the starknet_api update!

The bump from v0.8.0-rc3.1 to v0.8.0-rc3.2 looks good. This minor version update aligns with the PR objectives to update the implementation.

To ensure everything is daijobu, let's verify the compatibility:

crates/katana/executor/Cargo.toml (1)

18-18: Ohayo, sensei! The blockifier update looks good!

The change to update the blockifier dependency from v0.8.0-rc3.1 to v0.8.0-rc3.2 seems reasonable. It's generally a good practice to keep dependencies up-to-date for bug fixes and improvements.

Could you confirm that this update was intentional and that it has been tested with the current codebase to ensure compatibility?

crates/katana/primitives/src/genesis/test-genesis.json (2)

2-10: Ohayo, sensei! The initial block setup looks solid!

The initial block information and gas prices are well-defined. The inclusion of gas prices for both ETH and STRK tokens is a nice touch, providing flexibility in the genesis configuration.


11-21: Ohayo, sensei! The new feeToken section is a great addition!

This new section provides a comprehensive setup for the fee token, including its address, metadata, and initial storage state. This aligns well with the PR objectives and enhances the flexibility of the genesis configuration.

crates/katana/primitives/src/genesis/mod.rs (7)

11-11: Ohayo, sensei! LGTM on the constant renaming!

The renaming of constants improves code clarity and consistency. Nice work on aligning the names with their purposes!

Also applies to: 18-22


181-181: Ohayo again, sensei! The storage slot update looks good!

The use of DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT is consistent with the constant renaming. Well done on maintaining consistency!


250-250: Ohayo once more, sensei! The Default implementation is on point!

The updates in the Default implementation for Genesis are spot on. You've consistently applied the new constant names, maintaining harmony in the codebase. Excellent attention to detail!

Also applies to: 262-266, 278-282, 287-291


336-340: Ohayo, test-savvy sensei! The test setup looks great!

You've diligently updated the test setup to use the new constant names. This attention to detail ensures that the tests remain valid and consistent with the changes. Great job on maintaining the integrity of your test suite!

Also applies to: 344-348, 353-357, 367-367, 382-382, 394-394, 407-407


519-519: Ohayo, assertion ace sensei! Your test assertions are spot on!

The test assertions have been meticulously updated to reflect the new constant names. This ensures that your tests are checking the right things with the updated implementation. Excellent work on maintaining the accuracy of your test suite!

Also applies to: 525-525, 564-565, 572-574, 579-580, 587-588, 593-594, 599-600


617-617: Ohayo, detail-oriented sensei! The storage slot assertion update is perfect!

You've successfully updated the account allocation storage assertion to use DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT. This change maintains consistency with the earlier updates and ensures your tests are checking the correct storage slots. Great attention to detail!

Also applies to: 669-669


Line range hint 1-745: Ohayo, masterful sensei! Overall, this update is a work of art!

Your changes to update the default predeployed account class implementation have been executed flawlessly. The consistent renaming of constants throughout the file, including in the Genesis struct, its implementation, and the test cases, greatly improves code clarity and maintainability.

Here's a summary of the key improvements:

  1. Consistent naming conventions for constants
  2. Updated Genesis struct and its Default implementation
  3. Thoroughly revised test setup and assertions

These changes align perfectly with the PR objectives and should make the codebase more robust and easier to understand. Excellent work, sensei!

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

410-412: 🛠️ Refactor suggestion

Maintain consistency in error handling within tests

Ohayo, sensei! In lines 410-412, there is a mix of using .clone(), .flatten()?, and .unwrap(). For better consistency and to avoid potential panics during testing, consider using the ? operator or proper error handling uniformly.

Apply these changes:

-assert_eq!(actual_class, Some(DEFAULT_ACCOUNT_CLASS_CASM.clone()));
-assert_eq!(actual_sierra_class, Some(DEFAULT_ACCOUNT_CLASS.clone().flatten()?));
-assert_eq!(actual_legacy_class, Some(DEFAULT_LEGACY_ERC20_CASM.clone()));
+assert_eq!(actual_class, Some(DEFAULT_ACCOUNT_CLASS_CASM.clone()));
+assert_eq!(actual_sierra_class, Some(DEFAULT_ACCOUNT_CLASS.clone().flatten()?));
+assert_eq!(actual_legacy_class, Some(DEFAULT_LEGACY_ERC20_CASM.clone().flatten()?));

This approach enhances test reliability by handling potential errors gracefully.

Likely invalid or redundant comment.

crates/katana/primitives/src/genesis/json.rs (5)

29-34: Ohayo, sensei! Constants updated for clarity and consistency

The constants have been appropriately renamed, enhancing code readability and maintaining consistency across the codebase.


327-331: Ohayo, sensei! Controller class correctly incorporated into genesis

The addition of the CONTROLLER_CLASS_HASH and associated classes ensures the Controller class is properly included in the genesis configuration.


522-527: Ohayo, sensei! Default account class ensured in classes map

The check and insertion of the DEFAULT_ACCOUNT_CLASS into the classes map prevent potential issues with missing default account classes during genesis initialization.


Line range hint 951-973: Ohayo, sensei! Account classes assigned correctly

Accounts without a specified class are properly assigned the DEFAULT_ACCOUNT_CLASS_HASH, ensuring consistent behavior for all accounts.


Line range hint 1101-1141: Ohayo, sensei! Default classes initialized appropriately

The initialization of default classes for the legacy UDC, ERC20, and account contracts is correctly handled, setting up the necessary classes with their respective hashes and compiled representations.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 35dfdb2 and 05155a1.

📒 Files selected for processing (3)
  • crates/katana/executor/tests/executor.rs (7 hunks)
  • crates/katana/executor/tests/fixtures/mod.rs (4 hunks)
  • crates/katana/primitives/src/genesis/constant.rs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/katana/executor/tests/executor.rs
  • crates/katana/executor/tests/fixtures/mod.rs
🧰 Additional context used
🔇 Additional comments (6)
crates/katana/primitives/src/genesis/constant.rs (6)

20-23: Ohayo, sensei! Nice rename for clarity.

The renaming of OZ_ACCOUNT_CONTRACT_PUBKEY_STORAGE_SLOT to DEFAULT_ACCOUNT_CLASS_PUBKEY_STORAGE_SLOT improves clarity by removing the OpenZeppelin-specific reference. The updated documentation accurately reflects the constant's purpose.


78-79: Ohayo, sensei! Nice simplification of the constant name.

The renaming of CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH is a good simplification, removing redundant terms while maintaining clarity.


87-94: Ohayo, sensei! Good updates, let's verify the new paths and function.

The file paths in the include_str! macros have been updated, and the parse_compiled_class function has been replaced with read_compiled_class_artifact. These changes likely reflect a project restructuring and a new approach to parsing compiled classes.

To ensure the new paths are correct and the new function works as expected, you can run:

#!/bin/bash
# Verify the existence of the new build directory and files
ls -l ../../../contracts/build/
# Check the implementation of read_compiled_class_artifact
rg --type rust 'fn read_compiled_class_artifact'

100-101: Ohayo, sensei! Consistent updates here too.

The changes in this segment are consistent with the updates made earlier. The file path has been updated, and read_compiled_class_artifact is now used instead of parse_compiled_class.

To ensure the new path is correct and the file exists, you can run:

#!/bin/bash
# Verify the existence of the controller_CartridgeAccount.contract_class.json file
ls -l ../../../contracts/build/controller_CartridgeAccount.contract_class.json

70-76: Ohayo, sensei! Good updates, let's verify the new values.

The renaming of the constants from DEFAULT_OZ_ACCOUNT_CONTRACT_CLASS_HASH to DEFAULT_ACCOUNT_CLASS_HASH and DEFAULT_OZ_ACCOUNT_CONTRACT_COMPILED_CLASS_HASH to DEFAULT_ACCOUNT_COMPILED_CLASS_HASH is consistent with the move away from OpenZeppelin-specific naming. The new values likely reflect the updated implementation mentioned in the PR objectives.

To ensure the new values are correct, you can run:

#!/bin/bash
# Verify the new class hash and compiled class hash values
rg --type rust 'DEFAULT_ACCOUNT_CLASS_HASH.*0x03a1cb99c855ca8ff11633e37a0a971e2af84239f127ff3022ce5d4c2dbf50cb'
rg --type rust 'DEFAULT_ACCOUNT_COMPILED_CLASS_HASH.*0x0138105ded3d2e4ea1939a0bc106fb80fd8774c9eb89c1890d4aeac88e6a1b27'

123-126: ⚠️ Potential issue

Ohayo, sensei! Good update, but there's a small syntax issue.

The renaming of CONTROLLER_ACCOUNT_CONTRACT_CLASS_HASH to CONTROLLER_CLASS_HASH in the test module is consistent with the changes made earlier in the file. However, there's a small syntax error in the assertion statement.

Please add a semicolon at the end of the assertion to fix the syntax error:

-        assert_eq!(hash, CONTROLLER_CLASS_HASH)
+        assert_eq!(hash, CONTROLLER_CLASS_HASH);

Likely invalid or redundant comment.

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

🧹 Outside diff range and nitpick comments (2)
bin/sozo/tests/test_data/compiled_contracts/test_contract.json (2)

1-1: File path update detected.

The path for the compiled contract has been changed from compiled to build. This might indicate a change in the build process or directory structure.

Consider updating any documentation or scripts that might be referencing the old path to ensure consistency across the project.


Line range hint 1106-1385: ABI updates detected.

Ohayo, sensei! The abi section has undergone some modifications. Let's break them down:

  1. The constructor signature remains the same.
  2. The test_storage_read_write function now uses core::starknet::storage_access::StorageAddress instead of core::felt252 for the address parameter.
  3. The test_call_contract function now uses core::starknet::contract_address::ContractAddress for the contract_address parameter.
  4. The test_get_block_hash function now takes a core::integer::u64 instead of core::felt252 for the block_number parameter.
  5. The test_library_call and test_nested_library_call functions now use core::starknet::class_hash::ClassHash for the class_hash parameter.
  6. The test_replace_class function now takes a core::starknet::class_hash::ClassHash instead of core::felt252 for the class_hash parameter.
  7. The test_deploy function now uses core::starknet::class_hash::ClassHash for the class_hash parameter and core::bool for the deploy_from_zero parameter.

These changes appear to be using more specific and appropriate types, which is a good practice for improved type safety and clarity.

Consider updating any client code or tests that interact with this contract to use the new parameter types. This will ensure type consistency and prevent potential issues.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d31b9cc and f4071ce.

⛔ Files ignored due to path filters (2)
  • spawn-and-move-db.tar.gz is excluded by !**/*.gz
  • types-test-db.tar.gz is excluded by !**/*.gz
📒 Files selected for processing (1)
  • bin/sozo/tests/test_data/compiled_contracts/test_contract.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
bin/sozo/tests/test_data/compiled_contracts/test_contract.json (4)

Line range hint 1058-1062: No changes in sierra_program_debug_info.

The sierra_program_debug_info section remains unchanged with empty arrays for type names, libfunc names, and user func names.


Line range hint 1063-1063: Contract class version unchanged.

The contract_class_version remains at "0.1.0".


Line range hint 1064-1105: Entry points remain consistent.

The entry_points_by_type section shows no changes in the structure or content for EXTERNAL, L1_HANDLER, and CONSTRUCTOR types.


Line range hint 2-1057: Extensive changes in sierra_program detected.

The sierra_program section has undergone significant modifications. While it's challenging to review bytecode directly, these changes likely reflect updates in the contract's implementation or compiler optimizations.

To ensure these changes haven't introduced any unintended side effects, consider running the following verification:

Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 97.29730% with 3 lines in your changes missing coverage. Please review.

Project coverage is 69.29%. Comparing base (7035d54) to head (f4071ce).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
crates/katana/primitives/src/genesis/json.rs 93.02% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2524      +/-   ##
==========================================
- Coverage   69.30%   69.29%   -0.01%     
==========================================
  Files         388      388              
  Lines       50033    50012      -21     
==========================================
- Hits        34673    34656      -17     
+ Misses      15360    15356       -4     

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

@kariy kariy merged commit bc5d2f6 into main Oct 14, 2024
15 checks passed
@kariy kariy deleted the katana/update-default-account branch October 14, 2024 18:29
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.

1 participant