From 4ad41b508b5a36ad45dcf76d8ebe17b6e7a3ad8f Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 27 Jun 2024 15:51:20 +0200 Subject: [PATCH] chore: review feedback improvements --- testutil/keeper/params.go | 1 + tools/scripts/params/shared_all.json | 4 ++-- .../shared_claim_window_open_offset_blocks.json | 2 +- .../shared_grace_period_end_offset_blocks.json | 2 +- x/shared/types/params.go | 16 ++++++++++++++++ x/shared/types/params_test.go | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/testutil/keeper/params.go b/testutil/keeper/params.go index c66c91de0..0dc5ee158 100644 --- a/testutil/keeper/params.go +++ b/testutil/keeper/params.go @@ -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 } diff --git a/tools/scripts/params/shared_all.json b/tools/scripts/params/shared_all.json index 928b3ca54..fa5e04f78 100644 --- a/tools/scripts/params/shared_all.json +++ b/tools/scripts/params/shared_all.json @@ -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" diff --git a/tools/scripts/params/shared_claim_window_open_offset_blocks.json b/tools/scripts/params/shared_claim_window_open_offset_blocks.json index 7852a222d..37ec086cd 100644 --- a/tools/scripts/params/shared_claim_window_open_offset_blocks.json +++ b/tools/scripts/params/shared_claim_window_open_offset_blocks.json @@ -5,7 +5,7 @@ "@type": "/poktroll.shared.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "claim_window_open_offset_blocks", - "as_int64": "0" + "as_int64": "1" } ] } diff --git a/tools/scripts/params/shared_grace_period_end_offset_blocks.json b/tools/scripts/params/shared_grace_period_end_offset_blocks.json index c16e39001..d9d872718 100644 --- a/tools/scripts/params/shared_grace_period_end_offset_blocks.json +++ b/tools/scripts/params/shared_grace_period_end_offset_blocks.json @@ -5,7 +5,7 @@ "@type": "/poktroll.shared.MsgUpdateParam", "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", "name": "grace_period_end_offset_blocks", - "as_int64": "2" + "as_int64": "1" } ] } diff --git a/x/shared/types/params.go b/x/shared/types/params.go index 37ce3c9f2..39415ea41 100644 --- a/x/shared/types/params.go +++ b/x/shared/types/params.go @@ -116,6 +116,10 @@ func (params *Params) ValidateBasic() error { return err } + if err := validateClaimWindowOpenOffsetIsAtLeastGracePeriodEndOffset(params); err != nil { + return err + } + return nil } @@ -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 +} diff --git a/x/shared/types/params_test.go b/x/shared/types/params_test.go index e3edb133c..5c39f5c90 100644 --- a/x/shared/types/params_test.go +++ b/x/shared/types/params_test.go @@ -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())