-
Notifications
You must be signed in to change notification settings - Fork 172
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(katana): implement Arbitrary
trait for all db types
#2568
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kariy
changed the base branch from
katana/db-benchmark
to
katana/simplify-in-memory-provider
October 22, 2024 17:58
kariy
force-pushed
the
katana/simplify-in-memory-provider
branch
from
October 22, 2024 17:59
fd5d1ed
to
63d0330
Compare
kariy
force-pushed
the
katana/arbitrary
branch
from
October 22, 2024 18:00
45c2fcf
to
54c70ac
Compare
kariy
changed the title
feat: implement
feat(katana): implement Oct 22, 2024
Arbitrary
trait for all db typesArbitrary
trait for all db types
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## katana/simplify-in-memory-provider #2568 +/- ##
=====================================================================
Coverage ? 69.54%
=====================================================================
Files ? 401
Lines ? 50753
Branches ? 0
=====================================================================
Hits ? 35295
Misses ? 15458
Partials ? 0 ☔ View full report in Codecov by Sentry. |
kariy
added a commit
that referenced
this pull request
Oct 23, 2024
implement the [`Arbitray`](https://docs.rs/arbitrary/latest/arbitrary/trait.Arbitrary.html) trait for all types that are used in the database. this is for generating random values of all the database types. helpful for due to Rust's orphan rule, there are some types that we use from external crate (mainly `starknet-rs`) that don't implement the trait, so we can't directly derive it. to get around this, the simplest solution is to just own the types and define it ourselves. this approach requires that we do more marshalling between our primitives types to the rpc types (rpc we mostly use types from starknet-rs). which is not the most elegant solution. i think eventually we probably should not rely on external crate for our rpc types and maintain them ourselves for more flexibility (if the changes that we need cant be included upstream). the idea for this PR, is to use this for generating bunch of random values for all db types and use them in a benchmark. --- test db needs to be updated because of the we define the [`ExecutionResources`](https://github.com/dojoengine/dojo/blob/a4ee208b517daead41ac1a6b855af3abb03294c3/crates/katana/primitives/src/trace.rs#L12-L20) and it doesn't serde into the same format as the one we used before (from the [cairo-vm](https://github.com/dojoengine/dojo/blob/a4ee208b517daead41ac1a6b855af3abb03294c3/crates/katana/primitives/src/trace.rs#L12-L20)) i would prefer to keep the breaking serde, mainly because it doesnt de/serialize the `builtin_instance_counter` as raw strings of the builtin names. therefore more storage optimized. we're still using the builin name types from cairo-vm anyway so marshalling between them is straightforward as we dont need to convert the individual map entry. though this changes break the db format, as we already bumped it at #2560, and it hasnt been included in a release yet, theres no need to bump it again.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
implement the
Arbitray
trait for all types that are used in the database. this is for generating random values of all the database types. helpful fordue to Rust's orphan rule, there are some types that we use from external crate (mainly
starknet-rs
) that don't implement the trait, so we can't directly derive it. to get around this, the simplest solution is to just own the types and define it ourselves. this approach requires that we do more marshalling between our primitives types to the rpc types (rpc we mostly use types from starknet-rs). which is not the most elegant solution. i think eventually we probably should not rely on external crate for our rpc types and maintain them ourselves for more flexibility (if the changes that we need cant be included upstream).the idea for this PR, is to use this for generating bunch of random values for all db types and use them in a benchmark.
test db needs to be updated because of the we define the
ExecutionResources
and it doesn't serde into the same format as the one we used before (from the cairo-vm)i would prefer to keep the breaking serde, mainly because it doesnt de/serialize the
builtin_instance_counter
as raw strings of the builtin names. therefore more storage optimized. we're still using the builin name types from cairo-vm anyway so marshalling between them is straightforward as we dont need to convert the individual map entry.though this changes break the db format, as we already bumped it at #2560, and it hasnt been included in a release yet, theres no need to bump it again.