@@ -38,10 +38,16 @@ type collectionInfo struct {
3838
3939 collectionIndex int
4040 * entity.CompleteCollection
41-
42- isSystemTransaction bool
4341}
4442
43+ type ComputerTransactionType uint
44+
45+ const (
46+ ComputerTransactionTypeUser ComputerTransactionType = iota
47+ ComputerTransactionTypeSystem
48+ ComputerTransactionTypeScheduled
49+ )
50+
4551type TransactionRequest struct {
4652 collectionInfo
4753
@@ -50,6 +56,7 @@ type TransactionRequest struct {
5056
5157 txnIndex uint32
5258
59+ transactionType ComputerTransactionType
5360 lastTransactionInCollection bool
5461
5562 ctx fvm.Context
@@ -62,6 +69,7 @@ func newTransactionRequest(
6269 collectionLogger zerolog.Logger ,
6370 txnIndex uint32 ,
6471 txnBody * flow.TransactionBody ,
72+ transactionType ComputerTransactionType ,
6573 lastTransactionInCollection bool ,
6674) TransactionRequest {
6775 txnId := txnBody .ID ()
@@ -83,6 +91,7 @@ func newTransactionRequest(
8391 txnId ,
8492 txnIndex ,
8593 txnBody ),
94+ transactionType : transactionType ,
8695 lastTransactionInCollection : lastTransactionInCollection ,
8796 }
8897}
@@ -281,12 +290,11 @@ func (e *blockComputer) queueUserTransactions(
281290 Logger ()
282291
283292 collectionInfo := collectionInfo {
284- blockId : blockId ,
285- blockIdStr : blockIdStr ,
286- blockHeight : blockHeader .Height ,
287- collectionIndex : idx ,
288- CompleteCollection : collection ,
289- isSystemTransaction : false ,
293+ blockId : blockId ,
294+ blockIdStr : blockIdStr ,
295+ blockHeight : blockHeader .Height ,
296+ collectionIndex : idx ,
297+ CompleteCollection : collection ,
290298 }
291299
292300 for i , txnBody := range collection .Collection .Transactions {
@@ -296,7 +304,9 @@ func (e *blockComputer) queueUserTransactions(
296304 collectionLogger ,
297305 txnIndex ,
298306 txnBody ,
299- i == len (collection .Collection .Transactions )- 1 )
307+ ComputerTransactionTypeUser ,
308+ i == len (collection .Collection .Transactions )- 1 ,
309+ )
300310 txnIndex += 1
301311 }
302312 }
@@ -307,49 +317,50 @@ func (e *blockComputer) queueUserTransactions(
307317func (e * blockComputer ) queueSystemTransactions (
308318 callbackCtx fvm.Context ,
309319 systemChunkCtx fvm.Context ,
310- systemColection collectionInfo ,
320+ systemCollection collectionInfo ,
311321 systemTxn * flow.TransactionBody ,
312322 executeCallbackTxs []* flow.TransactionBody ,
313323 txnIndex uint32 ,
314324 systemLogger zerolog.Logger ,
315325) chan TransactionRequest {
316- var logger zerolog.Logger
317326
318- systemChunkTxLogger := systemLogger .With ().
319- Uint32 ("num_txs" , uint32 (len (systemColection .CompleteCollection .Collection .Transactions ))).
327+ systemTxLogger := systemLogger .With ().
328+ Uint32 ("num_txs" , uint32 (len (systemCollection .CompleteCollection .Collection .Transactions ))).
329+ Bool ("system_transaction" , true ).
320330 Logger ()
321331
322- scheduledTxLogger := systemChunkTxLogger .With ().
332+ scheduledTxLogger := systemLogger .With ().
333+ Uint32 ("num_txs" , uint32 (len (systemCollection .CompleteCollection .Collection .Transactions ))).
323334 Bool ("scheduled_transaction" , true ).
324- Bool ("critical_error" , false ).
325335 Logger ()
326336
327- allTxs := append (executeCallbackTxs , systemTxn )
328- txQueue := make (chan TransactionRequest , len (allTxs ))
337+ txQueue := make (chan TransactionRequest , len (executeCallbackTxs )+ 1 )
329338 defer close (txQueue )
330339
331- for i , txBody := range allTxs {
332- systemChunkTx := i == len (allTxs )- 1 // last tx in collection is system chunk
333- ctx := callbackCtx
334- logger = scheduledTxLogger
335-
336- if systemChunkTx {
337- ctx = systemChunkCtx
338- logger = systemChunkTxLogger
339- }
340-
340+ for _ , txBody := range executeCallbackTxs {
341341 txQueue <- newTransactionRequest (
342- systemColection ,
343- ctx ,
344- logger ,
342+ systemCollection ,
343+ callbackCtx ,
344+ scheduledTxLogger ,
345345 txnIndex ,
346346 txBody ,
347- systemChunkTx ,
347+ ComputerTransactionTypeScheduled ,
348+ false ,
348349 )
349350
350351 txnIndex ++
351352 }
352353
354+ txQueue <- newTransactionRequest (
355+ systemCollection ,
356+ systemChunkCtx ,
357+ systemTxLogger ,
358+ txnIndex ,
359+ systemTxn ,
360+ ComputerTransactionTypeSystem ,
361+ true ,
362+ )
363+
353364 return txQueue
354365}
355366
@@ -495,20 +506,17 @@ func (e *blockComputer) executeSystemTransactions(
495506 )
496507
497508 systemCollectionInfo := collectionInfo {
498- blockId : block .BlockID (),
499- blockIdStr : block .BlockID ().String (),
500- blockHeight : block .Block .Height ,
501- collectionIndex : userCollectionCount ,
502- CompleteCollection : nil , // We do not yet know all the scheduled callbacks, so postpone construction of the collection.
503- isSystemTransaction : true ,
509+ blockId : block .BlockID (),
510+ blockIdStr : block .BlockID ().String (),
511+ blockHeight : block .Block .Height ,
512+ collectionIndex : userCollectionCount ,
513+ CompleteCollection : nil , // We do not yet know all the scheduled callbacks, so postpone construction of the collection.
504514 }
505515
506- systemLogger := callbackCtx .Logger .With ().
516+ systemChunkLogger := callbackCtx .Logger .With ().
507517 Str ("block_id" , block .BlockID ().String ()).
508518 Uint64 ("height" , block .Block .Height ).
509519 Bool ("system_chunk" , true ).
510- Bool ("system_transaction" , true ).
511- Bool ("critical_error" , true ).
512520 Int ("num_collections" , userCollectionCount ).
513521 Logger ()
514522
@@ -528,7 +536,7 @@ func (e *blockComputer) executeSystemTransactions(
528536 database ,
529537 blockSpan ,
530538 txIndex ,
531- systemLogger ,
539+ systemChunkLogger ,
532540 )
533541 if err != nil {
534542 return err
@@ -565,7 +573,7 @@ func (e *blockComputer) executeSystemTransactions(
565573 e .systemTxn ,
566574 callbackTxs ,
567575 txIndex ,
568- systemLogger ,
576+ systemChunkLogger ,
569577 )
570578
571579 e .executeQueue (blockSpan , database , txQueue )
@@ -616,7 +624,7 @@ func (e *blockComputer) executeProcessCallback(
616624 systemLogger zerolog.Logger ,
617625) ([]* flow.TransactionBody , uint32 , error ) {
618626 callbackLogger := systemLogger .With ().
619- Bool ("scheduled_transaction " , true ).
627+ Bool ("system_transaction " , true ).
620628 Logger ()
621629
622630 request := newTransactionRequest (
@@ -625,6 +633,7 @@ func (e *blockComputer) executeProcessCallback(
625633 callbackLogger ,
626634 txnIndex ,
627635 e .processCallbackTxn ,
636+ ComputerTransactionTypeSystem ,
628637 false )
629638
630639 txnIndex ++
@@ -730,7 +739,7 @@ func (e *blockComputer) executeTransaction(
730739 attempt )
731740 if err != nil {
732741 prefix := ""
733- if request .isSystemTransaction {
742+ if request .transactionType == ComputerTransactionTypeSystem {
734743 prefix = "system "
735744 }
736745
0 commit comments