-
Notifications
You must be signed in to change notification settings - Fork 118
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
Generalize builder #1767
Conversation
Co-authored-by: Aaron Buchwald <aaron.buchwald56@gmail.com>
internal/builder/time.go
Outdated
Len(context.Context) int // items | ||
} | ||
|
||
type GetPreferedTimestampAndBlockGap func(int64) (int64, int64) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure!
@@ -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) { |
There was a problem hiding this comment.
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).
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.