Skip to content

Commit

Permalink
fix: eliminate non-determinism of floating point
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Sep 17, 2024
1 parent 9be2beb commit 0ac8a40
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions x/gov/types/v1/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ func (p Params) ValidateBasic() error {
if p.QuorumTimeout.Seconds() < 0 {
return fmt.Errorf("quorum timeout must be 0 or greater: %s", p.QuorumTimeout)
}
if p.QuorumTimeout.Seconds() >= p.VotingPeriod.Seconds() {
if p.QuorumTimeout.Nanoseconds() >= p.VotingPeriod.Nanoseconds() {
return fmt.Errorf("quorum timeout %s must be strictly less than the voting period %s", p.QuorumTimeout, p.VotingPeriod)
}

if p.MaxVotingPeriodExtension == nil {
return fmt.Errorf("max voting period extension must not be nil: %d", p.MaxVotingPeriodExtension)
}
if p.MaxVotingPeriodExtension.Seconds() < p.VotingPeriod.Seconds()-p.QuorumTimeout.Seconds() {
if p.MaxVotingPeriodExtension.Nanoseconds() < p.VotingPeriod.Nanoseconds()-p.QuorumTimeout.Nanoseconds() {
return fmt.Errorf("max voting period extension %s must be greater than or equal to the difference between the voting period %s and the quorum timeout %s", p.MaxVotingPeriodExtension, p.VotingPeriod, p.QuorumTimeout)
}
}
Expand Down

0 comments on commit 0ac8a40

Please sign in to comment.