Skip to content

course_milestone: set_min_lrn_to_propose accepts lrn == 0 but min_lrn should be positive #558

@Anuoluwapo25

Description

@Anuoluwapo25

Bug

set_min_lrn_to_propose rejects lrn < 0 but allows lrn == 0, which is effectively the same as having no minimum and silently disables the gate.

File: contracts/course_milestone/src/lib.rs

if lrn < 0 {
    panic_with_error!(&env, Error::InvalidReward);
}

The guard should be lrn <= 0 so that callers are forced to set a meaningful minimum, or there should be a dedicated set_min_lrn_to_propose(0) path that explicitly clears the requirement.

Impact

Any admin can inadvertently zero-out the proposal minimum and allow any holder with 0 LRN to submit proposals, bypassing governance reputation gating.

Fix

Change lrn < 0lrn < 0 is fine only if 0 is intentionally a valid "no minimum" sentinel; document that explicitly. Otherwise change to lrn <= 0 and return InvalidReward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions