Skip to content

Commit

Permalink
chore: review feedback improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jun 27, 2024
1 parent 7bdb1a8 commit 4ad41b5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions testutil/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func AssertDefaultParamsEqualExceptFields[P any](

for fieldIdx := 0; fieldIdx < expectedParamsValue.NumField(); fieldIdx++ {
fieldName := expectedParamsValue.Type().Field(fieldIdx).Name
// Skip all fields in the exceptFields list.
if isFieldException(fieldName, exceptFields) {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions tools/scripts/params/shared_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"params": {
"num_blocks_per_session": "4",
"grace_period_end_offset_blocks": "2",
"claim_window_open_offset_blocks": "0",
"grace_period_end_offset_blocks": "1",
"claim_window_open_offset_blocks": "1",
"claim_window_close_offset_blocks": "4",
"proof_window_open_offset_blocks": "0",
"proof_window_close_offset_blocks": "4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": "/poktroll.shared.MsgUpdateParam",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"name": "claim_window_open_offset_blocks",
"as_int64": "0"
"as_int64": "1"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": "/poktroll.shared.MsgUpdateParam",
"authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t",
"name": "grace_period_end_offset_blocks",
"as_int64": "2"
"as_int64": "1"
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions x/shared/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func (params *Params) ValidateBasic() error {
return err
}

if err := validateClaimWindowOpenOffsetIsAtLeastGracePeriodEndOffset(params); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -173,3 +177,15 @@ func validateIsUint64(value any) error {

return nil
}

func validateClaimWindowOpenOffsetIsAtLeastGracePeriodEndOffset(params *Params) error {
if params.ClaimWindowOpenOffsetBlocks < params.GracePeriodEndOffsetBlocks {
return ErrSharedParamInvalid.Wrapf(
"ClaimWindowOpenOffsetBlocks (%v) must be at least GracePeriodEndOffsetBlocks (%v)",
params.ClaimWindowOpenOffsetBlocks,
params.GracePeriodEndOffsetBlocks,
)
}

return nil
}
2 changes: 1 addition & 1 deletion x/shared/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestParams_ValidateGracePeriodEndOffsetBlocks(t *testing.T) {

for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
err := ValidateProofWindowCloseOffsetBlocks(tt.gracePeriodEndOffsetBlocks)
err := ValidateGracePeriodEndOffsetBlocks(tt.gracePeriodEndOffsetBlocks)
if tt.err != nil {
require.Error(t, err)
require.Contains(t, err.Error(), tt.err.Error())
Expand Down

0 comments on commit 4ad41b5

Please sign in to comment.