Skip to content

Commit 7e05fe2

Browse files
feat!: removing final machine support (#132)
## What ❔ * Removing support for 2^25 'final' machine * We use 2^23 with delegations instead. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e582bd9 commit 7e05fe2

File tree

13 files changed

+65
-229
lines changed

13 files changed

+65
-229
lines changed

execution_utils/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ pub const FINAL_RECURSION_LAYER_VERIFIER_WITH_OUTPUT: &[u8] =
5858

5959
pub const UNIVERSAL_CIRCUIT_VERIFIER: &[u8] = include_bytes!("../../tools/verifier/universal.bin");
6060

61-
pub const UNIVERSAL_CIRCUIT_NO_DELEGATION_VERIFIER: &[u8] =
62-
include_bytes!("../../tools/verifier/universal_no_delegation.bin");
63-
6461
// Methods to fetch the verification keys for the binaries above.
6562
// They are usually refreshed with build_vk.sh
6663
pub fn base_layer_verifier_vk() -> VerificationKey {
@@ -112,13 +109,6 @@ pub fn universal_circuit_log_23_verifier_vk() -> VerificationKey {
112109
.unwrap()
113110
}
114111

115-
pub fn universal_circuit_no_delegation_verifier_vk() -> VerificationKey {
116-
serde_json::from_slice::<VerificationKey>(include_bytes!(
117-
"../../tools/verifier/universal_no_delegation.final.vk.json"
118-
))
119-
.unwrap()
120-
}
121-
122112
pub fn get_padded_binary(binary: &[u8]) -> Vec<u32> {
123113
let mut bytecode = binary
124114
.as_chunks::<4>()

execution_utils/src/proofs.rs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ pub struct ProofMetadata {
3030
pub basic_proof_count: usize,
3131
pub reduced_proof_count: usize,
3232
pub reduced_log_23_proof_count: usize,
33-
pub final_proof_count: usize,
33+
34+
/// This field is deprecated and should not be used anymore.
35+
#[serde(alias = "final_proof_count")]
36+
pub deprecated_final_proof_count: usize,
37+
3438
pub delegation_proof_count: Vec<(u32, usize)>,
3539
pub register_values: Vec<FinalRegisterValue>,
3640
// hash from current binary (from end pc and setup tree).
@@ -46,7 +50,6 @@ pub struct ProofList {
4650
pub basic_proofs: Vec<Proof>,
4751
pub reduced_proofs: Vec<Proof>,
4852
pub reduced_log_23_proofs: Vec<Proof>,
49-
pub final_proofs: Vec<Proof>,
5053
pub delegation_proofs: Vec<(u32, Vec<Proof>)>,
5154
}
5255

@@ -115,7 +118,7 @@ impl ProgramProof {
115118
proof_metadata: &ProofMetadata,
116119
) -> ProgramProof {
117120
// program proof doesn't distinguish between final, reduced & basic proofs.
118-
let mut base_layer_proofs = proof_list.final_proofs.clone();
121+
let mut base_layer_proofs = vec![];
119122
base_layer_proofs.extend_from_slice(&proof_list.basic_proofs);
120123
base_layer_proofs.extend_from_slice(&proof_list.reduced_log_23_proofs);
121124
base_layer_proofs.extend_from_slice(&proof_list.reduced_proofs);
@@ -136,15 +139,14 @@ impl ProgramProof {
136139
// Here we're guessing - as ProgramProof doesn't distinguish between basic and reduced proofs.
137140
reduced_proofs: self.base_layer_proofs,
138141
reduced_log_23_proofs: vec![],
139-
final_proofs: vec![],
140142
delegation_proofs: self.delegation_proofs.clone().into_iter().collect(),
141143
};
142144

143145
let proof_metadata = ProofMetadata {
144146
basic_proof_count: 0,
145147
reduced_proof_count,
146148
reduced_log_23_proof_count: 0,
147-
final_proof_count: 0,
149+
deprecated_final_proof_count: 0,
148150
delegation_proof_count: vec![],
149151
register_values: self.register_final_values,
150152
end_params: self.end_params,
@@ -160,7 +162,6 @@ impl ProofMetadata {
160162
self.basic_proof_count
161163
+ self.reduced_proof_count
162164
+ self.reduced_log_23_proof_count
163-
+ self.final_proof_count
164165
+ self
165166
.delegation_proof_count
166167
.iter()
@@ -194,12 +195,6 @@ impl ProofList {
194195
&Path::new(output_dir).join(&format!("reduced_log_23_proof_{}.json", i)),
195196
);
196197
}
197-
for (i, proof) in self.final_proofs.iter().enumerate() {
198-
serialize_to_file(
199-
proof,
200-
&Path::new(output_dir).join(&format!("final_proof_{}.json", i)),
201-
);
202-
}
203198
for (delegation_type, proofs) in self.delegation_proofs.iter() {
204199
for (i, proof) in proofs.iter().enumerate() {
205200
serialize_to_file(
@@ -233,13 +228,6 @@ impl ProofList {
233228
reduced_log_23_proofs.push(proof);
234229
}
235230

236-
let mut final_proofs = vec![];
237-
for i in 0..metadata.final_proof_count {
238-
let proof_path = Path::new(input_dir).join(format!("final_proof_{}.json", i));
239-
let proof: Proof = deserialize_from_file(proof_path.to_str().unwrap());
240-
final_proofs.push(proof);
241-
}
242-
243231
let mut delegation_proofs = vec![];
244232
for (delegation_type, count) in metadata.delegation_proof_count.iter() {
245233
let mut proofs = vec![];
@@ -256,19 +244,16 @@ impl ProofList {
256244
basic_proofs,
257245
reduced_proofs,
258246
reduced_log_23_proofs,
259-
final_proofs,
260247
delegation_proofs,
261248
}
262249
}
263250

264251
pub fn get_last_proof(&self) -> &Proof {
265-
self.final_proofs.last().unwrap_or_else(|| {
266-
self.basic_proofs.last().unwrap_or_else(|| {
267-
self.reduced_log_23_proofs.last().unwrap_or_else(|| {
268-
self.reduced_proofs
269-
.last()
270-
.expect("Neither main proof nor reduced proof is present")
271-
})
252+
self.basic_proofs.last().unwrap_or_else(|| {
253+
self.reduced_log_23_proofs.last().unwrap_or_else(|| {
254+
self.reduced_proofs
255+
.last()
256+
.expect("Neither main proof nor reduced proof is present")
272257
})
273258
})
274259
}

execution_utils/src/recursion.rs

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
use crate::{
2-
get_padded_binary, Machine, ProofMetadata, UNIVERSAL_CIRCUIT_NO_DELEGATION_VERIFIER,
3-
UNIVERSAL_CIRCUIT_VERIFIER,
4-
};
1+
use crate::{get_padded_binary, Machine, ProofMetadata, UNIVERSAL_CIRCUIT_VERIFIER};
52
use clap::ValueEnum;
63
use std::alloc::Global;
74

85
use crate::{
9-
base_layer_verifier_vk, compute_chain_encoding, final_recursion_layer_verifier_vk,
10-
recursion_layer_no_delegation_verifier_vk, recursion_layer_verifier_vk,
11-
recursion_log_23_layer_verifier_vk, universal_circuit_log_23_verifier_vk,
12-
universal_circuit_no_delegation_verifier_vk, universal_circuit_verifier_vk,
6+
compute_chain_encoding, recursion_layer_verifier_vk, recursion_log_23_layer_verifier_vk,
7+
universal_circuit_log_23_verifier_vk, universal_circuit_verifier_vk,
138
};
149
use verifier_common::blake2s_u32::BLAKE2S_DIGEST_SIZE_U32_WORDS;
1510

1611
/// We have two layers of recursion:
1712
/// 1. Reduced machine (2^22 cycles) + blake delegation
1813
/// 2. Here we have two options:
19-
/// - Final reduced machine (2^25 cycles)
14+
/// - Final reduced machine (2^25 cycles) - no longer supported.
2015
/// - Reduced log23 machine (2^23 cycles) + blake delegation
2116
/// Note: end_params constant differs if we do 1 or multiple repetitions of the 2nd layer.
2217
/// So we need to run the 2nd layer exactly one time or at least twice.
2318
/// Then we can define four recursion strategies:
2419
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq)]
2520
pub enum RecursionStrategy {
26-
/// Does 1st layer until 2 reduced + 1 delegation then final reduced machine (always two repetitions)
27-
UseFinalMachine,
21+
/// UseFinalMachine is no longer supported.
22+
// UseFinalMachine,
2823
/// Does 1st layer until 2 reduced + 1 delegation then 1 reduced 2^23 + 1 delegation (one repetition)
2924
UseReducedLog23Machine,
3025
/// Does 1st layer until N reduced + M delegation then reduced 2^23 + delegation (at least two repetitions)
@@ -46,13 +41,6 @@ impl RecursionStrategy {
4641
const M: usize = 2;
4742

4843
let continue_first_layer = match self {
49-
RecursionStrategy::UseFinalMachine => {
50-
proof_metadata.reduced_proof_count > 2
51-
|| proof_metadata
52-
.delegation_proof_count
53-
.iter()
54-
.any(|(_, x)| *x > 1)
55-
}
5644
RecursionStrategy::UseReducedLog23Machine => {
5745
proof_metadata.reduced_proof_count > 2
5846
|| proof_metadata
@@ -79,7 +67,6 @@ impl RecursionStrategy {
7967
proof_level: usize,
8068
) -> bool {
8169
let continue_second_layer = match self {
82-
RecursionStrategy::UseFinalMachine => proof_metadata.final_proof_count > 1,
8370
RecursionStrategy::UseReducedLog23Machine => {
8471
// In this strategy we should run only one repetition of 2nd layer
8572
assert!(proof_level == 0);
@@ -103,7 +90,6 @@ impl RecursionStrategy {
10390

10491
pub fn get_second_layer_machine(&self) -> Machine {
10592
match self {
106-
RecursionStrategy::UseFinalMachine => Machine::ReducedFinal,
10793
RecursionStrategy::UseReducedLog23Machine
10894
| RecursionStrategy::UseReducedLog23MachineMultiple
10995
| RecursionStrategy::UseReducedLog23MachineOnly => Machine::ReducedLog23,
@@ -112,9 +98,6 @@ impl RecursionStrategy {
11298

11399
pub fn get_second_layer_binary(&self) -> Vec<u32> {
114100
match self {
115-
RecursionStrategy::UseFinalMachine => {
116-
get_padded_binary(UNIVERSAL_CIRCUIT_NO_DELEGATION_VERIFIER)
117-
}
118101
RecursionStrategy::UseReducedLog23Machine
119102
| RecursionStrategy::UseReducedLog23MachineMultiple
120103
| RecursionStrategy::UseReducedLog23MachineOnly => {
@@ -124,10 +107,7 @@ impl RecursionStrategy {
124107
}
125108

126109
pub fn use_final_machine(&self) -> bool {
127-
match self {
128-
RecursionStrategy::UseFinalMachine => true,
129-
_ => false,
130-
}
110+
false
131111
}
132112
}
133113

@@ -143,20 +123,6 @@ pub fn generate_constants_for_binary(
143123
let (end_params, aux_values) = if universal_verifier {
144124
if recompute {
145125
match recursion_mode {
146-
RecursionStrategy::UseFinalMachine => generate_params_and_register_values(
147-
&[
148-
(&base_layer_bin, Machine::Standard),
149-
(&crate::UNIVERSAL_CIRCUIT_VERIFIER, Machine::Reduced),
150-
(
151-
&crate::UNIVERSAL_CIRCUIT_NO_DELEGATION_VERIFIER,
152-
Machine::ReducedFinal,
153-
),
154-
],
155-
(
156-
&crate::UNIVERSAL_CIRCUIT_NO_DELEGATION_VERIFIER,
157-
Machine::ReducedFinal,
158-
),
159-
),
160126
RecursionStrategy::UseReducedLog23Machine => generate_params_and_register_values(
161127
&[
162128
(&base_layer_bin, Machine::Standard),
@@ -188,19 +154,6 @@ pub fn generate_constants_for_binary(
188154
let base_params = generate_params_for_binary(&base_layer_bin, Machine::Standard);
189155

190156
match recursion_mode {
191-
RecursionStrategy::UseFinalMachine => {
192-
let aux_values = compute_chain_encoding(vec![
193-
[0u32; 8],
194-
base_params,
195-
universal_circuit_verifier_vk().params,
196-
universal_circuit_no_delegation_verifier_vk().params,
197-
]);
198-
199-
(
200-
universal_circuit_no_delegation_verifier_vk().params,
201-
aux_values,
202-
)
203-
}
204157
RecursionStrategy::UseReducedLog23Machine => {
205158
let aux_values = compute_chain_encoding(vec![
206159
[0u32; 8],
@@ -234,21 +187,6 @@ pub fn generate_constants_for_binary(
234187
} else {
235188
if recompute {
236189
match recursion_mode {
237-
RecursionStrategy::UseFinalMachine => generate_params_and_register_values(
238-
&[
239-
(&base_layer_bin, Machine::Standard),
240-
(&crate::BASE_LAYER_VERIFIER, Machine::Reduced),
241-
(&crate::RECURSION_LAYER_VERIFIER, Machine::Reduced),
242-
(
243-
&crate::RECURSION_LAYER_NO_DELEGATION_VERIFIER,
244-
Machine::ReducedFinal,
245-
),
246-
],
247-
(
248-
&crate::FINAL_RECURSION_LAYER_VERIFIER,
249-
Machine::ReducedFinal,
250-
),
251-
),
252190
RecursionStrategy::UseReducedLog23Machine => generate_params_and_register_values(
253191
&[
254192
(&base_layer_bin, Machine::Standard),
@@ -263,17 +201,6 @@ pub fn generate_constants_for_binary(
263201
let base_params = generate_params_for_binary(&base_layer_bin, Machine::Standard);
264202

265203
match recursion_mode {
266-
RecursionStrategy::UseFinalMachine => {
267-
let aux_values = compute_chain_encoding(vec![
268-
[0u32; 8],
269-
base_params,
270-
base_layer_verifier_vk().params,
271-
recursion_layer_verifier_vk().params,
272-
recursion_layer_no_delegation_verifier_vk().params,
273-
]);
274-
275-
(final_recursion_layer_verifier_vk().params, aux_values)
276-
}
277204
RecursionStrategy::UseReducedLog23Machine => {
278205
let aux_values = compute_chain_encoding(vec![
279206
[0u32; 8],

execution_utils/src/verifiers.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub enum VerifierCircuitsIdentifiers {
1212
// This enum is used inside tools/verifier/main.rs
1313
BaseLayer = 0,
1414
RecursionLayer = 1,
15-
FinalLayer = 2,
15+
// Final layer is not used / supported anymore. We use Log23 layer instead.
16+
// FinalLayer = 2,
1617
RiscV = 3,
1718
/// Combine 2 proofs (from recursion layers) into one.
1819
// This is used in OhBender to combine previous block proof with current one.
@@ -35,7 +36,7 @@ pub fn generate_oracle_data_for_universal_verifier(
3536
} else if metadata.reduced_log_23_proof_count > 0 {
3637
oracle.insert(0, VerifierCircuitsIdentifiers::RecursionLog23Layer as u32);
3738
} else {
38-
oracle.insert(0, VerifierCircuitsIdentifiers::FinalLayer as u32);
39+
panic!("Final proofs are no longer supported. Use log23 proofs instead.");
3940
};
4041
oracle
4142
}
@@ -102,19 +103,7 @@ pub fn generate_oracle_data_from_metadata_and_proof_list(
102103

103104
reduced_machine_allowed_delegation_types()
104105
} else {
105-
oracle_data.push(metadata.final_proof_count.try_into().unwrap());
106-
107-
for i in 0..metadata.final_proof_count {
108-
let proof = &proofs.final_proofs[i];
109-
oracle_data
110-
.extend(verifier_common::proof_flattener::flatten_proof_for_skeleton(proof, true));
111-
for query in proof.queries.iter() {
112-
oracle_data.extend(verifier_common::proof_flattener::flatten_query(query));
113-
}
114-
}
115-
116-
// For final proof - empty vec.
117-
vec![]
106+
panic!("No proofs");
118107
};
119108

120109
for (k, _) in metadata.delegation_proof_count.iter() {

tools/cli/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ fn flatten_all(input_metadata: &String, output_file: &String) {
560560
} else if metadata.reduced_proof_count > 0 {
561561
oracle.insert(0, VerifierCircuitsIdentifiers::RecursionLayer as u32);
562562
} else {
563-
oracle.insert(0, VerifierCircuitsIdentifiers::FinalLayer as u32);
563+
panic!("No proofs");
564564
};
565565

566566
u32_to_file(output_file, &oracle);
@@ -598,11 +598,10 @@ fn verify_all(metadata_path: &String) {
598598
assert!(metadata.reduced_proof_count > 0);
599599
let output = full_statement_verifier::verify_recursion_layer();
600600
println!("Output is: {:?}", output);
601+
} else if metadata.reduced_log_23_proof_count > 0 {
602+
todo!("not implemented yet");
601603
} else {
602-
println!("Running final recursive");
603-
assert!(metadata.final_proof_count > 0);
604-
let output = full_statement_verifier::verify_final_recursion_layer();
605-
println!("Output is: {:?}", output);
604+
panic!("No proofs");
606605
};
607606
assert!(
608607
verifier_common::prover::nd_source_std::try_read_word().is_none(),

0 commit comments

Comments
 (0)