1
1
use std:: {
2
- ffi:: { c_char, c_int, c_uchar, c_void, CStr } ,
3
- slice,
4
- str:: FromStr ,
5
- sync:: Mutex ,
2
+ ffi:: { c_char, c_int, c_uchar, c_void, CStr } , slice, str:: FromStr , sync:: Mutex
6
3
} ;
7
4
8
5
use blockifier:: execution:: contract_class:: RunnableCompiledClass ;
@@ -132,6 +129,7 @@ impl StateReader for JunoStateReader {
132
129
133
130
/// Returns the contract class of the given class hash.
134
131
fn get_compiled_class ( & self , class_hash : ClassHash ) -> StateResult < RunnableCompiledClass > {
132
+ dbg ! ( class_hash) ;
135
133
if let Some ( cached_class) = CLASS_CACHE . lock ( ) . unwrap ( ) . cache_get ( & class_hash) {
136
134
// skip the cache if it comes from a height higher than ours. Class might be undefined on the height
137
135
// that we are reading from right now.
@@ -145,7 +143,14 @@ impl StateReader for JunoStateReader {
145
143
// with the same block number but with the state at the end of that block. That is why, we cannot use classes from cache
146
144
// if they are cached on the same height that we are executing on. Because they might be cached using a state instance that
147
145
// is in the future compared to the state that we are currently executing on, even tho they have the same height.
146
+ dbg ! ( "cached" , cached_class. cached_on_height, self . height) ;
148
147
if cached_class. cached_on_height < self . height {
148
+ if class_hash. 0 == StarkFelt :: from_str ( "0x076791ef97c042f81fbf352ad95f39a22554ee8d7927b2ce3c681f3418b5206a" ) . unwrap ( ) {
149
+ return Err ( StateError :: StateReadError ( format ! (
150
+ "cached class {} is not valid for height {}, cached on height {}" ,
151
+ class_hash. 0 , self . height, cached_class. cached_on_height
152
+ ) ) ) ;
153
+ }
149
154
return Ok ( cached_class. definition . clone ( ) ) ;
150
155
}
151
156
}
@@ -164,6 +169,7 @@ impl StateReader for JunoStateReader {
164
169
Ok ( class) => {
165
170
let runnable_compiled_class =
166
171
RunnableCompiledClass :: try_from ( class. contract_class ) . unwrap ( ) ;
172
+ dbg ! ( "set" , self . height) ;
167
173
CLASS_CACHE . lock ( ) . unwrap ( ) . cache_set (
168
174
class_hash,
169
175
CachedRunnableCompiledClass {
@@ -173,6 +179,12 @@ impl StateReader for JunoStateReader {
173
179
cached_on_height : self . height ,
174
180
} ,
175
181
) ;
182
+ if class_hash. 0 == StarkFelt :: from_str ( "0x076791ef97c042f81fbf352ad95f39a22554ee8d7927b2ce3c681f3418b5206a" ) . unwrap ( ) {
183
+ return Err ( StateError :: StateReadError ( format ! (
184
+ "newly fetched class {} is not valid for height {}" ,
185
+ class_hash. 0 , self . height
186
+ ) ) ) ;
187
+ }
176
188
Ok ( runnable_compiled_class)
177
189
}
178
190
Err ( e) => Err ( StateError :: StateReadError ( format ! (
0 commit comments