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

app/retry: refactor to not timeout exit duty #667

Merged
merged 2 commits into from
Jun 6, 2022
Merged

Conversation

corverroos
Copy link
Contributor

Refactor retryer to support different timeouts for different duty types. Specificlally, DutyExit should not timeout since it can be linked to any past or future slot.

I had to make it generic, since retryer cannot import core which results in a import cycle. Defining DeadlineFunc in core also a makes a bit more sense, since the core package owns duties.

category: refactor
ticket: #553

@corverroos corverroos changed the title app/retry: refactor to not deadline duty exit app/retry: refactor to not timeout exit duty Jun 3, 2022
@codecov
Copy link

codecov bot commented Jun 3, 2022

Codecov Report

Merging #667 (57cf745) into main (94e616b) will decrease coverage by 0.09%.
The diff coverage is 34.00%.

@@            Coverage Diff             @@
##             main     #667      +/-   ##
==========================================
- Coverage   55.11%   55.01%   -0.10%     
==========================================
  Files          98       99       +1     
  Lines        9652     9664      +12     
==========================================
- Hits         5320     5317       -3     
- Misses       3561     3579      +18     
+ Partials      771      768       -3     
Impacted Files Coverage Δ
core/deadline.go 0.00% <0.00%> (ø)
core/retry.go 0.00% <0.00%> (ø)
core/validatorapi/validatorapi.go 54.90% <ø> (ø)
app/app.go 58.43% <40.00%> (+0.42%) ⬆️
app/retry/retry.go 85.41% <83.33%> (+6.32%) ⬆️
core/qbft/qbft.go 80.38% <0.00%> (-1.08%) ⬇️
core/dutydb/memory.go 79.48% <0.00%> (+1.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94e616b...57cf745. Read the comment docs.

"github.com/obolnetwork/charon/app/errors"
)

// lateFactor defines the number of slots duties may be late.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
// lateFactor defines the number of slots duties may be late.
// lateFactor defines the number of slots that the duties may be late.

return nil, err
}

duration, err := eth2Cl.SlotDuration(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can rename duration to durationPerSlot

backoffProvider func() func() <-chan time.Time

wg sync.WaitGroup
}

// DoAsync will execute the function including retries on network or context errors.
// It is intended to be used asynchronously:
// go retryer.DoAsync(ctx, duty.Slot, "foo", fn)
func (r *Retryer) DoAsync(parent context.Context, slot int64, name string, fn func(context.Context) error) {
// go retryer.DoAsync(ctx, duty, "foo", fn)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
// go retryer.DoAsync(ctx, duty, "foo", fn)
// USAGE: go retryer.DoAsync(ctx, duty, "foo", fn)

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jun 6, 2022
@obol-bulldozer obol-bulldozer bot merged commit b21f7f7 into main Jun 6, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/retryexit branch June 6, 2022 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants