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

Transfer total slots calculation to smesher service #6624

Open
Tracked by #338
poszu opened this issue Jan 16, 2025 · 1 comment
Open
Tracked by #338

Transfer total slots calculation to smesher service #6624

poszu opened this issue Jan 16, 2025 · 1 comment
Assignees

Comments

@poszu
Copy link
Contributor

poszu commented Jan 16, 2025

No description provided.

@poszu poszu self-assigned this Jan 16, 2025
@poszu
Copy link
Contributor Author

poszu commented Jan 16, 2025

Moving this calculation to the smeshing service might not give the expected benefit. Currently, slots are calculated on the node-service like this:

ballot, err := ballots.FirstInEpoch(pb.db, s.atx, s.epoch)
if err != nil && !errors.Is(err, sql.ErrNotFound) {
return fmt.Errorf("get refballot %w", err)
}
if errors.Is(err, sql.ErrNotFound) {
s.beacon = pb.shared.beacon
s.eligibilities.slots = proposals.MustGetNumEligibleSlots(
s.atxWeight,
minweight.Select(lid.GetEpoch(), pb.cfg.minActiveSetWeight),
pb.shared.active.weight,
pb.cfg.layerSize,
pb.cfg.layersPerEpoch,
)
} else {
if ballot.EpochData == nil {
return fmt.Errorf("atx %d created invalid first ballot", s.atx)
}
s.ref = ballot.ID()
s.beacon = ballot.EpochData.Beacon
s.eligibilities.slots = ballot.EpochData.EligibilityCount
}

AFAIR, the calculation might return a different result depending on which node is asked or when it is asked (what view on atxSetWeight it has) . Because the smesher must be consistent about its slots throughout the epoch, it mustn't change its mind after publihing the first ballot.

Thus, to remove the API to calculate the slots I would need to add another one to obtain the first ballot. At this point, the entire effort loses the point because it's trading 1 API call for another...

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

No branches or pull requests

1 participant