Skip to content

Commit 209a22b

Browse files
committed
add weight sum < 1 invariant
1 parent 7aa53a7 commit 209a22b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

x/clp/types/params.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,18 @@ func (p Params) Validate() error { // TODO determine all checks
8181
if err := validatePmtpEndBlock(p.PmtpEndBlock); err != nil {
8282
return err
8383
}
84-
if p.PmtpEndBlock < (p.PmtpStartBlock) {
84+
if p.PmtpEndBlock < p.PmtpStartBlock {
8585
return fmt.Errorf(
8686
"end block (%d) must be after begin block (%d)",
8787
p.PmtpEndBlock, p.PmtpStartBlock,
8888
)
8989
}
90+
if p.PmtpNativeWeight.Add(p.PmtpExternalWeight).GT(sdk.NewDec(1)) {
91+
return fmt.Errorf(
92+
"sum of native weight (%d) and external weight (%d) cannot exceed 1",
93+
p.PmtpEndBlock, p.PmtpStartBlock,
94+
)
95+
}
9096
return nil
9197
}
9298

0 commit comments

Comments
 (0)