Skip to content

Conversation

@tsachiherman
Copy link
Contributor

@tsachiherman tsachiherman commented Sep 3, 2021

Summary

Refactor the bloom filter implementation to have two "implementations" : testableBloomFilter and bloomFilter.

testableBloomFilter is used exclusively when being received from the network; it does not contain any encoded
fields, nor does it include transactionsRange which is used for generating new bloom filters.

bloomFilter on the flip side is used only for outgoing bloom filters. It doesn't support testing, and it contains only the encoded bloom filter ( and not the underlying bloom filter needed for testing, for instance ).

This separation allows us to ensure we don't store bloom filter object beyond the required scope, improving the memory utilization.

Test Plan

This PR does not introduce any new functionality. The existing unit tests were updated to use the updated constructs.

@codecov-commenter
Copy link

codecov-commenter commented Sep 3, 2021

Codecov Report

Merging #2834 (f57e585) into feature/txnsync (5ee56d6) will decrease coverage by 0.00%.
The diff coverage is 88.00%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feature/txnsync    #2834      +/-   ##
===================================================
- Coverage            43.35%   43.34%   -0.01%     
===================================================
  Files                  374      374              
  Lines                84636    84616      -20     
===================================================
- Hits                 36695    36681      -14     
+ Misses               42139    42131       -8     
- Partials              5802     5804       +2     
Impacted Files Coverage Δ
txnsync/peer.go 95.79% <60.00%> (+0.30%) ⬆️
txnsync/bloomFilter.go 92.94% <88.57%> (-7.06%) ⬇️
txnsync/incoming.go 100.00% <100.00%> (ø)
txnsync/msgp_gen.go 30.60% <100.00%> (-0.02%) ⬇️
txnsync/outgoing.go 95.04% <100.00%> (-0.05%) ⬇️
network/netprio.go 69.56% <0.00%> (-8.70%) ⬇️
txnsync/mainloop.go 85.71% <0.00%> (-0.96%) ⬇️
network/wsNetwork.go 63.14% <0.00%> (+0.18%) ⬆️
ledger/acctupdates.go 62.80% <0.00%> (+0.25%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ee56d6...f57e585. Read the comment docs.

@tsachiherman tsachiherman self-assigned this Sep 3, 2021
@tsachiherman tsachiherman marked this pull request as ready for review September 3, 2021 19:49
@tsachiherman tsachiherman changed the title bloom filter refactoring txnsync: bloom filter refactoring Sep 3, 2021
Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.
A few minor comments.

testableBf, err := decodeBloomFilter(enc)
require.NoError(t, err)
for _, tx := range txnGroups {
ans := testableBf.test(tx.GroupTransactionID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the Modulator variations dropped here?
test checks the modulator value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I'll add that back. ( i.e. I think that we don't need this for the encoding part.. but we want to verify the testing )

@tsachiherman tsachiherman merged commit 3c23379 into algorand:feature/txnsync Sep 7, 2021
@tsachiherman tsachiherman deleted the tsachi/bloomfilter-refactoring branch September 7, 2021 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants