1
1
//! Collection of structs and functions used to:
2
- //! - Define the internals of a [`MemoryOp `], [`StackOp`] and [`StorageOp`].
2
+ //! - Define the internals of a [`MemoryWordOp `], [`StackOp`] and [`StorageOp`].
3
3
//! - Define the actual operation types and a wrapper over them (the [`Operation`] enum).
4
4
//! - Define structures that interact with operations such as [`OperationContainer`].
5
5
pub ( crate ) mod container;
@@ -86,8 +86,6 @@ impl RWCounter {
86
86
pub enum Target {
87
87
/// Start is a padding operation.
88
88
Start ,
89
- /// Means the target of the operation is the Memory.
90
- Memory ,
91
89
/// Means the target of the operation is the MemoryWord.
92
90
MemoryWord ,
93
91
/// Means the target of the operation is the Stack.
@@ -120,83 +118,6 @@ pub trait Op: Clone + Eq + Ord {
120
118
fn reverse ( & self ) -> Self ;
121
119
}
122
120
123
- /// Represents a [`READ`](RW::READ)/[`WRITE`](RW::WRITE) into the memory implied
124
- /// by an specific [`OpcodeId`](eth_types::evm_types::opcode_ids::OpcodeId) of
125
- /// the [`ExecStep`](crate::circuit_input_builder::ExecStep).
126
- #[ derive( Clone , PartialEq , Eq ) ]
127
- pub struct MemoryOp {
128
- /// Call ID
129
- pub call_id : usize ,
130
- /// Memory Address
131
- pub address : MemoryAddress ,
132
- /// Value
133
- pub value : u8 ,
134
- }
135
-
136
- impl fmt:: Debug for MemoryOp {
137
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
138
- f. write_str ( "MemoryOp { " ) ?;
139
- f. write_fmt ( format_args ! (
140
- "call_id: {:?}, addr: {:?}, value: 0x{:02x}" ,
141
- self . call_id, self . address, self . value
142
- ) ) ?;
143
- f. write_str ( " }" )
144
- }
145
- }
146
-
147
- impl MemoryOp {
148
- /// Create a new instance of a `MemoryOp` from it's components.
149
- pub fn new ( call_id : usize , address : MemoryAddress , value : u8 ) -> MemoryOp {
150
- MemoryOp {
151
- call_id,
152
- address,
153
- value,
154
- }
155
- }
156
-
157
- /// Returns the [`Target`] (operation type) of this operation.
158
- pub const fn target ( & self ) -> Target {
159
- Target :: Memory
160
- }
161
-
162
- /// Returns the call id associated to this Operation.
163
- pub const fn call_id ( & self ) -> usize {
164
- self . call_id
165
- }
166
-
167
- /// Returns the [`MemoryAddress`] associated to this Operation.
168
- pub const fn address ( & self ) -> & MemoryAddress {
169
- & self . address
170
- }
171
-
172
- /// Returns the bytes read or written by this operation.
173
- pub fn value ( & self ) -> u8 {
174
- self . value
175
- }
176
- }
177
-
178
- impl Op for MemoryOp {
179
- fn into_enum ( self ) -> OpEnum {
180
- OpEnum :: Memory ( self )
181
- }
182
-
183
- fn reverse ( & self ) -> Self {
184
- unreachable ! ( "MemoryOp can't be reverted" )
185
- }
186
- }
187
-
188
- impl PartialOrd for MemoryOp {
189
- fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
190
- Some ( self . cmp ( other) )
191
- }
192
- }
193
-
194
- impl Ord for MemoryOp {
195
- fn cmp ( & self , other : & Self ) -> Ordering {
196
- ( & self . call_id , & self . address ) . cmp ( & ( & other. call_id , & other. address ) )
197
- }
198
- }
199
-
200
121
// new Memory ops for word value
201
122
/// Represents a [`READ`](RW::READ)/[`WRITE`](RW::WRITE) into the memory implied
202
123
/// by an specific [`OpcodeId`](eth_types::evm_types::opcode_ids::OpcodeId) of
@@ -223,7 +144,7 @@ impl fmt::Debug for MemoryWordOp {
223
144
}
224
145
225
146
impl MemoryWordOp {
226
- /// Create a new instance of a `MemoryOp ` from it's components.
147
+ /// Create a new instance of a `MemoryWordOp ` from it's components.
227
148
pub fn new ( call_id : usize , address : MemoryAddress , value : Word ) -> MemoryWordOp {
228
149
MemoryWordOp {
229
150
call_id,
@@ -234,7 +155,7 @@ impl MemoryWordOp {
234
155
235
156
/// Returns the [`Target`] (operation type) of this operation.
236
157
pub const fn target ( & self ) -> Target {
237
- Target :: Memory
158
+ Target :: MemoryWord
238
159
}
239
160
240
161
/// Returns the call id associated to this Operation.
@@ -259,7 +180,7 @@ impl Op for MemoryWordOp {
259
180
}
260
181
261
182
fn reverse ( & self ) -> Self {
262
- unreachable ! ( "MemoryOp can't be reverted" )
183
+ unreachable ! ( "MemoryWordOp can't be reverted" )
263
184
}
264
185
}
265
186
@@ -985,13 +906,11 @@ impl Op for TxReceiptOp {
985
906
}
986
907
987
908
/// Generic enum that wraps over all the operation types possible.
988
- /// In particular [`StackOp`], [`MemoryOp `] and [`StorageOp`].
909
+ /// In particular [`StackOp`], [`MemoryWordOp `] and [`StorageOp`].
989
910
#[ derive( Debug , Clone ) ]
990
911
pub enum OpEnum {
991
912
/// Stack
992
913
Stack ( StackOp ) ,
993
- /// Memory
994
- Memory ( MemoryOp ) ,
995
914
/// Memory word
996
915
MemoryWord ( MemoryWordOp ) ,
997
916
/// Storage
@@ -1159,7 +1078,7 @@ mod operation_tests {
1159
1078
1160
1079
let stack_op_as_operation = Operation :: new ( RWCounter ( 1 ) , RW :: WRITE , stack_op. clone ( ) ) ;
1161
1080
1162
- let memory_op = MemoryOp :: new ( 1 , MemoryAddress ( 0x40 ) , 0x40 ) ;
1081
+ let memory_op = MemoryWordOp :: new ( 1 , MemoryAddress ( 0x40 ) , Word :: from ( 0x40 ) ) ;
1163
1082
1164
1083
let memory_op_as_operation = Operation :: new ( RWCounter ( 1 ) , RW :: WRITE , memory_op. clone ( ) ) ;
1165
1084
0 commit comments