Skip to content

Commit

Permalink
Begin prove_rpc.rs impl
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerad committed Nov 14, 2024
1 parent bf70bda commit 01ab634
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ categories.workspace = true
publish = false

[dependencies]
alloy.workspace = true
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
Expand Down
61 changes: 61 additions & 0 deletions scripts/prove_rpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use alloy::{eips::BlockId, transports::http::reqwest::Url};
use anyhow::Result;
use clap::{arg, Args, ValueEnum, ValueHint};

#[derive(ValueEnum, Clone)]
enum RpcType {
Jerigon,
Native,
}

#[derive(ValueEnum, Clone)]
enum RunMode {
/// Dummy proof is generated only. Useful for quickly testing decoding and
/// all other non-proving logic.
Test,
/// The proof generated but is not verified.
Prove,
/// The proof generated and verified.
Verify,
}

#[derive(Args)]
pub struct ProveRpcArgs {
/// The node RPC URL.
#[arg(short = 'u', value_hint = ValueHint::Url)]
rpc_url: Url,
/// The RPC type (jerigon or native).
#[arg(short = 't', long)]
rpc_type: RpcType,
/// The start of the block range to prove (inclusive).
#[arg(short = 's', long)]
start_block: BlockId,
/// The end of the block range to prove. If None, start_block-1 is used.
#[arg(short = 'e', long)]
checkpoint_block: Option<BlockId>,
/// The end of the block range to prove (inclusive).
#[arg(short = 'e', long)]
end_block: Option<BlockId>,
/// Backoff in milliseconds for retry requests
#[arg(short = 'b', long, default_value_t = 0)]
backoff: u64,
/// The maximum number of retries
#[arg(short = 'r', long, default_value_t = 0)]
max_retries: u32,
/// Whether to generate a proof and verify it or not.
#[arg(short = 'm', long)]
mode: RunMode,
}
// 1 --> Start block (number in decimal or block hash with prefix 0x). E.g.
// `1234` or `0x1d5e7a08dd1f4ce7fa52afe7f4960d78e82e508c874838dee594d5300b8df625`.
// 2 --> End block (number or hash, inclusive). Same format as start block.
// 3 --> Rpc endpoint:port (eg. http://35.246.1.96:8545)
// 4 --> Rpc type (eg. jerigon / native)
// 5 --> Checkpoint block (number or hash). If argument is missing, start block
// predecessor will be used. 6 --> Backoff in milliseconds (optional [default:
// 0]) 7 --> Number of retries (optional [default: 0])
// 8 --> Test run only flag `test_only` (optional)

pub fn prove_via_rpc(args: ProveRpcArgs) -> Result<()> {
todo!()
}
5 changes: 5 additions & 0 deletions scripts/xtask.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! General purpose scripts for development
mod outdated;
mod prove_rpc;

use anyhow::Result;
use clap::Parser;
use outdated::list_outdated_deps;
use prove_rpc::{prove_via_rpc, ProveRpcArgs};

#[derive(Parser)]
enum Args {
Expand All @@ -16,10 +18,13 @@ enum Args {
/// Note that we only warn on our _direct_ dependencies,
/// not the entire supply chain.
Outdated,
/// Execute proving via RPC endpoint.
ProveRpc(Box<ProveRpcArgs>),
}

fn main() -> Result<()> {
match Args::parse() {
Args::Outdated => list_outdated_deps(),
Args::ProveRpc(args) => prove_via_rpc(*args),
}
}

0 comments on commit 01ab634

Please sign in to comment.