Skip to content

Commit

Permalink
Revert degree changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyunyunyunyu committed Jan 23, 2025
1 parent 4fee261 commit ae71e73
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 45 deletions.
4 changes: 2 additions & 2 deletions crates/sdk/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn test_static_verifier_custom_pv_handler() {

// Test setup
println!("test setup");
let app_log_blowup = 2;
let app_log_blowup = 1;
let app_config = small_test_app_config(app_log_blowup);
let app_pk = Sdk.app_keygen(app_config.clone()).unwrap();
let app_committed_exe = app_committed_exe_for_test(app_log_blowup);
Expand Down Expand Up @@ -358,7 +358,7 @@ fn test_static_verifier_custom_pv_handler() {

#[test]
fn test_e2e_proof_generation_and_verification() {
let app_log_blowup = 2;
let app_log_blowup = 1;
let app_config = small_test_app_config(app_log_blowup);
let app_pk = Sdk.app_keygen(app_config).unwrap();
let params_reader = CacheHalo2ParamsReader::new_with_default_params_dir();
Expand Down
7 changes: 4 additions & 3 deletions crates/vm/src/arch/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use super::{
use crate::system::memory::BOUNDARY_AIR_OFFSET;

const DEFAULT_MAX_SEGMENT_LEN: usize = (1 << 22) - 100;
// FRI Reduced Opening Chip has degree = 4.
const DEFAULT_MAX_CONSTRAINT_DEGREE: usize = 4;
// sbox is decomposed to have this max degree for Poseidon2. We set to 3 so quotient_degree = 2
// allows log_blowup = 1
const DEFAULT_POSEIDON2_MAX_CONSTRAINT_DEGREE: usize = 3;
/// Width of Poseidon2 VM uses.
pub const POSEIDON2_WIDTH: usize = 16;
/// Returns a Poseidon2 config for the VM.
Expand Down Expand Up @@ -167,7 +168,7 @@ impl SystemConfig {
impl Default for SystemConfig {
fn default() -> Self {
Self::new(
DEFAULT_MAX_CONSTRAINT_DEGREE,
DEFAULT_POSEIDON2_MAX_CONSTRAINT_DEGREE,
Default::default(),
DEFAULT_MAX_NUM_PUBLIC_VALUES,
)
Expand Down
22 changes: 9 additions & 13 deletions crates/vm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn test_vm_override_executor_height() {
));

// Test getting heights.
let vm_config = NativeConfig::aggregation(8, 5);
let vm_config = NativeConfig::aggregation(8, 3);

let executor = SingleSegmentVmExecutor::new(vm_config.clone());
let res = executor
Expand Down Expand Up @@ -211,7 +211,7 @@ fn test_vm_override_executor_height() {
fn test_vm_1_optional_air() {
// Aggregation VmConfig has Core/Poseidon2/FieldArithmetic/FieldExtension chips. The program only
// uses Core and FieldArithmetic. All other chips should not have AIR proof inputs.
let config = NativeConfig::aggregation(4, 5);
let config = NativeConfig::aggregation(4, 3);
let engine =
BabyBearPoseidon2Engine::new(standard_fri_params_with_100_bits_conjectured_security(3));
let vm = VirtualMachine::new(engine, config);
Expand Down Expand Up @@ -319,7 +319,7 @@ fn test_vm_initial_memory() {
.into_iter()
.collect();

let config = NativeConfig::aggregation(0, 5).with_continuations();
let config = NativeConfig::aggregation(0, 3).with_continuations();
let exe = VmExe {
program,
pc_start: 0,
Expand All @@ -331,11 +331,9 @@ fn test_vm_initial_memory() {

#[test]
fn test_vm_1_persistent() {
let engine = BabyBearPoseidon2Engine::new(
FriParameters::standard_with_100_bits_conjectured_security(2),
);
let engine = BabyBearPoseidon2Engine::new(FriParameters::standard_fast());
let config = NativeConfig {
system: SystemConfig::new(5, MemoryConfig::new(1, 1, 16, 10, 6, 64, 1024), 0),
system: SystemConfig::new(3, MemoryConfig::new(1, 1, 16, 10, 6, 64, 1024), 0),
native: Default::default(),
}
.with_continuations();
Expand Down Expand Up @@ -445,7 +443,7 @@ fn test_vm_continuations() {
let n = 200000;
let program = gen_continuation_test_program(n);
let config = NativeConfig {
system: SystemConfig::new(5, MemoryConfig::default(), 0).with_max_segment_len(200000),
system: SystemConfig::new(3, MemoryConfig::default(), 0).with_max_segment_len(200000),
native: Default::default(),
}
.with_continuations();
Expand Down Expand Up @@ -475,13 +473,11 @@ fn test_vm_continuations_recover_state() {
let n = 2000;
let program = gen_continuation_test_program(n);
let config = NativeConfig {
system: SystemConfig::new(5, MemoryConfig::default(), 0).with_max_segment_len(500),
system: SystemConfig::new(3, MemoryConfig::default(), 0).with_max_segment_len(500),
native: Default::default(),
}
.with_continuations();
let engine = BabyBearPoseidon2Engine::new(
FriParameters::standard_with_100_bits_conjectured_security(2),
);
let engine = BabyBearPoseidon2Engine::new(FriParameters::standard_fast());
let vm = VirtualMachine::new(engine, config.clone());
let pk = vm.keygen();
let segments = vm
Expand Down Expand Up @@ -733,7 +729,7 @@ fn test_vm_field_extension_arithmetic_persistent() {

let program = Program::from_instructions(&instructions);
let config = NativeConfig {
system: SystemConfig::new(5, MemoryConfig::new(1, 1, 16, 10, 6, 64, 1024), 0)
system: SystemConfig::new(3, MemoryConfig::new(1, 1, 16, 10, 6, 64, 1024), 0)
.with_continuations(),
native: Default::default(),
};
Expand Down
4 changes: 2 additions & 2 deletions extensions/native/circuit/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ impl NativeConfig {
self
}

pub fn aggregation(num_public_values: usize, max_constraint_degree: usize) -> Self {
pub fn aggregation(num_public_values: usize, poseidon2_max_constraint_degree: usize) -> Self {
Self {
system: SystemConfig::new(
max_constraint_degree,
poseidon2_max_constraint_degree,
MemoryConfig {
max_access_adapter_n: 8,
..Default::default()
Expand Down
26 changes: 4 additions & 22 deletions extensions/native/circuit/src/fri/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ use openvm_stark_backend::{
utils::disable_debug_builder,
verifier::VerificationError,
};
use openvm_stark_sdk::{
config::{baby_bear_poseidon2::BabyBearPoseidon2Engine, FriParameters},
engine::StarkFriEngine,
p3_baby_bear::BabyBear,
utils::create_seeded_rng,
};
use openvm_stark_sdk::{engine::StarkFriEngine, p3_baby_bear::BabyBear, utils::create_seeded_rng};
use rand::Rng;

use super::{super::field_extension::FieldExtension, elem_to_ext, FriReducedOpeningChip, EXT_DEG};
Expand Down Expand Up @@ -123,15 +118,8 @@ fn fri_mat_opening_air_test() {
assert_eq!(result, tester.read(address_space, result_pointer));
}

let mut tester = tester.build_babybear_poseidon2().load(chip).finalize();
// Degree needs >= 4
tester
.test::<BabyBearPoseidon2Engine, _>(|| {
BabyBearPoseidon2Engine::new(
FriParameters::standard_with_100_bits_conjectured_security(2),
)
})
.expect("Verification failed");
let mut tester = tester.build().load(chip).finalize();
tester.simple_test().expect("Verification failed");

disable_debug_builder();
// negative test pranking each value
Expand All @@ -148,13 +136,7 @@ fn fri_mat_opening_air_test() {

// Run a test after pranking each row
assert_eq!(
tester
.test::<BabyBearPoseidon2Engine, _>(|| {
BabyBearPoseidon2Engine::new(
FriParameters::standard_with_100_bits_conjectured_security(2),
)
})
.err(),
tester.simple_test().err(),
Some(VerificationError::OodEvaluationMismatch),
"Expected constraint to fail"
);
Expand Down
4 changes: 1 addition & 3 deletions extensions/native/recursion/src/testing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ pub mod inner {
fri_params: FriParameters,
) {
let vparams = test_proof_input
.run_test(&BabyBearPoseidon2Engine::new(
FriParameters::standard_with_100_bits_conjectured_security(2),
))
.run_test(&BabyBearPoseidon2Engine::new(FriParameters::standard_fast()))
.unwrap();

recursive_stark_test(
Expand Down

0 comments on commit ae71e73

Please sign in to comment.