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

Replace snowball/snowflake interface with single shared snow interface #2717

Merged
merged 10 commits into from
Feb 12, 2024

Conversation

aaronbuchwald
Copy link
Collaborator

Why this should be merged

This PR replaces the separate snowball/snowflake interfaces for the Unary, Binary, and Nnary consensus types with a single shared snow interface.

The only difference that we change is previously UnarySnowball had a RecordPollPreference function whereas UnarySnowflake did not. The reason for this is that in the unary case, there is only one possible preference and we have not received enough votes to increment our confidence towards finalizing.

Therefore, in the snowball case where we maintain a confidence counter for preference, this has the impact of increasing our confidence in our current preference even though we don't get closer to finalizing.

In snowflake, there is no notion of incrementing confidence in our preference, so RecordPollPreference simply resets the confidence counter on a unary instance.

This also removes the slush interfaces since there is only a single implementation.

How this works

This code change is intended solely as a refactor to reduce instances where we have an interface where there is only a single implementation.

How this was tested

This was tested with the existing unit tests and uses the same snowball/snowflake consensus factory as the unit tests previously used since the current tests are specific to the snowball/snowflake implementation behaviors.

@aaronbuchwald aaronbuchwald self-assigned this Feb 8, 2024
snow/consensus/snowball/consensus.go Outdated Show resolved Hide resolved
snow/consensus/snowball/nnary_snowball.go Outdated Show resolved Hide resolved
snow/consensus/snowball/nnary_snowflake.go Outdated Show resolved Hide resolved
snow/consensus/snowball/tree.go Outdated Show resolved Hide resolved
@joshua-kim joshua-kim added cleanup Code quality improvement consensus This involves consensus labels Feb 12, 2024
snow/consensus/snowball/consensus.go Outdated Show resolved Hide resolved
snow/consensus/snowball/consensus.go Outdated Show resolved Hide resolved
snow/consensus/snowball/nnary_snowball.go Outdated Show resolved Hide resolved
snow/consensus/snowball/consensus.go Outdated Show resolved Hide resolved
snow/consensus/snowball/consensus_performance_test.go Outdated Show resolved Hide resolved
snow/consensus/snowball/flat.go Outdated Show resolved Hide resolved
snow/consensus/snowball/flat.go Outdated Show resolved Hide resolved
snow/consensus/snowball/nnary_snowflake.go Outdated Show resolved Hide resolved
@StephenButtolph StephenButtolph added this to the v1.11.0 milestone Feb 12, 2024
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

small nits around comment lengths (wrapping at 80 chars)

snow/consensus/snowball/consensus.go Outdated Show resolved Hide resolved
snow/consensus/snowball/unary_snowflake.go Outdated Show resolved Hide resolved
Signed-off-by: Stephen Buttolph <stephen@avalabs.org>
@StephenButtolph StephenButtolph added this pull request to the merge queue Feb 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 12, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Feb 12, 2024
Merged via the queue into master with commit adc1d4b Feb 12, 2024
17 checks passed
@StephenButtolph StephenButtolph deleted the remove-near-duplicate-snow-intfs branch February 12, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement consensus This involves consensus
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants