@@ -20,7 +20,7 @@ use starknet_api::core::{
20
20
} ;
21
21
use starknet_api:: hash:: StarkHash ;
22
22
use starknet_api:: transaction:: { L1ToL2Payload , L2ToL1Payload , MessageToL1 } ;
23
- use starknet_types_core:: felt:: { Felt , NonZeroFelt } ;
23
+ use starknet_types_core:: felt:: Felt ;
24
24
25
25
use crate :: errors:: StarknetOsError ;
26
26
use crate :: hints:: hint_implementation:: stateless_compression:: utils:: decompress;
@@ -30,26 +30,13 @@ use crate::io::os_output_types::{
30
30
FullContractStorageUpdate ,
31
31
FullOsStateDiff ,
32
32
PartialCommitmentOsStateDiff ,
33
- PartialContractChanges ,
34
- PartialContractStorageUpdate ,
35
33
PartialOsStateDiff ,
36
34
} ;
37
35
use crate :: metrics:: OsMetrics ;
38
36
39
- #[ cfg( test) ]
40
- #[ path = "os_output_test.rs" ]
41
- mod os_output_test;
42
-
43
37
// Cairo DictAccess types for concrete objects.
44
38
type CompiledClassHashUpdate = ( ClassHash , ( Option < CompiledClassHash > , CompiledClassHash ) ) ;
45
39
46
- // Defined in output.cairo
47
- const N_UPDATES_BOUND : NonZeroFelt =
48
- NonZeroFelt :: from_felt_unchecked ( Felt :: from_hex_unchecked ( "10000000000000000" ) ) ; // 2^64.
49
- const N_UPDATES_SMALL_PACKING_BOUND : NonZeroFelt =
50
- NonZeroFelt :: from_felt_unchecked ( Felt :: from_hex_unchecked ( "100" ) ) ; // 2^8.
51
- const FLAG_BOUND : NonZeroFelt = NonZeroFelt :: TWO ;
52
-
53
40
const MESSAGE_TO_L1_CONST_FIELD_SIZE : usize = 3 ; // from_address, to_address, payload_size.
54
41
// from_address, to_address, nonce, selector, payload_size.
55
42
const MESSAGE_TO_L2_CONST_FIELD_SIZE : usize = 5 ;
@@ -67,7 +54,10 @@ pub(crate) fn wrap_missing<T>(val: Option<T>, val_name: &str) -> Result<T, OsOut
67
54
val. ok_or_else ( || OsOutputError :: MissingFieldInOutput ( val_name. to_string ( ) ) )
68
55
}
69
56
70
- fn try_into_custom_error < T : TryFrom < Felt > > ( val : Felt , val_name : & str ) -> Result < T , OsOutputError >
57
+ pub ( crate ) fn try_into_custom_error < T : TryFrom < Felt > > (
58
+ val : Felt ,
59
+ val_name : & str ,
60
+ ) -> Result < T , OsOutputError >
71
61
where
72
62
<T as TryFrom < Felt > >:: Error : std:: fmt:: Display ,
73
63
{
@@ -147,73 +137,6 @@ impl MessageToL2 {
147
137
}
148
138
}
149
139
150
- impl FullContractChanges {
151
- pub fn from_output_iter < It : Iterator < Item = Felt > + ?Sized > (
152
- iter : & mut It ,
153
- ) -> Result < Self , OsOutputError > {
154
- Ok ( Self {
155
- addr : wrap_missing_as ( iter. next ( ) , "addr" ) ?,
156
- prev_nonce : Nonce ( wrap_missing ( iter. next ( ) , "prev_nonce" ) ?) ,
157
- new_nonce : Nonce ( wrap_missing_as ( iter. next ( ) , "new_nonce" ) ?) ,
158
- prev_class_hash : ClassHash ( wrap_missing_as ( iter. next ( ) , "prev_class_hash" ) ?) ,
159
- new_class_hash : ClassHash ( wrap_missing_as ( iter. next ( ) , "new_class_hash" ) ?) ,
160
- storage_changes : {
161
- let n_changes = wrap_missing_as ( iter. next ( ) , "n_storage_changes" ) ?;
162
- let mut storage_changes = Vec :: with_capacity ( n_changes) ;
163
- for _ in 0 ..n_changes {
164
- storage_changes. push ( FullContractStorageUpdate :: from_output_iter ( iter) ?) ;
165
- }
166
- storage_changes
167
- } ,
168
- } )
169
- }
170
- }
171
-
172
- impl PartialContractChanges {
173
- pub fn from_output_iter < It : Iterator < Item = Felt > + ?Sized > (
174
- iter : & mut It ,
175
- ) -> Result < Self , OsOutputError > {
176
- let addr = wrap_missing_as ( iter. next ( ) , "addr" ) ?;
177
- // Parse packed info.
178
- let nonce_n_changes_two_flags = wrap_missing ( iter. next ( ) , "nonce_n_changes_two_flags" ) ?;
179
-
180
- // Parse flags.
181
- let ( nonce_n_changes_one_flag, class_updated_felt) =
182
- nonce_n_changes_two_flags. div_rem ( & FLAG_BOUND ) ;
183
- let class_updated = felt_as_bool ( class_updated_felt, "class_updated" ) ?;
184
- let ( nonce_n_changes, is_n_updates_small_felt) =
185
- nonce_n_changes_one_flag. div_rem ( & FLAG_BOUND ) ;
186
- let is_n_updates_small = felt_as_bool ( is_n_updates_small_felt, "is_n_updates_small" ) ?;
187
-
188
- // Parse n_changes.
189
- let n_updates_bound =
190
- if is_n_updates_small { N_UPDATES_SMALL_PACKING_BOUND } else { N_UPDATES_BOUND } ;
191
- let ( nonce, n_changes) = nonce_n_changes. div_rem ( & n_updates_bound) ;
192
-
193
- // Parse nonce.
194
- let new_nonce = if nonce == Felt :: ZERO { None } else { Some ( Nonce ( nonce) ) } ;
195
-
196
- let new_class_hash = if class_updated {
197
- Some ( ClassHash ( wrap_missing ( iter. next ( ) , "new_class_hash" ) ?) )
198
- } else {
199
- None
200
- } ;
201
- Ok ( Self {
202
- addr,
203
- new_nonce,
204
- new_class_hash,
205
- storage_changes : {
206
- let n_changes = try_into_custom_error ( n_changes, "n_changes" ) ?;
207
- let mut storage_changes = Vec :: with_capacity ( n_changes) ;
208
- for _ in 0 ..n_changes {
209
- storage_changes. push ( PartialContractStorageUpdate :: from_output_iter ( iter) ?) ;
210
- }
211
- storage_changes
212
- } ,
213
- } )
214
- }
215
- }
216
-
217
140
#[ cfg_attr( feature = "deserialize" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
218
141
#[ derive( Debug , PartialEq ) ]
219
142
/// A representation of the state diff of an OS run, with 4 variants that depends on the use_kzg_da
0 commit comments