@@ -21,6 +21,9 @@ func (s *InitState) ProcessEvent(event Event,
2121
2222 switch event .(type ) {
2323 case * InitEvent :
24+ log .Debugf ("Processing InitEvent for asset: %s" ,
25+ env .AssetSpec .String ())
26+
2427 ctx := context .Background ()
2528
2629 // Retrieve the set of unspent pre-commitments for the asset
@@ -54,6 +57,12 @@ func (s *InitState) ProcessEvent(event Event,
5457 "verified supply commitment found" )
5558 }
5659
60+ log .Infof ("Transitioning from InitState to " +
61+ "WatchOutputsState for asset: %s, " +
62+ "pre_commits=%d, has_latest_commit=%v" ,
63+ env .AssetSpec .String (), len (preCommits ),
64+ latestCommit != nil )
65+
5766 return & StateTransition {
5867 NextState : & WatchOutputsState {},
5968 NewEvents : lfn .Some (FsmEvent {
@@ -102,6 +111,9 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
102111
103112 switch e := event .(type ) {
104113 case * SyncVerifyEvent :
114+ log .Debugf ("Processing SyncVerifyEvent for asset: %s" ,
115+ env .AssetSpec .String ())
116+
105117 ctx := context .Background ()
106118
107119 // Check to ensure that we haven't already processed a supply
@@ -133,6 +145,10 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
133145 return nil , err
134146 }
135147
148+ log .Debugf ("Supply commitment already " +
149+ "processed, transitioning to " +
150+ "WatchOutputsState" )
151+
136152 watchEvent := WatchOutputsEvent {
137153 SupplyCommit : & commit ,
138154 }
@@ -185,6 +201,7 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
185201
186202 verifier , err := NewVerifier (
187203 VerifierCfg {
204+ AssetSpec : env .AssetSpec ,
188205 ChainBridge : env .Chain ,
189206 AssetLookup : env .AssetLookup ,
190207 Lnd : env .Lnd ,
@@ -207,6 +224,8 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
207224 "commitment: %w" , err )
208225 }
209226
227+ log .Debugf ("Storing verified supply commitment" )
228+
210229 // Store the verified commitment.
211230 err = env .SupplyCommitView .InsertSupplyCommit (
212231 ctx , env .AssetSpec , supplyCommit .RootCommitment ,
@@ -217,6 +236,11 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
217236 "commitment: %w" , err )
218237 }
219238
239+ log .Infof ("Successfully synced and verified supply " +
240+ "commitment for asset: %s, " +
241+ "transitioning to WatchOutputsState" ,
242+ env .AssetSpec .String ())
243+
220244 // After syncing, verifying, and storing the latest supply
221245 // commitment, transition to the watch state to await its spend.
222246 watchEvent := WatchOutputsEvent {
@@ -232,12 +256,18 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
232256 }, nil
233257
234258 case * SpendEvent :
259+ log .Infof ("Received SpendEvent for asset: %s, spend_tx=%s" ,
260+ env .AssetSpec .String (),
261+ e .SpendDetail .SpendingTx .TxHash ())
262+
235263 // A watched output has been spent, so transition to the sync
236264 // state to fetch the new supply commitment. Before syncing,
237265 // apply a delay to give the issuer time to publish it.
238266 switch {
239267 case e .WatchStartTimestamp .IsZero ():
240268 // No watch start timestamp: wait the full sync delay.
269+ log .Debugf ("Waiting full sync delay of %v before " +
270+ "syncing" , env .SpendSyncDelay )
241271 time .Sleep (env .SpendSyncDelay )
242272
243273 default :
@@ -246,6 +276,10 @@ func (s *SyncVerifyState) ProcessEvent(event Event,
246276 timeSinceWatch := time .Since (e .WatchStartTimestamp )
247277 if timeSinceWatch < env .SpendSyncDelay {
248278 delay := env .SpendSyncDelay - timeSinceWatch
279+
280+ env .Logger ().Debugf ("Waiting remaining sync " +
281+ "delay of %v before syncing" , delay )
282+
249283 time .Sleep (delay )
250284 }
251285 }
@@ -283,6 +317,8 @@ func (s *WatchOutputsState) ProcessEvent(event Event,
283317
284318 switch e := event .(type ) {
285319 case * WatchOutputsEvent :
320+ env .Logger ().Debugf ("Processing WatchOutputsEvent" )
321+
286322 preCommits := e .PreCommits
287323
288324 // If no pre-commitments were provided, then we'll query our
@@ -342,6 +378,11 @@ func (s *WatchOutputsState) ProcessEvent(event Event,
342378 Hash : e .SupplyCommit .Txn .TxHash (),
343379 Index : e .SupplyCommit .TxOutIdx ,
344380 }
381+
382+ env .Logger ().Debugf ("Registering spend watch for " +
383+ "supply commitment outpoint: %s" ,
384+ outpoint .String ())
385+
345386 txOutIdx := e .SupplyCommit .TxOutIdx
346387 txOut := e .SupplyCommit .Txn .TxOut [txOutIdx ]
347388
@@ -365,6 +406,9 @@ func (s *WatchOutputsState) ProcessEvent(event Event,
365406 })
366407 }
367408
409+ env .Logger ().Infof ("Transitioning to SyncVerifyState, " +
410+ "watching %d outputs" , len (events ))
411+
368412 // Otherwise, we'll transition to the verify state to await
369413 // a spend of one of the outputs we're watching.
370414 return & StateTransition {
0 commit comments