Skip to content

refactor: TaskGenerator rewrite #635

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

Merged
merged 5 commits into from
Apr 28, 2025
Merged

refactor: TaskGenerator rewrite #635

merged 5 commits into from
Apr 28, 2025

Conversation

MegaRedHand
Copy link
Collaborator

@MegaRedHand MegaRedHand commented Apr 14, 2025

Fixes # .

What Changed?

This PR rewrites the TaskGenerator to reduce the amount of code an AVS would need to write.

Reviewer Checklist

  • Code is well-documented
  • Code adheres to Go naming conventions
  • Code deprecates any old functionality before removing it

type TaskGenerator struct {
// Type is generic over the task input type
type TaskManager[Input any] interface {
CreateNewTask(opts *bind.TransactOpts, input Input, quorumThresholdPercentage uint32, quorumNumbers []byte) (*gethtypes.Transaction, error)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like that this requires the implementor to return the Transaction because it limits the kind of things they could do inside of this. However, one could hack around this restriction by simply returning an empty transaction and nil error, and using a custom TxManager that ignores all transactions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a good catch. However, I think we can leave this change for a future change.

@MegaRedHand
Copy link
Collaborator Author

I left some TODOs in the code, but they can be addressed later. The main idea is whole.

@MegaRedHand MegaRedHand mentioned this pull request Apr 15, 2025
@MegaRedHand
Copy link
Collaborator Author

I added a configuration struct with the quorum parameters, logger, and time between tasks (which I changed to be of type time.Duration).

I also tried doing a refactor to split the interface in two, which I found too complex for now (so I reverted it), but we might want to revisit it later: adc5dd2

@MegaRedHand MegaRedHand requested a review from pablodeymo April 16, 2025 20:50
@MegaRedHand MegaRedHand merged commit 73a99a5 into v2 Apr 28, 2025
8 of 10 checks passed
@MegaRedHand MegaRedHand deleted the task-generator-rewrite branch April 28, 2025 16:42
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.

3 participants