Skip to content

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
@yacovm yacovm force-pushed the tidyEngineAPI branch 2 times, most recently from a839591 to 3cacae5 Compare September 24, 2024 00:36

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!

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