-
Notifications
You must be signed in to change notification settings - Fork 25
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(blockifier): add read and write cairo native syscalls #1305
Conversation
Benchmark movements: |
2324871
to
f4a0965
Compare
4b0b2f6
to
d03252a
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.
Reviewed 3 of 3 files at r1, 1 of 2 files at r2, 2 of 2 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: 8 of 9 files reviewed, 1 unresolved discussion (waiting on @rodrigo-pino)
scripts/dependencies.sh
line 79 at r4 (raw file):
function main() { # [ "$(uname)" = "Linux" ] && install_essential_deps_linux # setup_llvm_deps
Why?
Code quote:
# [ "$(uname)" = "Linux" ] && install_essential_deps_linux
# setup_llvm_deps
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.
Reviewed 3 of 3 files at r1, 1 of 2 files at r2, 2 of 2 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: 8 of 9 files reviewed, 5 unresolved discussions (waiting on @meship-starkware and @rodrigo-pino)
crates/blockifier/src/execution/native/syscall_handler.rs
line 187 at r4 (raw file):
let key = StorageKey( PatriciaKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?, );
Why not?
Suggestion:
let key = StorageKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?;
crates/blockifier/src/execution/native/syscall_handler.rs
line 190 at r4 (raw file):
let read_result = self.state.get_storage_at(self.contract_address, key); let value = read_result.map_err(|e| encode_str_as_felts(&e.to_string()))?;
We don't do this error encoding in our current syscall handler. Are you sure we can't just use ?
here?
Suggestion:
self.state.get_storage_at(self.contract_address, key)?;
crates/blockifier/src/execution/native/syscall_handler.rs
line 212 at r4 (raw file):
let key = StorageKey( PatriciaKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?, );
Suggestion:
let key = StorageKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?;
crates/blockifier/src/execution/native/syscall_handler.rs
line 216 at r4 (raw file):
let write_result = self.state.set_storage_at(self.contract_address, key, value); write_result.map_err(|e| encode_str_as_felts(&e.to_string()))?;
as suggested above
can this work?
Suggestion:
self.state.set_storage_at(self.contract_address, key, value)?;
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.
Reviewable status: 8 of 9 files reviewed, 7 unresolved discussions (waiting on @meship-starkware and @rodrigo-pino)
Cargo.toml
line 100 at r4 (raw file):
cairo-lang-utils = "2.8.2" # cairo-native = "0.2.0-alpha.2" cairo-native = { git = "https://github.com/NethermindEth/cairo_native", branch = "rdr/resolve-runtime-library-path-2.8.2" }
Why?
Code quote:
# cairo-native = "0.2.0-alpha.2"
cairo-native = { git = "https://github.com/NethermindEth/cairo_native", branch = "rdr/resolve-runtime-library-path-2.8.2" }
.cargo/config.toml
line 2 at r4 (raw file):
[env] CAIRO_NATIVE_RUNTIME_LIBRARY = "libcairo_native_runtime.a"
Please make this change in #1242
Code quote:
CAIRO_NATIVE_RUNTIME_LIBRARY = "libcairo_native_runtime.a"
2139d88
to
c304c51
Compare
6a139cd
to
fc9b733
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.
Reviewable status: 2 of 9 files reviewed, 7 unresolved discussions (waiting on @avi-starkware and @meship-starkware)
Cargo.toml
line 100 at r4 (raw file):
Previously, avi-starkware wrote…
Why?
Required to correctly solve CAIRO_NATIVE_RUNTIME_LIBRARY
otherwise we cannot use the .cargo/config.toml
solution.
.cargo/config.toml
line 2 at r4 (raw file):
Previously, avi-starkware wrote…
Please make this change in #1242
Done!
crates/blockifier/src/execution/native/syscall_handler.rs
line 187 at r4 (raw file):
Previously, avi-starkware wrote…
Why not?
Done! Thanks!
crates/blockifier/src/execution/native/syscall_handler.rs
line 190 at r4 (raw file):
Previously, avi-starkware wrote…
We don't do this error encoding in our current syscall handler. Are you sure we can't just use
?
here?
You return a StateError
which Native doesn't understand.
Cairo 1 (through Native) is expecting a SyscallResult, Cairo1/Sierra doesn't understand what a StateError
is. What we do is that we propagate the error back by encoding the StateError
message as a bunch of Felts and return control to the Contract.
Take into account that each time we are executing a contract we treat it as a black box. Each syscall is a request to the blockifier using the communication protocol established by the StarknetSyscallHandler
trait.
crates/blockifier/src/execution/native/syscall_handler.rs
line 212 at r4 (raw file):
let key = StorageKey( PatriciaKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?, );
Done!
scripts/dependencies.sh
line 79 at r4 (raw file):
Previously, meship-starkware (Meshi Peled) wrote…
Why?
It wasn't intentional
Benchmark movements: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1305 +/- ##
===========================================
+ Coverage 40.10% 62.61% +22.51%
===========================================
Files 26 361 +335
Lines 1895 39045 +37150
Branches 1895 39045 +37150
===========================================
+ Hits 760 24449 +23689
- Misses 1100 12567 +11467
- Partials 35 2029 +1994 ☔ 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.
Reviewed 2 of 6 files at r5, 2 of 2 files at r6, 3 of 3 files at r7, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @avi-starkware and @rodrigo-pino)
8f9d345
to
01cf9d1
Compare
Benchmark movements: |
0fec098
to
db3afa3
Compare
Benchmark movements: full_committer_flow performance improved 😺 |
3dcf885
to
f6c89ed
Compare
Benchmark movements: |
139d79d
to
3d4ab3d
Compare
83b6168
to
2f085d2
Compare
Artifacts upload triggered. View details here |
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.
Reviewed 1 of 1 files at r21, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware and @noaov1)
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.
Reviewed 1 of 1 files at r21, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware)
2f085d2
to
2fe81ff
Compare
Artifacts upload triggered. View details here |
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.
Reviewed all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware)
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.
Reviewed all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware)
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.
Dismissed @ilyalesokhin-starkware from a discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware and @ilyalesokhin-starkware)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware and @noaov1)
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Can you add a wrapper for unprovable errors? Suggestion: handle_unprovable_error(err) |
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.
Reviewed 5 of 5 files at r24, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware, @noaov1, and @rodrigo-pino)
-- commits
line 5 at r24:
Can you squash these two commits into one
Code quote:
New commits in r22 on 11/11/2024 at 00:24, probably rebased from r21:
- 2fe81ff: feat(blockifier): add read & write syscalls
New commits in r24 (same as r22) on 11/11/2024 at 12:19:
- 2fe81ff: feat(blockifier): add read & write syscalls
Artifacts upload triggered. View details here |
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.
Reviewable status: 30 of 31 files reviewed, 3 unresolved discussions (waiting on @ilyalesokhin-starkware, @meship-starkware, and @noaov1)
Previously, meship-starkware (Meshi Peled) wrote…
Can you squash these two commits into one
It is weird, in my log I just have one commit 🤔 , not sure how to fix this.
crates/blockifier/src/execution/native/syscall_handler.rs
line 202 at r22 (raw file):
Previously, ilyalesokhin-starkware wrote…
Can you add a wrapper for unprovable errors?
Done
crates/blockifier/src/execution/native/syscall_handler.rs
line 101 at r25 (raw file):
} fn handle_error(
Defined inside the impl intentionally (self
will be used in the error handling)
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.
Reviewable status: 30 of 31 files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware and @noaov1)
Previously, rodrigo-pino (Rodrigo) wrote…
It is weird, in my log I just have one commit 🤔 , not sure how to fix this.
Then never mind, it will be squashed when merging
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.
Reviewed 1 of 2 files at r19, 1 of 1 files at r25.
Reviewable status: all files reviewed (commit messages unreviewed), 1 unresolved discussion (waiting on @noaov1)
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.
Reviewed 1 of 1 files at r25, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware and @meship-starkware)
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.
Reviewed 1 of 1 files at r25, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @avi-starkware, @ilyalesokhin-starkware, and @noaov1)
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.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @rodrigo-pino)
Add the read and write syscalls to the
NativeSyscallHandler
.Open for you to see and react. Notice that Cairo Native dependency has changed, this is because I had to update that relative paths are solved in order for it to detect the Runtime based on the
.cargo/config.toml
file.Looking forward to your feedback.
This change is