-
Notifications
You must be signed in to change notification settings - Fork 11
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: implement create_engine #14
Conversation
f2f7f2a
to
0d7bb3c
Compare
0d7bb3c
to
4c3cd0c
Compare
7203d5a
to
4c3cd0c
Compare
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.
Thank you so much @tamaralipows 🙏🏼 This looks good, I like it! I only have small questions/suggestions!
unsafe impl Send for MockDatabase {} | ||
unsafe impl Sync for MockDatabase {} |
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.
Very interesting, why was this needed? What does it breaks if the mock db isn't Send
or Sync
?
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.
The usage of Arc for the test:
warning: usage of an `Arc` that is not `Send` and `Sync`
--> src/protocol/vm/engine.rs:138:18
|
138 | let db = Arc::new(RwLock::new(MockDatabase::default()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `Arc<RwLock<MockDatabase>>` is not `Send` and `Sync` as `RwLock<MockDatabase>` is not `Sync`
= help: if the `Arc` will not used be across threads replace it with an `Rc`
= help: otherwise make `RwLock<MockDatabase>` `Send` and `Sync` or consider a wrapper type such as `Mutex`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
= note: `#[warn(clippy::arc_with_non_send_sync)]` on by default
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.
FYI, it's not send and sync because you used a RefCell
here
If you change this to be something like a Mutex then you don't need this unsafe code
Also please note that these two lines are really dangerous and should never be used in the program code
- Change database.rs -> simulation_db.rs for clarity. - Make EXTERNAL_ACCOUNT already an address, so we don't need to re-convert it in the engine creation - remove supposedly unnecessary `auto_impl`
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.
Yeeesss looks good 🙏🏼 ✨ Thank you thank you!
This PR is included in version 0.25.0 🎉 |
Task
Unforeseen changes:
init_account
into a Trait implemented by bothSimulationDB
andTychoDB
in order to keep the simulation engine creation generalized. More information in this slack thread.DatabaseRef
here since theSimulationEngine.simulate
method requires this trait when initializing the builderNotes:
We plan on creating a more thorough integration test after finishing the sprint goals (which will leave us with everything necessary for creating the integration test). This is why we are not wasting too much time integration-testing the engine and
ProtoSim/Adapter
contracts. The test in the engine for this PR simply checks that the call toinit_account
succeeds with the expected types.