@@ -4,55 +4,17 @@ use super::{Identifier, Range};
44// ================================================================================================
55pub type TraceSegment = u8 ;
66
7- /// [TraceBinding] is used to represent one or more columns in the execution trace that are bound to
8- /// a name. For single columns, the size is 1. For groups, the size is the number of columns in the
9- /// group. The offset is the column index in the trace where the first column of the binding starts.
10- #[ derive( Debug , Clone , Eq , PartialEq , Ord , PartialOrd ) ]
11- pub struct TraceBinding {
12- binding : Identifier ,
13- trace_segment : TraceSegment ,
14- offset : usize ,
15- size : usize ,
16- }
17-
18- impl TraceBinding {
19- /// Creates a new trace binding.
20- pub fn new ( binding : Identifier , trace_segment : usize , offset : usize , size : u64 ) -> Self {
21- Self {
22- binding,
23- trace_segment : trace_segment as TraceSegment ,
24- offset,
25- size : size as usize ,
26- }
27- }
28-
29- /// Returns the name of the trace binding.
30- pub fn name ( & self ) -> & str {
31- self . binding . name ( )
32- }
33-
34- /// Returns the trace segment of the trace binding.
35- pub fn trace_segment ( & self ) -> TraceSegment {
36- self . trace_segment
37- }
38-
39- /// Returns the offset of the trace binding.
40- pub fn offset ( & self ) -> usize {
41- self . offset
42- }
43-
44- /// Returns the size of the trace binding.
45- pub fn size ( & self ) -> usize {
46- self . size
47- }
48- }
49-
50- /// [TraceAccess] is used to represent accessing an element in the execution trace during
51- /// constraint evaluation. The trace_segment specifies
52- /// how many trace commitments have preceded the specified segment. `col_idx` specifies the index
53- /// of the column within that trace segment, and `row_offset` specifies the offset from the current
54- /// row. For example, an element in the "next" row of the "main" trace would be specified by
55- /// a trace_segment of 0 and a row_offset of 1.
7+ /// [TraceAccess] is used to represent accessing one or more elements in the execution trace during
8+ /// constraint evaluation.
9+ ///
10+ /// - `trace_segment`: specifies how many trace commitments have preceded the specified segment.
11+ /// - `col_idx`: specifies the index of the column within that trace segment at which the access
12+ /// starts.
13+ /// - `size`: refers to how many columns are being accessed.
14+ /// - `row_offset`: specifies the offset from the current row.
15+ ///
16+ /// For example, a single element in the "next" row of
17+ /// the "main" trace would be specified by a trace_segment of 0, a size of 1, and a row_offset of 1.
5618#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
5719pub struct TraceAccess {
5820 trace_segment : TraceSegment ,
@@ -98,24 +60,79 @@ impl TraceAccess {
9860 }
9961}
10062
101- /// [TraceBindingAccess ] is used to indicate a column in the trace by specifying its offset within
102- /// a set of trace columns with the given identifier. If the identifier refers to a single column
103- /// then the index is always zero .
104- #[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
105- pub struct TraceBindingAccess {
63+ /// [TraceBinding ] is used to represent one or more columns in the execution trace that are bound to
64+ /// a name. For single columns, the size is 1. For groups, the size is the number of columns in the
65+ /// group. The offset is the column index in the trace where the first column of the binding starts .
66+ #[ derive( Debug , Clone , Eq , PartialEq , Ord , PartialOrd ) ]
67+ pub struct TraceBinding {
10668 binding : Identifier ,
107- col_offset : usize ,
108- size : TraceBindingAccessSize ,
109- row_offset : usize ,
69+ trace_segment : TraceSegment ,
70+ offset : usize ,
71+ size : usize ,
72+ }
73+
74+ impl TraceBinding {
75+ /// Creates a new trace binding.
76+ pub fn new ( binding : Identifier , trace_segment : usize , offset : usize , size : u64 ) -> Self {
77+ Self {
78+ binding,
79+ trace_segment : trace_segment as TraceSegment ,
80+ offset,
81+ size : size as usize ,
82+ }
83+ }
84+
85+ /// Returns the name of the trace binding.
86+ pub fn name ( & self ) -> & str {
87+ self . binding . name ( )
88+ }
89+
90+ /// Returns the trace segment of the trace binding.
91+ pub fn trace_segment ( & self ) -> TraceSegment {
92+ self . trace_segment
93+ }
94+
95+ /// Returns the offset of the trace binding.
96+ pub fn offset ( & self ) -> usize {
97+ self . offset
98+ }
99+
100+ /// Returns the size of the trace binding.
101+ pub fn size ( & self ) -> usize {
102+ self . size
103+ }
110104}
111105
106+ /// Indicates how much of a [TraceBinding] is being accessed.
107+ ///
108+ /// TODO: check that this is correct for `Single`.
109+ /// - `Single`: only a single element from the [TraceBinding] is being referenced.
110+ /// - `Slice`: the specified range of the [TraceBinding] is being referenced.
111+ /// - `Full`: the entire [TraceBinding] is being referenced.
112112#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
113113pub enum TraceBindingAccessSize {
114114 Single ,
115115 Slice ( Range ) ,
116116 Full ,
117117}
118118
119+ /// [TraceBindingAccess] is used to indicate accessing a [TraceBinding].
120+ ///
121+ /// - `binding`: is the identifier of the [TraceBinding] being accessed.
122+ /// - `col_offset`: specifies the column within the [TraceBinding] where the access starts. For
123+ /// example, if a [TraceBinding] has `offset` = 2 and the [TraceBindingAccess] has
124+ /// `col_offset` = 2, then the offset of the access within the trace segment will be 4. If the
125+ /// [TraceBinding] refers to a single column, then this value will be zero.
126+ /// - `size`: specifies how much of the [TraceBinding] is being accessed.
127+ /// - `row_offset`: specifies the offset from the current row.
128+ #[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
129+ pub struct TraceBindingAccess {
130+ binding : Identifier ,
131+ col_offset : usize ,
132+ size : TraceBindingAccessSize ,
133+ row_offset : usize ,
134+ }
135+
119136impl TraceBindingAccess {
120137 pub fn new (
121138 binding : Identifier ,
0 commit comments