Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R4R]fix blockhash not correct for the logs of system tx receipt #444

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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