@@ -21,10 +21,7 @@ fn read_bytes_with_gas(
2121 gas : & graph:: runtime:: gas:: GasCounter ,
2222) -> Result < Vec < u8 > , anyhow:: Error > {
2323 // Charge gas for memory read
24- gas. consume_host_fn_with_metrics (
25- Gas :: new ( GAS_COST_LOAD as u64 * len as u64 ) ,
26- "rust_abi_read" ,
27- ) ?;
24+ gas. consume_host_fn_with_metrics ( Gas :: new ( GAS_COST_LOAD as u64 * len as u64 ) , "rust_abi_read" ) ?;
2825
2926 let data = memory. data ( & store) ;
3027 let start = ptr as usize ;
@@ -160,8 +157,13 @@ pub fn link_rust_host_functions(
160157 let memory = get_memory ( & mut caller) ?;
161158 let gas = caller. data ( ) . gas . cheap_clone ( ) ;
162159
163- let entity_type =
164- read_string_with_gas ( & memory, & caller, entity_type_ptr, entity_type_len, & gas) ?;
160+ let entity_type = read_string_with_gas (
161+ & memory,
162+ & caller,
163+ entity_type_ptr,
164+ entity_type_len,
165+ & gas,
166+ ) ?;
165167 let id = read_string_with_gas ( & memory, & caller, id_ptr, id_len, & gas) ?;
166168 let data_bytes =
167169 read_bytes_with_gas ( & memory, & caller, data_ptr, data_len, & gas) ?;
@@ -197,8 +199,13 @@ pub fn link_rust_host_functions(
197199 let memory = get_memory ( & mut caller) ?;
198200 let gas = caller. data ( ) . gas . cheap_clone ( ) ;
199201
200- let entity_type =
201- read_string_with_gas ( & memory, & caller, entity_type_ptr, entity_type_len, & gas) ?;
202+ let entity_type = read_string_with_gas (
203+ & memory,
204+ & caller,
205+ entity_type_ptr,
206+ entity_type_len,
207+ & gas,
208+ ) ?;
202209 let id = read_string_with_gas ( & memory, & caller, id_ptr, id_len, & gas) ?;
203210
204211 // Call the actual store_get through WasmInstanceContext
@@ -233,8 +240,13 @@ pub fn link_rust_host_functions(
233240 let memory = get_memory ( & mut caller) ?;
234241 let gas = caller. data ( ) . gas . cheap_clone ( ) ;
235242
236- let entity_type =
237- read_string_with_gas ( & memory, & caller, entity_type_ptr, entity_type_len, & gas) ?;
243+ let entity_type = read_string_with_gas (
244+ & memory,
245+ & caller,
246+ entity_type_ptr,
247+ entity_type_len,
248+ & gas,
249+ ) ?;
238250 let id = read_string_with_gas ( & memory, & caller, id_ptr, id_len, & gas) ?;
239251
240252 let mut ctx = std:: pin:: pin!( WasmInstanceContext :: new( & mut caller) ) ;
@@ -393,7 +405,13 @@ pub fn link_rust_host_functions(
393405 Ok ( bytes. len ( ) as u32 )
394406 }
395407 }
396- Err ( _) => Ok ( u32:: MAX ) , // Error indicator
408+ Err ( e) => {
409+ // Propagate reorg signals as traps so the block can be retried.
410+ if let graph:: runtime:: HostExportError :: PossibleReorg ( _) = & e {
411+ caller. data_mut ( ) . possible_reorg = true ;
412+ }
413+ Err ( anyhow:: anyhow!( "ipfs_cat failed: {}" , e) )
414+ }
397415 }
398416 } )
399417 } ,
@@ -438,8 +456,7 @@ pub fn link_rust_host_functions(
438456 address. copy_from_slice ( & addr_bytes) ;
439457
440458 // Read calldata
441- let calldata =
442- read_bytes_with_gas ( & memory, & caller, data_ptr, data_len, & gas) ?;
459+ let calldata = read_bytes_with_gas ( & memory, & caller, data_ptr, data_len, & gas) ?;
443460
444461 // Get the raw_eth_call capability from ctx
445462 let raw_eth_call = caller
@@ -457,7 +474,9 @@ pub fn link_rust_host_functions(
457474 let block_ptr = caller. data ( ) . ctx . block_ptr . cheap_clone ( ) ;
458475
459476 // Make the call
460- let result = raw_eth_call. call ( address, & calldata, & block_ptr, None ) . await ;
477+ let result = raw_eth_call
478+ . call ( address, & calldata, & block_ptr, None )
479+ . await ;
461480
462481 match result {
463482 Ok ( Some ( bytes) ) => {
@@ -503,8 +522,9 @@ pub fn link_rust_host_functions(
503522 let memory = get_memory ( & mut caller) ?;
504523 let gas = caller. data ( ) . gas . cheap_clone ( ) ;
505524
506- let message = read_string_with_gas ( & memory, & caller, message_ptr, message_len, & gas)
507- . unwrap_or_else ( |_| "<failed to read message>" . to_string ( ) ) ;
525+ let message =
526+ read_string_with_gas ( & memory, & caller, message_ptr, message_len, & gas)
527+ . unwrap_or_else ( |_| "<failed to read message>" . to_string ( ) ) ;
508528
509529 // Mark as deterministic trap
510530 caller. data_mut ( ) . deterministic_host_trap = true ;
0 commit comments