@@ -576,34 +576,30 @@ func (api *APIImpl) GetBlockReceipts(ctx context.Context, numberOrHash rpc.Block
576576 if err != nil {
577577 return nil , err
578578 }
579+
580+ // Get normal transaction receipts.
581+ // This DOES NOT generate state-sync transaction receipt for bor.
579582 receipts , err := api .getReceipts (ctx , tx , block )
580583 if err != nil {
581584 return nil , fmt .Errorf ("getReceipts error: %w" , err )
582585 }
583586
584587 numReceipts := len (receipts )
585- numTxs := len (block .Transactions ())
586588 result := make ([]map [string ]interface {}, 0 , numReceipts )
587589
588- // track if we already have a state-sync receipt coming from the generator
589- hasBorStateSyncReceipt := false
590-
590+ // Marshal normal transaction receipts and append to result
591591 for _ , receipt := range receipts {
592- // State-sync receipts' TransactionIndex is equal to numTxs.
593- if int (receipt .TransactionIndex ) == numTxs {
594- // This is a state-sync transaction receipt.
595- hasBorStateSyncReceipt = true
596- result = append (result , ethutils .MarshalReceipt (receipt , bortypes .NewBorTransaction (), chainConfig , block .HeaderNoCopy (), receipt .TxHash , false , true ))
597- } else {
598- // This is a normal transaction receipt.
599- txn := block .Transactions ()[receipt .TransactionIndex ]
600- result = append (result , ethutils .MarshalReceipt (receipt , txn , chainConfig , block .HeaderNoCopy (), txn .Hash (), true , true ))
601- }
592+ txn := block .Transactions ()[receipt .TransactionIndex ]
593+ result = append (result , ethutils .MarshalReceipt (receipt , txn , chainConfig , block .HeaderNoCopy (), txn .Hash (), true , true ))
594+ }
595+
596+ // check for state sync event logs and generate state-sync transaction receipt for bor.
597+ events , err := api .bridgeReader .Events (ctx , block .Hash (), blockNum )
598+ if err != nil {
599+ return nil , err
602600 }
603601
604- // if we've already included the state-sync
605- // receipt from the receipts generator, don't generate and append another one.
606- if chainConfig .Bor != nil && hasBorStateSyncReceipt {
602+ if len (events ) == 0 {
607603 return result , nil
608604 }
609605
@@ -615,19 +611,12 @@ func (api *APIImpl) GetBlockReceipts(ctx context.Context, numberOrHash rpc.Block
615611 }
616612 }
617613
618- events , err := api .bridgeReader . Events (ctx , block . Hash (), blockNum )
614+ borReceipt , err := api .borReceiptGenerator . GenerateBorReceipt (ctx , tx , block , events , chainConfig )
619615 if err != nil {
620616 return nil , err
621617 }
622618
623- if len (events ) != 0 {
624- borReceipt , err := api .borReceiptGenerator .GenerateBorReceipt (ctx , tx , block , events , chainConfig )
625- if err != nil {
626- return nil , err
627- }
628-
629- result = append (result , ethutils .MarshalReceipt (borReceipt , borTx , chainConfig , block .HeaderNoCopy (), borReceipt .TxHash , false , true ))
630- }
619+ result = append (result , ethutils .MarshalReceipt (borReceipt , borTx , chainConfig , block .HeaderNoCopy (), borReceipt .TxHash , false , true ))
631620
632621 return result , nil
633622}
0 commit comments