File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,20 @@ impl StorageBackend for ChallengeStorageBackend {
105105 signature,
106106 } ) ;
107107
108- // Fire and forget - don't block WASM execution on P2P
109- tracing:: info!(
108+ // Write locally first so WASM can read-your-own-writes during sync
109+ let storage_key = build_challenge_storage_key ( challenge_id, key) ;
110+ if let Err ( e) = tokio:: task:: block_in_place ( || {
111+ tokio:: runtime:: Handle :: current ( ) . block_on ( self . storage . put (
112+ storage_key,
113+ value. to_vec ( ) ,
114+ DPutOptions :: default ( ) ,
115+ ) )
116+ } ) {
117+ tracing:: warn!( error = %e, "Failed to write locally before P2P broadcast" ) ;
118+ }
119+
120+ // Broadcast via P2P so other validators also apply the write
121+ tracing:: debug!(
110122 proposal_id = %hex:: encode( & proposal_id[ ..8 ] ) ,
111123 challenge_id = %challenge_id,
112124 key_len = key. len( ) ,
@@ -115,7 +127,7 @@ impl StorageBackend for ChallengeStorageBackend {
115127 ) ;
116128 let _ = tx. try_send ( P2PCommand :: Broadcast ( msg) ) ;
117129
118- // Also add the proposal to our local state (we don't receive our own broadcasts)
130+ // Also add the proposal to our local state for vote tracking
119131 if let Some ( local_tx) = & self . local_proposal_tx {
120132 let local_proposal = StorageProposal {
121133 proposal_id,
Original file line number Diff line number Diff line change @@ -465,7 +465,7 @@ async fn main() -> Result<()> {
465465 ) ) ;
466466
467467 // Create event channel for network events
468- let ( event_tx, mut event_rx) = tokio:: sync:: mpsc:: channel :: < NetworkEvent > ( 256 ) ;
468+ let ( event_tx, mut event_rx) = tokio:: sync:: mpsc:: channel :: < NetworkEvent > ( 4096 ) ;
469469
470470 // Initialize P2P network
471471 let network = Arc :: new ( P2PNetwork :: new (
Original file line number Diff line number Diff line change @@ -1034,8 +1034,8 @@ impl WasmChallengeExecutor {
10341034 challenge_id : module_path. to_string ( ) ,
10351035 validator_id : "validator" . to_string ( ) ,
10361036 storage_host_config : StorageHostConfig {
1037- allow_direct_writes : true ,
1038- require_consensus : false ,
1037+ allow_direct_writes : false ,
1038+ require_consensus : true ,
10391039 ..self . config . storage_host_config . clone ( )
10401040 } ,
10411041 storage_backend : Arc :: clone ( & self . config . storage_backend ) ,
You can’t perform that action at this time.
0 commit comments