Skip to content

Commit

Permalink
fix: copy TxIndex TxBytes value (#150)
Browse files Browse the repository at this point in the history
* fix: copy TxIndex TxBytes value

* chore: changelog
  • Loading branch information
crnbarr93 authored Nov 18, 2024
1 parent 08ef650 commit fcd17ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This v0.38.12 branch was created at the [cf7836ad7b63bc1421deed23beb8630a3705b5d
* [#142](https://github.com/osmosis-labs/cometbft/pull/142) feat(p2p): render HasChannel(chID) is a public p2p.Peer method (#3510) #142
* [#143](https://github.com/osmosis-labs/cometbft/pull/143) fix: comment out expensive debug logs #143
* [#f2f9426](https://github.com/osmosis-labs/cometbft/commit/f2f9426c6985f2ea63ceb879c26858cf7f42f186) perf(blocksync): Parallelize logic for receiving a block from a peer. (backport cometbft#3554) (cometbft#3592)
* [#150](https://github.com/osmosis-labs/cometbft/pull/150) fix: copy TxIndex TxBytes value

## v26

Expand Down
9 changes: 7 additions & 2 deletions state/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,17 @@ type TxInfo struct {
}

func (*TxIndex) setTmpHashes(tmpHeights map[string]TxInfo, key, value []byte, height int64) {
// value comes from cometbft-db Iterator interface Value() API.
// Therefore, we must make a copy before storing references to it.
valueCp := make([]byte, len(value))
copy(valueCp, value)

eventSeq := extractEventSeqFromKey(key)
txInfo := TxInfo{
TxBytes: value,
TxBytes: valueCp,
Height: height,
}
tmpHeights[string(value)+eventSeq] = txInfo
tmpHeights[string(valueCp)+eventSeq] = txInfo
}

// match returns all matching txs by hash that meet a given condition and start
Expand Down

0 comments on commit fcd17ce

Please sign in to comment.