Skip to content

Commit c9b98c4

Browse files
authored
fix: TimeIotaMs must be strictly positive (#1872)
Implements celestiaorg/celestia-app#4888 (comment) ## Testing - [x] State sync a node on Mocha using v4.x - [x] Create a v3.x celestia-app binary that uses this PR - [x] Downgrade to the v3.x binary on the Mocha node. Confirm it can continue running ## Follow ups - [ ] Create a v0.34.x-celestia release - [ ] Bump in v3.x on celestia-app - [ ] Create another v3.x celestia-app release - [ ] Re-test downgrading from v4.x to v3.x
1 parent 6e5c70a commit c9b98c4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

types/params.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ func ValidateConsensusParams(params cmtproto.ConsensusParams) error {
8989
params.Block.MaxGas)
9090
}
9191

92-
if params.Block.TimeIotaMs <= 0 {
93-
return fmt.Errorf("block.TimeIotaMs must be greater than 0. Got %v",
94-
params.Block.TimeIotaMs)
92+
if params.Block.TimeIotaMs < 0 {
93+
return fmt.Errorf("block.TimeIotaMs must be positive. Got %v", params.Block.TimeIotaMs)
9594
}
9695

9796
if params.Evidence.MaxAgeNumBlocks <= 0 {

types/params_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ func TestConsensusParamsValidation(t *testing.T) {
3232
6: {makeParams(1024*1024*1024, 0, 10, 2, 0, valEd25519), false},
3333
7: {makeParams(1024*1024*1024, 0, 10, -1, 0, valEd25519), false},
3434
8: {makeParams(1, 0, -10, 2, 0, valEd25519), false},
35+
9: {makeParams(1, 0, 0, 2, 0, valEd25519), true}, // 0 is a valid time iota ms
3536
// test evidence params
36-
9: {makeParams(1, 0, 10, 0, 0, valEd25519), false},
37-
10: {makeParams(1, 0, 10, 2, 2, valEd25519), false},
38-
11: {makeParams(1000, 0, 10, 2, 1, valEd25519), true},
39-
12: {makeParams(1, 0, 10, -1, 0, valEd25519), false},
37+
10: {makeParams(1, 0, 10, 0, 0, valEd25519), false},
38+
11: {makeParams(1, 0, 10, 2, 2, valEd25519), false},
39+
12: {makeParams(1000, 0, 10, 2, 1, valEd25519), true},
40+
13: {makeParams(1, 0, 10, -1, 0, valEd25519), false},
4041
// test no pubkey type provided
41-
13: {makeParams(1, 0, 10, 2, 0, []string{}), false},
42+
14: {makeParams(1, 0, 10, 2, 0, []string{}), false},
4243
// test invalid pubkey type provided
43-
14: {makeParams(1, 0, 10, 2, 0, []string{"potatoes make good pubkeys"}), false},
44+
15: {makeParams(1, 0, 10, 2, 0, []string{"potatoes make good pubkeys"}), false},
4445
}
4546
for i, tc := range testCases {
4647
if tc.valid {

0 commit comments

Comments
 (0)