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

bug fix : tx sync was incorrectly validating transactions #3554

Merged
merged 4 commits into from
Feb 2, 2022
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
23 changes: 18 additions & 5 deletions rpcs/txSyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,31 @@ func (syncer *TxSyncer) syncFromClient(client TxSyncClient) error {
return fmt.Errorf("TxSyncer.Sync: peer '%v' error '%v'", client.Address(), err)
}

var pendingTxidMap map[transactions.Txid]struct{}
// test to see if all the transaction that we've received honor the bloom filter constraints
// that we've requested.
for _, txgroup := range txgroups {
var txnsInFilter int
for i := range txgroup {
txID := txgroup[i].ID()
if filter.Test(txID[:]) {
// we just found a transaction that shouldn't have been
// included in the response. maybe this is a false positive
// and other transactions in the group aren't included in the
// bloom filter, though.
txnsInFilter++
// having the transaction id tested here might still fall into the false-positive class, so we
// need to perform explicit check. This is not too bad since we're doing this check only on the fail
// cases.
if pendingTxidMap == nil {
// construct and initialize it.
pendingTxidMap = make(map[transactions.Txid]struct{}, len(pending))
for _, txid := range pending {
pendingTxidMap[txid] = struct{}{}
}
}
if _, has := pendingTxidMap[txID]; has {
// we just found a transaction that shouldn't have been
// included in the response. maybe this is a false positive
// and other transactions in the group aren't included in the
// bloom filter, though.
txnsInFilter++
}
}
}

Expand Down