-
Notifications
You must be signed in to change notification settings - Fork 174
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
fix(sozo): upgrade_contract use selector instead of contract_address #2234
Conversation
WalkthroughOhayo, sensei! The recent changes enhance the flexibility and functionality of the contract deployment and migration processes within the Dojo framework. Key modifications include the addition of contextual parameters in the Changes
Recent review detailsConfiguration used: .coderabbit.yaml Files selected for processing (4)
Files skipped from review as they are similar to previous changes (3)
Additional comments not posted (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2234 +/- ##
==========================================
+ Coverage 70.10% 70.27% +0.17%
==========================================
Files 340 340
Lines 44802 44806 +4
==========================================
+ Hits 31409 31489 +80
+ Misses 13393 13317 -76 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, thank you @notV4l.
We then need at least one test that ensures we don't break upgradeability in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_migrate_then_upgrade() { | ||
let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); | ||
let config = setup.build_test_config("spawn-and-move", Profile::DEV); | ||
let tmp_dir = config.manifest_path().parent().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohayo, sensei! Consider error handling for setup and config.
Adding error handling for the setup and config steps can improve robustness.
- let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/");
- let config = setup.build_test_config("spawn-and-move", Profile::DEV);
+ let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples()").expect("Failed to initialize CompilerTestSetup.");
+ let config = setup.build_test_config("spawn-and-move", Profile::DEV).expect("Failed to build test config.");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#[tokio::test(flavor = "multi_thread")] | |
async fn test_migrate_then_upgrade() { | |
let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); | |
let config = setup.build_test_config("spawn-and-move", Profile::DEV); | |
let tmp_dir = config.manifest_path().parent().unwrap(); | |
#[tokio::test(flavor = "multi_thread")] | |
async fn test_migrate_then_upgrade() { | |
let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/").expect("Failed to initialize CompilerTestSetup."); | |
let config = setup.build_test_config("spawn-and-move", Profile::DEV).expect("Failed to build test config."); | |
let tmp_dir = config.manifest_path().parent().unwrap(); |
get_snapbox().args(build_vec.iter()).assert().success(); | ||
|
||
let assert = get_snapbox().args(args_vec.iter()).assert().success(); | ||
let output = format!("{:#?}", assert.get_output()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohayo, sensei! Ensure output verification is robust.
Consider verifying the output more robustly by checking for specific expected values.
- let output = format!("{:#?}", assert.get_output());
+ let output = String::from_utf8(assert.get_output().to_vec()).expect("Failed to convert output to string.");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
get_snapbox().args(build_vec.iter()).assert().success(); | |
let assert = get_snapbox().args(args_vec.iter()).assert().success(); | |
let output = format!("{:#?}", assert.get_output()); | |
get_snapbox().args(build_vec.iter()).assert().success(); | |
let assert = get_snapbox().args(args_vec.iter()).assert().success(); | |
let output = String::from_utf8(assert.get_output().to_vec()).expect("Failed to convert output to string."); |
// Modify the actions contracts to have a new class hash. | ||
let actions_path = tmp_dir.join("src/actions.cairo"); | ||
let mut actions_content = fs::read_to_string(&actions_path).unwrap(); | ||
actions_content = actions_content.replace("quantity: 100", "quantity: 200"); | ||
fs::write(&actions_path, actions_content).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohayo, sensei! Ensure error handling for file operations.
Adding error handling for file read and write operations can improve robustness.
- let actions_content = fs::read_to_string(&actions_path).unwrap();
+ let actions_content = fs::read_to_string(&actions_path).expect("Failed to read actions contract file.");
- fs::write(&actions_path, actions_content).unwrap();
+ fs::write(&actions_path, actions_content).expect("Failed to write updated actions contract file.");
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Modify the actions contracts to have a new class hash. | |
let actions_path = tmp_dir.join("src/actions.cairo"); | |
let mut actions_content = fs::read_to_string(&actions_path).unwrap(); | |
actions_content = actions_content.replace("quantity: 100", "quantity: 200"); | |
fs::write(&actions_path, actions_content).unwrap(); | |
// Modify the actions contracts to have a new class hash. | |
let actions_path = tmp_dir.join("src/actions.cairo"); | |
let actions_content = fs::read_to_string(&actions_path).expect("Failed to read actions contract file."); | |
actions_content = actions_content.replace("quantity: 100", "quantity: 200"); | |
fs::write(&actions_path, actions_content).expect("Failed to write updated actions contract file."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @notV4l for the fix here. 👍
Summary by CodeRabbit
New Features
Bug Fixes