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: address all to-do's #19

Merged
merged 3 commits into from
Oct 18, 2023
Merged

app: address all to-do's #19

merged 3 commits into from
Oct 18, 2023

Conversation

gsora
Copy link
Collaborator

@gsora gsora commented Oct 16, 2023

  • we now dedup existing exits to avoid working them twice
  • reference obol api implementation doesn't return 400 if there are already threshold partial exits

category: refactor
ticket: none

- we now dedup existing exits to avoid working them twice
- reference obol api implementation doesn't return 400 if there are already threshold partial exits
@gsora gsora requested review from dB2510 and xenowits October 16, 2023 15:29
app/app.go Outdated Show resolved Hide resolved
return nil, errors.Wrap(err, "ejector exits glob")
}

ret := map[eth2p0.ValidatorIndex]struct{}{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can use make to initialize the map instead

Suggested change
ret := map[eth2p0.ValidatorIndex]struct{}{}
ret := make(map[eth2p0.ValidatorIndex]struct{})

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only difference I see between the two is that make allocs directly on the heap, while doing it as a literal implies that ret will eventually move to the heap.

While I see the optimization in the sense of "less stuff that the runtime must do", I don't think it's a big deal considering the execution pattern of this function (called once at startup).

WDYT?

app/app.go Outdated Show resolved Hide resolved
if len(ts.partialExits[exit.PublicKey])+1 > len(lock.Operators) { // we're already at threshold
writeErr(writer, http.StatusBadRequest, "already at threshold for selected validator")
return
if len(ts.partialExits[exit.PublicKey])+1 > len(lock.Operators) { // we're already at threshold, ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this condition imply? in specific, what does len(ts.partialExits[exit.PublicKey]) return?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ts.partialExits maps a validator's public key to the list of its partial exits, so len(ts.partialExits[exit.PublicKey]) returns the amount of partial exits already stored.

This if is equivalent to the question "if we added another partial exit for validator exit.PublicKey, would its size be greater than the operators amount?".

Consider that we must store at must len(lock.Operators) partial exits for each operator.

gsora and others added 2 commits October 17, 2023 09:56
Co-authored-by: Abhishek Kumar <43061995+xenowits@users.noreply.github.com>
@gsora gsora merged commit c2fe38d into main Oct 18, 2023
6 checks passed
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