Skip to content

Commit

Permalink
workaround tx hash issue in event parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jul 19, 2022
1 parent e190fec commit 4658529
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rpc/ethereum/types/events.go
Expand Up @@ -155,8 +155,21 @@ func (p *ParsedTxs) newTx(attrs []abci.EventAttribute) error {
}

// updateTx updates an exiting tx from events, called during parsing.
// In event format 2, we update the tx with the attributes of the second `ethereum_tx` event,
// Due to bug https://github.com/evmos/ethermint/issues/1175, the first `ethereum_tx` event may emit incorrect tx hash,
// so we prefer the second event and override the first one.
func (p *ParsedTxs) updateTx(eventIndex int, attrs []abci.EventAttribute) error {
return fillTxAttributes(&p.Txs[eventIndex], attrs)
tx := NewParsedTx(eventIndex)
if err := fillTxAttributes(&tx, attrs); err != nil {
return err
}
if tx.Hash != p.Txs[eventIndex].Hash {
// if hash is different, index the new one too
p.TxHashes[tx.Hash] = eventIndex
}
// override the tx because the second event is more trustworthy
p.Txs[eventIndex] = tx
return nil
}

// GetTxByHash find ParsedTx by tx hash, returns nil if not exists.
Expand Down

0 comments on commit 4658529

Please sign in to comment.