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: merge audit branch #1533

Merged
merged 61 commits into from
Feb 18, 2024
Merged

feat: merge audit branch #1533

merged 61 commits into from
Feb 18, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Feb 12, 2024

The audit branch contains several important changes:

  1. The resource metadata are now manipulated as a model. But a special model that is automatically registered by sozo when the owner of the world deploys it.
  2. The executor is no longer present. Now, the models are deployed to ensure there's no attack vector by executing the library_call syscall.
  3. Add support for Array<felt252> in models.

Tasks:

  • Ensure the address of a model is always tracked by the manifest.
  • Verify how the array is handled into introspect and associated layout. SQL test are failing for this reason.
  • Add a link to the audit PDF on Nethermind public repository of audited codebase.

This commit aims at having more flexibility in the dojo storage
engine, to automatically use several storage slots segments depending
on the packed size.

The offset and length fields are not more required for the database to work.
The layout is still exposed for the moment.
There were a security issue with the executor, as currently
the library_call is not immutable. Hence, a function called
by library_call may contains other syscall. For this reason,
the executor is removed in favor of deploying the model
to get it's name.
@glihm
Copy link
Collaborator Author

glihm commented Feb 14, 2024

I believe it comes from the "cainome" dependency. It's caused by tokio and maybe some other deps - gotta check if tokio is the only one. Tokio won't compile if the feature "full" is used. Only these features are supported on WASM image

Appreciate the feedback on that, will double check cainome and possible sources based on that. Thanks mate. 🙏

Copy link
Contributor

@tarrencev tarrencev left a comment

Choose a reason for hiding this comment

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

some minor feedback from a initial pass

bin/sozo/src/commands/model.rs Show resolved Hide resolved
bin/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
crates/dojo-core/src/base_test.cairo Show resolved Hide resolved
crates/dojo-core/src/base_test.cairo Outdated Show resolved Hide resolved
crates/dojo-core/src/database_test.cairo Outdated Show resolved Hide resolved
@glihm
Copy link
Collaborator Author

glihm commented Feb 14, 2024

@ThePinion and @neotheprogramist if you have a chance I would appreciate a counter review on the core contracts changes. 🙏

@neotheprogramist you had started hard and great work on indexing, however for the audit it was removed as we should reconsider the model for this in a later phase. Appreciate your comprehension on that mate.

@glihm glihm requested a review from kariy February 14, 2024 18:37
Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: 81 lines in your changes are missing coverage. Please review.

Comparison is base (374f2bf) 70.06% compared to head (082e369) 70.50%.
Report is 37 commits behind head on main.

Files Patch % Lines
crates/dojo-lang/src/inline_macros/array_cap.rs 73.91% 24 Missing ⚠️
crates/torii/grpc/src/server/mod.rs 0.00% 12 Missing ⚠️
crates/dojo-lang/src/introspect.rs 86.66% 10 Missing ⚠️
crates/torii/core/src/processors/register_model.rs 40.00% 9 Missing ⚠️
bin/sozo/src/ops/model.rs 0.00% 7 Missing ⚠️
crates/torii/core/src/model.rs 63.63% 4 Missing ⚠️
crates/dojo-world/src/contracts/model.rs 83.33% 3 Missing ⚠️
crates/dojo-world/src/manifest.rs 86.36% 3 Missing ⚠️
crates/dojo-world/src/migration/mod.rs 0.00% 3 Missing ⚠️
crates/dojo-lang/src/plugin.rs 91.30% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1533      +/-   ##
==========================================
+ Coverage   70.06%   70.50%   +0.43%     
==========================================
  Files         236      261      +25     
  Lines       22531    25300    +2769     
==========================================
+ Hits        15786    17837    +2051     
- Misses       6745     7463     +718     

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

Copy link
Collaborator Author

@glihm glihm left a comment

Choose a reason for hiding this comment

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

Some comments on the sozo capabilities for backward compatibilities.
Thanks guys for the feedback. 👍

bin/sozo/src/commands/migrate.rs Outdated Show resolved Hide resolved
bin/sozo/src/ops/migration/mod.rs Outdated Show resolved Hide resolved
Comment on lines +244 to +246
let do_expand: bool =
std::env::var(DOJO_PLUGIN_EXPAND_VAR_ENV).map_or(false, |v| v == "true" || v == "1");

Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose behind this env var? Is there a reason to print out the expanded code ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Debugging mostly.

While working on dojo-lang to introduce the array, I found that having the compiler rewritten node expanded was very useful.

crates/dojo-world/src/migration/mod.rs Outdated Show resolved Hide resolved
crates/dojo-test-utils/build.rs Show resolved Hide resolved
@glihm glihm merged commit 072a31d into dojoengine:main Feb 18, 2024
12 checks passed
@glihm glihm mentioned this pull request Feb 23, 2024
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.

6 participants