Skip to content

Question: is the discarded bail.Quo(...) result in HandleAndCloseVote intentional? #2292

@Tsunami43

Description

@Tsunami43

Summary

While reading x/conflict/keeper/vote.go I noticed that in HandleAndCloseVote, the bail amount for providers that failed to vote is computed but the division result appears to be discarded.

Location

x/conflict/keeper/vote.go (the default branch of the vote-counting switch):

// punish providers that didnt vote
providersWithoutVote = append(providersWithoutVote, vote.Address)
bail := stake
bail.Quo(sdk.NewIntFromUint64(BailStakeDiv))
err = k.pairingKeeper.JailEntry(ctx, vote.Address, conflictVote.ChainID,
    conflictVote.VoteStartBlock, blocksToSave,
    sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), bail))

Observation

sdk.Int / cosmossdk.io/math.Int (v1.3.0, the version pinned in go.mod) is immutable. Quo has a value receiver and returns a freshly allocated Int (SafeQuo → div() does new(big.Int).Quo(...)); it does not mutate the receiver. So the line bail.Quo(sdk.NewIntFromUint64(BailStakeDiv)) has no effect — its return value is dropped, and bail stays equal to the full stake.

The intent (per BailStakeDiv = 5 // 20% - Can't be 0!) seems to be bailing non-voters at stake / 5. A few lines below, totalVotes.Quo(...) is used in the assigning form (halfTotalVotes := totalVotes.Quo(...)), which suggests the non-assigning call here is an oversight rather than deliberate.

Questions

Is bailing non-voters at the full stake intended, or should it be stake / BailStakeDiv as the constant name/comment imply?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions