Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions proto/lumera/action/v1/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions proto/lumera/supernode/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
58 changes: 36 additions & 22 deletions proto/lumera/supernode/v1/supernode_state.proto
Original file line number Diff line number Diff line change
@@ -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\""];
Expand Down
4 changes: 2 additions & 2 deletions x/action/v1/keeper/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down
22 changes: 11 additions & 11 deletions x/action/v1/keeper/query_action_by_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions x/action/v1/keeper/query_get_action_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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
},
Expand Down
2 changes: 1 addition & 1 deletion x/action/v1/keeper/query_get_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions x/action/v1/keeper/query_list_actions_by_block_height_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions x/action/v1/keeper/query_list_actions_by_sn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
24 changes: 12 additions & 12 deletions x/action/v1/keeper/query_list_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions x/action/v1/keeper/query_list_expired_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions x/action/v1/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 1 addition & 12 deletions x/action/v1/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions x/action/v1/simulation/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading