Skip to content

core/bloombits: handle non 8-bit boundary section matches#15489

Merged
karalabe merged 1 commit into
ethereum:masterfrom
karalabe:bloombits-shifted-start
Nov 15, 2017
Merged

core/bloombits: handle non 8-bit boundary section matches#15489
karalabe merged 1 commit into
ethereum:masterfrom
karalabe:bloombits-shifted-start

Conversation

@karalabe
Copy link
Copy Markdown
Member

In our bloombits matcher, we maintain matched blocks via a []byte bitset. After filtering the blocks and generating the final bitset, we iterate over the block interval and check whether they match according to the bitset.

Since the bitset contains bytes, if a bitset element is zero, we can skip ahead 8 blocks, since none of them will match. This has a subtlety that we got wrong. If we start filtering from a block number that's not a multiple of 8, then we can't skip ahead 8 blocks when finding a zero bitset element, only 8 - number % 8 elements, since skipping 8 would overlap with the next byte in the bitset.

This PR fixes it by only skipping 8 blocks if we're at a bitset byte boundary, otherwise just increment blocks 1-by-1 until we do reach a byte boundary.

Fixes #15309.

@karalabe karalabe added this to the 1.7.3 milestone Nov 15, 2017
Copy link
Copy Markdown
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@slavik0329
Copy link
Copy Markdown

Thank god for this fix. Should be released. It's a pretty big issue

@karalabe
Copy link
Copy Markdown
Member Author

Will be on Monday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log filtering doesn't work sometimes when fromBlock is specified

3 participants