@@ -246,6 +246,8 @@ pub(crate) struct WasmInstanceContext {
246246
247247 // A trap ocurred due to a possible reorg detection.
248248 possible_reorg : bool ,
249+
250+ pub ( crate ) allow_non_determinstic_ipfs : bool ,
249251}
250252
251253impl WasmInstance {
@@ -255,6 +257,7 @@ impl WasmInstance {
255257 ctx : MappingContext ,
256258 host_metrics : Arc < HostMetrics > ,
257259 timeout : Option < Duration > ,
260+ allow_non_determinstic_ipfs : bool ,
258261 ) -> Result < WasmInstance , anyhow:: Error > {
259262 let mut linker = wasmtime:: Linker :: new ( & wasmtime:: Store :: new ( valid_module. module . engine ( ) ) ) ;
260263
@@ -322,6 +325,7 @@ impl WasmInstance {
322325 host_metrics. cheap_clone( ) ,
323326 timeout,
324327 timeout_stopwatch. cheap_clone( ) ,
328+ allow_non_determinstic_ipfs
325329 ) . unwrap( ) )
326330 }
327331
@@ -366,6 +370,7 @@ impl WasmInstance {
366370 host_metrics. cheap_clone ( ) ,
367371 timeout,
368372 timeout_stopwatch. cheap_clone ( ) ,
373+ allow_non_determinstic_ipfs,
369374 )
370375 . unwrap ( ) ,
371376 )
@@ -482,6 +487,7 @@ impl WasmInstance {
482487 host_metrics,
483488 timeout,
484489 timeout_stopwatch,
490+ allow_non_determinstic_ipfs,
485491 ) ?) ;
486492 }
487493
@@ -548,6 +554,7 @@ impl WasmInstanceContext {
548554 host_metrics : Arc < HostMetrics > ,
549555 timeout : Option < Duration > ,
550556 timeout_stopwatch : Arc < std:: sync:: Mutex < TimeoutStopwatch > > ,
557+ allow_non_determinstic_ipfs : bool ,
551558 ) -> Result < Self , anyhow:: Error > {
552559 // Provide access to the WASM runtime linear memory
553560 let memory = instance
@@ -570,6 +577,7 @@ impl WasmInstanceContext {
570577 arena_free_size : 0 ,
571578 arena_start_ptr : 0 ,
572579 possible_reorg : false ,
580+ allow_non_determinstic_ipfs,
573581 } )
574582 }
575583
@@ -580,6 +588,7 @@ impl WasmInstanceContext {
580588 host_metrics : Arc < HostMetrics > ,
581589 timeout : Option < Duration > ,
582590 timeout_stopwatch : Arc < std:: sync:: Mutex < TimeoutStopwatch > > ,
591+ allow_non_determinstic_ipfs : bool ,
583592 ) -> Result < Self , anyhow:: Error > {
584593 let memory = caller
585594 . get_export ( "memory" )
@@ -605,6 +614,7 @@ impl WasmInstanceContext {
605614 arena_free_size : 0 ,
606615 arena_start_ptr : 0 ,
607616 possible_reorg : false ,
617+ allow_non_determinstic_ipfs,
608618 } )
609619 }
610620}
@@ -805,6 +815,13 @@ impl WasmInstanceContext {
805815
806816 /// function ipfs.cat(link: String): Bytes
807817 fn ipfs_cat ( & mut self , link_ptr : AscPtr < AscString > ) -> Result < AscPtr < Uint8Array > , Trap > {
818+ if !self . allow_non_determinstic_ipfs {
819+ return Err ( anyhow:: anyhow!(
820+ "`ipfs.cat` is deprecated. Improved support for IPFS will be added in the future"
821+ )
822+ . into ( ) ) ;
823+ }
824+
808825 let link = self . asc_get ( link_ptr) ;
809826 let ipfs_res = self . ctx . host_exports . ipfs_cat ( & self . ctx . logger , link) ;
810827 match ipfs_res {
@@ -831,6 +848,13 @@ impl WasmInstanceContext {
831848 user_data : AscPtr < AscEnum < StoreValueKind > > ,
832849 flags : AscPtr < Array < AscPtr < AscString > > > ,
833850 ) -> Result < ( ) , Trap > {
851+ if !self . allow_non_determinstic_ipfs {
852+ return Err ( anyhow:: anyhow!(
853+ "`ipfs.map` is deprecated. Improved support for IPFS will be added in the future"
854+ )
855+ . into ( ) ) ;
856+ }
857+
834858 let link: String = self . asc_get ( link_ptr) ;
835859 let callback: String = self . asc_get ( callback) ;
836860 let user_data: store:: Value = self . try_asc_get ( user_data) ?;
0 commit comments