-
Notifications
You must be signed in to change notification settings - Fork 0
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
Integrate Scroll prover with Snarkify SDK #4
Conversation
prover/src/bin/snarkify.rs
Outdated
let config: Config = Config::from_file("config.json".to_string()).map_err(|e| e.to_string())?; | ||
|
||
if let Err(e) = AssetsDirEnvConfig::init() { | ||
log::error!("AssetsDirEnvConfig init failed: {:#}", e); | ||
std::process::exit(-2); | ||
} | ||
|
||
let prover = Prover::new(&config).map_err(|e| e.to_string())?; | ||
|
||
log::info!( | ||
"prover start successfully. name: {}, type: {:?}, publickey: {}, version: {}", | ||
config.prover_name, | ||
config.proof_type, | ||
prover.get_public_key(), | ||
version::get_version(), | ||
); |
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.
@cyphersnake, Need some advice here. We want the prover to be reused across different reqeusts, so we woud like it to be stored as a static variable and lazily initialized. Chatgpt recommended to use
static PROVER: OnceCell<Prover> = OnceCell::new();
let prover = PROVER.get_or_init(|| {
...
})
but the compiler is giving many errors about thread-safty. In our use case we know that it is a single-threaded model, how should I rewrite the code to achieve my goal. Can you help take a look?
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.
https://doc.rust-lang.org/std/macro.thread_local.html
use std::cell::RefCell;
struct Prover;
impl Prover {
fn new() -> Self {
Self
}
fn ping(&self) -> u8 {
42
}
fn pong(&mut self) -> u8 {
42
}
}
thread_local! {
static GLOBAL: RefCell<Prover> = RefCell::new(Prover::new());
}
fn main() {
GLOBAL.with_borrow(|v| {
v.ping();
});
GLOBAL.with_borrow_mut(|v| {
v.pong();
});
}
Let me know if that's not enough
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.
Made the change as you suggested, and I think it works! Thanks!
This reverts commit 5776916.
* pin halo2-proofs version * update to tag
5b1430b
to
9999b1e
Compare
prover/README.md
Outdated
@@ -0,0 +1,30 @@ | |||
## How-to run Snarkify prover locally | |||
1. `make snarkify` | |||
2. update `config.json` with right coordinator and l2geth endpoints |
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: better to list what are the endpoints for testnet and mainnet.
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.
and why prover needs coordinator endpoint? My gut is that only relayer needs it.
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.
It doesn't use coordinator endpoint, I'll remove this requirement for now.
b942567
to
42121d6
Compare
No description provided.