Skip to content

Commit

Permalink
add weight sum < 1 invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinoBombino committed Feb 17, 2022
1 parent 865472a commit 7fa5b86
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion x/clp/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ func (p Params) Validate() error { // TODO determine all checks
if err := validatePmtpEndBlock(p.PmtpEndBlock); err != nil {
return err
}
if p.PmtpEndBlock < (p.PmtpStartBlock) {
if p.PmtpEndBlock < p.PmtpStartBlock {
return fmt.Errorf(
"end block (%d) must be after begin block (%d)",
p.PmtpEndBlock, p.PmtpStartBlock,
)
}
if p.PmtpNativeWeight.Add(p.PmtpExternalWeight).GT(sdk.NewDec(1)) {
return fmt.Errorf(
"sum of native weight (%d) and external weight (%d) cannot exceed 1",
p.PmtpEndBlock, p.PmtpStartBlock,
)
}
return nil
}

Expand Down

0 comments on commit 7fa5b86

Please sign in to comment.