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

Simplify common.Engine API #3406

Merged
merged 1 commit into from
Sep 24, 2024
Merged

Conversation

yacovm
Copy link
Contributor

@yacovm yacovm commented Sep 20, 2024

Why this should be merged

Halt() is only used for the bootstrapper engine, and not invoked on other engine types.

Context() is only used in tests.

Therefore, this commit removes these methods from the common engine API to simplify it.

How this works

Tidies up some code.

How this was tested

Unit tests

@yacovm yacovm force-pushed the tidyEngineAPI branch 4 times, most recently from 26015d1 to 4a200b1 Compare September 20, 2024 19:25
Copy link

@philipjonsen philipjonsen left a comment

Choose a reason for hiding this comment

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

nice work! did a fuzzing without problem

@yacovm yacovm self-assigned this Sep 23, 2024
snow/networking/handler/handler.go Outdated Show resolved Hide resolved
snow/engine/snowman/bootstrap/config.go Outdated Show resolved Hide resolved
@yacovm yacovm force-pushed the tidyEngineAPI branch 2 times, most recently from a839591 to 3cacae5 Compare September 24, 2024 00:36
@@ -1013,17 +1017,19 @@ func (m *manager) createAvalancheChain(
avalancheBootstrapperConfig.StopVertexID = m.Upgrades.CortinaXChainStopVertexID
}

avalancheBootstrapper, err := avbootstrap.New(
var avalancheBootstrapper common.BootstrapableEngine
avBoot, err := avbootstrap.New(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we actually need the avBoot var.

Suggested change
avBoot, err := avbootstrap.New(
avalancheBootstrapper, err = avbootstrap.New(

I think the only place we use avBoot we could just use avalancheBootstrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

avbootstrap.New now returns a concrete type.
common.TraceBootstrapableEngine returns an interface type, so we cannot override the original reference of the bootstrapper any longer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that, but avalancheBootstrapper has type common.TraceBootstrapableEngine. We can assign to it directly here without creating an intermediate variable avBoot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks for clarifying.

Fixed!

snow/engine/avalanche/bootstrap/bootstrapper.go Outdated Show resolved Hide resolved
chains/manager.go Outdated Show resolved Hide resolved
chains/manager.go Outdated Show resolved Hide resolved
Halt() is only used for the bootstrapper engine, and not invoked on other engine types.

Context() is only used in tests.

Therefore, this commit removes these methods from the common engine API to simplify it.

Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
@StephenButtolph StephenButtolph added the cleanup Code quality improvement label Sep 24, 2024
@StephenButtolph StephenButtolph added this to the v1.11.12 milestone Sep 24, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 24, 2024
Merged via the queue into ava-labs:master with commit 1b6288f Sep 24, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants