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

core/tracker: add analyser and deleter #996

Merged
merged 4 commits into from
Aug 19, 2022
Merged

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Aug 18, 2022

Adds 2 deadliners in tracker: analyser and deleter. When analyser deadline hits, tracker analyser failures and participation. When deleter deadline hits track trims internal state of duties.

category: bug
ticket: #993

@dB2510 dB2510 linked an issue Aug 18, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 18, 2022

Codecov Report

Merging #996 (8da46b8) into main (e9241bf) will increase coverage by 0.05%.
The diff coverage is 61.90%.

@@            Coverage Diff             @@
##             main     #996      +/-   ##
==========================================
+ Coverage   53.84%   53.90%   +0.05%     
==========================================
  Files         117      117              
  Lines       13022    13117      +95     
==========================================
+ Hits         7012     7071      +59     
- Misses       4988     5020      +32     
- Partials     1022     1026       +4     
Impacted Files Coverage Δ
core/deadline.go 66.66% <36.84%> (-4.25%) ⬇️
app/retry/retry.go 79.20% <60.00%> (-1.61%) ⬇️
core/tracker/tracker.go 71.49% <75.00%> (+0.80%) ⬆️
app/app.go 58.26% <100.00%> (+1.01%) ⬆️
p2p/peer.go 25.49% <0.00%> (-22.66%) ⬇️
p2p/bootnode.go 18.69% <0.00%> (-16.91%) ⬇️
cmd/bootnode.go 32.16% <0.00%> (-2.14%) ⬇️
p2p/gater.go 72.97% <0.00%> (-1.23%) ⬇️
p2p/relay.go 0.00% <0.00%> (ø)
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

// ctxTimeoutFunc returns a context that is cancelled when duties for a slot have elapsed.
ctxTimeoutFunc := func(ctx context.Context, t T) (context.Context, context.CancelFunc) {
return context.WithDeadline(ctx, timeoutFunc(t))
// Ignoring boolean value as it is of no use here.
timeout, _ := timeoutFunc(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

the point of returning false is to indicate the it never times out, so then you should never cancel the context...

timeout, ok := timeoutFunc(t)
if !ok {
  return ctx, func()
}
return context.WithDeadline(ctx, timeout)

core/deadline.go Outdated
Comment on lines 124 to 125
// Ignoring boolean value
deadline, canExpire := deadlineFunc(input.duty)
Copy link
Contributor

Choose a reason for hiding this comment

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

mmmm, the point of the boolean value is to not ignore it. You cannot use deadline response if ok is false.

deadline, ok := deadlineFunc(input.duty)
if !ok { 
  // Drop duties that never expire
  input.success <- false
  return 
}

core/deadline.go Outdated
var currDuty Duty
currDeadline := time.Date(9999, 1, 1, 0, 0, 0, 0, time.UTC)

for duty := range duties {
dutyDeadline := deadlineFunc(duty)
dutyDeadline, _ := deadlineFunc(duty)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, you cannot use dutyDeadline of ok==false

core/deadline.go Outdated
@@ -192,7 +193,7 @@ func getCurrDuty(duties map[Duty]bool, deadlineFunc func(duty Duty) time.Time) (
}

// NewDutyDeadlineFunc returns the function that provides duty deadlines.
Copy link
Contributor

Choose a reason for hiding this comment

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

// NewDutyDeadlineFunc returns the function that provides duty deadlines or false if the duty never deadlines.

core/deadline.go Outdated
if duty.Type == DutyExit || duty.Type == DutyBuilderRegistration {
// Do not timeout exit or registration duties.
return time.Date(9999, 1, 1, 0, 0, 0, 0, time.UTC)
return time.Date(9999, 1, 1, 0, 0, 0, 0, time.UTC), false
Copy link
Contributor

Choose a reason for hiding this comment

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

return time.Time{}, false

events map[core.Duty][]event
// analyser returns duty from analyser.C() when it is deadlined to analyse for failures and participation.
analyser core.Deadliner
// deleter returns duty from deleter.C() after 2 * deadline time to delete from memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Tracker does not know this.

	// analyser triggers duty analysis
	analyser core.Deadliner
	// deleter triggers duty deletion after all associated analysis are done.
	deleter core.Deadliner

@@ -86,12 +89,13 @@ type Tracker struct {
}

// New returns a new Tracker.
Copy link
Contributor

@corverroos corverroos Aug 19, 2022

Choose a reason for hiding this comment

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

// New returns a new Tracker. The deleter deadliner must return well after analyser deadliner since duties of the same slot are often analysed together.

@@ -110,13 +114,13 @@ func (t *Tracker) Run(ctx context.Context) error {
case <-ctx.Done():
return ctx.Err()
case e := <-t.input:
if !t.deadliner.Add(e.duty) {
if !t.analyser.Add(e.duty) && !t.deleter.Add(e.duty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if !t.deleter.Add(e.duty) || !t.analyser.Add(e.duty) {
  continue // Ignore expired or never expiring duties
}

Copy link
Contributor

@corverroos corverroos left a comment

Choose a reason for hiding this comment

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

🚀

@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Aug 19, 2022
@obol-bulldozer obol-bulldozer bot merged commit f435c66 into main Aug 19, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/trackerbug branch August 19, 2022 09:09
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.

Trackers always detects randao events as unexpected
2 participants