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

Implement traversal based early termination #3337

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yacovm
Copy link
Contributor

@yacovm yacovm commented Aug 27, 2024

This commit makes the early termination logic of the snowflake poll consider also transitive voting. A block b0 is transitively voted by all votes for block b1 if b0 is an ancestor of b1.

This transitive termination logic also works for shard common block prefixes. If block b0 is a direct ancestor of b1 and b2 and the latter have a shared prefix, then the logic in this commit may not early terminate the vote if a future vote might improve the confidence of the shared prefix, as it correspons to a snowflake instance.

Note: I will rename the file name early_term_no_traversal.go after this is merged. I didn't rename them in the same commit so that it will be easy to distinguish between old code and new code.

Why this should be merged

Considering transitive votes in early termination logic improves consensus performance by reducing the time to block finalization due to earlier termination than when not taking into account transitive voting.

How this works

When the early termination logic is asked whether to terminate or not, it creates a graph out of the votes, where each ID of a block corresponds to a vertex. Parent vertices point to their descendants and descendants to their parents.
When considering how many votes for a block ID exist, the direct vote as well as the votes for the descendants are now taken int account.

Additionally, in order to adhere to the same logic that snowman employs for the bit decomposition of blocks, the termination logic also takes into account votes for shared bit prefixes of block IDs. For each vertex, its direct descendants are observed, and a graph of shared prefixes is built. Every inner vertex in the graph that corresponds to a unary node that represents a shared prefix is also taken account in transitive voting.

How this was tested

Unit tests for added code are included.

I ran a modified build on mainnet for 24 hours alongside a regular build and observed that transitive voting reduces occurrence of consensus rounds lasting more than 1200 milliseconds from 14% to 1.5% on mainnet.

The following graphs show the latency of consensus rounds as a function of time on mainnet.
Without transitive voting:

Screenshot 2024-08-26 at 16 56 52

With transitive voting:
Screenshot 2024-08-26 at 17 15 43

@yacovm yacovm self-assigned this Aug 27, 2024
@yacovm yacovm force-pushed the earlyterm_yes_traversal branch 3 times, most recently from ccfaac5 to 7b6f256 Compare August 27, 2024 16:37
@yacovm yacovm added the consensus This involves consensus label Aug 27, 2024
This commit makes the early termination logic of the snowflake poll consider also transitive voting.
A block `b0` is transitively voted by all votes for block `b1` if `b0` is an ancestor of `b1`.

This transitive termination logic also works for shard common block prefixes.
If block `b0` is a direct ancestor of `b1` and `b2` and the latter have a shared prefix,
then the logic in this commit may not early terminate the vote if a future vote might improve the confidence
of the shared prefix, as it correspons to a snowflake instance.

Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus This involves consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant