@@ -258,42 +258,30 @@ func (m *Manager) ProcessFraudProof(ctx context.Context, cancel context.CancelFu
258258 }
259259 defer sub .Cancel ()
260260
261- // continuously process the fraud proofs received via subscription
262- for {
263- // sub.Proof is a blocking call that only returns on proof received or context ended
264- proof , err := sub .Proof (ctx )
265- if err != nil {
266- m .logger .Error ("failed to receive gossiped fraud proof" , "error" , err )
267- return
268- }
261+ // blocks until a valid fraud proof is received via subscription
262+ // sub.Proof is a blocking call that only returns on proof received or context ended
263+ proof , err := sub .Proof (ctx )
264+ if err != nil {
265+ m .logger .Error ("failed to receive gossiped fraud proof" , "error" , err )
266+ return
267+ }
269268
270- // only handle the state fraud proofs for now
271- fraudProof , ok := proof .(* types.StateFraudProof )
272- if ! ok {
273- m .logger .Error ("unexpected type received for state fraud proof" , "error" , err )
274- return
275- }
276- m .logger .Debug ("fraud proof received" ,
277- "block height" , fraudProof .BlockHeight ,
278- "pre-state app hash" , fraudProof .PreStateAppHash ,
279- "expected valid app hash" , fraudProof .ExpectedValidAppHash ,
280- "length of state witness" , len (fraudProof .StateWitness ),
281- )
282- // TODO(light-client): Set up a new cosmos-sdk app
283- // TODO: Add fraud proof window validation
284-
285- success , err := m .executor .VerifyFraudProof (& fraudProof .FraudProof , fraudProof .ExpectedValidAppHash )
286- if err != nil {
287- m .logger .Error ("failed to verify fraud proof" , "error" , err )
288- continue
289- }
290- if success {
291- // halt chain
292- m .logger .Info ("verified fraud proof, halting chain" )
293- cancel ()
294- return
295- }
269+ // only handle the state fraud proofs for now
270+ fraudProof , ok := proof .(* types.StateFraudProof )
271+ if ! ok {
272+ m .logger .Error ("unexpected type received for state fraud proof" , "error" , err )
273+ return
296274 }
275+ m .logger .Debug ("fraud proof received" ,
276+ "block height" , fraudProof .BlockHeight ,
277+ "pre-state app hash" , fraudProof .PreStateAppHash ,
278+ "expected valid app hash" , fraudProof .ExpectedValidAppHash ,
279+ "length of state witness" , len (fraudProof .StateWitness ),
280+ )
281+
282+ // halt chain
283+ m .logger .Info ("verified fraud proof, halting chain" )
284+ cancel ()
297285}
298286
299287// SyncLoop is responsible for syncing blocks.
0 commit comments