-
Notifications
You must be signed in to change notification settings - Fork 360
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(sdk): add types and use builder pattern #1846
Conversation
SP1 Performance Test Results Branch: mattstam/sdk-network-polish
|
pub mod proto; | ||
mod proto; | ||
|
||
pub use client::*; |
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.
flattening this to make the API clean e.g. use sp1_sdk::network_v2::{Error, FulfillmentStrategy}
|
||
/// A 32-byte hash that uniquely identifies a proof request. | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub struct RequestId(Vec<u8>); |
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.
RequestHash, to be consistent?
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's request_id everywhere in the proto, on the RPC, and on the frontend - to avoid a massive refactor I feel like leaving at RequestId is fine
944fbba
to
61b83a2
Compare
/// Creates a new [NetworkProver] with the given private key. | ||
pub fn new(private_key: &str, rpc_url: Option<String>, skip_simulation: bool) -> Self { | ||
/// Creates a new `NetworkProver` with the given private key. | ||
pub fn new(private_key: &str) -> Self { |
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: Should we really use a string
here? Seems like B256
may be a better choice.
Alternatively, Alloy has the same problem and has a reasonable type that they expose for this: https://github.com/alloy-rs/alloy/blob/main/crates/signer-local/src/lib.rs
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'm open to it, although String seems the most versatile, as otherwise the client needs to import Alloy / whatever type we enforce.
@@ -109,6 +116,10 @@ impl<'a> Prove<'a> { | |||
core_opts: SP1CoreOpts::default(), | |||
recursion_opts: SP1CoreOpts::recursion(), | |||
timeout: None, |
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.
note: the actions prove struct, context builder, and proof opts seem kinda clunky to me (at least for using things on the network) - for example, it's not clear why max_cycles is not simply a field
but refactoring all this is out of scope of this PR, no users really see this anyway
2d1440a
to
8874706
Compare
This PR updates the network-v2 SDK with:
thiserror
(e.g. to implement different logic for unexecutable vs unfulfillable)New options for using ProverClient to request proofs:
note, because we are using ProverClient, we need to downcast the error:
Example of error bubbling up and handling it in
network.rs
:In a real situation, you may want to retry if it's unfulfillable or implement custom logic.