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

node-split-poc: calculate eligibility on epoch's first layer #6561

Merged
merged 9 commits into from
Dec 20, 2024

Conversation

kacpersaw
Copy link
Contributor

@kacpersaw kacpersaw commented Dec 20, 2024

Description

This pull request introduces a new API endpoint to calculate eligibility slots for a given node in a specific epoch. With that smesher service can calculate eligibility proofs at the start of the epoch.

Also, fixed standalone mode.

New API Endpoint for Eligibility Slots:

Node Service Enhancements:

  • api/node/client/client.go: Added CalculateEligibilitySlotsFor method to the NodeService to call the new API endpoint and handle the response.

API Specification Update:

Server and Middleware Updates:

Mock and Testing Enhancements:

  • api/node/server/mocks.go: Added mock methods to support testing of the new CalculateEligibilitySlotsFor functionality.

Dependency Update:

  • go.mod: Updated the github.com/spacemeshos/api/release/go dependency to the latest version.


type eligibilitySlotsResp struct {
Slots uint32
nonce types.VRFPostIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

How about exporting it and then you can avoid using a custom x-spacemesh-atx-nonce header?

Suggested change
nonce types.VRFPostIndex
Nonce types.VRFPostIndex

Comment on lines 586 to 590
signer := &signerSession{}
if err := pb.initSignerSessionData(&signer.session, epoch.FirstLayer(), node); err != nil {
return 0, 0, err
}
return signer.session.eligibilities.slots, signer.session.nonce, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need a session only:

Suggested change
signer := &signerSession{}
if err := pb.initSignerSessionData(&signer.session, epoch.FirstLayer(), node); err != nil {
return 0, 0, err
}
return signer.session.eligibilities.slots, signer.session.nonce, nil
var session session
if err := pb.initSignerSessionData(&session, epoch.FirstLayer(), node); err != nil {
return 0, 0, err
}
return session.eligibilities.slots, session.nonce, nil

Comment on lines 183 to 188
if layer.FirstInEpoch() {
slots, nonce, err := pb.proposalSvc.CalculateEligibilitySlotsFor(ctx, nodeId, epoch)
if err != nil {
pb.logger.Error("calculate eligibility slots error", zap.Error(err))
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the node is down during the first layer? It's safer to calculate slots whenever the eligibilities[nodeId] is vacant. Perhaps you could fetch slots and calculate eligibilties here:

if e := current.GetEpoch(); e > epoch {
eligibilities = make(map[types.NodeID]map[types.LayerID][]types.VotingEligibility)
epochBeacon = make(map[types.EpochID]types.Beacon)
epoch = e
}

@kacpersaw kacpersaw merged commit 95dcd57 into node-split-poc Dec 20, 2024
14 checks passed
@kacpersaw kacpersaw deleted the node-split-poc-eligble-state branch December 20, 2024 20:23
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