Skip to content

Commit

Permalink
fix blockhash not correct for the logs of system tx receipt (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro authored Oct 11, 2021
1 parent b2f1d25 commit 03febe1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,16 @@ func (bc *BlockChain) GetVMConfig() *vm.Config {
}

func (bc *BlockChain) cacheReceipts(hash common.Hash, receipts types.Receipts) {
// TODO, This is a hot fix for the block hash of logs is `0x0000000000000000000000000000000000000000000000000000000000000000` for system tx
// Please check details in https://github.com/binance-chain/bsc/issues/443
// This is a temporary fix, the official fix should be a hard fork.
const possibleSystemReceipts = 3 // One slash tx, two reward distribute txs.
numOfReceipts := len(receipts)
for i := numOfReceipts - 1; i >= 0 && i >= numOfReceipts-possibleSystemReceipts; i-- {
for j := 0; j < len(receipts[i].Logs); j++ {
receipts[i].Logs[j].BlockHash = hash
}
}
bc.receiptsCache.Add(hash, receipts)
}

Expand Down

0 comments on commit 03febe1

Please sign in to comment.