Skip to content

Commit ae050cc

Browse files
fasmatpigmej
authored andcommitted
Handle 0 eligibility slots correctly
1 parent a6f42d6 commit ae050cc

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

api/node/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (s *NodeService) Proposal(ctx context.Context, layer types.LayerID, node ty
246246
case http.StatusOK:
247247
case http.StatusNoContent:
248248
// special case - no error but also no proposal, means
249-
// we're no eligible this epoch with this node ID
249+
// we're not eligible this epoch with this node ID
250250
return nil, 0, nil
251251
default:
252252
return nil, 0, fmt.Errorf("unexpected status: %q", resp.Status())

miner/remote_proposals.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,19 @@ func (pb *RemoteProposalBuilder) build(
188188
if !ok {
189189
slots, nonce, err := pb.proposalSvc.CalculateEligibilitySlotsFor(ctx, nodeId, epoch)
190190
if err != nil {
191-
pb.logger.Error("calculate eligibility slots error", zap.Error(err))
191+
pb.logger.Error("calculate eligibility slots error",
192+
log.ZContext(ctx),
193+
zap.Stringer("node", nodeId),
194+
zap.Error(err),
195+
)
196+
continue
197+
}
198+
if slots == 0 {
199+
pb.logger.Info("node not eligible in this epoch, will try later",
200+
log.ZContext(ctx),
201+
zap.Stringer("node", nodeId),
202+
zap.Uint32("epoch", epoch.Uint32()),
203+
)
192204
continue
193205
}
194206
proofs = calcEligibilityProofs(
@@ -210,7 +222,11 @@ func (pb *RemoteProposalBuilder) build(
210222

211223
proposal, _, err := pb.proposalSvc.Proposal(ctx, layer, nodeId)
212224
if err != nil {
213-
pb.logger.Error("get partial proposal", zap.Error(err))
225+
pb.logger.Error("get partial proposal",
226+
log.ZContext(ctx),
227+
zap.Stringer("node", nodeId),
228+
zap.Error(err),
229+
)
214230
pb.identityStates.Set(nodeId, &smesherIdentity.ProposalBuildFailed{
215231
ErrorMsg: fmt.Sprintf("get partial proposal: %v", err),
216232
Layer: layer,
@@ -219,18 +235,28 @@ func (pb *RemoteProposalBuilder) build(
219235
}
220236
if proposal == nil {
221237
// this node signer isn't eligible this epoch, continue
222-
pb.logger.Info("node not eligible on this layer. will try later")
238+
pb.logger.Info("node not eligible on this layer: no proposal received, will try later",
239+
log.ZContext(ctx),
240+
zap.Stringer("node", nodeId),
241+
zap.Uint32("lid", layer.Uint32()),
242+
)
223243
continue
224244
}
225245

226-
eligibilities, ok := proofs[layer]
246+
// TODO(mafa): I don't think this belongs here, either do this check before requesting a proposal
247+
// (client decides about eligibilities) or don't do it at all (server decides eligibilities)
248+
eligProofs, ok := proofs[layer]
227249
if !ok {
228250
// not eligible in this layer, continue
229-
pb.logger.Info("node not eligible in this layer, will try later")
251+
pb.logger.Info("node not eligible in this layer, will try later",
252+
log.ZContext(ctx),
253+
zap.Stringer("node", nodeId),
254+
zap.Uint32("lid", layer.Uint32()),
255+
)
230256
continue
231257
}
232258

233-
proposal.EligibilityProofs = eligibilities
259+
proposal.EligibilityProofs = eligProofs
234260
proposal.Ballot.Signature = signer.signer.Sign(signing.BALLOT, proposal.Ballot.SignedBytes())
235261
proposal.Signature = signer.signer.Sign(signing.PROPOSAL, proposal.SignedBytes())
236262
err = proposal.Initialize()

0 commit comments

Comments
 (0)