-
Notifications
You must be signed in to change notification settings - Fork 16
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
is_prime
on sp1
#814
base: master
Are you sure you want to change the base?
is_prime
on sp1
#814
Conversation
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.
Could you post the interesting results you mentioned, please?
@@ -0,0 +1,127 @@ | |||
//! An end-to-end example of using the SP1 SDK to generate a proof of a program that can have an | |||
//! EVM-Compatible proof generated which can be verified on-chain. |
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.
Why are we going with evm compatible proofs?
Could we just do the simplest thing that SP1 allows? Or is there a good reason to go with something more complicated?
(I don't think our proof is evm-compatible? So it would be fair to require that of SP1.)
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.
I followed the instructions here. I generated the project via cargo prove new --bare is_prime
.
- I don't know why there's anything pertaining to
evm
there, it surprised me too. - It generated a Fibonacci project in a folder called
is_prime
:). I modified the logic, but didn't bother with all the modules, paths, etc. I changed them now.
My results for sp1:
and Ceno
You can see the number of cycles differs ( |
If I enable link time optimisation for SP1, I get 325_334 cycles. That takes care of most of the difference in cycles, since it's only about 2.7% more than Ceno. (We can investigate that a bit more.) diff --git a/is_prime/Cargo.toml b/is_prime/Cargo.toml
index 3915b209..9d246545 100644
--- a/is_prime/Cargo.toml
+++ b/is_prime/Cargo.toml
@@ -8,3 +8,14 @@ resolver = "2"
[workspace.dependencies]
alloy-sol-types = "0.7.7"
+
+[profile.release]
+lto = "fat"
+panic = "abort"
+codegen-units = 1
+
+[profile.host]
+inherits = "release"
+lto = "thin"
+panic = "abort"
+codegen-units = 16 cargo run --profile=host -- --n=5000 --execute Let me actually run the proving next. |
When proving on my machine with LTO turned on for SP1 (see comment above), I get the following: SP1
Ceno
Further resultsWith n = 20_000 I get this for Ceno
And this for SP1:
|
@mcalancea Could you please do the sorting benchmark for SP1 and ceno? Not the quadratic one, just the one that uses Vec's built-in sorting, please. I suspect that's more representative of real world workloads than 'is-prime' or the quadratic sorting. Thanks! |
Sandbox branch, shouldn't be merged.
Based on #813 . Hardcodes
is_prime
intobin/
and adds theis_prime/
sp1
project at the top level. I've been running:and
Results are very interesting 👀 👀 . But can we confirm them @matthiasgoergens ?
Later Edit:
Ignore the Fibonacci names, it's auto-generated by
sp1
.Consult https://docs.succinct.xyz/docs/getting-started/quickstart for more.