Skip to content

Commit f73da4d

Browse files
authored
fix(new-execution): warn if max_constraint_degree differ (#1979)
- emit a warning if `max_constraint_degree` don't matching between `VmConfig` and `StarkFriConfig`
1 parent 120f6db commit f73da4d

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

benchmarks/prove/src/bin/verify_fibair.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn main() -> Result<()> {
5454
app_fri_params.max_constraint_degree().min(7),
5555
);
5656
app_vm_config.system.profiling = args.profiling;
57+
app_vm_config.system.max_constraint_degree = (1 << app_log_blowup) + 1;
5758

5859
let compiler_options = CompilerOptions::default();
5960
let app_config = AppConfig {

benchmarks/prove/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ impl BenchmarkCli {
8888
let leaf_log_blowup = self.leaf_log_blowup.unwrap_or(DEFAULT_LEAF_LOG_BLOWUP);
8989

9090
app_vm_config.as_mut().profiling = self.profiling;
91+
app_vm_config.as_mut().max_constraint_degree = (1 << app_log_blowup) + 1;
9192
if let Some(max_height) = self.max_segment_length {
9293
app_vm_config.as_mut().segmentation_limits.max_trace_height = max_height;
9394
}

crates/sdk/src/keygen/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use crate::{
4949
perm::AirIdPermutation,
5050
},
5151
prover::vm::types::VmProvingKey,
52+
util::check_max_constraint_degrees,
5253
RootSC, SC,
5354
};
5455

@@ -126,6 +127,10 @@ where
126127
vm_pk.max_constraint_degree
127128
<= config.app_fri_params.fri_params.max_constraint_degree()
128129
);
130+
check_max_constraint_degrees(
131+
config.app_vm_config.as_ref(),
132+
&config.app_fri_params.fri_params,
133+
);
129134
VmProvingKey {
130135
fri_params: config.app_fri_params.fri_params,
131136
vm_config: config.app_vm_config.clone(),
@@ -306,6 +311,7 @@ impl AggProvingKey {
306311
leaf_vm_config.clone(),
307312
)?;
308313
assert!(vm_pk.max_constraint_degree <= config.leaf_fri_params.max_constraint_degree());
314+
check_max_constraint_degrees(&leaf_vm_config.system, &config.leaf_fri_params);
309315
Arc::new(VmProvingKey {
310316
fri_params: config.leaf_fri_params,
311317
vm_config: leaf_vm_config,
@@ -325,6 +331,7 @@ impl AggProvingKey {
325331
NativeCpuBuilder,
326332
internal_vm_config.clone(),
327333
)?;
334+
check_max_constraint_degrees(&internal_vm_config.system, &config.internal_fri_params);
328335
assert!(vm_pk.max_constraint_degree <= config.internal_fri_params.max_constraint_degree());
329336
let internal_vm_pk = Arc::new(VmProvingKey {
330337
fri_params: config.internal_fri_params,

crates/sdk/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ pub mod fs;
7373
pub mod keygen;
7474
pub mod prover;
7575
pub mod types;
76+
pub mod util;
7677

7778
mod error;
7879
mod stdin;

crates/sdk/src/prover/agg.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use openvm_stark_sdk::{engine::StarkFriEngine, openvm_stark_backend::proof::Proo
1616
use tracing::{info_span, instrument};
1717

1818
use crate::{
19-
config::AggregationTreeConfig, keygen::AggProvingKey, prover::vm::new_local_prover, F, SC,
19+
config::AggregationTreeConfig, keygen::AggProvingKey, prover::vm::new_local_prover,
20+
util::check_max_constraint_degrees, F, SC,
2021
};
2122
#[cfg(feature = "evm-prove")]
2223
use crate::{prover::RootVerifierLocalProver, RootSC};
@@ -124,6 +125,10 @@ where
124125
&mut self,
125126
app_proofs: &ContinuationVmProof<SC>,
126127
) -> Result<Vec<Proof<SC>>, VirtualMachineError> {
128+
check_max_constraint_degrees(
129+
self.leaf_prover.vm.config().as_ref(),
130+
&self.leaf_prover.vm.engine.fri_params(),
131+
);
127132
self.leaf_controller
128133
.generate_proof(&mut self.leaf_prover, app_proofs)
129134
}
@@ -146,6 +151,11 @@ where
146151
leaf_proofs: Vec<Proof<SC>>,
147152
public_values: Vec<F>,
148153
) -> Result<VmStarkProof<SC>, VirtualMachineError> {
154+
check_max_constraint_degrees(
155+
self.internal_prover.vm.config().as_ref(),
156+
&self.internal_prover.vm.engine.fri_params(),
157+
);
158+
149159
let mut internal_node_idx = -1;
150160
let mut internal_node_height = 0;
151161
let mut proofs = leaf_proofs;
@@ -258,6 +268,10 @@ where
258268
&mut self,
259269
root_input: RootVmVerifierInput<SC>,
260270
) -> Result<Proof<RootSC>, VirtualMachineError> {
271+
check_max_constraint_degrees(
272+
self.root_prover.vm_config().as_ref(),
273+
self.root_prover.fri_params(),
274+
);
261275
let input = root_input.write();
262276
#[cfg(feature = "metrics")]
263277
metrics::counter!("fri.log_blowup")

crates/sdk/src/prover/app.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::{
2727
commit::{AppExecutionCommit, CommitBytes},
2828
keygen::AppVerifyingKey,
2929
prover::vm::{new_local_prover, types::VmProvingKey},
30+
util::check_max_constraint_degrees,
3031
StdIn, F, SC,
3132
};
3233

@@ -133,6 +134,10 @@ where
133134
self.vm_config().as_ref().continuation_enabled,
134135
"Use generate_app_proof_without_continuations instead."
135136
);
137+
check_max_constraint_degrees(
138+
self.vm_config().as_ref(),
139+
&self.instance.vm.engine.fri_params(),
140+
);
136141
let proofs = info_span!(
137142
"app proof",
138143
group = self

crates/sdk/src/util.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use openvm_circuit::arch::SystemConfig;
2+
use openvm_stark_sdk::config::FriParameters;
3+
4+
pub fn check_max_constraint_degrees(config: &SystemConfig, fri_params: &FriParameters) {
5+
if config.max_constraint_degree != fri_params.max_constraint_degree() {
6+
tracing::warn!(
7+
"config.max_constraint_degree ({}) != fri_params.max_constraint_degree() ({})",
8+
config.max_constraint_degree,
9+
fri_params.max_constraint_degree()
10+
);
11+
}
12+
}

0 commit comments

Comments
 (0)