-
Notifications
You must be signed in to change notification settings - Fork 215
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
Conversation
…rom node through node-service api.
api/node/server/server.go
Outdated
|
||
type eligibilitySlotsResp struct { | ||
Slots uint32 | ||
nonce types.VRFPostIndex |
There was a problem hiding this comment.
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?
nonce types.VRFPostIndex | |
Nonce types.VRFPostIndex |
miner/proposal_builder.go
Outdated
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 |
There was a problem hiding this comment.
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:
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 |
miner/remote_proposals.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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:
go-spacemesh/miner/remote_proposals.go
Lines 139 to 143 in 913a87a
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 | |
} |
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:
api/node/client/client.gen.go
: AddedGetEligibilitySlotsNodeEpoch
method to theClientInterface
andClientWithResponsesInterface
, and implemented the request and response handling for this new endpoint. [1] [2] [3] [4] [5] [6] [7]Node Service Enhancements:
api/node/client/client.go
: AddedCalculateEligibilitySlotsFor
method to theNodeService
to call the new API endpoint and handle the response.API Specification Update:
api/node/node_service.yaml
: Defined the new/eligibility/slots/{node}/{epoch}
endpoint in the API specification.Server and Middleware Updates:
api/node/server/server.gen.go
: Updated server interface and middleware to include the new endpoint, and added corresponding request and response objects. [1] [2] [3] [4] [5] [6]api/node/server/server.go
: Implemented the server-side logic for the new endpoint. [1] [2] [3]Mock and Testing Enhancements:
api/node/server/mocks.go
: Added mock methods to support testing of the newCalculateEligibilitySlotsFor
functionality.Dependency Update:
go.mod
: Updated thegithub.com/spacemeshos/api/release/go
dependency to the latest version.