Skip to content

Commit

Permalink
fix: return early for empty bundles in SkipUploaderRole
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Jul 31, 2024
1 parent b963de9 commit dfd70e2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 2 additions & 4 deletions x/bundles/keeper/logic_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,9 @@ func (k Keeper) GetVoteDistribution(ctx sdk.Context, poolId uint64) (voteDistrib

// tallyBundleProposal evaluates the votes of a bundle proposal and determines the outcome
func (k Keeper) tallyBundleProposal(ctx sdk.Context, bundleProposal types.BundleProposal, poolId uint64) (types.TallyResult, error) {
// Increase points of stakers who did not vote at all + slash + remove if there is a bundle proposal.
// Increase points of stakers who did not vote at all + slash + remove if necessary.
// The protocol requires everybody to stay always active.
if bundleProposal.StorageId != "" {
k.handleNonVoters(ctx, poolId)
}
k.handleNonVoters(ctx, poolId)

// evaluate all votes and determine status based on the votes weighted with stake + delegation
voteDistribution := k.GetVoteDistribution(ctx, poolId)
Expand Down
16 changes: 16 additions & 0 deletions x/bundles/keeper/msg_server_skip_uploader_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ func (k msgServer) SkipUploaderRole(goCtx context.Context, msg *types.MsgSkipUpl
// reset points of uploader as node has proven to be active
k.resetPoints(ctx, msg.PoolId, msg.Staker)

// If previous bundle was dropped just skip uploader role
// No previous round needs to be evaluated
if bundleProposal.StorageId == "" {
nextUploader := k.chooseNextUploader(ctx, msg.PoolId)

// Register empty bundle with next uploader
bundleProposal = types.BundleProposal{
PoolId: msg.PoolId,
NextUploader: nextUploader,
UpdatedAt: uint64(ctx.BlockTime().Unix()),
}
k.SetBundleProposal(ctx, bundleProposal)

return &types.MsgSkipUploaderRoleResponse{}, nil
}

// Previous round contains a bundle which needs to be validated now
result, err := k.tallyBundleProposal(ctx, bundleProposal, msg.PoolId)
if err != nil {
Expand Down

0 comments on commit dfd70e2

Please sign in to comment.