@@ -34,28 +34,28 @@ use cnidarium::{
34
34
use prost:: Message ;
35
35
use tracing:: instrument;
36
36
37
- fn block_hash_by_height_key ( height : u64 ) -> String {
38
- format ! ( "blockhash/{height}" )
37
+ fn block_hash_by_height_key ( height : u64 ) -> Vec < u8 > {
38
+ [ b "blockhash/" . as_slice ( ) , & height . to_le_bytes ( ) ] . concat ( )
39
39
}
40
40
41
- fn sequencer_block_header_by_hash_key ( hash : & [ u8 ] ) -> String {
42
- format ! ( "blockheader/{} " , crate :: utils :: Hex ( hash) )
41
+ fn sequencer_block_header_by_hash_key ( hash : & [ u8 ] ) -> Vec < u8 > {
42
+ [ b "blockheader/", hash] . concat ( )
43
43
}
44
44
45
- fn rollup_data_by_hash_and_rollup_id_key ( hash : & [ u8 ] , rollup_id : & RollupId ) -> String {
46
- format ! ( "rollupdata/{}/{} " , crate :: utils :: Hex ( hash) , rollup_id)
45
+ fn rollup_data_by_hash_and_rollup_id_key ( hash : & [ u8 ] , rollup_id : & RollupId ) -> Vec < u8 > {
46
+ [ b "rollupdata/", hash, rollup_id. as_ref ( ) ] . concat ( )
47
47
}
48
48
49
- fn rollup_ids_by_hash_key ( hash : & [ u8 ] ) -> String {
50
- format ! ( "rollupids/{} " , crate :: utils :: Hex ( hash) )
49
+ fn rollup_ids_by_hash_key ( hash : & [ u8 ] ) -> Vec < u8 > {
50
+ [ b "rollupids/", hash] . concat ( )
51
51
}
52
52
53
- fn rollup_transactions_proof_by_hash_key ( hash : & [ u8 ] ) -> String {
54
- format ! ( "rolluptxsproof/{} " , crate :: utils :: Hex ( hash) )
53
+ fn rollup_transactions_proof_by_hash_key ( hash : & [ u8 ] ) -> Vec < u8 > {
54
+ [ b "rolluptxsproof/", hash] . concat ( )
55
55
}
56
56
57
- fn rollup_ids_proof_by_hash_key ( hash : & [ u8 ] ) -> String {
58
- format ! ( "rollupidsproof/{} " , crate :: utils :: Hex ( hash) )
57
+ fn rollup_ids_proof_by_hash_key ( hash : & [ u8 ] ) -> Vec < u8 > {
58
+ [ b "rollupidsproof/", hash] . concat ( )
59
59
}
60
60
61
61
#[ derive( BorshSerialize , BorshDeserialize ) ]
@@ -139,7 +139,7 @@ pub(crate) trait StateReadExt: StateRead {
139
139
async fn get_block_hash_by_height ( & self , height : u64 ) -> Result < [ u8 ; 32 ] > {
140
140
let key = block_hash_by_height_key ( height) ;
141
141
let Some ( hash) = self
142
- . get_raw ( & key)
142
+ . nonverifiable_get_raw ( & key)
143
143
. await
144
144
. map_err ( anyhow_to_eyre)
145
145
. wrap_err ( "failed to read block hash by height from state" ) ?
@@ -160,7 +160,7 @@ pub(crate) trait StateReadExt: StateRead {
160
160
) -> Result < SequencerBlockHeader > {
161
161
let key = sequencer_block_header_by_hash_key ( hash) ;
162
162
let Some ( header_bytes) = self
163
- . get_raw ( & key)
163
+ . nonverifiable_get_raw ( & key)
164
164
. await
165
165
. map_err ( anyhow_to_eyre)
166
166
. wrap_err ( "failed to read raw sequencer block from state" ) ?
@@ -179,7 +179,7 @@ pub(crate) trait StateReadExt: StateRead {
179
179
async fn get_rollup_ids_by_block_hash ( & self , hash : & [ u8 ] ) -> Result < Vec < RollupId > > {
180
180
let key = rollup_ids_by_hash_key ( hash) ;
181
181
let Some ( rollup_ids_bytes) = self
182
- . get_raw ( & key)
182
+ . nonverifiable_get_raw ( & key)
183
183
. await
184
184
. map_err ( anyhow_to_eyre)
185
185
. wrap_err ( "failed to read rollup IDs by block hash from state" ) ?
@@ -195,7 +195,7 @@ pub(crate) trait StateReadExt: StateRead {
195
195
#[ instrument( skip_all) ]
196
196
async fn get_sequencer_block_by_hash ( & self , hash : & [ u8 ] ) -> Result < SequencerBlock > {
197
197
let Some ( header_bytes) = self
198
- . get_raw ( & sequencer_block_header_by_hash_key ( hash) )
198
+ . nonverifiable_get_raw ( & sequencer_block_header_by_hash_key ( hash) )
199
199
. await
200
200
. map_err ( anyhow_to_eyre)
201
201
. wrap_err ( "failed to read raw sequencer block from state" ) ?
@@ -214,10 +214,11 @@ pub(crate) trait StateReadExt: StateRead {
214
214
let mut rollup_transactions = Vec :: with_capacity ( rollup_ids. len ( ) ) ;
215
215
for id in & rollup_ids {
216
216
let key = rollup_data_by_hash_and_rollup_id_key ( hash, id) ;
217
- let raw =
218
- self . get_raw ( & key) . await . map_err ( anyhow_to_eyre) . wrap_err (
219
- "failed to read rollup data by block hash and rollup ID from state" ,
220
- ) ?;
217
+ let raw = self
218
+ . nonverifiable_get_raw ( & key)
219
+ . await
220
+ . map_err ( anyhow_to_eyre)
221
+ . context ( "failed to read rollup data by block hash and rollup ID from state" ) ?;
221
222
if let Some ( raw) = raw {
222
223
let raw = raw. as_slice ( ) ;
223
224
let rollup_data = raw:: RollupTransactions :: decode ( raw)
@@ -227,7 +228,7 @@ pub(crate) trait StateReadExt: StateRead {
227
228
}
228
229
229
230
let Some ( rollup_transactions_proof) = self
230
- . get_raw ( & rollup_transactions_proof_by_hash_key ( hash) )
231
+ . nonverifiable_get_raw ( & rollup_transactions_proof_by_hash_key ( hash) )
231
232
. await
232
233
. map_err ( anyhow_to_eyre)
233
234
. wrap_err ( "failed to read rollup transactions proof by block hash from state" ) ?
@@ -240,7 +241,7 @@ pub(crate) trait StateReadExt: StateRead {
240
241
. wrap_err ( "failed to decode rollup transactions proof from raw bytes" ) ?;
241
242
242
243
let Some ( rollup_ids_proof) = self
243
- . get_raw ( & rollup_ids_proof_by_hash_key ( hash) )
244
+ . nonverifiable_get_raw ( & rollup_ids_proof_by_hash_key ( hash) )
244
245
. await
245
246
. map_err ( anyhow_to_eyre)
246
247
. wrap_err ( "failed to read rollup IDs proof by block hash from state" ) ?
@@ -284,7 +285,7 @@ pub(crate) trait StateReadExt: StateRead {
284
285
) -> Result < RollupTransactions > {
285
286
let key = rollup_data_by_hash_and_rollup_id_key ( hash, rollup_id) ;
286
287
let Some ( bytes) = self
287
- . get_raw ( & key)
288
+ . nonverifiable_get_raw ( & key)
288
289
. await
289
290
. map_err ( anyhow_to_eyre)
290
291
. wrap_err ( "failed to read rollup data by block hash and rollup ID from state" ) ?
@@ -306,7 +307,7 @@ pub(crate) trait StateReadExt: StateRead {
306
307
hash : & [ u8 ] ,
307
308
) -> Result < ( primitiveRaw:: Proof , primitiveRaw:: Proof ) > {
308
309
let Some ( rollup_transactions_proof) = self
309
- . get_raw ( & rollup_transactions_proof_by_hash_key ( hash) )
310
+ . nonverifiable_get_raw ( & rollup_transactions_proof_by_hash_key ( hash) )
310
311
. await
311
312
. map_err ( anyhow_to_eyre)
312
313
. wrap_err ( "failed to read rollup transactions proof by block hash from state" ) ?
@@ -319,7 +320,7 @@ pub(crate) trait StateReadExt: StateRead {
319
320
. wrap_err ( "failed to decode rollup transactions proof from raw bytes" ) ?;
320
321
321
322
let Some ( rollup_ids_proof) = self
322
- . get_raw ( & rollup_ids_proof_by_hash_key ( hash) )
323
+ . nonverifiable_get_raw ( & rollup_ids_proof_by_hash_key ( hash) )
323
324
. await
324
325
. map_err ( anyhow_to_eyre)
325
326
. wrap_err ( "failed to read rollup IDs proof by block hash from state" ) ?
@@ -348,7 +349,7 @@ pub(crate) trait StateWriteExt: StateWrite {
348
349
// 6. block hash to rollup IDs proof
349
350
350
351
let key = block_hash_by_height_key ( block. height ( ) . into ( ) ) ;
351
- self . put_raw ( key, block. block_hash ( ) . to_vec ( ) ) ;
352
+ self . nonverifiable_put_raw ( key, block. block_hash ( ) . to_vec ( ) ) ;
352
353
353
354
let rollup_ids = block
354
355
. rollup_transactions ( )
@@ -359,7 +360,7 @@ pub(crate) trait StateWriteExt: StateWrite {
359
360
360
361
let key = rollup_ids_by_hash_key ( & block. block_hash ( ) ) ;
361
362
362
- self . put_raw (
363
+ self . nonverifiable_put_raw (
363
364
key,
364
365
borsh:: to_vec ( & RollupIdSeq ( rollup_ids) )
365
366
. wrap_err ( "failed to serialize rollup IDs list" ) ?,
@@ -374,18 +375,18 @@ pub(crate) trait StateWriteExt: StateWrite {
374
375
rollup_ids_proof,
375
376
} = block. into_parts ( ) ;
376
377
let header = header. into_raw ( ) ;
377
- self . put_raw ( key, header. encode_to_vec ( ) ) ;
378
+ self . nonverifiable_put_raw ( key, header. encode_to_vec ( ) ) ;
378
379
379
380
for ( id, rollup_data) in rollup_transactions {
380
381
let key = rollup_data_by_hash_and_rollup_id_key ( & block_hash, & id) ;
381
- self . put_raw ( key, rollup_data. into_raw ( ) . encode_to_vec ( ) ) ;
382
+ self . nonverifiable_put_raw ( key, rollup_data. into_raw ( ) . encode_to_vec ( ) ) ;
382
383
}
383
384
384
385
let key = rollup_transactions_proof_by_hash_key ( & block_hash) ;
385
- self . put_raw ( key, rollup_transactions_proof. into_raw ( ) . encode_to_vec ( ) ) ;
386
+ self . nonverifiable_put_raw ( key, rollup_transactions_proof. into_raw ( ) . encode_to_vec ( ) ) ;
386
387
387
388
let key = rollup_ids_proof_by_hash_key ( & block_hash) ;
388
- self . put_raw ( key, rollup_ids_proof. into_raw ( ) . encode_to_vec ( ) ) ;
389
+ self . nonverifiable_put_raw ( key, rollup_ids_proof. into_raw ( ) . encode_to_vec ( ) ) ;
389
390
390
391
Ok ( ( ) )
391
392
}
0 commit comments