From c113520d5daeeb24f5968395cd9ad2db2d16fe32 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 1 Nov 2021 01:50:29 -0500 Subject: [PATCH] miner: fix receipt deep copy in worker (#23835) --- miner/worker.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 5399adf1d..4ef2c8c0d 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -632,17 +632,23 @@ func (w *worker) resultLoop() { receipts = make([]*types.Receipt, len(task.receipts)) logs []*types.Log ) - for i, receipt := range task.receipts { + for i, taskReceipt := range task.receipts { + receipt := new(types.Receipt) + receipts[i] = receipt + *receipt = *taskReceipt + // add block location fields receipt.BlockHash = hash receipt.BlockNumber = block.Number() receipt.TransactionIndex = uint(i) - receipts[i] = new(types.Receipt) - *receipts[i] = *receipt // Update the block hash in all logs since it is now available and not when the // receipt/log of individual transactions were created. - for _, log := range receipt.Logs { + receipt.Logs = make([]*types.Log, len(taskReceipt.Logs)) + for i, taskLog := range taskReceipt.Logs { + log := new(types.Log) + receipt.Logs[i] = log + *log = *taskLog log.BlockHash = hash } logs = append(logs, receipt.Logs...)