Skip to content

Commit 6597158

Browse files
authored
refactor: bulk rename combined prover to batch prover (#286)
* refactor: bulk rename combined prover to batch prover * chore: cargo fmt
1 parent 876bef9 commit 6597158

File tree

28 files changed

+85
-85
lines changed

28 files changed

+85
-85
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ members = [
44
"crates/ev-prover",
55
"crates/ev-state-queries",
66
"crates/ev-zkevm-types",
7-
"crates/sp1/ev-combined/program",
8-
"crates/sp1/ev-combined/script",
7+
"crates/sp1/ev-batch-exec/program",
8+
"crates/sp1/ev-batch-exec/script",
99
"crates/sp1/ev-exec/program",
1010
"crates/sp1/ev-exec/script",
1111
"crates/sp1/ev-hyperlane/program",

crates/ev-prover/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[features]
7-
combined = []
7+
batch_mode = []
88

99
[dependencies]
1010
alloy = { workspace = true }

crates/ev-prover/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
The `ev-prover` service is a simple gRPC service designed to serve ZK proofs to clients.
33
It encapsulates the SP1 programs maintained under `sp1`, and uses the `sp1_sdk::ProverClient` in order to interface with them.
44

5-
## Running the ev-prover service in `combined` mode for a private or public testnet
6-
The combined mode aggregates a range of blocks and proves them in one go, using a single GPU instance. This mode is better than default
5+
## Running the ev-prover service in `batch_mode` mode for a private or public testnet
6+
The batch mode aggregates a range of blocks and proves them in one go, using a single GPU instance. This mode is better than default
77
when using the succinct prover network, because in default mode the base fee will accumulate and cause huge costs.
88

99
### Setup
@@ -26,7 +26,7 @@ Run the following commands from the root of the repository.
2626

2727
1. Install the binary to Cargo binary directory ~/.cargo/bin
2828
```shell
29-
cargo install --path ./crates/ev-prover --features combined
29+
cargo install --path ./crates/ev-prover --features batch_mode
3030
```
3131

3232
2. Initialize a new `ev-prover` home directory and configuration file with defaults:
@@ -40,10 +40,10 @@ Run the following commands from the root of the repository.
4040
RUST_LOG="ev_prover=debug" ev-prover start
4141
```
4242

43-
The service will join the tasks in `src/prover/programs/combined.rs` and `src/prover/programs/message.rs`.
43+
The service will join the tasks in `src/prover/programs/batch.rs` and `src/prover/programs/message.rs`.
4444

4545
## Running the ev-prover service using the `ev-exec` and `ev-range-exec` circuits
46-
The default mode, without the `combined` feature enabled, will prove every single blocks and recursively verify block proofs in a
46+
The default mode, without the `batch_mode` feature enabled, will prove every single blocks and recursively verify block proofs in a
4747
range circuit. This is ideal for minimum latency, but expensive when running on Succinct's prover network / when paying for every prover instance
4848
launch.
4949

crates/ev-prover/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
44
build_program_with_args("../sp1/ev-exec/program", Default::default());
55
build_program_with_args("../sp1/ev-range-exec/program", Default::default());
66
build_program_with_args("../sp1/ev-hyperlane/program", Default::default());
7-
build_program_with_args("../sp1/ev-combined/program", Default::default());
7+
build_program_with_args("../sp1/ev-batch-exec/program", Default::default());
88
Ok(())
99
}

crates/ev-prover/src/command/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::proto::celestia::prover::v1::{
2020
GetBlockProofRequest, GetBlockProofsInRangeRequest, GetLatestBlockProofRequest, GetLatestMembershipProofRequest,
2121
GetMembershipProofRequest, GetRangeProofsRequest,
2222
};
23-
use crate::prover::programs::combined::EV_COMBINED_ELF;
23+
use crate::prover::programs::batch::BATCH_ELF;
2424
use crate::prover::programs::message::EV_HYPERLANE_ELF;
2525
use crate::server::start_server;
2626
use storage::proofs::{ProofStorage, RocksDbProofStorage};
@@ -86,7 +86,7 @@ pub async fn create_zkism() -> Result<()> {
8686

8787
info!("setting up ELF for state proofs");
8888
let prover = ProverClient::builder().cpu().build();
89-
let (_, vk) = prover.setup(EV_COMBINED_ELF);
89+
let (_, vk) = prover.setup(BATCH_ELF);
9090
let state_transition_vkey = vk.bytes32_raw().to_vec();
9191

9292
info!("setting up ELF for membership proofs");

crates/ev-prover/src/prover/programs/combined.rs renamed to crates/ev-prover/src/prover/programs/batch.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use celestia_types::{
1919
Blob,
2020
};
2121
use ev_types::v1::SignedData;
22-
use ev_zkevm_types::programs::block::{BlockExecInput, BlockRangeExecOutput, EvCombinedInput};
22+
use ev_zkevm_types::programs::block::{BatchExecInput, BlockExecInput, BlockRangeExecOutput};
2323
use prost::Message;
2424
use reth_chainspec::ChainSpec;
2525
use rsp_client_executor::io::EthClientExecutorInput;
@@ -33,7 +33,7 @@ use crate::prover::ProgramProver;
3333
use crate::prover::{prover_from_env, SP1Prover};
3434

3535
/// The ELF (executable and linkable format) file for the Succinct RISC-V zkVM.
36-
pub const EV_COMBINED_ELF: &[u8] = include_elf!("ev-combined-program");
36+
pub const BATCH_ELF: &[u8] = include_elf!("ev-batch-program");
3737

3838
/// ProverStatus of the latest Celestia state relevant to the prover loop.
3939
///
@@ -105,23 +105,23 @@ impl AppContext {
105105
}
106106

107107
#[derive(Clone)]
108-
pub struct CombinedProverConfig {
108+
pub struct BatchProverConfig {
109109
pub pk: Arc<SP1ProvingKey>,
110110
pub vk: Arc<SP1VerifyingKey>,
111111
pub proof_mode: SP1ProofMode,
112112
}
113113

114-
impl CombinedProverConfig {
114+
impl BatchProverConfig {
115115
pub fn new(pk: SP1ProvingKey, vk: SP1VerifyingKey, mode: SP1ProofMode) -> Self {
116-
CombinedProverConfig {
116+
BatchProverConfig {
117117
pk: Arc::new(pk),
118118
vk: Arc::new(vk),
119119
proof_mode: mode,
120120
}
121121
}
122122
}
123123

124-
impl ProverConfig for CombinedProverConfig {
124+
impl ProverConfig for BatchProverConfig {
125125
fn pk(&self) -> Arc<SP1ProvingKey> {
126126
Arc::clone(&self.pk)
127127
}
@@ -135,17 +135,17 @@ impl ProverConfig for CombinedProverConfig {
135135
}
136136
}
137137

138-
pub struct EvCombinedProver {
138+
pub struct BatchExecProver {
139139
app: AppContext,
140140
range_tx: mpsc::Sender<MessageProofRequest>,
141-
config: CombinedProverConfig,
141+
config: BatchProverConfig,
142142
prover: Arc<SP1Prover>,
143143
}
144144

145145
#[async_trait]
146-
impl ProgramProver for EvCombinedProver {
147-
type Config = CombinedProverConfig;
148-
type Input = EvCombinedInput;
146+
impl ProgramProver for BatchExecProver {
147+
type Config = BatchProverConfig;
148+
type Input = BatchExecInput;
149149
type Output = BlockRangeExecOutput;
150150

151151
fn cfg(&self) -> &Self::Config {
@@ -169,11 +169,11 @@ impl ProgramProver for EvCombinedProver {
169169
}
170170
}
171171

172-
impl EvCombinedProver {
172+
impl BatchExecProver {
173173
/// Creates a new prover instance.
174174
pub fn new(app: AppContext, range_tx: mpsc::Sender<MessageProofRequest>) -> Result<Self> {
175175
let prover = prover_from_env();
176-
let config = EvCombinedProver::default_config(prover.as_ref());
176+
let config = BatchExecProver::default_config(prover.as_ref());
177177

178178
Ok(Self {
179179
app,
@@ -184,9 +184,9 @@ impl EvCombinedProver {
184184
}
185185

186186
/// Returns the prover config.
187-
pub fn default_config(prover: &SP1Prover) -> CombinedProverConfig {
188-
let (pk, vk) = prover.setup(EV_COMBINED_ELF);
189-
CombinedProverConfig::new(pk, vk, SP1ProofMode::Groth16)
187+
pub fn default_config(prover: &SP1Prover) -> BatchProverConfig {
188+
let (pk, vk) = prover.setup(BATCH_ELF);
189+
BatchProverConfig::new(pk, vk, SP1ProofMode::Groth16)
190190
}
191191

192192
/// Starts the batched prover loop.
@@ -340,7 +340,7 @@ impl EvCombinedProver {
340340
start_height: u64,
341341
status: &ProverStatus,
342342
batch_size: u64,
343-
) -> Result<EvCombinedInput> {
343+
) -> Result<BatchExecInput> {
344344
let mut current_height = status.trusted_height;
345345
let mut current_root = status.trusted_root;
346346

@@ -365,7 +365,7 @@ impl EvCombinedProver {
365365

366366
// let mut stdin = SP1Stdin::new();
367367
// stdin.write(&);
368-
Ok(EvCombinedInput { blocks: block_inputs })
368+
Ok(BatchExecInput { blocks: block_inputs })
369369
}
370370

371371
/// Builds a single block prover input for the given height.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
pub mod batch;
12
pub mod block;
2-
pub mod combined;
33
pub mod message;
44
pub mod range;

crates/ev-prover/src/server/mod.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::prover::programs::message::HyperlaneMessageProver;
3131
use crate::prover::service::ProverService;
3232
use crate::prover::{MessageProofRequest, MessageProofSync};
3333

34-
#[cfg(not(feature = "combined"))]
34+
#[cfg(not(feature = "batch_mode"))]
3535
use crate::prover::{
3636
programs::{
3737
block::{AppContext, BlockExecProver},
@@ -42,37 +42,37 @@ use crate::prover::{
4242

4343
use crate::prover::programs::message::AppContext as MessageAppContext;
4444
use storage::proofs::ProofStorage;
45-
#[cfg(feature = "combined")]
45+
#[cfg(feature = "batch_mode")]
4646
use {
47-
crate::prover::programs::combined::{AppContext as CombinedAppContext, EvCombinedProver},
47+
crate::prover::programs::batch::{AppContext as BatchAppContext, BatchExecProver},
4848
std::time::Duration,
4949
};
5050

5151
struct Server {
5252
pub message_prover: Arc<HyperlaneMessageProver>,
53-
#[cfg(not(feature = "combined"))]
53+
#[cfg(not(feature = "batch_mode"))]
5454
pub block_prover: Arc<BlockExecProver>,
55-
#[cfg(not(feature = "combined"))]
55+
#[cfg(not(feature = "batch_mode"))]
5656
pub block_range_prover: Arc<BlockRangeExecProver>,
57-
#[cfg(feature = "combined")]
58-
pub combined_prover: Arc<EvCombinedProver>,
57+
#[cfg(feature = "batch_mode")]
58+
pub batch_prover: Arc<BatchExecProver>,
5959
}
6060

6161
impl Server {
6262
pub fn new(
6363
message_prover: Arc<HyperlaneMessageProver>,
64-
#[cfg(not(feature = "combined"))] block_prover: Arc<BlockExecProver>,
65-
#[cfg(not(feature = "combined"))] block_range_prover: Arc<BlockRangeExecProver>,
66-
#[cfg(feature = "combined")] combined_prover: Arc<EvCombinedProver>,
64+
#[cfg(not(feature = "batch_mode"))] block_prover: Arc<BlockExecProver>,
65+
#[cfg(not(feature = "batch_mode"))] block_range_prover: Arc<BlockRangeExecProver>,
66+
#[cfg(feature = "batch_mode")] batch_prover: Arc<BatchExecProver>,
6767
) -> Self {
6868
Self {
6969
message_prover,
70-
#[cfg(not(feature = "combined"))]
70+
#[cfg(not(feature = "batch_mode"))]
7171
block_prover,
72-
#[cfg(not(feature = "combined"))]
72+
#[cfg(not(feature = "batch_mode"))]
7373
block_range_prover,
74-
#[cfg(feature = "combined")]
75-
combined_prover,
74+
#[cfg(feature = "batch_mode")]
75+
batch_prover: batch_prover,
7676
}
7777
}
7878
pub async fn start_message_prover(
@@ -88,7 +88,7 @@ impl Server {
8888
}
8989
}))
9090
}
91-
#[cfg(not(feature = "combined"))]
91+
#[cfg(not(feature = "batch_mode"))]
9292
pub async fn start_block_prover(&self) -> Result<JoinHandle<()>> {
9393
let block_prover = Arc::clone(&self.block_prover);
9494
Ok(tokio::spawn(async move {
@@ -97,7 +97,7 @@ impl Server {
9797
}
9898
}))
9999
}
100-
#[cfg(not(feature = "combined"))]
100+
#[cfg(not(feature = "batch_mode"))]
101101
pub async fn start_block_range_prover(
102102
self,
103103
client: CelestiaIsmClient,
@@ -129,12 +129,12 @@ impl Server {
129129
}
130130
}))
131131
}
132-
#[cfg(feature = "combined")]
133-
pub async fn start_combined_prover(&self, message_sync: Arc<MessageProofSync>) -> Result<JoinHandle<()>> {
134-
let combined_prover = Arc::clone(&self.combined_prover);
132+
#[cfg(feature = "batch_mode")]
133+
pub async fn start_batch_prover(&self, message_sync: Arc<MessageProofSync>) -> Result<JoinHandle<()>> {
134+
let batch_prover = Arc::clone(&self.batch_prover);
135135
Ok(tokio::spawn(async move {
136-
if let Err(e) = combined_prover.run(message_sync).await {
137-
error!("Combined prover task failed: {e:?}");
136+
if let Err(e) = batch_prover.run(message_sync).await {
137+
error!("Batch prover task failed: {e:?}");
138138
}
139139
}))
140140
}
@@ -162,7 +162,7 @@ pub async fn start_server(config: Config) -> Result<()> {
162162
let config = ClientConfig::from_env()?;
163163
let ism_client = Arc::new(CelestiaIsmClient::new(config).await?);
164164

165-
#[cfg(not(feature = "combined"))]
165+
#[cfg(not(feature = "batch_mode"))]
166166
let wrapper_task = Some({
167167
let storage_clone: Arc<dyn ProofStorage> = storage.clone();
168168
let client_config = ClientConfig::from_env()?;
@@ -265,7 +265,7 @@ pub async fn start_server(config: Config) -> Result<()> {
265265
})
266266
});
267267

268-
#[cfg(feature = "combined")]
268+
#[cfg(feature = "batch_mode")]
269269
let wrapper_task = Some({
270270
let storage_clone: Arc<dyn ProofStorage> = storage.clone();
271271
let message_sync = MessageProofSync::shared();
@@ -274,18 +274,18 @@ pub async fn start_server(config: Config) -> Result<()> {
274274
tokio::spawn(async move {
275275
loop {
276276
let (tx_range, rx_range) = mpsc::channel::<MessageProofRequest>(256);
277-
let combined_context =
278-
match CombinedAppContext::from_config(&config_clone, Arc::clone(&ism_client_clone)).await {
277+
let batch_context =
278+
match BatchAppContext::from_config(&config_clone, Arc::clone(&ism_client_clone)).await {
279279
Ok(context) => context,
280280
Err(e) => {
281-
error!("Failed to create combined context: {e:?}");
281+
error!("Failed to create batch context: {e:?}");
282282
continue;
283283
}
284284
};
285-
let combined_prover = match EvCombinedProver::new(combined_context, tx_range) {
285+
let batch_prover = match BatchExecProver::new(batch_context, tx_range) {
286286
Ok(prover) => prover,
287287
Err(e) => {
288-
error!("Failed to create combined prover: {e:?}");
288+
error!("Failed to create batch prover: {e:?}");
289289
continue;
290290
}
291291
};
@@ -297,12 +297,12 @@ pub async fn start_server(config: Config) -> Result<()> {
297297
continue;
298298
}
299299
};
300-
let server = Arc::new(Server::new(Arc::new(message_prover), Arc::new(combined_prover)));
300+
let server = Arc::new(Server::new(Arc::new(message_prover), Arc::new(batch_prover)));
301301

302-
let mut combined_handle = match server.start_combined_prover(Arc::clone(&message_sync)).await {
302+
let mut batch_handle = match server.start_batch_prover(Arc::clone(&message_sync)).await {
303303
Ok(handle) => handle,
304304
Err(e) => {
305-
error!("Failed to start combined prover: {e:?}");
305+
error!("Failed to start batch prover: {e:?}");
306306
continue;
307307
}
308308
};
@@ -318,13 +318,13 @@ pub async fn start_server(config: Config) -> Result<()> {
318318
};
319319

320320
tokio::select! {
321-
r = &mut combined_handle => {
322-
error!("combined prover stopped: {:?}", r);
321+
r = &mut batch_handle => {
322+
error!("batch prover stopped: {:?}", r);
323323
message_handle.abort();
324324
}
325325
r = &mut message_handle => {
326326
error!("message prover stopped: {:?}", r);
327-
combined_handle.abort();
327+
batch_handle.abort();
328328
}
329329
}
330330
tokio::time::sleep(Duration::from_secs(1)).await;

crates/ev-zkevm-types/src/programs/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct BlockRangeExecInput {
9191
}
9292

9393
#[derive(Serialize, Deserialize, Debug)]
94-
pub struct EvCombinedInput {
94+
pub struct BatchExecInput {
9595
pub blocks: Vec<BlockExecInput>,
9696
}
9797

0 commit comments

Comments
 (0)