@@ -35,7 +35,7 @@ impl AirConstraintEvaluation {
3535
3636 /// The values returned here should match those used by STARK proof
3737 pub fn conventional_air_constraint_memory_layout ( ) -> TasmConstraintEvaluationMemoryLayout {
38- const CURRENT_BASE_ROW_PTR : u64 = 28u64 ;
38+ const CURRENT_BASE_ROW_PTR : u64 = 30u64 ;
3939 const BASE_ROW_SIZE : u64 = ( NUM_BASE_COLUMNS * EXTENSION_DEGREE ) as u64 ;
4040 const EXT_ROW_SIZE : u64 = ( NUM_EXT_COLUMNS * EXTENSION_DEGREE ) as u64 ;
4141 const METADATA_SIZE_PER_PROOF_ITEM_ELEMENT : u64 = 2 ; // 1 for discriminant, 1 for elem size
@@ -175,15 +175,18 @@ mod tests {
175175
176176 use arbitrary:: Arbitrary ;
177177 use arbitrary:: Unstructured ;
178+ use num_traits:: ConstZero ;
178179 use rand:: distributions:: Standard ;
179180 use rand:: prelude:: * ;
180181 use triton_vm:: proof_stream:: ProofStream ;
181182 use triton_vm:: twenty_first:: math:: x_field_element:: EXTENSION_DEGREE ;
182183
183184 use crate :: execute_test;
184185 use crate :: linker:: link_for_isolated_run;
186+ use crate :: memory:: encode_to_memory;
185187 use crate :: rust_shadowing_helper_functions:: array:: array_get;
186188 use crate :: rust_shadowing_helper_functions:: array:: insert_as_array;
189+ use crate :: structure:: tasm_object:: decode_from_memory_with_size;
187190 use crate :: traits:: function:: Function ;
188191 use crate :: traits:: function:: FunctionInitialState ;
189192
@@ -195,7 +198,7 @@ mod tests {
195198 }
196199
197200 #[ test]
198- fn conventional_memory_layout_agrees_with_tvm_proof ( ) {
201+ fn conventional_memory_layout_agrees_with_tvm_proof_stored_at_address_zero ( ) {
199202 let program = triton_program ! ( halt) ;
200203 let claim = Claim :: about_program ( & program) ;
201204
@@ -206,27 +209,34 @@ mod tests {
206209 NonDeterminism :: default ( ) ,
207210 )
208211 . unwrap ( ) ;
209- let Proof ( proof_sequence) = proof. clone ( ) ;
210- let proof_stream: ProofStream = ( & proof) . try_into ( ) . unwrap ( ) ;
212+
213+ const PROOF_ADDRESS : BFieldElement = BFieldElement :: ZERO ;
214+ let mut memory = HashMap :: < BFieldElement , BFieldElement > :: new ( ) ;
215+ let proof_stream = ProofStream :: try_from ( & proof) . unwrap ( ) ;
216+ encode_to_memory ( & mut memory, PROOF_ADDRESS , proof) ;
217+
211218 let assumed_memory_layout =
212219 AirConstraintEvaluation :: conventional_air_constraint_memory_layout ( ) ;
213220 const BASE_ROW_SIZE : usize = NUM_BASE_COLUMNS * EXTENSION_DEGREE ;
214221 const EXT_ROW_SIZE : usize = NUM_EXT_COLUMNS * EXTENSION_DEGREE ;
215222
216- let assumed_curr_base_row_ptr = assumed_memory_layout. curr_base_row_ptr . value ( ) as usize ;
217- let assumed_curr_base_row: [ XFieldElement ; NUM_BASE_COLUMNS ] = * BFieldCodec :: decode (
218- & proof_sequence[ assumed_curr_base_row_ptr..assumed_curr_base_row_ptr + BASE_ROW_SIZE ] ,
219- )
220- . unwrap ( ) ;
223+ let assumed_curr_base_row: [ XFieldElement ; NUM_BASE_COLUMNS ] =
224+ * decode_from_memory_with_size (
225+ & memory,
226+ assumed_memory_layout. curr_base_row_ptr ,
227+ BASE_ROW_SIZE ,
228+ )
229+ . unwrap ( ) ;
221230 let actual_curr_base_row_from_proof = proof_stream. items [ 4 ]
222231 . clone ( )
223232 . try_into_out_of_domain_base_row ( )
224233 . unwrap ( ) ;
225234 assert_eq ! ( * actual_curr_base_row_from_proof, assumed_curr_base_row) ;
226235
227- let assumed_curr_ext_row_ptr = assumed_memory_layout. curr_ext_row_ptr . value ( ) as usize ;
228- let assumed_curr_ext_row: [ XFieldElement ; NUM_EXT_COLUMNS ] = * BFieldCodec :: decode (
229- & proof_sequence[ assumed_curr_ext_row_ptr..assumed_curr_ext_row_ptr + EXT_ROW_SIZE ] ,
236+ let assumed_curr_ext_row: [ XFieldElement ; NUM_EXT_COLUMNS ] = * decode_from_memory_with_size (
237+ & memory,
238+ assumed_memory_layout. curr_ext_row_ptr ,
239+ EXT_ROW_SIZE ,
230240 )
231241 . unwrap ( ) ;
232242 let actual_curr_ext_row_from_proof = proof_stream. items [ 5 ]
@@ -235,20 +245,23 @@ mod tests {
235245 . unwrap ( ) ;
236246 assert_eq ! ( * actual_curr_ext_row_from_proof, assumed_curr_ext_row) ;
237247
238- let assumed_next_base_row_ptr = assumed_memory_layout. next_base_row_ptr . value ( ) as usize ;
239- let assumed_next_base_row: [ XFieldElement ; NUM_BASE_COLUMNS ] = * BFieldCodec :: decode (
240- & proof_sequence[ assumed_next_base_row_ptr..assumed_next_base_row_ptr + BASE_ROW_SIZE ] ,
241- )
242- . unwrap ( ) ;
248+ let assumed_next_base_row: [ XFieldElement ; NUM_BASE_COLUMNS ] =
249+ * decode_from_memory_with_size (
250+ & memory,
251+ assumed_memory_layout. next_base_row_ptr ,
252+ BASE_ROW_SIZE ,
253+ )
254+ . unwrap ( ) ;
243255 let actual_next_base_row_from_proof = proof_stream. items [ 6 ]
244256 . clone ( )
245257 . try_into_out_of_domain_base_row ( )
246258 . unwrap ( ) ;
247259 assert_eq ! ( * actual_next_base_row_from_proof, assumed_next_base_row) ;
248260
249- let assumed_next_ext_row_ptr = assumed_memory_layout. next_ext_row_ptr . value ( ) as usize ;
250- let assumed_next_ext_row: [ XFieldElement ; NUM_EXT_COLUMNS ] = * BFieldCodec :: decode (
251- & proof_sequence[ assumed_next_ext_row_ptr..assumed_next_ext_row_ptr + EXT_ROW_SIZE ] ,
261+ let assumed_next_ext_row: [ XFieldElement ; NUM_EXT_COLUMNS ] = * decode_from_memory_with_size (
262+ & memory,
263+ assumed_memory_layout. next_ext_row_ptr ,
264+ EXT_ROW_SIZE ,
252265 )
253266 . unwrap ( ) ;
254267 let actual_next_ext_row_from_proof = proof_stream. items [ 7 ]
0 commit comments