Skip to content
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

Oxidize prove_rpc.sh #796

Merged
merged 22 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/jerigon-native.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--- # Run and populate blockchain with transactions and generate proofs using native tracer
--- # Run and populate blockchain with transactions and generate proofs using native tracer

name: Jerigon Integration

Expand Down Expand Up @@ -76,14 +76,14 @@ jobs:
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
ulimit -n 8192
OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 1 15 $ETH_RPC_URL native 0 3000 100 test_only
cargo xtask prove-rpc "$ETH_RPC_URL" native test 1 -e 15 -c 0 -b 3000 -r 100
echo "Proving blocks in test_only mode finished"

- name: Run prove blocks with native tracer in real mode
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./scripts/prove_rpc.sh 4 7 $ETH_RPC_URL native 3 3000 100
cargo xtask prove-rpc "$ETH_RPC_URL" native verify 4 -e 7 -c 3 -b 3000 -r 100
echo "Proving blocks in real mode finished"

- name: Shut down network
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/jerigon-zero.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--- # Run and populate blockchain with transactions and generate proofs using zero tracer
--- # Run and populate blockchain with transactions and generate proofs using zero tracer

name: Jerigon Integration

Expand Down Expand Up @@ -76,14 +76,14 @@ jobs:
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
ulimit -n 8192
OUTPUT_TO_TERMINAL=true ./scripts/prove_rpc.sh 1 15 $ETH_RPC_URL jerigon 0 3000 100 test_only
cargo xtask prove-rpc "$ETH_RPC_URL" jerigon test 1 -e 15 -c 0 -b 3000 -r 100
echo "Proving blocks in test_only mode finished"

- name: Run prove blocks with zero tracer in real mode
run: |
ETH_RPC_URL="$(kurtosis port print cancun-testnet el-2-erigon-lighthouse ws-rpc)"
rm -rf proofs/* circuits/* ./proofs.json test.out verify.out leader.out
OUTPUT_TO_TERMINAL=true RUN_VERIFICATION=true ./scripts/prove_rpc.sh 2 5 $ETH_RPC_URL jerigon 1 3000 100
cargo xtask prove-rpc "$ETH_RPC_URL" jerigon verify 2 -e 5 -c 1 -b 3000 -r 100
echo "Proving blocks in real mode finished"

- name: Shut down network
Expand Down
82 changes: 80 additions & 2 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ categories.workspace = true
publish = false

[dependencies]
alloy.workspace = true
anyhow.workspace = true
clap = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
sysinfo = "0.32.0"

[lints]
workspace = true
Expand Down
54 changes: 54 additions & 0 deletions scripts/outdated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::process::{Command, Stdio};

use anyhow::Result;
atanmarko marked this conversation as resolved.
Show resolved Hide resolved
use anyhow::{ensure, Context as _};
use serde::Deserialize;

#[derive(Deserialize)]
struct Outdated<'a> {
crate_name: &'a str,
dependencies: Vec<Dependency<'a>>,
}

#[derive(Deserialize)]
struct Dependency<'a> {
name: &'a str,
project: &'a str,
latest: &'a str,
}

pub fn list_outdated_deps() -> Result<()> {
let output = Command::new("cargo")
.args(["outdated", "--root-deps-only", "--format=json"])
.stderr(Stdio::inherit())
.stdout(Stdio::piped())
.output()
.context("couldn't exec `cargo`")?;
ensure!(
output.status.success(),
"command failed with {}",
output.status
);

let outdated_items = serde_json::Deserializer::from_slice(&output.stdout)
.into_iter::<Outdated<'_>>()
.collect::<Result<Vec<_>, _>>()
.context("failed to parse output from `cargo outdated`")?;
for Outdated {
crate_name,
dependencies,
} in outdated_items
{
for Dependency {
name,
project,
latest,
} in dependencies
{
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
println!("::warning title=outdated-dependency::dependency {name} of crate {crate_name} is at version {project}, but the latest is {latest}")
}
}

Ok(())
}
59 changes: 59 additions & 0 deletions scripts/process.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use std::{
atanmarko marked this conversation as resolved.
Show resolved Hide resolved
fs::File,
path::Path,
process::{Command, Stdio},
};

use anyhow::{ensure, Context as _, Result};
atanmarko marked this conversation as resolved.
Show resolved Hide resolved

/// A means of running a command as a subprocess.
pub struct Process {
cmd: String,
args: Vec<String>,
stdout: Stdio,
stderr: Stdio,
}

impl Process {
/// Create a new runner with the given command.
pub fn new(cmd: impl Into<String>) -> Self {
Self {
cmd: cmd.into(),
args: vec![],
stdout: Stdio::inherit(),
stderr: Stdio::inherit(),
}
}

/// Add arguments to the command.
pub fn args(mut self, args: &[&str]) -> Self {
self.args.extend(args.iter().map(|s| s.to_string()));
self
}

/// Create the file specified by `output_filepath` and set it as the stdout
/// and stderr of the command.
pub fn pipe(mut self, output_filepath: &Path) -> Result<Self> {
let out = File::create(output_filepath)?;
let err = out.try_clone()?;
self.stdout = Stdio::from(out);
self.stderr = Stdio::from(err);
Ok(self)
}

/// Run the command.
pub fn run(self) -> Result<()> {
let output = Command::new(&self.cmd)
.args(&self.args)
.stdout(self.stdout)
.stderr(self.stderr)
.output()
.context(format!("couldn't exec `{}`", &self.cmd))?;
ensure!(
output.status.success(),
"command failed with {}",
output.status
);
Ok(())
}
}
Loading
Loading