diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index d6cdcbb08b..54fe693d94 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -1071,17 +1071,25 @@ func insertStateSyncTransactionAndCalculateReceipt(stateSyncData []*types.StateS logsFromReceiptCount := countLogsFromReceipts(receipts) stateSyncLogs := allLogs[logsFromReceiptCount:] + txIndex := uint(len(body.Transactions) - 1) + for _, l := range stateSyncLogs { + l.TxIndex = txIndex + } + stateSyncReceipt := &types.Receipt{ + // Consensus fields Type: types.StateSyncTxType, - PostState: header.Root.Bytes(), Status: types.ReceiptStatusSuccessful, CumulativeGasUsed: header.GasUsed, - TxHash: stateSyncTx.Hash(), Logs: stateSyncLogs, - BlockNumber: header.Number, - TransactionIndex: uint(len(body.Transactions)), // we already appended state sync tx on body - EffectiveGasPrice: big.NewInt(0), + // Implementation fields + TxHash: stateSyncTx.Hash(), + GasUsed: 0, + // Inclusion information + BlockNumber: header.Number, + TransactionIndex: txIndex, } + stateSyncReceipt.Bloom = types.CreateBloom(stateSyncReceipt) receipts = append(receipts, stateSyncReceipt) diff --git a/core/types/receipt.go b/core/types/receipt.go index 931170bf5e..f22cb5c184 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -218,7 +218,7 @@ func (r *Receipt) decodeTyped(b []byte) error { } switch b[0] { - case DynamicFeeTxType, AccessListTxType, BlobTxType, SetCodeTxType: + case DynamicFeeTxType, AccessListTxType, BlobTxType, SetCodeTxType, StateSyncTxType: var data receiptRLP err := rlp.DecodeBytes(b[1:], &data) @@ -394,7 +394,7 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) { } w.WriteByte(r.Type) switch r.Type { - case AccessListTxType, DynamicFeeTxType, BlobTxType, SetCodeTxType: + case AccessListTxType, DynamicFeeTxType, BlobTxType, SetCodeTxType, StateSyncTxType: rlp.Encode(w, data) default: // For unsupported types, write nothing. Since this is for