Skip to content

Commit

Permalink
remove confusing error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
countvonzero committed Aug 31, 2023
1 parent b458324 commit 55392a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
27 changes: 17 additions & 10 deletions miner/proposal_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ func (pb *ProposalBuilder) handleLayer(ctx context.Context, layerID types.LayerI
if !pb.syncer.IsSynced(ctx) {
return errNotSynced
}

// make sure the miner is eligible first
nonce, err := pb.nonceFetcher.VRFNonce(pb.signer.NodeID(), layerID.GetEpoch())
if err != nil {
if errors.Is(err, sql.ErrNotFound) {
pb.logger.WithContext(ctx).With().Info("miner has no valid vrf nonce, not building proposal", layerID)
return nil
}
return err

Check warning on line 384 in miner/proposal_builder.go

View check run for this annotation

Codecov / codecov/patch

miner/proposal_builder.go#L380-L384

Added lines #L380 - L384 were not covered by tests
}

if beacon, err = pb.beaconProvider.GetBeacon(epoch); err != nil {
return errNoBeacon
}
Expand All @@ -386,14 +397,6 @@ func (pb *ProposalBuilder) handleLayer(ctx context.Context, layerID types.LayerI
return errDuplicateLayer
}

nonce, err := pb.nonceFetcher.VRFNonce(pb.signer.NodeID(), layerID.GetEpoch())
if err != nil {
if errors.Is(err, sql.ErrNotFound) {
pb.logger.WithContext(ctx).With().Info("miner has no valid vrf nonce, not building proposal", layerID)
return nil
}
return err
}
epochEligibility, err := pb.proposalOracle.ProposalEligibility(layerID, beacon, nonce)
if err != nil {
if errors.Is(err, errMinerHasNoATXInPreviousEpoch) {
Expand Down Expand Up @@ -470,8 +473,12 @@ func (pb *ProposalBuilder) createProposalLoop(ctx context.Context) {
}
next = current.Add(1)
lyrCtx := log.WithNewSessionID(ctx)
if err := pb.handleLayer(lyrCtx, current); err != nil && !errors.Is(err, errGenesis) {
pb.logger.WithContext(lyrCtx).With().Warning("failed to build proposal", current, log.Err(err))
if err := pb.handleLayer(lyrCtx, current); err != nil {
switch {
case errors.Is(err, errGenesis), errors.Is(err, errNotSynced):
default:
pb.logger.WithContext(lyrCtx).With().Warning("failed to build proposal", current, log.Err(err))

Check warning on line 480 in miner/proposal_builder.go

View check run for this annotation

Codecov / codecov/patch

miner/proposal_builder.go#L479-L480

Added lines #L479 - L480 were not covered by tests
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions miner/proposal_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func TestBuilder_HandleLayer_NoBeacon(t *testing.T) {

layerID := types.LayerID(layersPerEpoch * 3)
b.mSync.EXPECT().IsSynced(gomock.Any()).Return(true)
b.mNonce.EXPECT().VRFNonce(gomock.Any(), gomock.Any()).Return(types.VRFPostIndex(22), nil)
b.mBeacon.EXPECT().GetBeacon(gomock.Any()).Return(types.EmptyBeacon, errors.New("unknown"))

require.ErrorIs(t, b.handleLayer(context.Background(), layerID), errNoBeacon)
Expand Down Expand Up @@ -661,6 +662,7 @@ func TestBuilder_HandleLayer_Duplicate(t *testing.T) {
ballot := types.NewExistingBallot(types.BallotID{1}, types.EmptyEdSignature, b.signer.NodeID(), layerID)
require.NoError(t, ballots.Add(b.cdb, &ballot))
b.mSync.EXPECT().IsSynced(gomock.Any()).Return(true)
b.mNonce.EXPECT().VRFNonce(gomock.Any(), gomock.Any()).Return(types.VRFPostIndex(22), nil)
b.mBeacon.EXPECT().GetBeacon(gomock.Any()).Return(beacon, nil)
require.ErrorIs(t, b.handleLayer(context.Background(), layerID), errDuplicateLayer)
}
Expand Down

0 comments on commit 55392a0

Please sign in to comment.