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

feat(sozo): add ability to migrate the world #1698

Merged
merged 14 commits into from
Apr 4, 2024

Conversation

lambda-0x
Copy link
Contributor

@lambda-0x lambda-0x commented Mar 25, 2024

fix: #1671
fix: DOJ-268

  • make sure its works as expected
  • add original_base_class_hash for DojoContracts

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 48.44444% with 232 lines in your changes are missing coverage. Please review.

Project coverage is 67.62%. Comparing base (c2280fe) to head (45964d2).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/sozo/ops/src/migration/mod.rs 44.37% 94 Missing ⚠️
crates/dojo-world/src/migration/mod.rs 27.63% 55 Missing ⚠️
crates/dojo-world/src/manifest/mod.rs 25.00% 48 Missing ⚠️
crates/dojo-world/src/manifest/types.rs 62.90% 23 Missing ⚠️
crates/dojo-world/src/migration/contract.rs 30.00% 7 Missing ⚠️
crates/dojo-world/src/migration/strategy.rs 42.85% 4 Missing ⚠️
crates/dojo-world/src/migration/world.rs 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1698      +/-   ##
==========================================
- Coverage   67.86%   67.62%   -0.24%     
==========================================
  Files         304      305       +1     
  Lines       33172    33431     +259     
==========================================
+ Hits        22512    22609      +97     
- Misses      10660    10822     +162     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm added the sozo label Mar 25, 2024
@glihm
Copy link
Collaborator

glihm commented Mar 27, 2024

As a note, the saya test is fixed on main. 👍

@glihm
Copy link
Collaborator

glihm commented Mar 30, 2024

@lambda-0x I've made a test where:

  1. migrate the spawn and move project without modification.
  2. change a bit the world to have a new class hash.
  3. migrate again, and the world is not updated in-place.
  4. the base class hash wasn't modify, we should expect a world upgrade, right?

@lambda-0x
Copy link
Contributor Author

@glihm would need to create an overlays/world.toml file with the original_class_hash set to the original class hash of the world

@lambda-0x lambda-0x marked this pull request as ready for review April 2, 2024 16:08
@lambda-0x
Copy link
Contributor Author

(will fix the conflicts once changes are reviewed)

@glihm
Copy link
Collaborator

glihm commented Apr 3, 2024

@glihm would need to create an overlays/world.toml file with the original_class_hash set to the original class hash of the world

an important point to keep for documentation, the name field is required.

@glihm
Copy link
Collaborator

glihm commented Apr 3, 2024

@lambda-0x it seems like if the world get back to the original class hash after being upgraded, it does not upgrade to ensure the class hash is restored.

  1. Deploy the world
  2. Modify the world + migrate + overlay -> it upgrades correctly
  3. Restore the world as it was in 1, and migrate + remove overlay -> it does not upgrade

We need a big refactoring on the code to organize the testing on all of that. 👍

Comment on lines 423 to 425
if world.diff.local_class_hash != world.diff.original_class_hash
&& world.diff.original_class_hash
== world.diff.remote_class_hash.unwrap_or_default()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about this condition and it's related to my previous comment.

To here, we want to actually upgrade anytime local class hash is different from the remote one, independently of the original class hash match.

}

#[derive(Clone, Debug)]
pub struct UpgradeOutput {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should see how to use that on the dojo contracts. Currently even if upgraded, we return a DeployOutput struct only.

@glihm
Copy link
Collaborator

glihm commented Apr 4, 2024

@lambda-0x would appreciate a double check if you have the bandwidth. 👍

@glihm
Copy link
Collaborator

glihm commented Apr 4, 2024

@lambda-0x I'll merge for now, we should catch up for tests architecture once you're available. 👍

Related to #1684.

@glihm glihm merged commit af7ec6e into dojoengine:main Apr 4, 2024
10 of 12 checks passed
@lambda-0x lambda-0x deleted the world-migrate branch April 25, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sozo] update the world during sozo migrate
2 participants