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

fix: copy TxIndex TxBytes value #150

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
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
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
Loading