Skip to content

Commit fa76da1

Browse files
Merge staging
1 parent 0e80244 commit fa76da1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+865
-162
lines changed

.github/workflows/build-and-test-rust.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ jobs:
124124
- name: Run AggregationMode tests
125125
run: |
126126
cd aggregation_mode/proof_aggregator && cargo test
127-
cd ../batcher && cargo test
127+
cd ../gateway && cargo test
128+
cd ../payments_poller && cargo test

Makefile

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -317,27 +317,29 @@ agg_mode_docker_clean: agg_mode_docker_down
317317
agg_mode_run_migrations: agg_mode_docker_up
318318
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin migrate -- postgres://postgres:postgres@localhost:5435/
319319

320-
agg_mode_batcher_start_local: agg_mode_run_migrations
321-
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher -- config-files/config-agg-mode-batcher.yaml
320+
agg_mode_gateway_start_local: agg_mode_run_migrations
321+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin gateway -- config-files/config-agg-mode-gateway.yaml
322322

323-
agg_mode_batcher_start_ethereum_package: agg_mode_run_migrations
324-
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin agg_mode_batcher -- config-files/config-agg-mode-batcher-ethereum-package.yaml
323+
agg_mode_gateway_start_ethereum_package: agg_mode_run_migrations
324+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin gateway -- config-files/config-agg-mode-gateway-ethereum-package.yaml
325+
326+
agg_mode_payments_poller_start_local: agg_mode_run_migrations
327+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin payments_poller -- config-files/config-agg-mode-gateway.yaml
328+
329+
agg_mode_payments_poller_start_ethereum_package: agg_mode_run_migrations
330+
cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin payments_poller -- config-files/config-agg-mode-gateway-ethereum-package.yaml
325331

326332
AGG_MODE_SENDER ?= 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
327-
agg_mode_batcher_send_payment:
333+
agg_mode_gateway_send_payment:
328334
@cast send --value 1ether \
329335
0x922D6956C99E12DFeB3224DEA977D0939758A1Fe \
330336
--private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
331337

332-
agg_mode_batcher_send_sp1_proof:
333-
@NONCE=$$(curl -s http://127.0.0.1:8089/nonce/0x70997970C51812dc3A010C7d01b50e0d17dc79C8 | jq -r '.data.nonce'); \
334-
curl -X POST \
335-
-H "Content-Type: multipart/form-data" \
336-
-F "nonce=$${NONCE}" \
337-
-F "proof=@scripts/test_files/sp1/sp1_fibonacci_5_0_0.proof" \
338-
-F "program_vk=@scripts/test_files/sp1/sp1_fibonacci_5_0_0_vk.bin" \
339-
-F "_signature_hex=0x0" \
340-
http://127.0.0.1:8089/proof/sp1
338+
agg_mode_gateway_send_sp1_proof:
339+
@cargo run --manifest-path aggregation_mode/cli/Cargo.toml -- submit sp1 \
340+
--proof scripts/test_files/sp1/sp1_fibonacci_5_0_0.proof \
341+
--vk scripts/test_files/sp1/sp1_fibonacci_5_0_0_vk.bin \
342+
--private-key "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
341343

342344
agg_mode_get_quotas:
343345
curl -X GET http://127.0.0.1:8089/quotas/0x70997970C51812dc3A010C7d01b50e0d17dc79C8

aggregation_mode/Cargo.lock

Lines changed: 72 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aggregation_mode/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["./batcher", "./proof_aggregator", "./db"]
3+
members = ["./gateway", "./proof_aggregator", "./db", "./payments_poller", "./sdk", "./cli"]
44

55
[workspace.package]
66
version = "0.1.0"

aggregation_mode/batcher/abi/AggregationModePaymentService.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

aggregation_mode/batcher/src/server/mod.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

aggregation_mode/cli/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "agg_mode_cli"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
serde = { workspace = true }
8+
tracing = { version = "0.1", features = ["log"] }
9+
tracing-subscriber = { version = "0.3.0", features = ["env-filter"] }
10+
bincode = "1.3.3"
11+
tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] }
12+
alloy = { workspace = true }
13+
agg_mode_sdk = { path = "../sdk"}
14+
sp1-sdk = "5.0.0"
15+
clap = { version = "4.5.4", features = ["derive"] }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod submit;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use agg_mode_sdk::{gateway::provider::AggregationModeGatewayProvider, types::Network};
2+
use alloy::signers::local::LocalSigner;
3+
use clap::{command, Args, Subcommand};
4+
use sp1_sdk::{SP1ProofWithPublicValues, SP1VerifyingKey};
5+
use std::{path::PathBuf, str::FromStr};
6+
7+
#[derive(Debug, Subcommand)]
8+
pub enum SubmitCommand {
9+
#[command(name = "sp1")]
10+
SP1(SubmitSP1Args),
11+
}
12+
13+
#[derive(Debug, Clone, Args)]
14+
pub struct SubmitSP1Args {
15+
#[arg(short = 'p', long = "proof")]
16+
proof_path: PathBuf,
17+
#[arg(long = "vk")]
18+
verifying_key_path: PathBuf,
19+
#[arg(long = "private-key")]
20+
private_key: String,
21+
#[arg(short = 'n', long = "network", default_value = "devnet", value_parser = parse_network)]
22+
network: Network,
23+
}
24+
25+
fn parse_network(value: &str) -> Result<Network, String> {
26+
Network::from_str(value).map_err(|_| format!("unsupported network supplied: {value}"))
27+
}
28+
29+
pub async fn run(args: SubmitSP1Args) {
30+
tracing::info!("Submitting SP1 proof to {:?} ", args.network);
31+
32+
let proof = load_proof(&args.proof_path).expect("Valid proof");
33+
let vk = load_vk(&args.verifying_key_path).expect("Valid vk");
34+
35+
let signer =
36+
LocalSigner::from_str(args.private_key.trim()).expect("failed to parse private key: {e}");
37+
38+
let provider = AggregationModeGatewayProvider::new_with_signer(args.network.clone(), signer)
39+
.expect("failed to initialize gateway client: {e:?}");
40+
41+
let response = provider
42+
.submit_sp1_proof(&proof, &vk)
43+
.await
44+
.expect("failed to submit proof: {e:?}");
45+
46+
tracing::info!(
47+
"Proof submitted successfully. Task ID: {}",
48+
response.data.task_id
49+
);
50+
}
51+
52+
fn load_proof(path: &PathBuf) -> Result<SP1ProofWithPublicValues, String> {
53+
let bytes = std::fs::read(path)
54+
.map_err(|e| format!("failed to read proof from {}: {e}", path.display()))?;
55+
56+
bincode::deserialize(&bytes)
57+
.map_err(|e| format!("failed to deserialize proof {}: {e}", path.display()))
58+
}
59+
60+
fn load_vk(path: &PathBuf) -> Result<SP1VerifyingKey, String> {
61+
let bytes = std::fs::read(path)
62+
.map_err(|e| format!("failed to read verifying key from {}: {e}", path.display()))?;
63+
64+
bincode::deserialize(&bytes).map_err(|e| {
65+
format!(
66+
"failed to deserialize verifying key {}: {e}",
67+
path.display()
68+
)
69+
})
70+
}

aggregation_mode/cli/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod commands;

0 commit comments

Comments
 (0)