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

Generalize builder #1767

Merged
merged 14 commits into from
Nov 14, 2024
Merged

Generalize builder #1767

merged 14 commits into from
Nov 14, 2024

Conversation

tsachiherman
Copy link
Contributor

@tsachiherman tsachiherman commented Nov 12, 2024

What ?

Decouple components that are unnecessarily tied to the chain package because they depend on either the block or transaction types. We should remove the pattern of using a resolutions.go and dependencies.go file to pass around mega objects and switch to passing in the required parameters to each type we need to construct.

This PR focuses on decoupling the builder from the chain package.

@tsachiherman tsachiherman self-assigned this Nov 12, 2024
@tsachiherman tsachiherman marked this pull request as ready for review November 13, 2024 17:43
tsachiherman and others added 2 commits November 13, 2024 13:27
Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>
Len(context.Context) int // items
}

type GetPreferedTimestampAndBlockGap func(int64) (int64, int64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: could we add variable names and a comment to make this more easily readable and an error, so that we don't need to use a special case of the latter return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure!

@aaronbuchwald aaronbuchwald merged commit 702d68c into main Nov 14, 2024
17 checks passed
@aaronbuchwald aaronbuchwald deleted the tsachi/builder-refactor branch November 14, 2024 18:11
@@ -324,6 +323,14 @@ func (vm *VM) Initialize(

vm.mempool = mempool.New[*chain.Transaction](vm.tracer, vm.config.MempoolSize, vm.config.MempoolSponsorSize)

vm.builder = builder.NewTime(toEngine, snowCtx.Log, vm.mempool, func(t int64) (int64, int64, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm moving this below where we apply options means that we will set the builder to this value even if the option to override the builder is specified. Moving this back above options causes the integration tests (which use the manual builder) to fail.

Seems this change may have introduced a bug in the manual builder that is covered up by this change. We could use builder.NewTime rather than manual implementation (clearly we don't need the manual implementation).

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.

2 participants