From 29982de549bea8777e251d1f67cf7e93fee71b99 Mon Sep 17 00:00:00 2001 From: Matee ullah Malik Date: Tue, 28 Apr 2026 08:58:52 +0000 Subject: [PATCH] chore(lint): clear scoped golangci-lint + buf BRIDGE-surface findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete dead state-machine helpers in x/supernode/v1/keeper: * metrics_state.go: markStorageFull, recoverFromStorageFull (audit module does these inline in x/audit/v1/keeper/state.go and enforcement.go; helpers were never wired up). * metrics_validation.go: lastNonDegradedState (zero call sites). - Delete unused x/action/v1 simulation scaffolding: * helpers.go: generateRandomOtiValues (unused stub). * module/simulation.go: 6 op_weight_msg_* / defaultWeightMsg* consts (no scaffolded simulation hooks reference them). - Fix ineffassign in x/supernode/v1/simulation/update_supernode.go: drop dead 'updateAccount = false' branch (supernodeAccount is already empty in that path, so the flag was redundant). - errcheck cleanup in scoped tests: wrap k.SetAction / k.SetParams / k.SetSuperNode in require.NoError(t, ...). Behavior preserved; tests now fail loudly on store errors instead of silently swallowing them. - staticcheck SA1019 cleanup: * Replace deprecated sdk.WrapSDKContext(ctx) with ctx (5 sites in msg_server_report_supernode_metrics_test.go). * Replace deprecated rand.Seed in crypto_test.go with rand.New(rand.NewSource(...)). * Annotate module.HasInvariants / sdk.InvariantRegistry usage with //nolint:staticcheck — SDK v0.50 still requires HasInvariants and only drops it when x/crisis is removed. - buf lint: add doc comments on BRIDGE-surface enums/messages (HashAlgo, RewardDistribution, SuperNodeState, SuperNodeStateRecord). No wire-affecting renames. Verification: - golangci-lint run ./x/action/v1/... ./x/supernode/v1/... -> 0 issues - go test ./x/action/v1/... ./x/supernode/v1/... -count=1 -> PASS - go test ./tests/integration/everlight ./tests/e2e/everlight ./app/upgrades/v1_12_0 ./tests/integration/action/... -> PASS - make build (lumerad) -> OK No state-machine, no schema, no on-chain behavior changes. Note: the dead helpers in metrics_state.go/metrics_validation.go are deleted rather than re-wired because audit-module enforcement already performs STORAGE_FULL/POSTPONED transitions inline. Routing both modules through one set of helpers is a separate, larger SSoT refactor not in scope for this lint cleanup. --- proto/lumera/action/v1/metadata.proto | 3 + proto/lumera/supernode/v1/params.proto | 3 + .../lumera/supernode/v1/supernode_state.proto | 58 ++++++++++++------- x/action/v1/keeper/crypto_test.go | 4 +- .../keeper/query_action_by_metadata_test.go | 22 +++---- .../v1/keeper/query_get_action_fee_test.go | 4 +- x/action/v1/keeper/query_get_action_test.go | 2 +- ...query_list_actions_by_block_height_test.go | 10 ++-- .../keeper/query_list_actions_by_sn_test.go | 14 ++--- x/action/v1/keeper/query_list_actions_test.go | 24 ++++---- .../keeper/query_list_expired_actions_test.go | 20 +++---- x/action/v1/module/module.go | 4 +- x/action/v1/module/simulation.go | 13 +---- x/action/v1/simulation/helpers.go | 5 -- x/supernode/v1/keeper/metrics_state.go | 42 -------------- x/supernode/v1/keeper/metrics_validation.go | 14 ----- .../msg_server_deregister_supernode_test.go | 4 +- ...sg_server_report_supernode_metrics_test.go | 10 ++-- x/supernode/v1/module/module.go | 4 +- x/supernode/v1/simulation/update_supernode.go | 5 +- 20 files changed, 105 insertions(+), 160 deletions(-) diff --git a/proto/lumera/action/v1/metadata.proto b/proto/lumera/action/v1/metadata.proto index 6b2c8e28..b3484f9a 100644 --- a/proto/lumera/action/v1/metadata.proto +++ b/proto/lumera/action/v1/metadata.proto @@ -8,8 +8,11 @@ import "gogoproto/gogo.proto"; // HashAlgo enumerates the supported hash algorithms for availability // commitments. enum HashAlgo { + // HASH_ALGO_UNSPECIFIED is the zero value; rejected by validation. HASH_ALGO_UNSPECIFIED = 0; + // HASH_ALGO_BLAKE3 selects BLAKE3 as the chunk/leaf hash function. HASH_ALGO_BLAKE3 = 1; + // HASH_ALGO_SHA256 selects SHA-256 as the chunk/leaf hash function. HASH_ALGO_SHA256 = 2; } diff --git a/proto/lumera/supernode/v1/params.proto b/proto/lumera/supernode/v1/params.proto index a952a9bf..9aadec8f 100644 --- a/proto/lumera/supernode/v1/params.proto +++ b/proto/lumera/supernode/v1/params.proto @@ -7,6 +7,9 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +// RewardDistribution governs the Everlight reward pool's payout cadence, +// eligibility floor, ramp-up, smoothing window and growth cap. All fields +// are governance-mutable via supernode MsgUpdateParams. message RewardDistribution { option (gogoproto.equal) = true; diff --git a/proto/lumera/supernode/v1/supernode_state.proto b/proto/lumera/supernode/v1/supernode_state.proto index 5029b936..0b875c79 100644 --- a/proto/lumera/supernode/v1/supernode_state.proto +++ b/proto/lumera/supernode/v1/supernode_state.proto @@ -1,26 +1,40 @@ -syntax = "proto3"; -package lumera.supernode.v1; - -option go_package = "x/supernode/v1/types"; - -import "gogoproto/gogo.proto"; - -enum SuperNodeState { - option (gogoproto.goproto_enum_prefix) = false; - option (gogoproto.goproto_enum_stringer) = true; - - SUPERNODE_STATE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "SuperNodeStateUnspecified"]; - SUPERNODE_STATE_ACTIVE = 1 [(gogoproto.enumvalue_customname) = "SuperNodeStateActive"]; - SUPERNODE_STATE_DISABLED = 2 [(gogoproto.enumvalue_customname) = "SuperNodeStateDisabled"]; - SUPERNODE_STATE_STOPPED = 3 [(gogoproto.enumvalue_customname) = "SuperNodeStateStopped"]; - SUPERNODE_STATE_PENALIZED = 4 [(gogoproto.enumvalue_customname) = "SuperNodeStatePenalized"]; - SUPERNODE_STATE_POSTPONED = 5 [(gogoproto.enumvalue_customname) = "SuperNodeStatePostponed"]; - SUPERNODE_STATE_STORAGE_FULL = 6 [(gogoproto.enumvalue_customname) = "SuperNodeStateStorageFull"]; -} - -message SuperNodeStateRecord { +syntax = "proto3"; +package lumera.supernode.v1; + +option go_package = "x/supernode/v1/types"; + +import "gogoproto/gogo.proto"; + +// SuperNodeState is the lifecycle state of a SuperNode. Transitions are +// governed by the supernode and audit modules; see x/supernode/v1/keeper +// and x/audit/v1/keeper for the authoritative state machine. +enum SuperNodeState { + option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.goproto_enum_stringer) = true; + + // SUPERNODE_STATE_UNSPECIFIED is the proto3 zero value; never persisted. + SUPERNODE_STATE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "SuperNodeStateUnspecified"]; + // SUPERNODE_STATE_ACTIVE: SuperNode is healthy and eligible for all duties. + SUPERNODE_STATE_ACTIVE = 1 [(gogoproto.enumvalue_customname) = "SuperNodeStateActive"]; + // SUPERNODE_STATE_DISABLED: operator-disabled (deregistered) SuperNode. + SUPERNODE_STATE_DISABLED = 2 [(gogoproto.enumvalue_customname) = "SuperNodeStateDisabled"]; + // SUPERNODE_STATE_STOPPED: operator-stopped SuperNode (recoverable). + SUPERNODE_STATE_STOPPED = 3 [(gogoproto.enumvalue_customname) = "SuperNodeStateStopped"]; + // SUPERNODE_STATE_PENALIZED: penalized by chain enforcement (e.g. slashing). + SUPERNODE_STATE_PENALIZED = 4 [(gogoproto.enumvalue_customname) = "SuperNodeStatePenalized"]; + // SUPERNODE_STATE_POSTPONED: temporarily ineligible due to missing/overdue + // metrics or compliance violations; recovers on the next healthy report. + SUPERNODE_STATE_POSTPONED = 5 [(gogoproto.enumvalue_customname) = "SuperNodeStatePostponed"]; + // SUPERNODE_STATE_STORAGE_FULL: storage usage above max threshold; + // excluded from Cascade duties but still eligible for Sense/Agents. + SUPERNODE_STATE_STORAGE_FULL = 6 [(gogoproto.enumvalue_customname) = "SuperNodeStateStorageFull"]; +} + +// SuperNodeStateRecord is one entry in the append-only state history of a +// SuperNode. The latest entry is the current state. +message SuperNodeStateRecord { SuperNodeState state = 1 [(gogoproto.moretags) = "yaml:\"state\""]; - int64 height = 2; + int64 height = 2; // reason is an optional string describing why the state transition occurred. // It is currently set only for transitions into POSTPONED. string reason = 3 [(gogoproto.moretags) = "yaml:\"reason\""]; diff --git a/x/action/v1/keeper/crypto_test.go b/x/action/v1/keeper/crypto_test.go index bb29ebdb..20a09e36 100644 --- a/x/action/v1/keeper/crypto_test.go +++ b/x/action/v1/keeper/crypto_test.go @@ -267,8 +267,8 @@ func TestGenerateSupernodeRQIDs(t *testing.T) { rqMax uint32 } - rand.Seed(time.Now().UnixNano()) - ic := uint32(rand.Intn(100000)) + rng := rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec // test-only randomness + ic := uint32(rng.Intn(100000)) tests := []testCase{ { diff --git a/x/action/v1/keeper/query_action_by_metadata_test.go b/x/action/v1/keeper/query_action_by_metadata_test.go index a9a99c36..a0fbf961 100644 --- a/x/action/v1/keeper/query_action_by_metadata_test.go +++ b/x/action/v1/keeper/query_action_by_metadata_test.go @@ -132,10 +132,10 @@ func TestQueryActionByMetadata(t *testing.T) { MetadataQuery: "collection_id=collection1", }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) - k.SetAction(ctx, &action4) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) + require.NoError(t, k.SetAction(ctx, &action4)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryActionByMetadataResponse) { @@ -152,9 +152,9 @@ func TestQueryActionByMetadata(t *testing.T) { MetadataQuery: "collection_id=collection3", }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryActionByMetadataResponse) { @@ -173,10 +173,10 @@ func TestQueryActionByMetadata(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) - k.SetAction(ctx, &action4) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) + require.NoError(t, k.SetAction(ctx, &action4)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryActionByMetadataResponse) { diff --git a/x/action/v1/keeper/query_get_action_fee_test.go b/x/action/v1/keeper/query_get_action_fee_test.go index 1e0598f3..830e864f 100644 --- a/x/action/v1/keeper/query_get_action_fee_test.go +++ b/x/action/v1/keeper/query_get_action_fee_test.go @@ -40,7 +40,7 @@ func TestKeeper_GetActionFee(t *testing.T) { params := types.DefaultParams() params.BaseActionFee = sdk.NewCoin("ulume", math.NewInt(10000)) params.FeePerKbyte = sdk.NewCoin("ulume", math.NewInt(100)) - k.SetParams(ctx, params) + require.NoError(t, k.SetParams(ctx, params)) }, expectedFee: "10000", }, @@ -51,7 +51,7 @@ func TestKeeper_GetActionFee(t *testing.T) { params := types.DefaultParams() params.BaseActionFee = sdk.NewCoin("ulume", math.NewInt(10000)) params.FeePerKbyte = sdk.NewCoin("ulume", math.NewInt(100)) - k.SetParams(ctx, params) + require.NoError(t, k.SetParams(ctx, params)) }, expectedFee: "30000", // 100 * 200 + 10000 }, diff --git a/x/action/v1/keeper/query_get_action_test.go b/x/action/v1/keeper/query_get_action_test.go index cf97991a..4d2c9e80 100644 --- a/x/action/v1/keeper/query_get_action_test.go +++ b/x/action/v1/keeper/query_get_action_test.go @@ -60,7 +60,7 @@ func TestKeeper_GetAction(t *testing.T) { }, setupState: func(k keeper.Keeper, ctx sdk.Context) { action.Price = price.String() - k.SetAction(ctx, &action) + require.NoError(t, k.SetAction(ctx, &action)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryGetActionResponse) { diff --git a/x/action/v1/keeper/query_list_actions_by_block_height_test.go b/x/action/v1/keeper/query_list_actions_by_block_height_test.go index 2e67bdb7..d1b227ed 100644 --- a/x/action/v1/keeper/query_list_actions_by_block_height_test.go +++ b/x/action/v1/keeper/query_list_actions_by_block_height_test.go @@ -93,8 +93,8 @@ func TestKeeper_ListActionsByBlockHeight(t *testing.T) { BlockHeight: blockHeight, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsByBlockHeightResponse) { @@ -110,9 +110,9 @@ func TestKeeper_ListActionsByBlockHeight(t *testing.T) { BlockHeight: blockHeight, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsByBlockHeightResponse) { diff --git a/x/action/v1/keeper/query_list_actions_by_sn_test.go b/x/action/v1/keeper/query_list_actions_by_sn_test.go index 54ab7aa5..4e207adf 100644 --- a/x/action/v1/keeper/query_list_actions_by_sn_test.go +++ b/x/action/v1/keeper/query_list_actions_by_sn_test.go @@ -91,8 +91,8 @@ func TestKeeper_ListActionsBySuperNode(t *testing.T) { SuperNodeAddress: superNodeAddr, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsBySuperNodeResponse) { @@ -108,9 +108,9 @@ func TestKeeper_ListActionsBySuperNode(t *testing.T) { SuperNodeAddress: superNodeAddr, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsBySuperNodeResponse) { @@ -129,8 +129,8 @@ func TestKeeper_ListActionsBySuperNode(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsBySuperNodeResponse) { diff --git a/x/action/v1/keeper/query_list_actions_test.go b/x/action/v1/keeper/query_list_actions_test.go index f0400432..fba40d41 100644 --- a/x/action/v1/keeper/query_list_actions_test.go +++ b/x/action/v1/keeper/query_list_actions_test.go @@ -74,9 +74,9 @@ func TestKeeper_ListActions(t *testing.T) { ActionState: types.ActionStateProcessing, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsResponse) { @@ -91,9 +91,9 @@ func TestKeeper_ListActions(t *testing.T) { ActionType: types.ActionTypeCascade, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsResponse) { @@ -111,9 +111,9 @@ func TestKeeper_ListActions(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsResponse) { @@ -131,9 +131,9 @@ func TestKeeper_ListActions(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListActionsResponse) { diff --git a/x/action/v1/keeper/query_list_expired_actions_test.go b/x/action/v1/keeper/query_list_expired_actions_test.go index 02a773c4..1fc60340 100644 --- a/x/action/v1/keeper/query_list_expired_actions_test.go +++ b/x/action/v1/keeper/query_list_expired_actions_test.go @@ -71,9 +71,9 @@ func TestKeeper_ListExpiredActions(t *testing.T) { name: "actions found with EXPIRED state", req: &types.QueryListExpiredActionsRequest{}, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListExpiredActionsResponse) { @@ -87,7 +87,7 @@ func TestKeeper_ListExpiredActions(t *testing.T) { name: "no expired actions", req: &types.QueryListExpiredActionsRequest{}, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action2) + require.NoError(t, k.SetAction(ctx, &action2)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListExpiredActionsResponse) { @@ -104,9 +104,9 @@ func TestKeeper_ListExpiredActions(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListExpiredActionsResponse) { @@ -124,9 +124,9 @@ func TestKeeper_ListExpiredActions(t *testing.T) { }, }, setupState: func(k keeper.Keeper, ctx sdk.Context) { - k.SetAction(ctx, &action1) - k.SetAction(ctx, &action2) - k.SetAction(ctx, &action3) + require.NoError(t, k.SetAction(ctx, &action1)) + require.NoError(t, k.SetAction(ctx, &action2)) + require.NoError(t, k.SetAction(ctx, &action3)) }, expectedErr: nil, checkResult: func(t *testing.T, resp *types.QueryListExpiredActionsResponse) { diff --git a/x/action/v1/module/module.go b/x/action/v1/module/module.go index 28213178..cffdf5ac 100644 --- a/x/action/v1/module/module.go +++ b/x/action/v1/module/module.go @@ -25,7 +25,7 @@ var ( _ module.AppModuleBasic = (*AppModule)(nil) _ module.AppModuleSimulation = (*AppModule)(nil) _ module.HasGenesis = (*AppModule)(nil) - _ module.HasInvariants = (*AppModule)(nil) + _ module.HasInvariants = (*AppModule)(nil) //nolint:staticcheck // SDK v0.50 still requires HasInvariants; removed only when x/crisis is dropped. _ module.HasConsensusVersion = (*AppModule)(nil) _ appmodule.AppModule = (*AppModule)(nil) @@ -129,7 +129,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} //nolint:staticcheck // see HasInvariants note above // InitGenesis performs the module's genesis initialization. It returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) { diff --git a/x/action/v1/module/simulation.go b/x/action/v1/module/simulation.go index 946aea5b..e2620f7d 100644 --- a/x/action/v1/module/simulation.go +++ b/x/action/v1/module/simulation.go @@ -23,19 +23,8 @@ var ( ) const ( - opWeightMsgRequestAction = "op_weight_msg_request_action" - // TODO: Determine the simulation weight value - defaultWeightMsgRequestAction int = 100 - - opWeightMsgFinalizeAction = "op_weight_msg_finalize_action" - // TODO: Determine the simulation weight value - defaultWeightMsgFinalizeAction int = 100 - - opWeightMsgApproveAction = "op_weight_msg_approve_action" - // TODO: Determine the simulation weight value - defaultWeightMsgApproveAction int = 100 - // this line is used by starport scaffolding # simapp/module/const + _ = "" // placeholder to keep starport scaffolding line stable ) // GenerateGenesisState creates a randomized GenState of the module. diff --git a/x/action/v1/simulation/helpers.go b/x/action/v1/simulation/helpers.go index f00a4654..acf5c8dc 100644 --- a/x/action/v1/simulation/helpers.go +++ b/x/action/v1/simulation/helpers.go @@ -385,11 +385,6 @@ func selectRandomActionType(r *rand.Rand) string { return actionTypes[r.Intn(len(actionTypes))] } -// generateRandomOtiValues generates n random bytes as OTI value for CASCADE metadata -func generateRandomOtiValues(n int) []byte { - return make([]byte, n) -} - // getRandomActiveSupernodes simulates getting a list of active supernodes from the system func getRandomActiveSupernodes(r *rand.Rand, ctx sdk.Context, numSupernodes int, ak types.AuthKeeper, k keeper.Keeper, accs []simtypes.Account) ([]simtypes.Account, error) { top10 := getTop10Supernodes(ctx, k) diff --git a/x/supernode/v1/keeper/metrics_state.go b/x/supernode/v1/keeper/metrics_state.go index 750a36e8..42cf6fb0 100644 --- a/x/supernode/v1/keeper/metrics_state.go +++ b/x/supernode/v1/keeper/metrics_state.go @@ -53,48 +53,6 @@ func recoverFromPostponed(ctx sdk.Context, keeper types.SupernodeKeeper, sn *typ return nil } -func markStorageFull(ctx sdk.Context, keeper types.SupernodeKeeper, sn *types.SuperNode) error { - if len(sn.States) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "supernode state missing") - } - last := sn.States[len(sn.States)-1] - if last.State == types.SuperNodeStateStorageFull { - return nil - } - sn.States = append(sn.States, &types.SuperNodeStateRecord{State: types.SuperNodeStateStorageFull, Height: ctx.BlockHeight()}) - if err := keeper.SetSuperNode(ctx, *sn); err != nil { - return err - } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeSupernodeStorageFull, - sdk.NewAttribute(types.AttributeKeyValidatorAddress, sn.ValidatorAddress), - sdk.NewAttribute(types.AttributeKeyOldState, last.State.String()), - sdk.NewAttribute(types.AttributeKeyHeight, stringHeight(ctx.BlockHeight())), - ), - ) - return nil -} - -func recoverFromStorageFull(ctx sdk.Context, keeper types.SupernodeKeeper, sn *types.SuperNode, target types.SuperNodeState) error { - if target == types.SuperNodeStateUnspecified { - target = types.SuperNodeStateActive - } - sn.States = append(sn.States, &types.SuperNodeStateRecord{State: target, Height: ctx.BlockHeight()}) - if err := keeper.SetSuperNode(ctx, *sn); err != nil { - return err - } - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeSupernodeStorageRecovered, - sdk.NewAttribute(types.AttributeKeyValidatorAddress, sn.ValidatorAddress), - sdk.NewAttribute(types.AttributeKeyOldState, types.SuperNodeStateStorageFull.String()), - sdk.NewAttribute(types.AttributeKeyHeight, stringHeight(ctx.BlockHeight())), - ), - ) - return nil -} - func stringHeight(height int64) string { return strconv.FormatInt(height, 10) } diff --git a/x/supernode/v1/keeper/metrics_validation.go b/x/supernode/v1/keeper/metrics_validation.go index 5497dc44..c805a27a 100644 --- a/x/supernode/v1/keeper/metrics_validation.go +++ b/x/supernode/v1/keeper/metrics_validation.go @@ -205,17 +205,3 @@ func evaluateCompliance(ctx sdk.Context, params types.Params, m types.SupernodeM return ComplianceResult{Issues: issues, StorageFull: storageFull} } -// lastNonDegradedState returns the most recent state that is not POSTPONED -// or STORAGE_FULL, for use when recovering from a degraded state. -func lastNonDegradedState(states []*types.SuperNodeStateRecord) types.SuperNodeState { - for i := len(states) - 1; i >= 0; i-- { - if states[i] == nil { - continue - } - s := states[i].State - if s != types.SuperNodeStatePostponed && s != types.SuperNodeStateStorageFull { - return s - } - } - return types.SuperNodeStateUnspecified -} diff --git a/x/supernode/v1/keeper/msg_server_deregister_supernode_test.go b/x/supernode/v1/keeper/msg_server_deregister_supernode_test.go index 672c721a..97d41352 100644 --- a/x/supernode/v1/keeper/msg_server_deregister_supernode_test.go +++ b/x/supernode/v1/keeper/msg_server_deregister_supernode_test.go @@ -89,7 +89,7 @@ func TestMsgServer_DeRegisterSupernode(t *testing.T) { k, ctx := setupKeeperForTest(t, stakingKeeper, slashingKeeper, bankKeeper) if tc.expectedError != sdkerrors.ErrNotFound { - k.SetSuperNode(ctx, types.SuperNode{ + require.NoError(t, k.SetSuperNode(ctx, types.SuperNode{ SupernodeAccount: creatorAddr.String(), ValidatorAddress: valAddr.String(), Note: "1.0.0", @@ -111,7 +111,7 @@ func TestMsgServer_DeRegisterSupernode(t *testing.T) { }, }, P2PPort: "26657", - }) + })) } msgServer := keeper.NewMsgServerImpl(k) diff --git a/x/supernode/v1/keeper/msg_server_report_supernode_metrics_test.go b/x/supernode/v1/keeper/msg_server_report_supernode_metrics_test.go index d202bcaa..7193482c 100644 --- a/x/supernode/v1/keeper/msg_server_report_supernode_metrics_test.go +++ b/x/supernode/v1/keeper/msg_server_report_supernode_metrics_test.go @@ -98,7 +98,7 @@ func TestReportSupernodeMetrics_SingleReportRecoversPostponed(t *testing.T) { ctx = ctx.WithBlockHeader(header) resp, err := ms.ReportSupernodeMetrics( - sdk.WrapSDKContext(ctx), + ctx, &types.MsgReportSupernodeMetrics{ ValidatorAddress: supernode.ValidatorAddress, SupernodeAccount: supernode.SupernodeAccount, @@ -174,7 +174,7 @@ func TestReportSupernodeMetrics_ClosedRequiredPortDoesNotPostpone(t *testing.T) ctx = ctx.WithBlockHeader(header) resp, err := ms.ReportSupernodeMetrics( - sdk.WrapSDKContext(ctx), + ctx, &types.MsgReportSupernodeMetrics{ ValidatorAddress: supernode.ValidatorAddress, SupernodeAccount: supernode.SupernodeAccount, @@ -236,7 +236,7 @@ func TestReportSupernodeMetrics_EmptyPortsStillPersistsAndDoesNotRecover(t *test ctx = ctx.WithBlockHeader(header) resp, err := ms.ReportSupernodeMetrics( - sdk.WrapSDKContext(ctx), + ctx, &types.MsgReportSupernodeMetrics{ ValidatorAddress: supernode.ValidatorAddress, SupernodeAccount: supernode.SupernodeAccount, @@ -305,7 +305,7 @@ func TestReportSupernodeMetrics_StorageFullSignalDoesNotTransitionState(t *testi ctx = ctx.WithBlockHeader(tmproto.Header{Height: ctx.BlockHeight()}) resp, err := ms.ReportSupernodeMetrics( - sdk.WrapSDKContext(ctx), + ctx, &types.MsgReportSupernodeMetrics{ ValidatorAddress: supernode.ValidatorAddress, SupernodeAccount: supernode.SupernodeAccount, @@ -376,7 +376,7 @@ func TestReportSupernodeMetrics_DoesNotRecoverFromStorageFull(t *testing.T) { ctx = ctx.WithBlockHeader(tmproto.Header{Height: ctx.BlockHeight()}) resp, err := ms.ReportSupernodeMetrics( - sdk.WrapSDKContext(ctx), + ctx, &types.MsgReportSupernodeMetrics{ ValidatorAddress: supernode.ValidatorAddress, SupernodeAccount: supernode.SupernodeAccount, diff --git a/x/supernode/v1/module/module.go b/x/supernode/v1/module/module.go index e71d88a7..f74f723c 100644 --- a/x/supernode/v1/module/module.go +++ b/x/supernode/v1/module/module.go @@ -26,7 +26,7 @@ var ( _ module.AppModuleBasic = (*AppModule)(nil) _ module.AppModuleSimulation = (*AppModule)(nil) _ module.HasGenesis = (*AppModule)(nil) - _ module.HasInvariants = (*AppModule)(nil) + _ module.HasInvariants = (*AppModule)(nil) //nolint:staticcheck // SDK v0.50 still requires HasInvariants; removed only when x/crisis is dropped. _ module.HasConsensusVersion = (*AppModule)(nil) _ appmodule.AppModule = (*AppModule)(nil) @@ -132,7 +132,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) -func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} //nolint:staticcheck // see HasInvariants note above // InitGenesis performs the module's genesis initialization. It returns no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) { diff --git a/x/supernode/v1/simulation/update_supernode.go b/x/supernode/v1/simulation/update_supernode.go index adee841f..e4ddf652 100644 --- a/x/supernode/v1/simulation/update_supernode.go +++ b/x/supernode/v1/simulation/update_supernode.go @@ -81,10 +81,7 @@ func SimulateMsgUpdateSupernode( break } } - // If no free account found, skip updating the supernode account. - if supernodeAccount == "" { - updateAccount = false - } + // If no free account found, supernodeAccount stays empty and is skipped. } if updateVersion {