rpc: fix BlockBloom not found in header (#258)

* fix context index

* return default bloom if cannot be found

* fix blockbloom error

* fix setting blockbloom transient in ctx

* clean comments

* remove unused method

* update changelog

* Update CHANGELOG.md

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Thomas Nguy
2021-07-14 09:40:58 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer
parent e09bf23bd0
commit aab793e7f4
4 changed files with 17 additions and 36 deletions
+10 -6
View File
@@ -138,21 +138,25 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT
txHash := tx.Hash()
res.Hash = txHash.Hex()
logs := k.GetTxLogs(txHash)
// Set the bloom filter and commit only if transaction is NOT reverted
// Commit and switch to original context
if !res.Reverted {
commit()
}
k.ctx = originalCtx
// Logs needs to be ignored when tx is reverted
// Set the log and bloom filter only when the tx is NOT REVERTED
if !res.Reverted {
logs := k.GetTxLogs(txHash)
res.Logs = types.NewLogsFromEth(logs)
// update block bloom filter
// Update block bloom filter in the original context because blockbloom is set in EndBlock
bloom := k.GetBlockBloomTransient()
bloom.Or(bloom, big.NewInt(0).SetBytes(ethtypes.LogsBloom(logs)))
k.SetBlockBloomTransient(bloom)
commit()
}
// refund gas prior to handling the vm error in order to set the updated gas meter
k.ctx = originalCtx
leftoverGas := msg.Gas() - res.GasUsed
leftoverGas, err = k.RefundGas(msg, leftoverGas)
if err != nil {