-
Notifications
You must be signed in to change notification settings - Fork 331
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
fix: optimize tendermint zk light client #273
fix: optimize tendermint zk light client #273
Conversation
@puma314 What I am thinking is to make an optimization PR to tendermint-rs, and wait for it to merge. Is my understanding correct? |
@i-m-aditya it would be great if you could get the following TODO merged into |
@puma314 Sure I will get this done. |
That's awesome! That LGTM, so hopefully they merge it. I think working on the next steps makes sense, like adding stuff to the script to get the input and then read it in using Let me know if you need pointers, this is awesome work! |
@puma314 Because of the addition of reqwest crate in Cargo.toml,
I tried using hyper instead of request, but getting the same issue. |
Hey @i-m-aditya, you should join our TG support group and I can help in there! (Don't paste the entire error message in the chat since it pollutes it, just put it in a Github Gist and then put a link to that). The link to our TG support chat is in our docs at the top on the homepage: https://succinctlabs.github.io/sp1/ (I don't want to link directly in here to prevent spam). I took a look at your PR and it's actually really close to working! But you actually want to have all the stuff in THEN you can feed in the Then you can read the So you're really close! Just move all the fetching logic into script and out of program and you should be all good to go! Looking forward to it. |
@puma314 after moving fetching logic to the script, the build works. Thanks |
88aa1cc
to
ea04c63
Compare
Seeing that your editing tendermint-rs, this issue I made on the go side may apply for tendermint-rs as well! cometbft/cometbft#2365 I've never read the Tendermint-rs code, so not quite sure. Will try looking into the codebase for it |
bbae024
to
aae77fa
Compare
@i-m-aditya is this ready for a look? I can take a look over the weekend! |
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.
Overall this looks awesome! I'm curious on Tendermint how much this change actually saves. If you run the script with RUST_LOG=info
, you should see an output like this:
2024-03-02T07:35:01.965228Z INFO runtime.run(...):load memory: close time.busy=1.68ms time.idle=416ns
2024-03-02T07:35:02.390567Z INFO runtime.run(...):postprocess: close time.busy=8.69ms time.idle=708ns
2024-03-02T07:35:02.390582Z INFO runtime.run(...): close time.busy=427ms time.idle=85.4µs
2024-03-02T07:35:02.400696Z INFO runtime.prove(...): Sharding the execution record.
2024-03-02T07:35:02.400712Z INFO runtime.prove(...): Generating trace for each chip.
2024-03-02T07:35:02.400713Z INFO runtime.prove(...): Record stats before generate_trace (incomplete): ShardStats {
nb_cpu_events: 7476561,
nb_add_events: 2126546,
nb_mul_events: 11116,
nb_sub_events: 54075,
nb_bitwise_events: 646940,
nb_shift_left_events: 142595,
nb_shift_right_events: 274016,
nb_divrem_events: 0,
nb_lt_events: 81862,
nb_field_events: 0,
nb_sha_extend_events: 0,
nb_sha_compress_events: 0,
nb_keccak_permute_events: 2916,
nb_ed_add_events: 0,
nb_ed_decompress_events: 0,
nb_weierstrass_add_events: 0,
nb_weierstrass_double_events: 0,
nb_k256_decompress_events: 0,
}
I'm curious what the number of nb_ed_add_events
and nb_ed_decompress_events
are. Are you running this with your branch in Tendermint-rs with the fixes for early existing the stake weight?
// Generate proof. | ||
utils::setup_logger(); | ||
let stdin = SP1Stdin::new(); | ||
let peer_id: [u8; 20] = [ |
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.
what is this peer_id? can you add a comment/doc for it and what it stands for?
@@ -1,11 +1,30 @@ | |||
use sp1_core::{utils, SP1Prover, SP1Stdin, SP1Verifier}; | |||
|
|||
use crate::util::generate_light_block_at_given_block_height; | |||
|
|||
const ED25519_ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf"); |
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.
hm I know this isn't your fault but we should change the name of this :P
|
||
stdin.write(&light_block_1); | ||
stdin.write(&light_block_2); | ||
|
||
let proof = SP1Prover::prove(ED25519_ELF, stdin).expect("proving failed"); |
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.
nit: let's change the name of this to TENDERMINT_ELF
aae77fa
to
68ee3ce
Compare
@i-m-aditya when I ran this locally, I got this error in the runtime, which means that the program cannot deserialize the input that's being passed in.
|
@puma314 can you check now, there were earlier some dependency resolution issues. |
Hey @i-m-aditya, I think if you scroll up in your terminal, you'll see at the beginning of your program that your program is still panicking. This is why the number of cycles (8571) is so small in your image you shared--because the program is panicking and then early exiting. I actually have a PR out right now that will panic in the runtime if the program itself panics (it's still technical a valid execution of RISCV bytecode to panic, which is why you are still able to generate a proof). But I would suggest just scrolling up in your terminal to debug your program, or use the execution only mode of Let me know if you have any questions! Also feel free to join the SP1 telegram support group if you want to have more realtime chat support and I can help you out there! |
ec8e55e
to
d389efb
Compare
d389efb
to
2beee8e
Compare
Co-authored-by: Uma Roy <uma.roy.us@gmail.com>
fix: optimize tendermint zk light client
progress:
Refs: #233