From 3c47a24de49dddd8afc05167c770ac3266a1a599 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 10:43:06 +0200 Subject: [PATCH 01/11] Empty commit From 2848ab8e88964f18984d471f8aa8d414e84d6791 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 12:48:48 +0200 Subject: [PATCH 02/11] [Relayminer] Fix: relayminer on time sessions (#550) Co-authored-by: Daniel Olshansky --- pkg/relayer/session/session.go | 177 ++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 80 deletions(-) diff --git a/pkg/relayer/session/session.go b/pkg/relayer/session/session.go index 531c1208e..98a681d2a 100644 --- a/pkg/relayer/session/session.go +++ b/pkg/relayer/session/session.go @@ -89,10 +89,12 @@ func NewRelayerSessions( return nil, err } - rs.sessionsToClaimObs = channel.Map( + sessionsToClaimObs, sessionsToClaimPublishCh := channel.NewObservable[[]relayer.SessionTree]() + rs.sessionsToClaimObs = sessionsToClaimObs + channel.ForEach( ctx, rs.blockClient.CommittedBlocksSequence(ctx), - rs.mapBlockToSessionsToClaim, + rs.forEachBlockClaimSessionsFn(sessionsToClaimPublishCh), ) return rs, nil @@ -163,94 +165,109 @@ func (rs *relayerSessionsManager) ensureSessionTree(sessionHeader *sessiontypes. return sessionTree, nil } -// mapBlockToSessionsToClaim is a MapFn which maps committed blocks to a list of -// sessions which can be claimed as of that block. +// forEachBlockClaimSessionsFn returns a new ForEachFn that sends a lists of sessions which +// are eligible to be claimed at each block height on sessionsToClaimsPublishCh, effectively +// mapping committed blocks to a list of sessions which can be claimed as of that block. +// +// forEachBlockClaimSessionsFn returns a new ForEachFn that is called once for each block height. +// Given the current sessions in the rs.sessionsTrees map at the time of each call, it: +// - fetches the current shared module params +// - builds a list of "on-time" & "late" sessions that are eligible to be claimed as of a given block height +// - sends "late" & "on-time" sessions on sessionsToClaimsPublishCh as distinct notifications +// +// If "late" sessions are found, they are emitted as quickly as possible and are expected +// to bypass downstream delay operations. "late" sessions are emitted, as they're discovered +// (by iterating over map keys). +// +// Under nominal conditions, only one set of "on-time" sessions (w/ the same session start/end heights) +// should be present in the rs.sessionsTrees map. "Late" sessions +// are expected to present in the presence of network interruptions, restarts, or other +// disruptions to the relayminer process. // TODO_IMPROVE: Add the ability for the process to resume where it left off in // case the process is restarted or the connection is dropped and reconnected. -func (rs *relayerSessionsManager) mapBlockToSessionsToClaim( - ctx context.Context, - block client.Block, -) (sessionTrees []relayer.SessionTree, skip bool) { - rs.sessionsTreesMu.Lock() - defer rs.sessionsTreesMu.Unlock() - - // onTimeSessions are the sessions that are still within their grace period. - // They are on time and will wait for their create claim window to open. - // They will be emitted last, after all the late sessions have been emitted. - var onTimeSessions []relayer.SessionTree - - // TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. - // Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method - // to get the most recently (asynchronously) observed (and cached) value. - sharedParams, err := rs.sharedQueryClient.GetParams(ctx) - if err != nil { - rs.logger.Error().Err(err).Msg("unable to query shared module params") - return nil, true - } +func (rs *relayerSessionsManager) forEachBlockClaimSessionsFn( + sessionsToClaimsPublishCh chan<- []relayer.SessionTree, +) channel.ForEachFn[client.Block] { + return func(ctx context.Context, block client.Block) { + rs.sessionsTreesMu.Lock() + defer rs.sessionsTreesMu.Unlock() + + // onTimeSessions are the sessions that are still within their grace period. + // They are on time and will wait for their create claim window to open. + // They will be emitted last, after all the late sessions have been emitted. + var onTimeSessions []relayer.SessionTree + + // TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. + // Once `ModuleParamsClient` is implemented, use its replay observable's `#Last()` method + // to get the most recently (asynchronously) observed (and cached) value. + sharedParams, err := rs.sharedQueryClient.GetParams(ctx) + if err != nil { + rs.logger.Error().Err(err).Msg("unable to query shared module params") + return + } - numBlocksPerSession := sharedParams.NumBlocksPerSession - - // Check if there are sessions that need to enter the claim/proof phase as their - // end block height was the one before the last committed block or earlier. - // Iterate over the sessionsTrees map to get the ones that end at a block height - // lower than the current block height. - for sessionEndHeight, sessionsTreesEndingAtBlockHeight := range rs.sessionsTrees { - // Late sessions are the ones that have their session grace period elapsed - // and should already have been claimed. - // Group them by their end block height and emit each group separately - // before emitting the on-time sessions. - var lateSessions []relayer.SessionTree - - sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) - - // Checking for sessions to claim with <= operator, - // which means that it would include sessions that were supposed to be - // claimed in previous block heights too. - // These late sessions might have their create claim window closed and are - // no longer eligible to be claimed, but that's not always the case. - // Once claim window closing is implemented, they will be filtered out - // downstream at the waitForEarliestCreateClaimsHeight step. - // TODO_BLOCKER: Introduce governance claim and proof window durations, - // implement off-chain window closing and on-chain window checks. - if sessionGracePeriodEndHeight <= block.Height() { - // Iterate over the sessionsTrees that have grace period ending at this - // block height and add them to the list of sessionTrees to be published. - for _, sessionTree := range sessionsTreesEndingAtBlockHeight { - // Mark the session as claimed and add it to the list of sessionTrees to be published. - // If the session has already been claimed, it will be skipped. - // Appending the sessionTree to the list of sessionTrees is protected - // against concurrent access by the sessionsTreesMu such that the first - // call that marks the session as claimed will be the only one to add the - // sessionTree to the list. - if err := sessionTree.StartClaiming(); err != nil { - continue + numBlocksPerSession := sharedParams.NumBlocksPerSession + + // Check if there are sessions that need to enter the claim/proof phase as their + // end block height was the one before the last committed block or earlier. + // Iterate over the sessionsTrees map to get the ones that end at a block height + // lower than the current block height. + for sessionEndHeight, sessionsTreesEndingAtBlockHeight := range rs.sessionsTrees { + // Late sessions are the ones that have their session grace period elapsed + // and should already have been claimed. + // Group them by their end block height and emit each group separately + // before emitting the on-time sessions. + var lateSessions []relayer.SessionTree + + sessionGracePeriodEndHeight := shared.GetSessionGracePeriodEndHeight(sessionEndHeight) + + // Checking for sessions to claim with <= operator, + // which means that it would include sessions that were supposed to be + // claimed in previous block heights too. + // These late sessions might have their create claim window closed and are + // no longer eligible to be claimed, but that's not always the case. + // Once claim window closing is implemented, they will be filtered out + // downstream at the waitForEarliestCreateClaimsHeight step. + // TODO_BLOCKER: Introduce governance claim and proof window durations, + // implement off-chain window closing and on-chain window checks. + if sessionGracePeriodEndHeight <= block.Height() { + // Iterate over the sessionsTrees that have grace period ending at this + // block height and add them to the list of sessionTrees to be published. + for _, sessionTree := range sessionsTreesEndingAtBlockHeight { + // Mark the session as claimed and add it to the list of sessionTrees to be published. + // If the session has already been claimed, it will be skipped. + // Appending the sessionTree to the list of sessionTrees is protected + // against concurrent access by the sessionsTreesMu such that the first + // call that marks the session as claimed will be the only one to add the + // sessionTree to the list. + if err := sessionTree.StartClaiming(); err != nil { + continue + } + + // Separate the sessions that are on-time from the ones that are late. + // If the session is past its grace period, it is considered late, + // otherwise it is on time and will be emitted last. + if sessionGracePeriodEndHeight+int64(numBlocksPerSession) < block.Height() { + lateSessions = append(lateSessions, sessionTree) + } else { + onTimeSessions = append(onTimeSessions, sessionTree) + } } - // Separate the sessions that are on-time from the ones that are late. - // If the session is past its grace period, it is considered late, - // otherwise it is on time and will be emitted last. - if sessionGracePeriodEndHeight+int64(numBlocksPerSession) < block.Height() { - lateSessions = append(lateSessions, sessionTree) - } else { - onTimeSessions = append(onTimeSessions, sessionTree) + // If there are any late sessions to be claimed, emit them first. + // The wait for claim submission window pipeline step will return immediately + // without blocking them. + if len(lateSessions) > 0 { + sessionsToClaimsPublishCh <- lateSessions } } - - // If there are any late sessions to be claimed, emit them first. - // The wait for claim submission window pipeline step will return immediately - // without blocking them. - if len(lateSessions) > 0 { - return lateSessions, false - } } - } - // Emit the on-time sessions last, after all the late sessions have been emitted. - if len(onTimeSessions) > 0 { - return onTimeSessions, false + // Emit the on-time sessions last, after all the late sessions have been emitted. + if len(onTimeSessions) > 0 { + sessionsToClaimsPublishCh <- onTimeSessions + } } - - return nil, true } // removeFromRelayerSessions removes the SessionTree from the relayerSessions. From e83b90259b6137d6f89e581c90ae81a8455764ca Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 12:49:19 +0200 Subject: [PATCH 03/11] [Application] Refactor app module to fetch on-chain params (#555) Co-authored-by: Daniel Olshansky --- .../tests/relays_stress_helpers_test.go | 10 +-- pkg/crypto/rings/client.go | 2 +- testutil/keeper/application.go | 17 ++++- testutil/keeper/proof.go | 10 +++ testutil/keeper/tokenomics.go | 12 +++- .../testqueryclients/sessionquerier.go | 6 +- testutil/testproxy/relayerproxy.go | 4 +- x/application/keeper/keeper.go | 3 + .../msg_server_undelegate_from_gateway.go | 6 +- ...msg_server_undelegate_from_gateway_test.go | 18 +++-- x/application/keeper/prune_undelegations.go | 22 +++++-- x/application/module/module.go | 2 + x/application/types/expected_keepers.go | 9 ++- .../keeper/msg_server_create_claim_test.go | 2 +- x/proof/keeper/proof_test.go | 2 +- x/proof/module/helpers_test.go | 6 +- x/proof/types/message_submit_proof_test.go | 8 +-- x/session/keeper/session_hydrator.go | 11 ++-- x/shared/keeper/session.go | 35 ++++++++++ x/shared/session.go | 66 +++++++++++++++---- x/tokenomics/keeper/keeper_test.go | 2 +- .../keeper/settle_session_accounting_test.go | 6 +- 22 files changed, 204 insertions(+), 55 deletions(-) create mode 100644 x/shared/keeper/session.go diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index a78d42ac7..8acb4dc42 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -173,9 +173,9 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn( sessionInfo := &sessionInfoNotif{ blockHeight: blockHeight, - sessionNumber: shared.GetSessionNumber(blockHeight), - sessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), - sessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), + sessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), + sessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + sessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), } infoLogger := logger.Info(). @@ -720,7 +720,7 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( return false } - initialSessionNumber := shared.GetSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. actorSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber @@ -746,7 +746,7 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( return false } - initialSessionNumber := shared.GetSessionNumber(startBlockHeight) + initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. supplierSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber diff --git a/pkg/crypto/rings/client.go b/pkg/crypto/rings/client.go index 9e8560833..b494c4892 100644 --- a/pkg/crypto/rings/client.go +++ b/pkg/crypto/rings/client.go @@ -265,7 +265,7 @@ func (rc *ringClient) getRingPointsForAddressAtHeight( // gateways that have been undelegated after the target session end height. func GetRingAddressesAtBlock(app *apptypes.Application, blockHeight int64) []string { // Get the target session end height at which we want to get the active delegations. - targetSessionEndHeight := uint64(shared.GetSessionEndBlockHeight(blockHeight)) + targetSessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(blockHeight)) // Get the current active delegations for the application and use them as a base. activeDelegationsAtHeight := app.DelegateeGatewayAddresses diff --git a/testutil/keeper/application.go b/testutil/keeper/application.go index f7c5a165a..6680497d3 100644 --- a/testutil/keeper/application.go +++ b/testutil/keeper/application.go @@ -20,10 +20,12 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - mocks "github.com/pokt-network/poktroll/testutil/application/mocks" + "github.com/pokt-network/poktroll/testutil/application/mocks" "github.com/pokt-network/poktroll/x/application/keeper" "github.com/pokt-network/poktroll/x/application/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" + "github.com/pokt-network/poktroll/x/shared" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // stakedGatewayMap is used to mock whether a gateway is staked or not for use @@ -67,6 +69,18 @@ func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context) { }, ).AnyTimes() + mockSharedKeeper := mocks.NewMockSharedKeeper(ctrl) + mockSharedKeeper.EXPECT().GetParams(gomock.Any()). + DoAndReturn(func(_ context.Context) sharedtypes.Params { + return sharedtypes.DefaultParams() + }). + AnyTimes() + mockSharedKeeper.EXPECT().GetSessionEndHeight(gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, queryHeight int64) int64 { + return shared.GetSessionEndHeightWithDefaultParams(queryHeight) + }). + AnyTimes() + k := keeper.NewKeeper( cdc, runtime.NewKVStoreService(storeKey), @@ -75,6 +89,7 @@ func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockBankKeeper, mockAccountKeeper, mockGatewayKeeper, + mockSharedKeeper, ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) diff --git a/testutil/keeper/proof.go b/testutil/keeper/proof.go index 3a6e8b68c..7de11974e 100644 --- a/testutil/keeper/proof.go +++ b/testutil/keeper/proof.go @@ -39,6 +39,7 @@ import ( prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + sharedkeeper "github.com/pokt-network/poktroll/x/shared/keeper" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" supplierkeeper "github.com/pokt-network/poktroll/x/supplier/keeper" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" @@ -142,6 +143,14 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul authority.String(), ) + // Construct a real shared keeper. + sharedKeeper := sharedkeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(keys[sharedtypes.StoreKey]), + logger, + authority.String(), + ) + // Construct gateway keeper with a mocked bank keeper. gatewayKeeper := gatewaykeeper.NewKeeper( cdc, @@ -161,6 +170,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul applicationmocks.NewMockBankKeeper(ctrl), accountKeeper, gatewayKeeper, + sharedKeeper, ) require.NoError(t, appKeeper.SetParams(ctx, apptypes.DefaultParams())) diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index da1ebd131..f02b0b262 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -5,7 +5,7 @@ import ( "testing" "cosmossdk.io/log" - math "cosmossdk.io/math" + "cosmossdk.io/math" "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" @@ -38,6 +38,7 @@ import ( prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" + sharedkeeper "github.com/pokt-network/poktroll/x/shared/keeper" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" supplierkeeper "github.com/pokt-network/poktroll/x/supplier/keeper" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" @@ -239,6 +240,14 @@ func NewTokenomicsModuleKeepers( bankKeeper.MintCoins(ctx, suppliertypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", math.NewInt(1000000000000)))) bankKeeper.MintCoins(ctx, apptypes.ModuleName, sdk.NewCoins(sdk.NewCoin("upokt", math.NewInt(1000000000000)))) + // Construct a real shared keeper. + sharedKeeper := sharedkeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(keys[sharedtypes.StoreKey]), + logger, + authority.String(), + ) + // Construct gateway keeper with a mocked bank keeper. gatewayKeeper := gatewaykeeper.NewKeeper( cdc, @@ -258,6 +267,7 @@ func NewTokenomicsModuleKeepers( bankKeeper, accountKeeper, gatewayKeeper, + sharedKeeper, ) require.NoError(t, appKeeper.SetParams(ctx, apptypes.DefaultParams())) diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 552e66969..1b0c3c992 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -80,11 +80,11 @@ func AddToExistingSessions( Service: &sharedtypes.Service{Id: serviceId}, ApplicationAddress: appAddress, SessionId: sessionId, - SessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), }, NumBlocksPerSession: shared.NumBlocksPerSession, - SessionNumber: shared.GetSessionNumber(blockHeight), + SessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), SessionId: sessionId, Suppliers: []*sharedtypes.Supplier{}, } diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index 1e1363063..19eaa905d 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -409,8 +409,8 @@ func GenerateRelayRequest( ApplicationAddress: appAddress, SessionId: string(sessionId[:]), Service: &sharedtypes.Service{Id: serviceId}, - SessionStartBlockHeight: shared.GetSessionStartBlockHeight(blockHeight), - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(blockHeight), + SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), }, // The returned relay is unsigned and must be signed elsewhere for functionality Signature: []byte(""), diff --git a/x/application/keeper/keeper.go b/x/application/keeper/keeper.go index a621a1dcf..f26ef8d62 100644 --- a/x/application/keeper/keeper.go +++ b/x/application/keeper/keeper.go @@ -24,6 +24,7 @@ type ( bankKeeper types.BankKeeper accountKeeper types.AccountKeeper gatewayKeeper types.GatewayKeeper + sharedKeeper types.SharedKeeper } ) @@ -36,6 +37,7 @@ func NewKeeper( bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, gatewayKeeper types.GatewayKeeper, + sharedKeeper types.SharedKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -50,6 +52,7 @@ func NewKeeper( bankKeeper: bankKeeper, accountKeeper: accountKeeper, gatewayKeeper: gatewayKeeper, + sharedKeeper: sharedKeeper, } } diff --git a/x/application/keeper/msg_server_undelegate_from_gateway.go b/x/application/keeper/msg_server_undelegate_from_gateway.go index f5a0345da..99728994a 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway.go @@ -9,7 +9,6 @@ import ( "github.com/pokt-network/poktroll/telemetry" "github.com/pokt-network/poktroll/x/application/types" - "github.com/pokt-network/poktroll/x/shared" ) func (k msgServer) UndelegateFromGateway(ctx context.Context, msg *types.MsgUndelegateFromGateway) (*types.MsgUndelegateFromGatewayResponse, error) { @@ -55,7 +54,7 @@ func (k msgServer) UndelegateFromGateway(ctx context.Context, msg *types.MsgUnde sdkCtx := sdk.UnwrapSDKContext(ctx) currentBlock := sdkCtx.BlockHeight() - k.recordPendingUndelegation(&foundApp, msg.GatewayAddress, currentBlock) + k.recordPendingUndelegation(ctx, &foundApp, msg.GatewayAddress, currentBlock) // Update the application store with the new delegation k.SetApplication(ctx, foundApp) @@ -76,11 +75,12 @@ func (k msgServer) UndelegateFromGateway(ctx context.Context, msg *types.MsgUnde // recordPendingUndelegation adds the given gateway address to the application's // pending undelegations list. func (k Keeper) recordPendingUndelegation( + ctx context.Context, app *types.Application, gatewayAddress string, currentBlockHeight int64, ) { - sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(currentBlockHeight)) + sessionEndHeight := uint64(k.sharedKeeper.GetSessionEndHeight(ctx, currentBlockHeight)) undelegatingGatewayListAtBlock := app.PendingUndelegations[sessionEndHeight] // Add the gateway address to the undelegated gateways list if it's not already there. diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index c5d80977d..224b8f3c9 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -316,7 +316,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that the gateway is added to the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, pendingUndelegateFromAddr, @@ -384,7 +384,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsPrunedAfterRetentionPeriod( // Verify that the the pending undelegation map no longer contains the // sessionEndHeight key. - sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Empty(t, app.PendingUndelegations[sessionEndHeight]) // Verify that the reconstructed delegatee gateway list can no longer include @@ -423,7 +423,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS // Verify that the gateway is also present in the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetSessionEndBlockHeight(undelegationHeight)) + sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, gatewayAddrToRedelegate, @@ -533,7 +533,15 @@ func createAppStakeDelegateAndUndelegate( // getUndelegationPruningBlockHeight returns the block height at which undelegations // should be pruned for a given undlegation block height. func getUndelegationPruningBlockHeight(blockHeight int64) (pruningHeihgt int64) { - nextSessionStartHeight := shared.GetSessionEndBlockHeight(blockHeight) + 1 + nextSessionStartHeight := shared.GetSessionEndHeightWithDefaultParams(blockHeight) + 1 - return nextSessionStartHeight + keeper.GetNumBlocksUndelegationRetention() + return nextSessionStartHeight + getNumBlocksUndelegationRetentionWithDefaultParams() +} + +// getNumBlocksUndelegationRetentionWithDefaultParams returns the number of blocks for +// which undelegations should be kept before being pruned, given the default shared +// module parameters. +func getNumBlocksUndelegationRetentionWithDefaultParams() int64 { + sharedParams := sharedtypes.DefaultParams() + return keeper.GetNumBlocksUndelegationRetention(&sharedParams) } diff --git a/x/application/keeper/prune_undelegations.go b/x/application/keeper/prune_undelegations.go index 2cf10aa47..eb2e276e9 100644 --- a/x/application/keeper/prune_undelegations.go +++ b/x/application/keeper/prune_undelegations.go @@ -1,9 +1,12 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/pokt-network/poktroll/x/shared" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // NumSessionsAppToGatewayUndelegationRetention is the number of sessions for which @@ -20,7 +23,7 @@ func (k Keeper) EndBlockerPruneAppToGatewayPendingUndelegation(ctx sdk.Context) currentHeight := ctx.BlockHeight() // Calculate the block height at which undelegations should be pruned - numBlocksUndelegationRetention := GetNumBlocksUndelegationRetention() + numBlocksUndelegationRetention := k.GetNumBlocksUndelegationRetention(ctx) if currentHeight <= numBlocksUndelegationRetention { return nil } @@ -43,8 +46,19 @@ func (k Keeper) EndBlockerPruneAppToGatewayPendingUndelegation(ctx sdk.Context) } // GetNumBlocksUndelegationRetention returns the number of blocks for which -// undelegations should be kept before being pruned. -func GetNumBlocksUndelegationRetention() int64 { +// undelegations should be kept before being pruned, given the current on-chain +// shared module parameters. +func (k Keeper) GetNumBlocksUndelegationRetention(ctx context.Context) int64 { + sharedParams := k.sharedKeeper.GetParams(ctx) + return GetNumBlocksUndelegationRetention(&sharedParams) +} + +// GetNumBlocksUndelegationRetention returns the number of blocks for which +// undelegations should be kept before being pruned, given the passed shared +// module parameters. +func GetNumBlocksUndelegationRetention(sharedParams *sharedtypes.Params) int64 { + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + return shared.SessionGracePeriodBlocks + - (shared.NumBlocksPerSession * NumSessionsAppToGatewayUndelegationRetention) + (numBlocksPerSession * NumSessionsAppToGatewayUndelegationRetention) } diff --git a/x/application/module/module.go b/x/application/module/module.go index 72d0e86ac..050332a61 100644 --- a/x/application/module/module.go +++ b/x/application/module/module.go @@ -181,6 +181,7 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper GatewayKeeper types.GatewayKeeper + SharedKeeper types.SharedKeeper } type ModuleOutputs struct { @@ -204,6 +205,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.BankKeeper, in.AccountKeeper, in.GatewayKeeper, + in.SharedKeeper, ) m := NewAppModule( in.Cdc, diff --git a/x/application/types/expected_keepers.go b/x/application/types/expected_keepers.go index cc74e6f89..3c908df63 100644 --- a/x/application/types/expected_keepers.go +++ b/x/application/types/expected_keepers.go @@ -1,4 +1,4 @@ -//go:generate mockgen -destination ../../../testutil/application/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,GatewayKeeper +//go:generate mockgen -destination ../../../testutil/application/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,GatewayKeeper,SharedKeeper package types @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) // AccountKeeper defines the expected interface for the Account module. @@ -30,3 +31,9 @@ type BankKeeper interface { type GatewayKeeper interface { GetGateway(ctx context.Context, addr string) (gatewaytypes.Gateway, bool) } + +// SharedKeeper defines the expected interface needed to retrieve shared information. +type SharedKeeper interface { + GetParams(ctx context.Context) sharedtypes.Params + GetSessionEndHeight(ctx context.Context, queryHeight int64) int64 +} diff --git a/x/proof/keeper/msg_server_create_claim_test.go b/x/proof/keeper/msg_server_create_claim_test.go index 5f7da9c31..170f6cbd1 100644 --- a/x/proof/keeper/msg_server_create_claim_test.go +++ b/x/proof/keeper/msg_server_create_claim_test.go @@ -300,7 +300,7 @@ func newTestClaimMsg( Service: service, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, merkleRoot, ) diff --git a/x/proof/keeper/proof_test.go b/x/proof/keeper/proof_test.go index c72f32bbe..13c578f82 100644 --- a/x/proof/keeper/proof_test.go +++ b/x/proof/keeper/proof_test.go @@ -37,7 +37,7 @@ func createNProofs(keeper keeper.Keeper, ctx context.Context, n int) []types.Pro Service: &sharedtypes.Service{Id: testServiceId}, SessionId: fmt.Sprintf("session-%d", i), SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, ClosestMerkleProof: nil, } diff --git a/x/proof/module/helpers_test.go b/x/proof/module/helpers_test.go index b8588e554..3e2dd6045 100644 --- a/x/proof/module/helpers_test.go +++ b/x/proof/module/helpers_test.go @@ -130,7 +130,7 @@ func networkWithClaimObjects( claim := createClaim( t, net, ctx, supplierAcct.Address.String(), - shared.GetSessionStartBlockHeight(blockHeight), + shared.GetSessionStartHeightWithDefaultParams(blockHeight), appAcct.Address.String(), ) claims = append(claims, *claim) @@ -160,7 +160,7 @@ func encodeSessionHeader( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), } cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) sessionHeaderBz := cdc.MustMarshalJSON(sessionHeader) @@ -210,7 +210,7 @@ func createClaim( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(sessionStartHeight), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, RootHash: rootHash, } diff --git a/x/proof/types/message_submit_proof_test.go b/x/proof/types/message_submit_proof_test.go index d05419e38..00558bb93 100644 --- a/x/proof/types/message_submit_proof_test.go +++ b/x/proof/types/message_submit_proof_test.go @@ -30,7 +30,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -49,7 +49,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -68,7 +68,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: &sharedtypes.Service{Id: ""}, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -83,7 +83,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index cba24a8e0..0e397ccd8 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -99,11 +99,14 @@ func (k Keeper) hydrateSessionMetadata(ctx context.Context, sh *sessionHydrator) ) } + // TODO_UPNEXT(#517): Refactor session module to use current on-chain shared + // parameters instead of their corresponding constant stand-ins. + sh.session.NumBlocksPerSession = shared.NumBlocksPerSession - sh.session.SessionNumber = shared.GetSessionNumber(sh.blockHeight) + sh.session.SessionNumber = shared.GetSessionNumberWithDefaultParams(sh.blockHeight) - sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartBlockHeight(sh.blockHeight) - sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndBlockHeight(sh.blockHeight) + sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartHeightWithDefaultParams(sh.blockHeight) + sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndHeightWithDefaultParams(sh.blockHeight) return nil } @@ -291,7 +294,7 @@ func GetSessionId( // getSessionStartBlockHeightBz returns the bytes representation of the session // start block height given the block height. func getSessionStartBlockHeightBz(blockHeight int64) []byte { - sessionStartBlockHeight := shared.GetSessionStartBlockHeight(blockHeight) + sessionStartBlockHeight := shared.GetSessionStartHeightWithDefaultParams(blockHeight) sessionStartBlockHeightBz := make([]byte, 8) binary.LittleEndian.PutUint64(sessionStartBlockHeightBz, uint64(sessionStartBlockHeight)) return sessionStartBlockHeightBz diff --git a/x/shared/keeper/session.go b/x/shared/keeper/session.go new file mode 100644 index 000000000..c0d414c5f --- /dev/null +++ b/x/shared/keeper/session.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "context" + + "github.com/pokt-network/poktroll/x/shared" +) + +// GetSessionStartHeight returns the block height at which the session containing +// queryHeight starts, given the current shared on-chain parameters. +// Returns 0 if the block height is not a consensus produced block. +// Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. +func (k Keeper) GetSessionStartHeight(ctx context.Context, queryHeight int64) int64 { + sharedParams := k.GetParams(ctx) + return shared.GetSessionStartHeight(&sharedParams, queryHeight) +} + +// GetSessionEndHeight returns the block height at which the session containing +// queryHeight ends, given the current shared on-chain parameters. +// Returns 0 if the block height is not a consensus produced block. +// Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. +func (k Keeper) GetSessionEndHeight(ctx context.Context, queryHeight int64) int64 { + sharedParams := k.GetParams(ctx) + return shared.GetSessionEndHeight(&sharedParams, queryHeight) +} + +// GetSessionNumber returns the session number for the session containing queryHeight, +// given the current shared on-chain parameters. +// Returns session number 0 if the block height is not a consensus produced block. +// Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). +// i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. +func (k Keeper) GetSessionNumber(ctx context.Context, queryHeight int64) int64 { + sharedParams := k.GetParams(ctx) + return shared.GetSessionNumber(&sharedParams, queryHeight) +} diff --git a/x/shared/session.go b/x/shared/session.go index 5240059a5..3b3430cf3 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -1,5 +1,7 @@ package shared +import sharedtypes "github.com/pokt-network/poktroll/x/shared/types" + // NumBlocksPerSession is a place-holder that will be removed once the respective governance // parameter is implemented. // @@ -14,42 +16,82 @@ const NumBlocksPerSession = 4 // governance parameter is implemented. const SessionGracePeriodBlocks = 4 -// GetSessionStartBlockHeight returns the block height at which the session starts +// GetSessionStartHeightWithDefaultParams returns the block height at which the +// session containing queryHeight starts, given the default shared on-chain +// parameters. +// See GetSessionStartHeight for more details. +// +// TODO_TECHDEBT(#517): Move this function to shared testutils. +func GetSessionStartHeightWithDefaultParams(queryHeight int64) int64 { + sharedParams := sharedtypes.DefaultParams() + return GetSessionStartHeight(&sharedParams, queryHeight) +} + +// GetSessionStartHeight returns the block height at which the session containing +// queryHeight starts, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc. -func GetSessionStartBlockHeight(blockHeight int64) int64 { - if blockHeight <= 0 { +func GetSessionStartHeight(sharedParams *sharedtypes.Params, queryHeight int64) int64 { + if queryHeight <= 0 { return 0 } + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + // TODO_BLOCKER(#543): If the num_blocks_per_session param has ever been changed, // this function may cause unexpected behavior. - return blockHeight - ((blockHeight - 1) % NumBlocksPerSession) + return queryHeight - ((queryHeight - 1) % numBlocksPerSession) } -// GetSessionEndBlockHeight returns the block height at which the session ends +// GetSessionEndHeightWithDefaultParams returns the block height at which the session +// containing queryHeight ends, given the default shared on-chain parameters. +// See GetSessionEndHeight for more details. +// +// TODO_TECHDEBT(#517): Move this function to shared testutils. +func GetSessionEndHeightWithDefaultParams(queryHeight int64) int64 { + sharedParams := sharedtypes.DefaultParams() + return GetSessionEndHeight(&sharedParams, queryHeight) +} + +// GetSessionEndHeight returns the block height at which the session containing +// queryHeight ends, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. // Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc. -func GetSessionEndBlockHeight(blockHeight int64) int64 { - if blockHeight <= 0 { +func GetSessionEndHeight(sharedParams *sharedtypes.Params, queryHeight int64) int64 { + if queryHeight <= 0 { return 0 } - return GetSessionStartBlockHeight(blockHeight) + NumBlocksPerSession - 1 + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + + return GetSessionStartHeight(sharedParams, queryHeight) + numBlocksPerSession - 1 +} + +// GetSessionNumberWithDefaultParams returns the session number of the session +// containing queryHeight, given the default on-chain shared parameters. +// See GetSessionNumber for more details. +// +// TODO_TECHDEBT(#517): Move this function to shared testutils. +func GetSessionNumberWithDefaultParams(queryHeight int64) int64 { + sharedParams := sharedtypes.DefaultParams() + return GetSessionNumber(&sharedParams, queryHeight) } -// GetSessionNumber returns the session number given the block height. +// GetSessionNumber returns the session number of the session containing queryHeight, +// given the passed on-chain shared parameters. // Returns session number 0 if the block height is not a consensus produced block. // Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). // i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. -func GetSessionNumber(blockHeight int64) int64 { - if blockHeight <= 0 { +func GetSessionNumber(sharedParams *sharedtypes.Params, queryHeight int64) int64 { + if queryHeight <= 0 { return 0 } + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + // TODO_BLOCKER(#543): If the num_blocks_per_session param has ever been changed, // this function may cause unexpected behavior. - return ((blockHeight - 1) / NumBlocksPerSession) + 1 + return ((queryHeight - 1) / numBlocksPerSession) + 1 } // GetSessionGracePeriodEndHeight returns the block height at which the grace period diff --git a/x/tokenomics/keeper/keeper_test.go b/x/tokenomics/keeper/keeper_test.go index 3fdd0dd88..6103694a6 100644 --- a/x/tokenomics/keeper/keeper_test.go +++ b/x/tokenomics/keeper/keeper_test.go @@ -60,7 +60,7 @@ func (s *TestSuite) SetupTest() { Service: &sharedtypes.Service{Id: testServiceId}, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(69), } diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index 528250aa5..e1f65471b 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -52,7 +52,7 @@ func TestSettleSessionAccounting_HandleAppGoingIntoDebt(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(appStake.Amount.Uint64() + 1), // More than the app stake } @@ -93,7 +93,7 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(42), } @@ -297,7 +297,7 @@ func baseClaim(appAddr, supplierAddr string, sum uint64) prooftypes.Claim { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndBlockHeight(1), + SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(sum), } From eb84fdd8ea1c92cd80620a4e0c1ec24618469928 Mon Sep 17 00:00:00 2001 From: Dima K Date: Thu, 30 May 2024 04:35:12 -0700 Subject: [PATCH 04/11] [LoadTest] Switch funding account to key name instead of address (#562) Co-authored-by: Redouane Lakrache --- .../config/load_test_manifest_reader.go | 19 ++++++++++++++----- load-testing/loadtest_manifest.yaml | 3 +++ load-testing/localnet_loadtest_manifest.yaml | 3 +++ load-testing/tests/relays_stress_test.go | 8 ++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/load-testing/config/load_test_manifest_reader.go b/load-testing/config/load_test_manifest_reader.go index 1e603b2b1..3e1a1f1d5 100644 --- a/load-testing/config/load_test_manifest_reader.go +++ b/load-testing/config/load_test_manifest_reader.go @@ -21,11 +21,12 @@ type ProvisionedActorConfig struct { type LoadTestManifestYAML struct { // IsEphemeralChain is a flag that indicates whether the test is expected to be // run on LocalNet or long-living remote chain (i.e. TestNet/DevNet). - IsEphemeralChain bool `yaml:"is_ephemeral_chain"` - TestNetNode string `yaml:"testnet_node"` - ServiceId string `yaml:"service_id"` - Suppliers []ProvisionedActorConfig `yaml:"suppliers"` - Gateways []ProvisionedActorConfig `yaml:"gateways"` + IsEphemeralChain bool `yaml:"is_ephemeral_chain"` + TestNetNode string `yaml:"testnet_node"` + ServiceId string `yaml:"service_id"` + Suppliers []ProvisionedActorConfig `yaml:"suppliers"` + Gateways []ProvisionedActorConfig `yaml:"gateways"` + FundingAccountAddress string `yaml:"funding_account_address"` } // ParseLoadTestManifest reads the load test manifest from the given byte slice @@ -62,6 +63,10 @@ func validatedEphemeralChainManifest(manifest *LoadTestManifestYAML) (*LoadTestM return nil, ErrEphemeralChainLoadTestInvalidManifest.Wrap("empty service id") } + if len(manifest.FundingAccountAddress) == 0 { + return nil, ErrEphemeralChainLoadTestInvalidManifest.Wrap("empty funding account address") + } + for _, gateway := range manifest.Gateways { if len(gateway.Address) == 0 { return nil, ErrEphemeralChainLoadTestInvalidManifest.Wrap("empty gateway address") @@ -110,6 +115,10 @@ func validatedNonEphemeralChainManifest(manifest *LoadTestManifestYAML) (*LoadTe return nil, ErrNonEphemeralChainLoadTestInvalidManifest.Wrap("empty service id") } + if len(manifest.FundingAccountAddress) == 0 { + return nil, ErrNonEphemeralChainLoadTestInvalidManifest.Wrap("empty funding account address") + } + for _, gateway := range manifest.Gateways { if len(gateway.Address) == 0 { return nil, ErrNonEphemeralChainLoadTestInvalidManifest.Wrap("empty gateway address") diff --git a/load-testing/loadtest_manifest.yaml b/load-testing/loadtest_manifest.yaml index 7f6338925..1ca129424 100644 --- a/load-testing/loadtest_manifest.yaml +++ b/load-testing/loadtest_manifest.yaml @@ -6,6 +6,9 @@ is_ephemeral_chain: false testnet_node: https://testnet-validated-validator-rpc.poktroll.com # The service ID to request relays from. service_id: "0021" +# The address of the account that will be used to fund the the application accounts +# so that they can stake on the network. +funding_account_address: pokt14eh973xt99s7edugnyvd5d5u50d6j0hysw2vsm # address for pnf account # In non-ephemeral chains, the gateways are identified by their address. gateways: # address is the bech32 pokt address of the gateway. diff --git a/load-testing/localnet_loadtest_manifest.yaml b/load-testing/localnet_loadtest_manifest.yaml index 07184f214..7513eaa34 100644 --- a/load-testing/localnet_loadtest_manifest.yaml +++ b/load-testing/localnet_loadtest_manifest.yaml @@ -4,6 +4,9 @@ is_ephemeral_chain: true # The service ID to use for the load test. service_id: anvil +# The address of the account that will be used to fund the the application, +# gateway and supplier accounts so that they can stake on the network. +funding_account_address: pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw # address for pnf account # List of pre-provisioned suppliers used for load testing. # Thse suppliers will be progressively staked during the load test, according diff --git a/load-testing/tests/relays_stress_test.go b/load-testing/tests/relays_stress_test.go index a5e65a8c7..ca8c0f9ba 100644 --- a/load-testing/tests/relays_stress_test.go +++ b/load-testing/tests/relays_stress_test.go @@ -77,8 +77,8 @@ var ( // maxConcurrentRequestLimit is the maximum number of concurrent requests that can be made. // By default, it is set to the number of logical CPUs available to the process. maxConcurrentRequestLimit = runtime.GOMAXPROCS(0) - // fundingAccountAddress is the key name of the account used to fund other accounts. - fundingAccountAddress = "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw" // address for pnf account + // fundingAccountAddress is the address of the account used to fund other accounts. + fundingAccountAddress string // supplierStakeAmount is the amount of tokens to stake by suppliers. supplierStakeAmount sdk.Coin // gatewayStakeAmount is the amount of tokens to stake by gateways. @@ -191,7 +191,7 @@ type relaysSuite struct { // It is used to ensure that the suppliers are staked in the order they are provisioned. availableSupplierAddresses []string - // fundingAccountInfo is the account entry corresponding to the fundingAccountAddress. + // fundingAccountInfo is the account entry corresponding to the fundingAccountKeyName. // It is used to send transactions to fund other accounts. fundingAccountInfo *accountInfo // preparedGateways is the list of gateways that are already staked, delegated @@ -349,7 +349,7 @@ func (s *relaysSuite) LocalnetIsRunning() { s.setupTxEventListeners() // Initialize the funding account. - s.initFundingAccount(fundingAccountAddress) + s.initFundingAccount(loadTestParams.FundingAccountAddress) // Initialize the on-chain claims and proofs counter. s.countClaimAndProofs() From 4003ab385521795bc064d97565c1d2e440e0cb58 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 14:34:27 +0200 Subject: [PATCH 05/11] [Ring Client] refactor: ring client to use on-chain params (#556) Co-authored-by: Daniel Olshansky --- pkg/appgateserver/cmd/cmd.go | 1 + pkg/crypto/rings/cache_test.go | 6 ++- pkg/crypto/rings/client.go | 41 +++++++++++++++++-- testutil/keeper/proof.go | 7 ++++ testutil/keeper/tokenomics.go | 1 + testutil/testcrypto/rings/cache.go | 8 +--- testutil/testproxy/relayerproxy.go | 27 +++++++----- ...msg_server_undelegate_from_gateway_test.go | 27 ++++++++---- x/proof/keeper/keeper.go | 8 +++- .../keeper/msg_server_submit_proof_test.go | 2 + x/proof/module/module.go | 2 + x/proof/types/expected_keepers.go | 7 +++- x/proof/types/shared_query_client.go | 31 ++++++++++++++ 13 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 x/proof/types/shared_query_client.go diff --git a/pkg/appgateserver/cmd/cmd.go b/pkg/appgateserver/cmd/cmd.go index 5b76737b2..ff21d0ca8 100644 --- a/pkg/appgateserver/cmd/cmd.go +++ b/pkg/appgateserver/cmd/cmd.go @@ -198,6 +198,7 @@ func setupAppGateServerDependencies( config.NewSupplyAccountQuerierFn(), // leaf config.NewSupplyApplicationQuerierFn(), // leaf config.NewSupplySessionQuerierFn(), // leaf + config.NewSupplySharedQueryClientFn(), // leaf config.NewSupplyRingCacheFn(), config.NewSupplyPOKTRollSDKFn(appGateConfig.SigningKey), diff --git a/pkg/crypto/rings/cache_test.go b/pkg/crypto/rings/cache_test.go index 258f90ebd..0bc445b24 100644 --- a/pkg/crypto/rings/cache_test.go +++ b/pkg/crypto/rings/cache_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "cosmossdk.io/depinject" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/stretchr/testify/require" @@ -305,6 +306,9 @@ func createRingCache(ctx context.Context, t *testing.T, appAddress string) (cryp delegationClient := testdelegation.NewAnyTimesRedelegationsSequence(ctx, t, appAddress, redelegationObs) accQuerier := testqueryclients.NewTestAccountQueryClient(t) appQuerier := testqueryclients.NewTestApplicationQueryClient(t) - rc := testrings.NewRingCacheWithMockDependencies(ctx, t, accQuerier, appQuerier, delegationClient) + sharedQuerier := testqueryclients.NewTestSharedQueryClient(t) + + ringCacheDeps := depinject.Supply(accQuerier, appQuerier, delegationClient, sharedQuerier) + rc := testrings.NewRingCacheWithMockDependencies(ctx, t, ringCacheDeps) return rc, redelegationPublishCh } diff --git a/pkg/crypto/rings/client.go b/pkg/crypto/rings/client.go index b494c4892..a3a170ee3 100644 --- a/pkg/crypto/rings/client.go +++ b/pkg/crypto/rings/client.go @@ -17,6 +17,7 @@ import ( apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/service/types" "github.com/pokt-network/poktroll/x/shared" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) var _ crypto.RingClient = (*ringClient)(nil) @@ -33,6 +34,9 @@ type ringClient struct { // accountQuerier is used to fetch accounts for a given an account address. accountQuerier client.AccountQueryClient + + // sharedQuerier is used to fetch the shared module's parameters. + sharedQuerier client.SharedQueryClient } // NewRingClient returns a new ring client constructed from the given dependencies. @@ -50,6 +54,7 @@ func NewRingClient(deps depinject.Config) (_ crypto.RingClient, err error) { &rc.logger, &rc.accountQuerier, &rc.applicationQuerier, + &rc.sharedQuerier, ); err != nil { return nil, err } @@ -177,7 +182,10 @@ func (rc *ringClient) getRingPubKeysForAddress( // Reconstruct the delegatee gateway addresses at the given block height and // add them to the ring addresses. - delegateeGatewayAddresses := GetRingAddressesAtBlock(&app, blockHeight) + delegateeGatewayAddresses, err := rc.GetRingAddressesAtBlock(ctx, &app, blockHeight) + if err != nil { + return nil, err + } // Create a slice of addresses for the ring. ringAddresses := make([]string, 0) @@ -263,9 +271,36 @@ func (rc *ringClient) getRingPointsForAddressAtHeight( // should still be part of the ring at the given block height. // The ring addresses slice is reconstructed by adding back the past delegated // gateways that have been undelegated after the target session end height. -func GetRingAddressesAtBlock(app *apptypes.Application, blockHeight int64) []string { +func (rc *ringClient) GetRingAddressesAtBlock( + ctx context.Context, + app *apptypes.Application, + blockHeight int64, +) ([]string, error) { + // TODO_TECHDEBT(#543): We don't really want to have to query the params for every method call. + // Once `ModuleParamsClient` is implemented, use its replay observable's `#Last` method + // to get the most recently (asynchronously) observed (and cached) value. + // TODO_BLOCKER(#543): We also don't really want to use the current value of the params. + // Instead, we should be using the value that the params had for the session given by blockHeight. + sharedParams, err := rc.sharedQuerier.GetParams(ctx) + if err != nil { + return nil, err + } + return GetRingAddressesAtBlock(sharedParams, app, blockHeight), nil +} + +// GetRingAddressesAtBlock returns the active gateway addresses that need to be +// used to construct the ring in order to validate that the given app should pay for. +// It takes into account both active delegations and pending undelegations that +// should still be part of the ring at the given block height. +// The ring addresses slice is reconstructed by adding back the past delegated +// gateways that have been undelegated after the target session end height. +func GetRingAddressesAtBlock( + sharedParams *sharedtypes.Params, + app *apptypes.Application, + blockHeight int64, +) []string { // Get the target session end height at which we want to get the active delegations. - targetSessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(blockHeight)) + targetSessionEndHeight := uint64(shared.GetSessionEndHeight(sharedParams, blockHeight)) // Get the current active delegations for the application and use them as a base. activeDelegationsAtHeight := app.DelegateeGatewayAddresses diff --git a/testutil/keeper/proof.go b/testutil/keeper/proof.go index 7de11974e..d78454baa 100644 --- a/testutil/keeper/proof.go +++ b/testutil/keeper/proof.go @@ -57,6 +57,7 @@ type ProofModuleKeepers struct { prooftypes.SupplierKeeper prooftypes.ApplicationKeeper prooftypes.AccountKeeper + prooftypes.SharedKeeper Codec *codec.ProtoCodec } @@ -84,6 +85,7 @@ func ProofKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockSessionKeeper := mocks.NewMockSessionKeeper(ctrl) mockAppKeeper := mocks.NewMockApplicationKeeper(ctrl) mockAccountKeeper := mocks.NewMockAccountKeeper(ctrl) + mockSharedKeeper := mocks.NewMockSharedKeeper(ctrl) k := keeper.NewKeeper( cdc, @@ -93,6 +95,7 @@ func ProofKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockSessionKeeper, mockAppKeeper, mockAccountKeeper, + mockSharedKeeper, ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) @@ -114,6 +117,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul apptypes.StoreKey, gatewaytypes.StoreKey, authtypes.StoreKey, + sharedtypes.StoreKey, ) // Construct a multistore & mount store keys for each keeper that will interact with the state store. @@ -150,6 +154,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul logger, authority.String(), ) + require.NoError(t, sharedKeeper.SetParams(ctx, sharedtypes.DefaultParams())) // Construct gateway keeper with a mocked bank keeper. gatewayKeeper := gatewaykeeper.NewKeeper( @@ -206,6 +211,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul sessionKeeper, appKeeper, accountKeeper, + sharedKeeper, ) require.NoError(t, proofKeeper.SetParams(ctx, types.DefaultParams())) @@ -215,6 +221,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul SupplierKeeper: &supplierKeeper, ApplicationKeeper: &appKeeper, AccountKeeper: &accountKeeper, + SharedKeeper: &sharedKeeper, Codec: cdc, } diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index f02b0b262..337b34b99 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -303,6 +303,7 @@ func NewTokenomicsModuleKeepers( sessionKeeper, appKeeper, accountKeeper, + sharedKeeper, ) // Construct a real tokenomics keeper so that claims & tokenomics can be created. diff --git a/testutil/testcrypto/rings/cache.go b/testutil/testcrypto/rings/cache.go index ef25eb21b..640f24ba3 100644 --- a/testutil/testcrypto/rings/cache.go +++ b/testutil/testcrypto/rings/cache.go @@ -10,7 +10,6 @@ import ( "github.com/pokt-network/poktroll/pkg/crypto" "github.com/pokt-network/poktroll/pkg/crypto/rings" "github.com/pokt-network/poktroll/pkg/polylog" - "github.com/pokt-network/poktroll/testutil/mockclient" ) // NewRingCacheWithMockDependencies creates a new "real" RingCache with the given @@ -31,15 +30,12 @@ import ( func NewRingCacheWithMockDependencies( ctx context.Context, t *testing.T, - accQuerier *mockclient.MockAccountQueryClient, - appQuerier *mockclient.MockApplicationQueryClient, - delegationClient *mockclient.MockDelegationClient, + deps depinject.Config, ) crypto.RingCache { t.Helper() - // Create the dependency injector with the mock queriers logger := polylog.Ctx(ctx) - deps := depinject.Supply(logger, accQuerier, appQuerier, delegationClient) + deps = depinject.Configs(deps, depinject.Supply(logger)) ringCache, err := rings.NewRingCache(deps) require.NoError(t, err) diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index 19eaa905d..9c970f694 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -104,25 +104,30 @@ func WithRelayerProxyDependenciesForBlockHeight( applicationQueryClient := testqueryclients.NewTestApplicationQueryClient(test.t) sessionQueryClient := testqueryclients.NewTestSessionQueryClient(test.t) supplierQueryClient := testqueryclients.NewTestSupplierQueryClient(test.t) + sharedQueryClient := testqueryclients.NewTestSharedQueryClient(test.t) blockClient := testblock.NewAnyTimeLastBlockBlockClient(test.t, []byte{}, blockHeight) keyring, _ := testkeyring.NewTestKeyringWithKey(test.t, keyName) redelegationObs, _ := channel.NewReplayObservable[client.Redelegation](test.ctx, 1) delegationClient := testdelegation.NewAnyTimesRedelegationsSequence(test.ctx, test.t, "", redelegationObs) - ringCache := testrings.NewRingCacheWithMockDependencies(test.ctx, test.t, accountQueryClient, applicationQueryClient, delegationClient) - - deps := depinject.Supply( - logger, - accountQueryClient, - ringCache, - blockClient, - sessionQueryClient, - supplierQueryClient, - keyring, + + ringCacheDeps := depinject.Supply(accountQueryClient, applicationQueryClient, delegationClient, sharedQueryClient) + ringCache := testrings.NewRingCacheWithMockDependencies(test.ctx, test.t, ringCacheDeps) + + testDeps := depinject.Configs( + ringCacheDeps, + depinject.Supply( + logger, + ringCache, + blockClient, + sessionQueryClient, + supplierQueryClient, + keyring, + ), ) - test.Deps = deps + test.Deps = testDeps } } diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index 224b8f3c9..97bdce637 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -14,6 +14,7 @@ import ( "github.com/pokt-network/poktroll/testutil/sample" "github.com/pokt-network/poktroll/x/application/keeper" "github.com/pokt-network/poktroll/x/application/types" + apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -326,7 +327,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t require.Contains(t, app.DelegateeGatewayAddresses, delegateAddr) // Verify that the reconstructed delegatee gateway list includes the undelegated gateway. - gatewayAddresses := rings.GetRingAddressesAtBlock(&app, sdkCtx.BlockHeight()) + gatewayAddresses := getRingAddressesAtBlockWithDefaultParams(&app, sdkCtx.BlockHeight()) require.Contains(t, gatewayAddresses, pendingUndelegateFromAddr) // Increment the block height to the next session and run the pruning @@ -342,7 +343,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that when queried for the next session the reconstructed delegatee // gateway list does not include the undelegated gateway. - nextSessionGatewayAddresses := rings.GetRingAddressesAtBlock(&app, nextSessionStartHeight) + nextSessionGatewayAddresses := getRingAddressesAtBlockWithDefaultParams(&app, nextSessionStartHeight) require.NotContains(t, nextSessionGatewayAddresses, pendingUndelegateFromAddr) // Increment the block height past the tested session's grace period and run @@ -353,13 +354,13 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that when queried for a block height past the tested session's grace period, // the reconstructed delegatee gateway list does not include the undelegated gateway. - pastGracePeriodGatewayAddresses := rings.GetRingAddressesAtBlock(&app, afterSessionGracePeriodHeight) + pastGracePeriodGatewayAddresses := getRingAddressesAtBlockWithDefaultParams(&app, afterSessionGracePeriodHeight) require.NotContains(t, pastGracePeriodGatewayAddresses, pendingUndelegateFromAddr) // Ensure that when queried for the block height corresponding to the session // at which the undelegation occurred, the reconstructed delegatee gateway list // includes the undelegated gateway. - gatewayAddressesBeforeUndelegation := rings.GetRingAddressesAtBlock(&app, int64(sessionEndHeight)) + gatewayAddressesBeforeUndelegation := getRingAddressesAtBlockWithDefaultParams(&app, int64(sessionEndHeight)) require.Contains(t, gatewayAddressesBeforeUndelegation, pendingUndelegateFromAddr) } @@ -389,7 +390,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsPrunedAfterRetentionPeriod( // Verify that the reconstructed delegatee gateway list can no longer include // the undelegated gateway since it has been pruned. - gatewayAddressesAfterPruning := rings.GetRingAddressesAtBlock(&app, undelegationHeight) + gatewayAddressesAfterPruning := getRingAddressesAtBlockWithDefaultParams(&app, undelegationHeight) require.NotContains(t, gatewayAddressesAfterPruning, pendingUndelegateFromAddr) require.Contains(t, gatewayAddressesAfterPruning, delegateAddr) } @@ -430,7 +431,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS ) // Verify that the reconstructed delegatee gateway list includes the redelegated gateway. - gatewayAddresses := rings.GetRingAddressesAtBlock(&app, sdkCtx.BlockHeight()) + gatewayAddresses := getRingAddressesAtBlockWithDefaultParams(&app, sdkCtx.BlockHeight()) require.Contains(t, gatewayAddresses, gatewayAddrToRedelegate) // Increment the block height past the undelegation retention period then run @@ -452,7 +453,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS require.Empty(t, app.PendingUndelegations[sessionEndHeight]) // Verify that the reconstructed delegatee gateway list includes the redelegated gateway - gatewayAddressesAfterPruning := rings.GetRingAddressesAtBlock(&app, sdkCtx.BlockHeight()) + gatewayAddressesAfterPruning := getRingAddressesAtBlockWithDefaultParams(&app, sdkCtx.BlockHeight()) require.Contains(t, gatewayAddressesAfterPruning, gatewayAddrToRedelegate) } @@ -545,3 +546,15 @@ func getNumBlocksUndelegationRetentionWithDefaultParams() int64 { sharedParams := sharedtypes.DefaultParams() return keeper.GetNumBlocksUndelegationRetention(&sharedParams) } + +// getRingAddressesAtBlockWithDefaultParams returns the active gateway addresses that +// need to be used to construct the ring in order to validate that the given app should +// pay for. +// It takes into account both active delegations and pending undelegations that +// should still be part of the ring at the given block height. +// The ring addresses slice is reconstructed by adding back the past delegated +// gateways that have been undelegated after the target session end height. +func getRingAddressesAtBlockWithDefaultParams(app *apptypes.Application, blockHeight int64) []string { + sharedParams := sharedtypes.DefaultParams() + return rings.GetRingAddressesAtBlock(&sharedParams, app, blockHeight) +} diff --git a/x/proof/keeper/keeper.go b/x/proof/keeper/keeper.go index 4a6c69268..c12e9ee05 100644 --- a/x/proof/keeper/keeper.go +++ b/x/proof/keeper/keeper.go @@ -30,9 +30,11 @@ type ( sessionKeeper types.SessionKeeper applicationKeeper types.ApplicationKeeper + sharedKeeper types.SharedKeeper ringClient crypto.RingClient accountQuerier client.AccountQueryClient + sharedQuerier client.SharedQueryClient } ) @@ -45,6 +47,7 @@ func NewKeeper( sessionKeeper types.SessionKeeper, applicationKeeper types.ApplicationKeeper, accountKeeper types.AccountKeeper, + sharedKeeper types.SharedKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -54,6 +57,7 @@ func NewKeeper( polylogger := polylog.Ctx(context.Background()) applicationQuerier := types.NewAppKeeperQueryClient(applicationKeeper) accountQuerier := types.NewAccountKeeperQueryClient(accountKeeper) + sharedQuerier := types.NewSharedKeeperQueryClient(sharedKeeper) // RingKeeperClient holds the logic of verifying RelayRequests ring signatures // for both on-chain and off-chain actors. @@ -70,7 +74,7 @@ func NewKeeper( // application ring retrieval to the application keeper, and making it // retrievable using the application query client for off-chain actors. Signature // verification code will still be shared across off/on chain environments. - ringKeeperClientDeps := depinject.Supply(polylogger, applicationQuerier, accountQuerier) + ringKeeperClientDeps := depinject.Supply(polylogger, applicationQuerier, accountQuerier, sharedQuerier) ringKeeperClient, err := rings.NewRingClient(ringKeeperClientDeps) if err != nil { panic(err) @@ -84,9 +88,11 @@ func NewKeeper( sessionKeeper: sessionKeeper, applicationKeeper: applicationKeeper, + sharedKeeper: sharedKeeper, ringClient: ringKeeperClient, accountQuerier: accountQuerier, + sharedQuerier: sharedQuerier, } } diff --git a/x/proof/keeper/msg_server_submit_proof_test.go b/x/proof/keeper/msg_server_submit_proof_test.go index dcad1c395..a28673b6f 100644 --- a/x/proof/keeper/msg_server_submit_proof_test.go +++ b/x/proof/keeper/msg_server_submit_proof_test.go @@ -96,6 +96,7 @@ func TestMsgServer_SubmitProof_Success(t *testing.T) { polyzero.NewLogger(), types.NewAppKeeperQueryClient(keepers.ApplicationKeeper), types.NewAccountKeeperQueryClient(keepers.AccountKeeper), + types.NewSharedKeeperQueryClient(keepers.SharedKeeper), )) require.NoError(t, err) @@ -213,6 +214,7 @@ func TestMsgServer_SubmitProof_Error(t *testing.T) { polyzero.NewLogger(), types.NewAppKeeperQueryClient(keepers.ApplicationKeeper), types.NewAccountKeeperQueryClient(keepers.AccountKeeper), + types.NewSharedKeeperQueryClient(keepers.SharedKeeper), )) require.NoError(t, err) diff --git a/x/proof/module/module.go b/x/proof/module/module.go index 07ba82954..d102c2e2d 100644 --- a/x/proof/module/module.go +++ b/x/proof/module/module.go @@ -177,6 +177,7 @@ type ModuleInputs struct { SessionKeeper types.SessionKeeper ApplicationKeeper types.ApplicationKeeper AccountKeeper types.AccountKeeper + SharedKeeper types.SharedKeeper } type ModuleOutputs struct { @@ -200,6 +201,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.SessionKeeper, in.ApplicationKeeper, in.AccountKeeper, + in.SharedKeeper, ) m := NewAppModule( in.Cdc, diff --git a/x/proof/types/expected_keepers.go b/x/proof/types/expected_keepers.go index 9be7dfc0f..f7eb8dd8f 100644 --- a/x/proof/types/expected_keepers.go +++ b/x/proof/types/expected_keepers.go @@ -1,4 +1,4 @@ -//go:generate mockgen -destination=../../../testutil/proof/mocks/expected_keepers_mock.go -package=mocks . BankKeeper,SessionKeeper,ApplicationKeeper,AccountKeeper +//go:generate mockgen -destination=../../../testutil/proof/mocks/expected_keepers_mock.go -package=mocks . BankKeeper,SessionKeeper,ApplicationKeeper,AccountKeeper,SharedKeeper package types @@ -48,3 +48,8 @@ type ApplicationKeeper interface { GetAllApplications(ctx context.Context) []apptypes.Application SetApplication(context.Context, apptypes.Application) } + +// SharedKeeper defines the expected interface needed to retrieve shared information. +type SharedKeeper interface { + GetParams(ctx context.Context) sharedtypes.Params +} diff --git a/x/proof/types/shared_query_client.go b/x/proof/types/shared_query_client.go new file mode 100644 index 000000000..ea2a016a1 --- /dev/null +++ b/x/proof/types/shared_query_client.go @@ -0,0 +1,31 @@ +package types + +import ( + "context" + + "github.com/pokt-network/poktroll/pkg/client" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +var _ client.SharedQueryClient = (*SharedKeeperQueryClient)(nil) + +// SharedKeeperQueryClient is a thin wrapper around the SharedKeeper. +// It does not rely on the QueryClient, and therefore does not make any +// network requests as in the off-chain implementation. +type SharedKeeperQueryClient struct { + keeper SharedKeeper +} + +// NewSharedKeeperQueryClient returns a new SharedQueryClient that is backed +// by an SharedKeeper instance. +func NewSharedKeeperQueryClient(sharedKeeper SharedKeeper) client.SharedQueryClient { + return &SharedKeeperQueryClient{keeper: sharedKeeper} +} + +// GetParams queries & returns the shared module on-chain parameters. +func (sharedQueryClient *SharedKeeperQueryClient) GetParams( + ctx context.Context, +) (params *sharedtypes.Params, err error) { + sharedParams := sharedQueryClient.keeper.GetParams(ctx) + return &sharedParams, nil +} From 72d3e477999a007908ce6dacf18ccd4be5d37215 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 14:51:07 +0200 Subject: [PATCH 06/11] [Session Module] refactor: session module fetches on-chain params (#557) Co-authored-by: Daniel Olshansky --- testutil/keeper/proof.go | 1 + testutil/keeper/session.go | 13 +++++ testutil/keeper/tokenomics.go | 1 + .../testqueryclients/sessionquerier.go | 4 +- testutil/testproxy/relayerproxy.go | 2 +- x/session/keeper/keeper.go | 3 + x/session/keeper/session_hydrator.go | 58 ++++++++++++++----- x/session/module/module.go | 2 + x/session/types/expected_keepers.go | 8 ++- 9 files changed, 75 insertions(+), 17 deletions(-) diff --git a/testutil/keeper/proof.go b/testutil/keeper/proof.go index d78454baa..35ab490db 100644 --- a/testutil/keeper/proof.go +++ b/testutil/keeper/proof.go @@ -199,6 +199,7 @@ func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModul sessionmocks.NewMockBankKeeper(ctrl), appKeeper, supplierKeeper, + sharedKeeper, ) require.NoError(t, sessionKeeper.SetParams(ctx, sessiontypes.DefaultParams())) diff --git a/testutil/keeper/session.go b/testutil/keeper/session.go index f70d9a5e6..517643c8e 100644 --- a/testutil/keeper/session.go +++ b/testutil/keeper/session.go @@ -134,6 +134,7 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockAppKeeper := defaultAppKeeperMock(t) mockSupplierKeeper := defaultSupplierKeeperMock(t) + mockSharedKeeper := defaultSharedKeeperMock(t) k := keeper.NewKeeper( cdc, @@ -144,6 +145,7 @@ func SessionKeeper(t testing.TB) (keeper.Keeper, context.Context) { mockBankKeeper, mockAppKeeper, mockSupplierKeeper, + mockSharedKeeper, ) // TODO_TECHDEBT: See the comment at the bottom of this file explaining @@ -216,6 +218,17 @@ func defaultSupplierKeeperMock(t testing.TB) types.SupplierKeeper { return mockSupplierKeeper } +func defaultSharedKeeperMock(t testing.TB) types.SharedKeeper { + t.Helper() + ctrl := gomock.NewController(t) + + mockSharedKeeper := mocks.NewMockSharedKeeper(ctrl) + mockSharedKeeper.EXPECT().GetParams(gomock.Any()). + Return(sharedtypes.DefaultParams()). + AnyTimes() + return mockSharedKeeper +} + // TODO_TECHDEBT: Figure out how to vary the supplierKeep on a per test basis with exposing `SupplierKeeper publically` // type option[V any] func(k *keeper.Keeper) diff --git a/testutil/keeper/tokenomics.go b/testutil/keeper/tokenomics.go index 337b34b99..6b8e8f17e 100644 --- a/testutil/keeper/tokenomics.go +++ b/testutil/keeper/tokenomics.go @@ -291,6 +291,7 @@ func NewTokenomicsModuleKeepers( bankKeeper, appKeeper, supplierKeeper, + sharedKeeper, ) require.NoError(t, sessionKeeper.SetParams(ctx, sessiontypes.DefaultParams())) diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index 1b0c3c992..f9a30cbe0 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -48,7 +48,7 @@ func NewTestSessionQueryClient( serviceId string, blockHeight int64, ) (session *sessiontypes.Session, err error) { - sessionId, _ := sessionkeeper.GetSessionId(address, serviceId, blockHashBz, blockHeight) + sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(address, serviceId, blockHashBz, blockHeight) session, ok := sessionsMap[sessionId] if !ok { @@ -73,7 +73,7 @@ func AddToExistingSessions( ) { t.Helper() - sessionId, _ := sessionkeeper.GetSessionId(appAddress, serviceId, blockHashBz, blockHeight) + sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) session := sessiontypes.Session{ Header: &sessiontypes.SessionHeader{ diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index 9c970f694..21071e88c 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -406,7 +406,7 @@ func GenerateRelayRequest( payload []byte, ) *servicetypes.RelayRequest { appAddress := GetAddressFromPrivateKey(test, privKey) - sessionId, _ := sessionkeeper.GetSessionId(appAddress, serviceId, blockHashBz, blockHeight) + sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) return &servicetypes.RelayRequest{ Meta: servicetypes.RelayRequestMetadata{ diff --git a/x/session/keeper/keeper.go b/x/session/keeper/keeper.go index 45b6b0d20..e292b107e 100644 --- a/x/session/keeper/keeper.go +++ b/x/session/keeper/keeper.go @@ -28,6 +28,7 @@ type ( bankKeeper types.BankKeeper applicationKeeper types.ApplicationKeeper supplierKeeper types.SupplierKeeper + sharedKeeper types.SharedKeeper } ) @@ -41,6 +42,7 @@ func NewKeeper( bankKeeper types.BankKeeper, applicationKeeper types.ApplicationKeeper, supplierKeeper types.SupplierKeeper, + sharedKeeper types.SharedKeeper, ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -56,6 +58,7 @@ func NewKeeper( bankKeeper: bankKeeper, applicationKeeper: applicationKeeper, supplierKeeper: supplierKeeper, + sharedKeeper: sharedKeeper, } } diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 0e397ccd8..6e03cb8b9 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -99,14 +99,14 @@ func (k Keeper) hydrateSessionMetadata(ctx context.Context, sh *sessionHydrator) ) } - // TODO_UPNEXT(#517): Refactor session module to use current on-chain shared - // parameters instead of their corresponding constant stand-ins. - - sh.session.NumBlocksPerSession = shared.NumBlocksPerSession - sh.session.SessionNumber = shared.GetSessionNumberWithDefaultParams(sh.blockHeight) - - sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartHeightWithDefaultParams(sh.blockHeight) - sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndHeightWithDefaultParams(sh.blockHeight) + // TODO_BLOCKER(#543): If the num_blocks_per_session param has ever been changed, + // this function may cause unexpected behavior for historical sessions. + sharedParams := k.sharedKeeper.GetParams(ctx) + sh.session.NumBlocksPerSession = int64(sharedParams.NumBlocksPerSession) + sh.session.SessionNumber = shared.GetSessionNumber(&sharedParams, sh.blockHeight) + + sh.sessionHeader.SessionStartBlockHeight = shared.GetSessionStartHeight(&sharedParams, sh.blockHeight) + sh.sessionHeader.SessionEndBlockHeight = shared.GetSessionEndHeight(&sharedParams, sh.blockHeight) return nil } @@ -121,7 +121,8 @@ func (k Keeper) hydrateSessionID(ctx context.Context, sh *sessionHydrator) error return types.ErrSessionHydration.Wrapf("invalid service: %v", sh.sessionHeader.Service) } - sh.sessionHeader.SessionId, sh.sessionIDBz = GetSessionId( + sh.sessionHeader.SessionId, sh.sessionIDBz = k.GetSessionId( + ctx, sh.sessionHeader.ApplicationAddress, sh.sessionHeader.Service.Id, prevHashBz, @@ -269,7 +270,37 @@ func sha3Hash(bz []byte) []byte { // GetSessionId returns the string and bytes representation of the sessionId // given the application public key, service ID, block hash, and block height // that is used to get the session start block height. +func (k Keeper) GetSessionId( + ctx context.Context, + appPubKey, + serviceId string, + blockHashBz []byte, + blockHeight int64, +) (sessionId string, sessionIdBz []byte) { + sharedParams := k.sharedKeeper.GetParams(ctx) + return GetSessionId(&sharedParams, appPubKey, serviceId, blockHashBz, blockHeight) +} + +// GetSessionIdWithDefaultParams returns the string and bytes representation of the +// sessionId for the session containing blockHeight, given the default shared on-chain +// parameters, application public key, service ID, and block hash. +// +// TODO_TECHDEBT(#517): Move this to a shared testutil. +func GetSessionIdWithDefaultParams( + appPubKey, + serviceId string, + blockHashBz []byte, + blockHeight int64, +) (sessionId string, sessionIdBz []byte) { + sharedParams := sharedtypes.DefaultParams() + return GetSessionId(&sharedParams, appPubKey, serviceId, blockHashBz, blockHeight) +} + +// GetSessionId returns the string and bytes representation of the sessionId for the +// session containing blockHeight, given the shared on-chain parameters, application +// public key, service ID, and block hash. func GetSessionId( + sharedParams *sharedtypes.Params, appPubKey, serviceId string, blockHashBz []byte, @@ -278,7 +309,7 @@ func GetSessionId( appPubKeyBz := []byte(appPubKey) serviceIdBz := []byte(serviceId) - blockHeightBz := getSessionStartBlockHeightBz(blockHeight) + blockHeightBz := getSessionStartBlockHeightBz(sharedParams, blockHeight) sessionIdBz = concatWithDelimiter( SessionIDComponentDelimiter, blockHashBz, @@ -292,9 +323,10 @@ func GetSessionId( } // getSessionStartBlockHeightBz returns the bytes representation of the session -// start block height given the block height. -func getSessionStartBlockHeightBz(blockHeight int64) []byte { - sessionStartBlockHeight := shared.GetSessionStartHeightWithDefaultParams(blockHeight) +// start height for the session containing blockHeight, given the shared on-chain +// parameters. +func getSessionStartBlockHeightBz(sharedParams *sharedtypes.Params, blockHeight int64) []byte { + sessionStartBlockHeight := shared.GetSessionStartHeight(sharedParams, blockHeight) sessionStartBlockHeightBz := make([]byte, 8) binary.LittleEndian.PutUint64(sessionStartBlockHeightBz, uint64(sessionStartBlockHeight)) return sessionStartBlockHeightBz diff --git a/x/session/module/module.go b/x/session/module/module.go index d37744b35..3738b5331 100644 --- a/x/session/module/module.go +++ b/x/session/module/module.go @@ -190,6 +190,7 @@ type ModuleInputs struct { BankKeeper types.BankKeeper ApplicationKeeper types.ApplicationKeeper SupplierKeeper types.SupplierKeeper + SharedKeeper types.SharedKeeper } type ModuleOutputs struct { @@ -214,6 +215,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.BankKeeper, in.ApplicationKeeper, in.SupplierKeeper, + in.SharedKeeper, ) m := NewAppModule( in.Cdc, diff --git a/x/session/types/expected_keepers.go b/x/session/types/expected_keepers.go index 560226293..1af629d7f 100644 --- a/x/session/types/expected_keepers.go +++ b/x/session/types/expected_keepers.go @@ -1,4 +1,4 @@ -//go:generate mockgen -destination ../../../testutil/session/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,SupplierKeeper +//go:generate mockgen -destination ../../../testutil/session/mocks/expected_keepers_mock.go -package mocks . AccountKeeper,BankKeeper,ApplicationKeeper,SupplierKeeper,SharedKeeper package types @@ -26,6 +26,12 @@ type ApplicationKeeper interface { GetApplication(ctx context.Context, address string) (app apptypes.Application, found bool) } +// SupplierKeeper defines the expected interface needed to retrieve suppliers type SupplierKeeper interface { GetAllSuppliers(ctx context.Context) (suppliers []sharedtypes.Supplier) } + +// SharedKeeper defines the expected interface needed to retrieve shared parameters +type SharedKeeper interface { + GetParams(ctx context.Context) (params sharedtypes.Params) +} From 862b793d00df09ef38a32897741e77edb91b5ffd Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 15:17:39 +0200 Subject: [PATCH 07/11] [Code Health] chore: resolve & cleanup outstanding `TODO_TECHDEBT(#517)` comments (#559) Co-authored-by: Daniel Olshansky --- Makefile | 4 +- .../tests/relays_stress_helpers_test.go | 60 +++++++++++++------ load-testing/tests/relays_stress_test.go | 11 +++- pkg/client/interface.go | 3 + pkg/client/tx/context.go | 5 ++ pkg/relayer/proxy/proxy_test.go | 2 +- testutil/keeper/application.go | 4 +- testutil/session/session.go | 45 ++++++++++++++ .../testqueryclients/sessionquerier.go | 15 +++-- testutil/testproxy/relayerproxy.go | 11 ++-- ...msg_server_undelegate_from_gateway_test.go | 9 +-- .../keeper/msg_server_create_claim_test.go | 4 +- x/proof/keeper/proof_test.go | 4 +- x/proof/module/helpers_test.go | 8 +-- x/proof/module/query_claim_test.go | 8 +-- x/proof/types/message_submit_proof_test.go | 10 ++-- x/session/keeper/session_hydrator.go | 15 ----- x/shared/session.go | 39 +----------- x/tokenomics/keeper/keeper_test.go | 4 +- .../keeper/settle_session_accounting_test.go | 8 +-- 20 files changed, 150 insertions(+), 119 deletions(-) create mode 100644 testutil/session/session.go diff --git a/Makefile b/Makefile index 01d9ad9a4..3372ea32a 100644 --- a/Makefile +++ b/Makefile @@ -390,8 +390,8 @@ test_load_relays_stress: ## Run the stress test for E2E relays on non-ephemeral -tags=load,test -run LoadRelays --log-level=debug --timeout=30m \ --manifest ./load-testing/loadtest_manifest.yaml -.PHONY: test_localnet_load_relays_stress -test_localnet_load_relays_stress: test_e2e_env ## Run the stress test for E2E relays. +.PHONY: test_load_relays_stress_localnet +test_load_relays_stress_localnet: test_e2e_env ## Run the stress test for E2E relays. go test -v -count=1 ./load-testing/tests/... \ -tags=load,test -run LoadRelays --log-level=debug --timeout=30m \ --manifest ./load-testing/localnet_loadtest_manifest.yaml diff --git a/load-testing/tests/relays_stress_helpers_test.go b/load-testing/tests/relays_stress_helpers_test.go index 8acb4dc42..f16c4f0d0 100644 --- a/load-testing/tests/relays_stress_helpers_test.go +++ b/load-testing/tests/relays_stress_helpers_test.go @@ -32,9 +32,11 @@ import ( "github.com/pokt-network/poktroll/load-testing/config" "github.com/pokt-network/poktroll/pkg/client" "github.com/pokt-network/poktroll/pkg/client/events" + "github.com/pokt-network/poktroll/pkg/client/query" "github.com/pokt-network/poktroll/pkg/client/tx" "github.com/pokt-network/poktroll/pkg/observable/channel" "github.com/pokt-network/poktroll/pkg/sync2" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/testutil/testclient" "github.com/pokt-network/poktroll/testutil/testclient/testeventsquery" apptypes "github.com/pokt-network/poktroll/x/application/types" @@ -173,9 +175,9 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn( sessionInfo := &sessionInfoNotif{ blockHeight: blockHeight, - sessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), - sessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), - sessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), + sessionNumber: testsession.GetSessionNumberWithDefaultParams(blockHeight), + sessionStartBlockHeight: testsession.GetSessionStartHeightWithDefaultParams(blockHeight), + sessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(blockHeight), } infoLogger := logger.Info(). @@ -187,7 +189,7 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn( if waitingForFirstSession && blockHeight != sessionInfo.sessionStartBlockHeight { countDownToTestStart := sessionInfo.sessionEndBlockHeight - blockHeight + 1 infoLogger.Msgf( - "waiting for next session to start: in %d blocks", + "waiting for next testsession to start: in %d blocks", countDownToTestStart, ) @@ -269,7 +271,7 @@ func (s *relaysSuite) validateActorLoadTestIncrementPlans(plans *actorLoadTestIn } plans.validateAppSupplierPermutations(s) - plans.validateIncrementRates(s) + plans.validateIncrementRates(s, s.sharedParams) plans.validateMaxAmounts(s) require.Truef(s, @@ -328,17 +330,22 @@ func (plans *actorLoadTestIncrementPlans) validateAppSupplierPermutations(t gocu // validateIncrementRates ensures that the increment rates are multiples of the session length. // Otherwise, the expected baseline for several metrics will be periodically skewed. -func (plans *actorLoadTestIncrementPlans) validateIncrementRates(t gocuke.TestingT) { +func (plans *actorLoadTestIncrementPlans) validateIncrementRates( + t gocuke.TestingT, + sharedParams *sharedtypes.Params, +) { + numBlocksPerSession := int64(sharedParams.GetNumBlocksPerSession()) + require.Truef(t, - plans.gateways.blocksPerIncrement%shared.NumBlocksPerSession == 0, + plans.gateways.blocksPerIncrement%numBlocksPerSession == 0, "gateway increment rate must be a multiple of the session length", ) require.Truef(t, - plans.suppliers.blocksPerIncrement%shared.NumBlocksPerSession == 0, + plans.suppliers.blocksPerIncrement%numBlocksPerSession == 0, "supplier increment rate must be a multiple of the session length", ) require.Truef(t, - plans.apps.blocksPerIncrement%shared.NumBlocksPerSession == 0, + plans.apps.blocksPerIncrement%numBlocksPerSession == 0, "app increment rate must be a multiple of the session length", ) } @@ -364,7 +371,7 @@ func (plans *actorLoadTestIncrementPlans) validateMaxAmounts(t gocuke.TestingT) // totalDurationBlocks returns the number of blocks which will have elapsed when the // proof corresponding to the session in which the maxActorCount for the given actor // has been committed. -func (plans *actorLoadTestIncrementPlans) totalDurationBlocks() int64 { +func (plans *actorLoadTestIncrementPlans) totalDurationBlocks(sharedParams *sharedtypes.Params) int64 { // The last block of the last session SHOULD align with the last block of the // last increment duration (i.e. **after** maxActorCount actors are activated). blocksToLastSessionEnd := plans.maxActorBlocksToFinalIncrementEnd() @@ -373,7 +380,7 @@ func (plans *actorLoadTestIncrementPlans) totalDurationBlocks() int64 { // Add one session length so that the duration is inclusive of the block which // commits the last session's proof. - return blocksToLastProofWindowEnd + shared.NumBlocksPerSession + return blocksToLastProofWindowEnd + int64(sharedParams.GetNumBlocksPerSession()) } // blocksToFinalIncrementStart returns the number of blocks that will have @@ -416,19 +423,19 @@ func (s *relaysSuite) mapSessionInfoWhenStakingNewSuppliersAndGatewaysFn( // available for the beginning of the next one. // This is because the suppliers involvement is out of control of the test // suite and is driven by the AppGateServer's supplier endpoint selection. - if suppliersPlan.shouldIncrementSupplierCount(notif, activeSuppliers, s.testStartHeight) { + if suppliersPlan.shouldIncrementSupplierCount(s.sharedParams, notif, activeSuppliers, s.testStartHeight) { newSuppliers = s.sendStakeSuppliersTxs(notif, &suppliersPlan) } var newGateways []*accountInfo activeGateways := int64(len(s.activeGateways)) - if gatewaysPlan.shouldIncrementActorCount(notif, activeGateways, s.testStartHeight) { + if gatewaysPlan.shouldIncrementActorCount(s.sharedParams, notif, activeGateways, s.testStartHeight) { newGateways = s.sendStakeGatewaysTxs(notif, &gatewaysPlan) } var newApps []*accountInfo activeApps := int64(len(s.activeApplications)) - if appsPlan.shouldIncrementActorCount(notif, activeApps, s.testStartHeight) { + if appsPlan.shouldIncrementActorCount(s.sharedParams, notif, activeApps, s.testStartHeight) { newApps = s.sendFundNewAppsTx(notif, &appsPlan) } @@ -711,6 +718,7 @@ func (s *relaysSuite) sendDelegateInitialAppsTxs(apps, gateways []*accountInfo) // // TODO_UPNEXT(@red-One, @bryanchriswhite) move to a new file. func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( + sharedParams *sharedtypes.Params, sessionInfo *sessionInfoNotif, actorCount int64, startBlockHeight int64, @@ -720,9 +728,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( return false } - initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) + initialSessionNumber := testsession.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. - actorSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession + actorSessionIncRate := plan.blocksPerIncrement / int64(sharedParams.GetNumBlocksPerSession()) nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber isSessionStartHeight := sessionInfo.blockHeight == sessionInfo.sessionStartBlockHeight isActorIncrementHeight := nextSessionNumber%actorSessionIncRate == 0 @@ -737,6 +745,7 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementActorCount( // Suppliers stake transactions are sent at the end of the session so they are // available for the beginning of the next one. func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( + sharedParams *sharedtypes.Params, sessionInfo *sessionInfoNotif, actorCount int64, startBlockHeight int64, @@ -746,9 +755,9 @@ func (plan *actorLoadTestIncrementPlan) shouldIncrementSupplierCount( return false } - initialSessionNumber := shared.GetSessionNumberWithDefaultParams(startBlockHeight) + initialSessionNumber := testsession.GetSessionNumberWithDefaultParams(startBlockHeight) // TODO_TECHDEBT(#21): replace with gov param query when available. - supplierSessionIncRate := plan.blocksPerIncrement / shared.NumBlocksPerSession + supplierSessionIncRate := plan.blocksPerIncrement / int64(sharedParams.GetNumBlocksPerSession()) nextSessionNumber := sessionInfo.sessionNumber + 1 - initialSessionNumber isSessionEndHeight := sessionInfo.blockHeight == sessionInfo.sessionEndBlockHeight isActorIncrementHeight := nextSessionNumber%supplierSessionIncRate == 0 @@ -1352,6 +1361,21 @@ func (s *relaysSuite) countClaimAndProofs() { ) } +// querySharedParams queries the current on-chain shared module parameters for use +// over the duration of the test. +func (s *relaysSuite) querySharedParams() { + s.Helper() + + deps := depinject.Supply(s.txContext.GetClientCtx()) + sharedQueryClient, err := query.NewSharedQuerier(deps) + require.NoError(s, err) + + sharedParams, err := sharedQueryClient.GetParams(s.ctx) + require.NoError(s, err) + + s.sharedParams = sharedParams +} + // forEachStakedAndDelegatedAppPrepareApp is a ForEachFn that waits for txs which // were broadcast in previous pipeline stages have been committed. It ensures that // new applications were successfully staked and all application actors are delegated diff --git a/load-testing/tests/relays_stress_test.go b/load-testing/tests/relays_stress_test.go index ca8c0f9ba..c36b4f9ad 100644 --- a/load-testing/tests/relays_stress_test.go +++ b/load-testing/tests/relays_stress_test.go @@ -15,10 +15,11 @@ import ( "cosmossdk.io/math" "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/pokt-network/poktroll/testutil/testclient" "github.com/regen-network/gocuke" "github.com/stretchr/testify/require" + "github.com/pokt-network/poktroll/testutil/testclient" + "github.com/pokt-network/poktroll/cmd/signals" "github.com/pokt-network/poktroll/pkg/client" "github.com/pokt-network/poktroll/pkg/observable" @@ -133,6 +134,9 @@ type relaysSuite struct { newTxEventsObs observable.Observable[*types.TxResult] // txContext is the transaction context used to sign and send transactions. txContext client.TxContext + // sharedParams is the shared on-chain parameters used in the test. + // It is queried at the beginning of the test. + sharedParams *sharedtypes.Params // numRelaysSent is the number of relay requests sent during the test. numRelaysSent atomic.Uint64 @@ -354,6 +358,9 @@ func (s *relaysSuite) LocalnetIsRunning() { // Initialize the on-chain claims and proofs counter. s.countClaimAndProofs() + // Query for the current shared on-chain params. + s.querySharedParams() + // Some suppliers may already be staked at genesis, ensure that staking during // this test succeeds by increasing the sake amount. minStakeAmount := s.getProvisionedActorsCurrentStakedAmount() @@ -395,7 +402,7 @@ func (s *relaysSuite) MoreActorsAreStakedAsFollows(table gocuke.DataTable) { // The test duration indicates when the test is complete. // It is calculated as the relay load duration plus the time it takes to // submit all claims and proofs. - s.testDurationBlocks = plans.totalDurationBlocks() + s.testDurationBlocks = plans.totalDurationBlocks(s.sharedParams) if s.isEphemeralChain { // Adjust the max delegations parameter to the max gateways to permit all diff --git a/pkg/client/interface.go b/pkg/client/interface.go index 3f801bf6b..0383d22e2 100644 --- a/pkg/client/interface.go +++ b/pkg/client/interface.go @@ -102,6 +102,9 @@ type TxContext interface { txHash []byte, prove bool, ) (*cometrpctypes.ResultTx, error) + + // GetClientCtx returns the cosmos-sdk client context associated with the transaction context. + GetClientCtx() cosmosclient.Context } // Block is an interface which abstracts the details of a block to its minimal diff --git a/pkg/client/tx/context.go b/pkg/client/tx/context.go index 6ee1525cf..5f9c694ea 100644 --- a/pkg/client/tx/context.go +++ b/pkg/client/tx/context.go @@ -98,3 +98,8 @@ func (txCtx cosmosTxContext) QueryTx( ) (*cometrpctypes.ResultTx, error) { return txCtx.clientCtx.Client.Tx(ctx, txHash, prove) } + +// GetClientCtx returns the cosmos-sdk client context associated with the transaction context. +func (txCtx cosmosTxContext) GetClientCtx() cosmosclient.Context { + return cosmosclient.Context(txCtx.clientCtx) +} diff --git a/pkg/relayer/proxy/proxy_test.go b/pkg/relayer/proxy/proxy_test.go index 15a5d9866..4140b85b2 100644 --- a/pkg/relayer/proxy/proxy_test.go +++ b/pkg/relayer/proxy/proxy_test.go @@ -347,7 +347,7 @@ func TestRelayerProxy_Relays(t *testing.T) { // session's grace period and within the second session's grace period, // meaning a relay should not be handled at this block height. blockOutsideSessionGracePeriod := int64(blockHeight + - shared.NumBlocksPerSession + + sharedtypes.DefaultNumBlocksPerSession + shared.SessionGracePeriodBlocks) // blockWithinSessionGracePeriod is the block height that is after the first diff --git a/testutil/keeper/application.go b/testutil/keeper/application.go index 6680497d3..97d578a09 100644 --- a/testutil/keeper/application.go +++ b/testutil/keeper/application.go @@ -21,10 +21,10 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/application/mocks" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/x/application/keeper" "github.com/pokt-network/poktroll/x/application/types" gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -77,7 +77,7 @@ func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context) { AnyTimes() mockSharedKeeper.EXPECT().GetSessionEndHeight(gomock.Any(), gomock.Any()). DoAndReturn(func(_ context.Context, queryHeight int64) int64 { - return shared.GetSessionEndHeightWithDefaultParams(queryHeight) + return testsession.GetSessionEndHeightWithDefaultParams(queryHeight) }). AnyTimes() diff --git a/testutil/session/session.go b/testutil/session/session.go new file mode 100644 index 000000000..aac62eb5b --- /dev/null +++ b/testutil/session/session.go @@ -0,0 +1,45 @@ +package session + +import ( + "github.com/pokt-network/poktroll/x/session/keeper" + "github.com/pokt-network/poktroll/x/shared" + "github.com/pokt-network/poktroll/x/shared/types" +) + +// GetSessionIdWithDefaultParams returns the string and bytes representation of the +// sessionId for the session containing blockHeight, given the default shared on-chain +// parameters, application public key, service ID, and block hash. +func GetSessionIdWithDefaultParams( + appPubKey, + serviceId string, + blockHashBz []byte, + blockHeight int64, +) (sessionId string, sessionIdBz []byte) { + sharedParams := types.DefaultParams() + return keeper.GetSessionId(&sharedParams, appPubKey, serviceId, blockHashBz, blockHeight) +} + +// GetSessionStartHeightWithDefaultParams returns the block height at which the +// session containing queryHeight starts, given the default shared on-chain +// parameters. +// See shared.GetSessionStartHeight for more details. +func GetSessionStartHeightWithDefaultParams(queryHeight int64) int64 { + sharedParams := types.DefaultParams() + return shared.GetSessionStartHeight(&sharedParams, queryHeight) +} + +// GetSessionEndHeightWithDefaultParams returns the block height at which the session +// containing queryHeight ends, given the default shared on-chain parameters. +// See shared.GetSessionEndHeight for more details. +func GetSessionEndHeightWithDefaultParams(queryHeight int64) int64 { + sharedParams := types.DefaultParams() + return shared.GetSessionEndHeight(&sharedParams, queryHeight) +} + +// GetSessionNumberWithDefaultParams returns the session number of the session +// containing queryHeight, given the default on-chain shared parameters. +// See shared.GetSessionNumber for more details. +func GetSessionNumberWithDefaultParams(queryHeight int64) int64 { + sharedParams := types.DefaultParams() + return shared.GetSessionNumber(&sharedParams, queryHeight) +} diff --git a/testutil/testclient/testqueryclients/sessionquerier.go b/testutil/testclient/testqueryclients/sessionquerier.go index f9a30cbe0..e011ae29a 100644 --- a/testutil/testclient/testqueryclients/sessionquerier.go +++ b/testutil/testclient/testqueryclients/sessionquerier.go @@ -9,9 +9,8 @@ import ( "github.com/golang/mock/gomock" "github.com/pokt-network/poktroll/testutil/mockclient" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" + testsession "github.com/pokt-network/poktroll/testutil/session" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -48,7 +47,7 @@ func NewTestSessionQueryClient( serviceId string, blockHeight int64, ) (session *sessiontypes.Session, err error) { - sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(address, serviceId, blockHashBz, blockHeight) + sessionId, _ := testsession.GetSessionIdWithDefaultParams(address, serviceId, blockHashBz, blockHeight) session, ok := sessionsMap[sessionId] if !ok { @@ -73,18 +72,18 @@ func AddToExistingSessions( ) { t.Helper() - sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) + sessionId, _ := testsession.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) session := sessiontypes.Session{ Header: &sessiontypes.SessionHeader{ Service: &sharedtypes.Service{Id: serviceId}, ApplicationAddress: appAddress, SessionId: sessionId, - SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), + SessionStartBlockHeight: testsession.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(blockHeight), }, - NumBlocksPerSession: shared.NumBlocksPerSession, - SessionNumber: shared.GetSessionNumberWithDefaultParams(blockHeight), + NumBlocksPerSession: sharedtypes.DefaultNumBlocksPerSession, + SessionNumber: testsession.GetSessionNumberWithDefaultParams(blockHeight), SessionId: sessionId, Suppliers: []*sharedtypes.Supplier{}, } diff --git a/testutil/testproxy/relayerproxy.go b/testutil/testproxy/relayerproxy.go index 21071e88c..76bf96a85 100644 --- a/testutil/testproxy/relayerproxy.go +++ b/testutil/testproxy/relayerproxy.go @@ -26,15 +26,14 @@ import ( "github.com/pokt-network/poktroll/pkg/polylog" "github.com/pokt-network/poktroll/pkg/relayer/config" "github.com/pokt-network/poktroll/pkg/signer" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/testutil/testclient/testblock" "github.com/pokt-network/poktroll/testutil/testclient/testdelegation" "github.com/pokt-network/poktroll/testutil/testclient/testkeyring" "github.com/pokt-network/poktroll/testutil/testclient/testqueryclients" testrings "github.com/pokt-network/poktroll/testutil/testcrypto/rings" servicetypes "github.com/pokt-network/poktroll/x/service/types" - sessionkeeper "github.com/pokt-network/poktroll/x/session/keeper" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -276,7 +275,7 @@ func WithSuccessiveSessions( test.t, appAddress, serviceId, - shared.NumBlocksPerSession*int64(i), + sharedtypes.DefaultNumBlocksPerSession*int64(i), sessionSuppliers, ) } @@ -406,7 +405,7 @@ func GenerateRelayRequest( payload []byte, ) *servicetypes.RelayRequest { appAddress := GetAddressFromPrivateKey(test, privKey) - sessionId, _ := sessionkeeper.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) + sessionId, _ := testsession.GetSessionIdWithDefaultParams(appAddress, serviceId, blockHashBz, blockHeight) return &servicetypes.RelayRequest{ Meta: servicetypes.RelayRequestMetadata{ @@ -414,8 +413,8 @@ func GenerateRelayRequest( ApplicationAddress: appAddress, SessionId: string(sessionId[:]), Service: &sharedtypes.Service{Id: serviceId}, - SessionStartBlockHeight: shared.GetSessionStartHeightWithDefaultParams(blockHeight), - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(blockHeight), + SessionStartBlockHeight: testsession.GetSessionStartHeightWithDefaultParams(blockHeight), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(blockHeight), }, // The returned relay is unsigned and must be signed elsewhere for functionality Signature: []byte(""), diff --git a/x/application/keeper/msg_server_undelegate_from_gateway_test.go b/x/application/keeper/msg_server_undelegate_from_gateway_test.go index 97bdce637..1b4afcc89 100644 --- a/x/application/keeper/msg_server_undelegate_from_gateway_test.go +++ b/x/application/keeper/msg_server_undelegate_from_gateway_test.go @@ -12,6 +12,7 @@ import ( "github.com/pokt-network/poktroll/pkg/crypto/rings" keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/x/application/keeper" "github.com/pokt-network/poktroll/x/application/types" apptypes "github.com/pokt-network/poktroll/x/application/types" @@ -317,7 +318,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsActiveUntilNextSession(t *t // Verify that the gateway is added to the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) + sessionEndHeight := uint64(testsession.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, pendingUndelegateFromAddr, @@ -385,7 +386,7 @@ func TestMsgServer_UndelegateFromGateway_DelegationIsPrunedAfterRetentionPeriod( // Verify that the the pending undelegation map no longer contains the // sessionEndHeight key. - sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) + sessionEndHeight := uint64(testsession.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Empty(t, app.PendingUndelegations[sessionEndHeight]) // Verify that the reconstructed delegatee gateway list can no longer include @@ -424,7 +425,7 @@ func TestMsgServer_UndelegateFromGateway_RedelegationAfterUndelegationAtTheSameS // Verify that the gateway is also present in the pending undelegation list with the // right sessionEndHeight as the map key. - sessionEndHeight := uint64(shared.GetSessionEndHeightWithDefaultParams(undelegationHeight)) + sessionEndHeight := uint64(testsession.GetSessionEndHeightWithDefaultParams(undelegationHeight)) require.Contains(t, app.PendingUndelegations[sessionEndHeight].GatewayAddresses, gatewayAddrToRedelegate, @@ -534,7 +535,7 @@ func createAppStakeDelegateAndUndelegate( // getUndelegationPruningBlockHeight returns the block height at which undelegations // should be pruned for a given undlegation block height. func getUndelegationPruningBlockHeight(blockHeight int64) (pruningHeihgt int64) { - nextSessionStartHeight := shared.GetSessionEndHeightWithDefaultParams(blockHeight) + 1 + nextSessionStartHeight := testsession.GetSessionEndHeightWithDefaultParams(blockHeight) + 1 return nextSessionStartHeight + getNumBlocksUndelegationRetentionWithDefaultParams() } diff --git a/x/proof/keeper/msg_server_create_claim_test.go b/x/proof/keeper/msg_server_create_claim_test.go index 170f6cbd1..b4c6bbed3 100644 --- a/x/proof/keeper/msg_server_create_claim_test.go +++ b/x/proof/keeper/msg_server_create_claim_test.go @@ -10,11 +10,11 @@ import ( keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" apptypes "github.com/pokt-network/poktroll/x/application/types" "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -300,7 +300,7 @@ func newTestClaimMsg( Service: service, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, merkleRoot, ) diff --git a/x/proof/keeper/proof_test.go b/x/proof/keeper/proof_test.go index 13c578f82..d27ed7494 100644 --- a/x/proof/keeper/proof_test.go +++ b/x/proof/keeper/proof_test.go @@ -11,10 +11,10 @@ import ( keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/nullify" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/x/proof/keeper" "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -37,7 +37,7 @@ func createNProofs(keeper keeper.Keeper, ctx context.Context, n int) []types.Pro Service: &sharedtypes.Service{Id: testServiceId}, SessionId: fmt.Sprintf("session-%d", i), SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, ClosestMerkleProof: nil, } diff --git a/x/proof/module/helpers_test.go b/x/proof/module/helpers_test.go index 3e2dd6045..304cd4652 100644 --- a/x/proof/module/helpers_test.go +++ b/x/proof/module/helpers_test.go @@ -19,12 +19,12 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/network" + testsession "github.com/pokt-network/poktroll/testutil/session" "github.com/pokt-network/poktroll/testutil/testkeyring" apptypes "github.com/pokt-network/poktroll/x/application/types" proof "github.com/pokt-network/poktroll/x/proof/module" "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" suppliertypes "github.com/pokt-network/poktroll/x/supplier/types" ) @@ -130,7 +130,7 @@ func networkWithClaimObjects( claim := createClaim( t, net, ctx, supplierAcct.Address.String(), - shared.GetSessionStartHeightWithDefaultParams(blockHeight), + testsession.GetSessionStartHeightWithDefaultParams(blockHeight), appAcct.Address.String(), ) claims = append(claims, *claim) @@ -160,7 +160,7 @@ func encodeSessionHeader( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(sessionStartHeight), } cdc := codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) sessionHeaderBz := cdc.MustMarshalJSON(sessionHeader) @@ -210,7 +210,7 @@ func createClaim( Service: &sharedtypes.Service{Id: testServiceId}, SessionId: sessionId, SessionStartBlockHeight: sessionStartHeight, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(sessionStartHeight), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(sessionStartHeight), }, RootHash: rootHash, } diff --git a/x/proof/module/query_claim_test.go b/x/proof/module/query_claim_test.go index b941ea8b0..7054dd83a 100644 --- a/x/proof/module/query_claim_test.go +++ b/x/proof/module/query_claim_test.go @@ -16,7 +16,7 @@ import ( _ "github.com/pokt-network/poktroll/testutil/testpolylog" proof "github.com/pokt-network/poktroll/x/proof/module" "github.com/pokt-network/poktroll/x/proof/types" - "github.com/pokt-network/poktroll/x/shared" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) func TestClaim_Show(t *testing.T) { @@ -128,12 +128,12 @@ func TestClaim_List(t *testing.T) { // independent constant, which requires us to temporarily align the // with the num blocks per session. See the `forloop` in `networkWithClaimObjects` // that has a TODO_HACK as well. - require.Equal(t, 0, numSuppliers*numApps%shared.NumBlocksPerSession) + require.Equal(t, 0, numSuppliers*numApps%sharedtypes.DefaultNumBlocksPerSession) - numSessions := numSuppliers * numApps / shared.NumBlocksPerSession + numSessions := numSuppliers * numApps / sharedtypes.DefaultNumBlocksPerSession // Submitting one claim per block for simplicity - numClaimsPerSession := shared.NumBlocksPerSession + numClaimsPerSession := sharedtypes.DefaultNumBlocksPerSession totalClaims := numSessions * numClaimsPerSession net, claims := networkWithClaimObjects(t, numSessions, numSuppliers, numApps) diff --git a/x/proof/types/message_submit_proof_test.go b/x/proof/types/message_submit_proof_test.go index 00558bb93..155255d96 100644 --- a/x/proof/types/message_submit_proof_test.go +++ b/x/proof/types/message_submit_proof_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" ) @@ -30,7 +30,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -49,7 +49,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -68,7 +68,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: &sharedtypes.Service{Id: ""}, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, @@ -83,7 +83,7 @@ func TestMsgSubmitProof_ValidateBasic(t *testing.T) { Service: testService, SessionId: "mock_session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, Proof: testClosestMerkleProof, }, diff --git a/x/session/keeper/session_hydrator.go b/x/session/keeper/session_hydrator.go index 6e03cb8b9..08aa97722 100644 --- a/x/session/keeper/session_hydrator.go +++ b/x/session/keeper/session_hydrator.go @@ -281,21 +281,6 @@ func (k Keeper) GetSessionId( return GetSessionId(&sharedParams, appPubKey, serviceId, blockHashBz, blockHeight) } -// GetSessionIdWithDefaultParams returns the string and bytes representation of the -// sessionId for the session containing blockHeight, given the default shared on-chain -// parameters, application public key, service ID, and block hash. -// -// TODO_TECHDEBT(#517): Move this to a shared testutil. -func GetSessionIdWithDefaultParams( - appPubKey, - serviceId string, - blockHashBz []byte, - blockHeight int64, -) (sessionId string, sessionIdBz []byte) { - sharedParams := sharedtypes.DefaultParams() - return GetSessionId(&sharedParams, appPubKey, serviceId, blockHashBz, blockHeight) -} - // GetSessionId returns the string and bytes representation of the sessionId for the // session containing blockHeight, given the shared on-chain parameters, application // public key, service ID, and block hash. diff --git a/x/shared/session.go b/x/shared/session.go index 3b3430cf3..fa5675450 100644 --- a/x/shared/session.go +++ b/x/shared/session.go @@ -2,13 +2,6 @@ package shared import sharedtypes "github.com/pokt-network/poktroll/x/shared/types" -// NumBlocksPerSession is a place-holder that will be removed once the respective governance -// parameter is implemented. -// -// TODO_BLOCKER(#517): Remove direct usage of these constants in helper functions -// when they will be replaced by governance params -const NumBlocksPerSession = 4 - // SessionGracePeriodBlocks is the number of blocks after the session ends before the // "session grace period" is considered to have elapsed. // @@ -16,17 +9,6 @@ const NumBlocksPerSession = 4 // governance parameter is implemented. const SessionGracePeriodBlocks = 4 -// GetSessionStartHeightWithDefaultParams returns the block height at which the -// session containing queryHeight starts, given the default shared on-chain -// parameters. -// See GetSessionStartHeight for more details. -// -// TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetSessionStartHeightWithDefaultParams(queryHeight int64) int64 { - sharedParams := sharedtypes.DefaultParams() - return GetSessionStartHeight(&sharedParams, queryHeight) -} - // GetSessionStartHeight returns the block height at which the session containing // queryHeight starts, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. @@ -43,16 +25,6 @@ func GetSessionStartHeight(sharedParams *sharedtypes.Params, queryHeight int64) return queryHeight - ((queryHeight - 1) % numBlocksPerSession) } -// GetSessionEndHeightWithDefaultParams returns the block height at which the session -// containing queryHeight ends, given the default shared on-chain parameters. -// See GetSessionEndHeight for more details. -// -// TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetSessionEndHeightWithDefaultParams(queryHeight int64) int64 { - sharedParams := sharedtypes.DefaultParams() - return GetSessionEndHeight(&sharedParams, queryHeight) -} - // GetSessionEndHeight returns the block height at which the session containing // queryHeight ends, given the passed shared on-chain parameters. // Returns 0 if the block height is not a consensus produced block. @@ -67,18 +39,9 @@ func GetSessionEndHeight(sharedParams *sharedtypes.Params, queryHeight int64) in return GetSessionStartHeight(sharedParams, queryHeight) + numBlocksPerSession - 1 } -// GetSessionNumberWithDefaultParams returns the session number of the session -// containing queryHeight, given the default on-chain shared parameters. -// See GetSessionNumber for more details. -// -// TODO_TECHDEBT(#517): Move this function to shared testutils. -func GetSessionNumberWithDefaultParams(queryHeight int64) int64 { - sharedParams := sharedtypes.DefaultParams() - return GetSessionNumber(&sharedParams, queryHeight) -} - // GetSessionNumber returns the session number of the session containing queryHeight, // given the passed on-chain shared parameters. +// shared on-chain parameters. // Returns session number 0 if the block height is not a consensus produced block. // Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). // i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc. diff --git a/x/tokenomics/keeper/keeper_test.go b/x/tokenomics/keeper/keeper_test.go index 6103694a6..c9b59ab3b 100644 --- a/x/tokenomics/keeper/keeper_test.go +++ b/x/tokenomics/keeper/keeper_test.go @@ -16,10 +16,10 @@ import ( "github.com/pokt-network/poktroll/cmd/poktrolld/cmd" keepertest "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tokenomicskeeper "github.com/pokt-network/poktroll/x/tokenomics/keeper" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" @@ -60,7 +60,7 @@ func (s *TestSuite) SetupTest() { Service: &sharedtypes.Service{Id: testServiceId}, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(69), } diff --git a/x/tokenomics/keeper/settle_session_accounting_test.go b/x/tokenomics/keeper/settle_session_accounting_test.go index e1f65471b..614f88b34 100644 --- a/x/tokenomics/keeper/settle_session_accounting_test.go +++ b/x/tokenomics/keeper/settle_session_accounting_test.go @@ -12,10 +12,10 @@ import ( testkeeper "github.com/pokt-network/poktroll/testutil/keeper" "github.com/pokt-network/poktroll/testutil/sample" + testsession "github.com/pokt-network/poktroll/testutil/session" apptypes "github.com/pokt-network/poktroll/x/application/types" prooftypes "github.com/pokt-network/poktroll/x/proof/types" sessiontypes "github.com/pokt-network/poktroll/x/session/types" - "github.com/pokt-network/poktroll/x/shared" sharedtypes "github.com/pokt-network/poktroll/x/shared/types" tokenomicstypes "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -52,7 +52,7 @@ func TestSettleSessionAccounting_HandleAppGoingIntoDebt(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(appStake.Amount.Uint64() + 1), // More than the app stake } @@ -93,7 +93,7 @@ func TestSettleSessionAccounting_AppNotFound(t *testing.T) { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(42), } @@ -297,7 +297,7 @@ func baseClaim(appAddr, supplierAddr string, sum uint64) prooftypes.Claim { }, SessionId: "session_id", SessionStartBlockHeight: 1, - SessionEndBlockHeight: shared.GetSessionEndHeightWithDefaultParams(1), + SessionEndBlockHeight: testsession.GetSessionEndHeightWithDefaultParams(1), }, RootHash: smstRootWithSum(sum), } From 6091efe89112258eb0bef8617027eb7742edb496 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Thu, 30 May 2024 19:04:40 +0200 Subject: [PATCH 08/11] Empty commit From 488c0d2502c54fa88ecb3a1a8aff38fc6716d046 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 31 May 2024 10:02:49 +0200 Subject: [PATCH 09/11] [On-chain] chore: add single param updates to `shared` module (#560) Co-authored-by: Daniel Olshansky --- Makefile | 8 +- api/poktroll/shared/tx.pulsar.go | 1416 ++++++++++++++++- api/poktroll/shared/tx_grpc.pb.go | 37 + docs/static/openapi.yml | 1301 ++++----------- e2e/tests/parse_params_test.go | 31 +- e2e/tests/update_params.feature | 5 +- proto/poktroll/shared/tx.proto | 44 +- .../authz/dao_genesis_authorizations.json | 9 + .../params/shared_num_blocks_per_session.json | 12 + x/proof/keeper/msg_server_update_param.go | 5 +- x/proof/types/message_update_param_test.go | 2 +- x/shared/keeper/msg_server_update_param.go | 45 + .../keeper/msg_server_update_param_test.go | 42 + x/shared/keeper/msg_update_params.go | 2 +- x/shared/module/autocli.go | 16 +- x/shared/module/simulation.go | 25 +- x/shared/simulation/update_param.go | 29 + x/shared/types/codec.go | 3 + x/shared/types/errors.go | 7 +- x/shared/types/genesis.go | 6 +- x/shared/types/message_update_param.go | 67 + x/shared/types/message_update_param_test.go | 60 + x/shared/types/params.go | 4 +- x/shared/types/params_test.go | 4 +- x/shared/types/tx.pb.go | 731 ++++++++- .../keeper/msg_server_update_param.go | 5 +- .../types/message_update_param_test.go | 2 +- 27 files changed, 2833 insertions(+), 1085 deletions(-) create mode 100644 tools/scripts/params/shared_num_blocks_per_session.json create mode 100644 x/shared/keeper/msg_server_update_param.go create mode 100644 x/shared/keeper/msg_server_update_param_test.go create mode 100644 x/shared/simulation/update_param.go create mode 100644 x/shared/types/message_update_param.go create mode 100644 x/shared/types/message_update_param_test.go diff --git a/Makefile b/Makefile index 3372ea32a..0dd79ed99 100644 --- a/Makefile +++ b/Makefile @@ -837,11 +837,15 @@ params_update_proof_all: ## Update the proof module params params_update_proof_min_relay_difficulty_bits: ## Update the proof module params poktrolld tx authz exec ./tools/scripts/params/proof_min_relay_difficulty_bits.json $(PARAM_FLAGS) -### Session Module Params ### -.PHONY: params_update_session_all +### Shared Module Params ### +.PHONY: params_update_shared_all params_update_shared_all: ## Update the session module params poktrolld tx authz exec ./tools/scripts/params/shared_all.json $(PARAM_FLAGS) +.PHONY: params_update_shared_num_blocks_per_session +params_update_shared_num_blocks_per_session: ## Update the shared module params + poktrolld tx authz exec ./tools/scripts/params/shared_num_blocks_per_session.json $(PARAM_FLAGS) + .PHONY: params_query_all params_query_all: check_jq ## Query the params from all available modules @for module in $(MODULES); do \ diff --git a/api/poktroll/shared/tx.pulsar.go b/api/poktroll/shared/tx.pulsar.go index 152712a8d..7c8d19bc5 100644 --- a/api/poktroll/shared/tx.pulsar.go +++ b/api/poktroll/shared/tx.pulsar.go @@ -871,6 +871,1162 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } } +var ( + md_MsgUpdateParam protoreflect.MessageDescriptor + fd_MsgUpdateParam_authority protoreflect.FieldDescriptor + fd_MsgUpdateParam_name protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_string protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_int64 protoreflect.FieldDescriptor + fd_MsgUpdateParam_as_bytes protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_tx_proto_init() + md_MsgUpdateParam = File_poktroll_shared_tx_proto.Messages().ByName("MsgUpdateParam") + fd_MsgUpdateParam_authority = md_MsgUpdateParam.Fields().ByName("authority") + fd_MsgUpdateParam_name = md_MsgUpdateParam.Fields().ByName("name") + fd_MsgUpdateParam_as_string = md_MsgUpdateParam.Fields().ByName("as_string") + fd_MsgUpdateParam_as_int64 = md_MsgUpdateParam.Fields().ByName("as_int64") + fd_MsgUpdateParam_as_bytes = md_MsgUpdateParam.Fields().ByName("as_bytes") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParam)(nil) + +type fastReflection_MsgUpdateParam MsgUpdateParam + +func (x *MsgUpdateParam) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParam)(x) +} + +func (x *MsgUpdateParam) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_tx_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParam_messageType fastReflection_MsgUpdateParam_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParam_messageType{} + +type fastReflection_MsgUpdateParam_messageType struct{} + +func (x fastReflection_MsgUpdateParam_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParam)(nil) +} +func (x fastReflection_MsgUpdateParam_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParam) +} +func (x fastReflection_MsgUpdateParam_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParam +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParam) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParam +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParam) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParam_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParam) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParam) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParam) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParam)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParam) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Authority != "" { + value := protoreflect.ValueOfString(x.Authority) + if !f(fd_MsgUpdateParam_authority, value) { + return + } + } + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_MsgUpdateParam_name, value) { + return + } + } + if x.AsType != nil { + switch o := x.AsType.(type) { + case *MsgUpdateParam_AsString: + v := o.AsString + value := protoreflect.ValueOfString(v) + if !f(fd_MsgUpdateParam_as_string, value) { + return + } + case *MsgUpdateParam_AsInt64: + v := o.AsInt64 + value := protoreflect.ValueOfInt64(v) + if !f(fd_MsgUpdateParam_as_int64, value) { + return + } + case *MsgUpdateParam_AsBytes: + v := o.AsBytes + value := protoreflect.ValueOfBytes(v) + if !f(fd_MsgUpdateParam_as_bytes, value) { + return + } + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParam) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + return x.Authority != "" + case "poktroll.shared.MsgUpdateParam.name": + return x.Name != "" + case "poktroll.shared.MsgUpdateParam.as_string": + if x.AsType == nil { + return false + } else if _, ok := x.AsType.(*MsgUpdateParam_AsString); ok { + return true + } else { + return false + } + case "poktroll.shared.MsgUpdateParam.as_int64": + if x.AsType == nil { + return false + } else if _, ok := x.AsType.(*MsgUpdateParam_AsInt64); ok { + return true + } else { + return false + } + case "poktroll.shared.MsgUpdateParam.as_bytes": + if x.AsType == nil { + return false + } else if _, ok := x.AsType.(*MsgUpdateParam_AsBytes); ok { + return true + } else { + return false + } + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + x.Authority = "" + case "poktroll.shared.MsgUpdateParam.name": + x.Name = "" + case "poktroll.shared.MsgUpdateParam.as_string": + x.AsType = nil + case "poktroll.shared.MsgUpdateParam.as_int64": + x.AsType = nil + case "poktroll.shared.MsgUpdateParam.as_bytes": + x.AsType = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParam) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + value := x.Authority + return protoreflect.ValueOfString(value) + case "poktroll.shared.MsgUpdateParam.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "poktroll.shared.MsgUpdateParam.as_string": + if x.AsType == nil { + return protoreflect.ValueOfString("") + } else if v, ok := x.AsType.(*MsgUpdateParam_AsString); ok { + return protoreflect.ValueOfString(v.AsString) + } else { + return protoreflect.ValueOfString("") + } + case "poktroll.shared.MsgUpdateParam.as_int64": + if x.AsType == nil { + return protoreflect.ValueOfInt64(int64(0)) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsInt64); ok { + return protoreflect.ValueOfInt64(v.AsInt64) + } else { + return protoreflect.ValueOfInt64(int64(0)) + } + case "poktroll.shared.MsgUpdateParam.as_bytes": + if x.AsType == nil { + return protoreflect.ValueOfBytes(nil) + } else if v, ok := x.AsType.(*MsgUpdateParam_AsBytes); ok { + return protoreflect.ValueOfBytes(v.AsBytes) + } else { + return protoreflect.ValueOfBytes(nil) + } + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + x.Authority = value.Interface().(string) + case "poktroll.shared.MsgUpdateParam.name": + x.Name = value.Interface().(string) + case "poktroll.shared.MsgUpdateParam.as_string": + cv := value.Interface().(string) + x.AsType = &MsgUpdateParam_AsString{AsString: cv} + case "poktroll.shared.MsgUpdateParam.as_int64": + cv := value.Int() + x.AsType = &MsgUpdateParam_AsInt64{AsInt64: cv} + case "poktroll.shared.MsgUpdateParam.as_bytes": + cv := value.Bytes() + x.AsType = &MsgUpdateParam_AsBytes{AsBytes: cv} + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + panic(fmt.Errorf("field authority of message poktroll.shared.MsgUpdateParam is not mutable")) + case "poktroll.shared.MsgUpdateParam.name": + panic(fmt.Errorf("field name of message poktroll.shared.MsgUpdateParam is not mutable")) + case "poktroll.shared.MsgUpdateParam.as_string": + panic(fmt.Errorf("field as_string of message poktroll.shared.MsgUpdateParam is not mutable")) + case "poktroll.shared.MsgUpdateParam.as_int64": + panic(fmt.Errorf("field as_int64 of message poktroll.shared.MsgUpdateParam is not mutable")) + case "poktroll.shared.MsgUpdateParam.as_bytes": + panic(fmt.Errorf("field as_bytes of message poktroll.shared.MsgUpdateParam is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParam) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParam.authority": + return protoreflect.ValueOfString("") + case "poktroll.shared.MsgUpdateParam.name": + return protoreflect.ValueOfString("") + case "poktroll.shared.MsgUpdateParam.as_string": + return protoreflect.ValueOfString("") + case "poktroll.shared.MsgUpdateParam.as_int64": + return protoreflect.ValueOfInt64(int64(0)) + case "poktroll.shared.MsgUpdateParam.as_bytes": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParam")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParam does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgUpdateParam) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + case "poktroll.shared.MsgUpdateParam.as_type": + if x.AsType == nil { + return nil + } + switch x.AsType.(type) { + case *MsgUpdateParam_AsString: + return x.Descriptor().Fields().ByName("as_string") + case *MsgUpdateParam_AsInt64: + return x.Descriptor().Fields().ByName("as_int64") + case *MsgUpdateParam_AsBytes: + return x.Descriptor().Fields().ByName("as_bytes") + } + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.MsgUpdateParam", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParam) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParam) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParam) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParam) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Authority) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsString: + if x == nil { + break + } + l = len(x.AsString) + n += 1 + l + runtime.Sov(uint64(l)) + case *MsgUpdateParam_AsInt64: + if x == nil { + break + } + n += 1 + runtime.Sov(uint64(x.AsInt64)) + case *MsgUpdateParam_AsBytes: + if x == nil { + break + } + l = len(x.AsBytes) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + switch x := x.AsType.(type) { + case *MsgUpdateParam_AsString: + i -= len(x.AsString) + copy(dAtA[i:], x.AsString) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AsString))) + i-- + dAtA[i] = 0x1a + case *MsgUpdateParam_AsInt64: + i = runtime.EncodeVarint(dAtA, i, uint64(x.AsInt64)) + i-- + dAtA[i] = 0x30 + case *MsgUpdateParam_AsBytes: + i -= len(x.AsBytes) + copy(dAtA[i:], x.AsBytes) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AsBytes))) + i-- + dAtA[i] = 0x3a + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0x12 + } + if len(x.Authority) > 0 { + i -= len(x.Authority) + copy(dAtA[i:], x.Authority) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParam) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParam: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParam: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsString", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AsType = &MsgUpdateParam_AsString{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + case 6: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsInt64", wireType) + } + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.AsType = &MsgUpdateParam_AsInt64{v} + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AsBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + x.AsType = &MsgUpdateParam_AsBytes{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_MsgUpdateParamResponse protoreflect.MessageDescriptor + fd_MsgUpdateParamResponse_params protoreflect.FieldDescriptor +) + +func init() { + file_poktroll_shared_tx_proto_init() + md_MsgUpdateParamResponse = File_poktroll_shared_tx_proto.Messages().ByName("MsgUpdateParamResponse") + fd_MsgUpdateParamResponse_params = md_MsgUpdateParamResponse.Fields().ByName("params") +} + +var _ protoreflect.Message = (*fastReflection_MsgUpdateParamResponse)(nil) + +type fastReflection_MsgUpdateParamResponse MsgUpdateParamResponse + +func (x *MsgUpdateParamResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_MsgUpdateParamResponse)(x) +} + +func (x *MsgUpdateParamResponse) slowProtoReflect() protoreflect.Message { + mi := &file_poktroll_shared_tx_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_MsgUpdateParamResponse_messageType fastReflection_MsgUpdateParamResponse_messageType +var _ protoreflect.MessageType = fastReflection_MsgUpdateParamResponse_messageType{} + +type fastReflection_MsgUpdateParamResponse_messageType struct{} + +func (x fastReflection_MsgUpdateParamResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_MsgUpdateParamResponse)(nil) +} +func (x fastReflection_MsgUpdateParamResponse_messageType) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamResponse) +} +func (x fastReflection_MsgUpdateParamResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_MsgUpdateParamResponse) Descriptor() protoreflect.MessageDescriptor { + return md_MsgUpdateParamResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_MsgUpdateParamResponse) Type() protoreflect.MessageType { + return _fastReflection_MsgUpdateParamResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_MsgUpdateParamResponse) New() protoreflect.Message { + return new(fastReflection_MsgUpdateParamResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_MsgUpdateParamResponse) Interface() protoreflect.ProtoMessage { + return (*MsgUpdateParamResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_MsgUpdateParamResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Params != nil { + value := protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + if !f(fd_MsgUpdateParamResponse_params, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_MsgUpdateParamResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + return x.Params != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + x.Params = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_MsgUpdateParamResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + value := x.Params + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + x.Params = value.Message().Interface().(*Params) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + if x.Params == nil { + x.Params = new(Params) + } + return protoreflect.ValueOfMessage(x.Params.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_MsgUpdateParamResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "poktroll.shared.MsgUpdateParamResponse.params": + m := new(Params) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: poktroll.shared.MsgUpdateParamResponse")) + } + panic(fmt.Errorf("message poktroll.shared.MsgUpdateParamResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_MsgUpdateParamResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in poktroll.shared.MsgUpdateParamResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_MsgUpdateParamResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_MsgUpdateParamResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_MsgUpdateParamResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_MsgUpdateParamResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Params != nil { + l = options.Size(x.Params) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Params != nil { + encoded, err := options.Marshal(x.Params) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*MsgUpdateParamResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgUpdateParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Params == nil { + x.Params = &Params{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Params); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -892,8 +2048,6 @@ type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the module parameters to update. - // // NOTE: All parameters must be supplied. Params *Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"` } @@ -960,6 +2114,144 @@ func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return file_poktroll_shared_tx_proto_rawDescGZIP(), []int{1} } +// MsgUpdateParam is the Msg/UpdateParam request type to update a single param. +type MsgUpdateParam struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Types that are assignable to AsType: + // + // *MsgUpdateParam_AsString + // *MsgUpdateParam_AsInt64 + // *MsgUpdateParam_AsBytes + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` +} + +func (x *MsgUpdateParam) Reset() { + *x = MsgUpdateParam{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_tx_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParam) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParam) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParam.ProtoReflect.Descriptor instead. +func (*MsgUpdateParam) Descriptor() ([]byte, []int) { + return file_poktroll_shared_tx_proto_rawDescGZIP(), []int{2} +} + +func (x *MsgUpdateParam) GetAuthority() string { + if x != nil { + return x.Authority + } + return "" +} + +func (x *MsgUpdateParam) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { + if x != nil { + return x.AsType + } + return nil +} + +func (x *MsgUpdateParam) GetAsString() string { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsString); ok { + return x.AsString + } + return "" +} + +func (x *MsgUpdateParam) GetAsInt64() int64 { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsInt64); ok { + return x.AsInt64 + } + return 0 +} + +func (x *MsgUpdateParam) GetAsBytes() []byte { + if x, ok := x.GetAsType().(*MsgUpdateParam_AsBytes); ok { + return x.AsBytes + } + return nil +} + +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() +} + +type MsgUpdateParam_AsString struct { + AsString string `protobuf:"bytes,3,opt,name=as_string,json=asString,proto3,oneof"` +} + +type MsgUpdateParam_AsInt64 struct { + AsInt64 int64 `protobuf:"varint,6,opt,name=as_int64,json=asInt64,proto3,oneof"` +} + +type MsgUpdateParam_AsBytes struct { + AsBytes []byte `protobuf:"bytes,7,opt,name=as_bytes,json=asBytes,proto3,oneof"` +} + +func (*MsgUpdateParam_AsString) isMsgUpdateParam_AsType() {} + +func (*MsgUpdateParam_AsInt64) isMsgUpdateParam_AsType() {} + +func (*MsgUpdateParam_AsBytes) isMsgUpdateParam_AsType() {} + +// MsgUpdateParamResponse defines the response structure for executing a +// MsgUpdateParam message after a single param update. +type MsgUpdateParamResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (x *MsgUpdateParamResponse) Reset() { + *x = MsgUpdateParamResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_poktroll_shared_tx_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MsgUpdateParamResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MsgUpdateParamResponse) ProtoMessage() {} + +// Deprecated: Use MsgUpdateParamResponse.ProtoReflect.Descriptor instead. +func (*MsgUpdateParamResponse) Descriptor() ([]byte, []int) { + return file_poktroll_shared_tx_proto_rawDescGZIP(), []int{3} +} + +func (x *MsgUpdateParamResponse) GetParams() *Params { + if x != nil { + return x.Params + } + return nil +} + var File_poktroll_shared_tx_proto protoreflect.FileDescriptor var file_poktroll_shared_tx_proto_rawDesc = []byte{ @@ -986,25 +2278,51 @@ var file_poktroll_shared_tx_proto_rawDesc = []byte{ 0xb0, 0x2a, 0x21, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x78, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, - 0x68, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x5a, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x20, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0x9d, 0x01, 0x0a, 0x13, 0x63, 0x6f, - 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, - 0x64, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, - 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0xa2, 0x02, - 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, - 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, 0x6b, 0x74, 0x72, - 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, - 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0xfb, 0x01, 0x0a, 0x0e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, + 0x0a, 0x09, 0x61, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x61, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x48, 0x00, 0x52, 0x08, 0x61, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x29, 0x0a, 0x08, + 0x61, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, + 0xea, 0xde, 0x1f, 0x08, 0x61, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x48, 0x00, 0x52, 0x07, + 0x61, 0x73, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x29, 0x0a, 0x08, 0x61, 0x73, 0x5f, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, 0x61, + 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x48, 0x00, 0x52, 0x07, 0x61, 0x73, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x42, 0x09, 0x0a, 0x07, 0x61, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0x49, 0x0a, + 0x16, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0xc1, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, + 0x12, 0x5a, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x12, 0x20, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x1a, 0x28, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x57, 0x0a, 0x0b, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x1f, 0x2e, 0x70, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x1a, 0x27, 0x2e, 0x70, + 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x4d, + 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0x9d, 0x01, 0x0a, + 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2e, 0x73, 0x68, + 0x61, 0x72, 0x65, 0x64, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x70, 0x6f, 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, + 0x64, 0xa2, 0x02, 0x03, 0x50, 0x53, 0x58, 0xaa, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, 0x72, 0x6f, + 0x6c, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xca, 0x02, 0x0f, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0xe2, 0x02, 0x1b, 0x50, 0x6f, + 0x6b, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x5c, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x10, 0x50, 0x6f, 0x6b, 0x74, + 0x72, 0x6f, 0x6c, 0x6c, 0x3a, 0x3a, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1019,21 +2337,26 @@ func file_poktroll_shared_tx_proto_rawDescGZIP() []byte { return file_poktroll_shared_tx_proto_rawDescData } -var file_poktroll_shared_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_poktroll_shared_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_poktroll_shared_tx_proto_goTypes = []interface{}{ (*MsgUpdateParams)(nil), // 0: poktroll.shared.MsgUpdateParams (*MsgUpdateParamsResponse)(nil), // 1: poktroll.shared.MsgUpdateParamsResponse - (*Params)(nil), // 2: poktroll.shared.Params + (*MsgUpdateParam)(nil), // 2: poktroll.shared.MsgUpdateParam + (*MsgUpdateParamResponse)(nil), // 3: poktroll.shared.MsgUpdateParamResponse + (*Params)(nil), // 4: poktroll.shared.Params } var file_poktroll_shared_tx_proto_depIdxs = []int32{ - 2, // 0: poktroll.shared.MsgUpdateParams.params:type_name -> poktroll.shared.Params - 0, // 1: poktroll.shared.Msg.UpdateParams:input_type -> poktroll.shared.MsgUpdateParams - 1, // 2: poktroll.shared.Msg.UpdateParams:output_type -> poktroll.shared.MsgUpdateParamsResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 4, // 0: poktroll.shared.MsgUpdateParams.params:type_name -> poktroll.shared.Params + 4, // 1: poktroll.shared.MsgUpdateParamResponse.params:type_name -> poktroll.shared.Params + 0, // 2: poktroll.shared.Msg.UpdateParams:input_type -> poktroll.shared.MsgUpdateParams + 2, // 3: poktroll.shared.Msg.UpdateParam:input_type -> poktroll.shared.MsgUpdateParam + 1, // 4: poktroll.shared.Msg.UpdateParams:output_type -> poktroll.shared.MsgUpdateParamsResponse + 3, // 5: poktroll.shared.Msg.UpdateParam:output_type -> poktroll.shared.MsgUpdateParamResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_poktroll_shared_tx_proto_init() } @@ -1067,6 +2390,35 @@ func file_poktroll_shared_tx_proto_init() { return nil } } + file_poktroll_shared_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParam); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poktroll_shared_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MsgUpdateParamResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_poktroll_shared_tx_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*MsgUpdateParam_AsString)(nil), + (*MsgUpdateParam_AsInt64)(nil), + (*MsgUpdateParam_AsBytes)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -1074,7 +2426,7 @@ func file_poktroll_shared_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poktroll_shared_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, diff --git a/api/poktroll/shared/tx_grpc.pb.go b/api/poktroll/shared/tx_grpc.pb.go index 6e760cdf7..f9ab841de 100644 --- a/api/poktroll/shared/tx_grpc.pb.go +++ b/api/poktroll/shared/tx_grpc.pb.go @@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( Msg_UpdateParams_FullMethodName = "/poktroll.shared.Msg/UpdateParams" + Msg_UpdateParam_FullMethodName = "/poktroll.shared.Msg/UpdateParam" ) // MsgClient is the client API for Msg service. @@ -29,6 +30,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) } type msgClient struct { @@ -48,6 +50,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) { + out := new(MsgUpdateParamResponse) + err := c.cc.Invoke(ctx, Msg_UpdateParam_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -55,6 +66,7 @@ type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) mustEmbedUnimplementedMsgServer() } @@ -65,6 +77,9 @@ type UnimplementedMsgServer struct { func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (UnimplementedMsgServer) UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParam not implemented") +} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -96,6 +111,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParam(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Msg_UpdateParam_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParam(ctx, req.(*MsgUpdateParam)) + } + return interceptor(ctx, in, info, handler) +} + // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -107,6 +140,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "UpdateParam", + Handler: _Msg_UpdateParam_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/shared/tx.proto", diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index f09f70e84..11f698dd2 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -15929,403 +15929,6 @@ paths: parameters. tags: - Msg - /pokt-network/poktroll/application/application: - get: - operationId: PoktrollApplicationQuery_AllApplications - responses: - '200': - description: A successful response. - schema: - type: object - properties: - applications: - type: array - items: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - stake: - title: The total amount of uPOKT the application has staked - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - service_configs: - type: array - items: - type: object - properties: - service: - title: >- - The Service for which the application is - configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a - session for a certain service but with some - additional configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for - the service - title: >- - TODO_TECHDEBT: Name is currently unused but - acts as a reminder that an optional onchain - representation of the service is necessary - title: >- - ApplicationServiceConfig holds the service - configuration the application stakes for - title: >- - The list of services this appliccation is configured to - request service for - delegatee_gateway_addresses: - type: array - items: - type: string - description: >- - TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to - `gateway_addresses_delegated_to`. - - Ensure to rename all relevant configs, comments, - variables, function names, etc as well. - - - The Bech32 encoded addresses for all delegatee Gateways, - in a non-nullable slice - pending_undelegations: - type: object - additionalProperties: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: >- - UndelegatingGatewayList is used as the Value of - `pending_undelegations`. - - It is required to store a repeated list of strings as - a map value. - description: >- - A map from sessionEndHeights to a list of Gateways. - - The key is the height of the last block of the session - during which the - - respective undelegation was committed. - - The value is a list of gateways being undelegated from. - - TODO_DOCUMENT(@red-0ne): Need to document the flow from - this comment - - so its clear to everyone why this is necessary; - https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. - title: >- - Application defines the type used to store an on-chain - definition and state for an application - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query - /pokt-network/poktroll/application/application/{address}: - get: - summary: Queries a list of Application items. - operationId: PoktrollApplicationQuery_Application - responses: - '200': - description: A successful response. - schema: - type: object - properties: - application: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - stake: - title: The total amount of uPOKT the application has staked - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - service_configs: - type: array - items: - type: object - properties: - service: - title: The Service for which the application is configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a - session for a certain service but with some - additional configs that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts - as a reminder that an optional onchain - representation of the service is necessary - title: >- - ApplicationServiceConfig holds the service configuration - the application stakes for - title: >- - The list of services this appliccation is configured to - request service for - delegatee_gateway_addresses: - type: array - items: - type: string - description: >- - TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to - `gateway_addresses_delegated_to`. - - Ensure to rename all relevant configs, comments, - variables, function names, etc as well. - - - The Bech32 encoded addresses for all delegatee Gateways, - in a non-nullable slice - pending_undelegations: - type: object - additionalProperties: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: >- - UndelegatingGatewayList is used as the Value of - `pending_undelegations`. - - It is required to store a repeated list of strings as a - map value. - description: >- - A map from sessionEndHeights to a list of Gateways. - - The key is the height of the last block of the session - during which the - - respective undelegation was committed. - - The value is a list of gateways being undelegated from. - - TODO_DOCUMENT(@red-0ne): Need to document the flow from - this comment - - so its clear to everyone why this is necessary; - https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. - title: >- - Application defines the type used to store an on-chain - definition and state for an application - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: address - in: path - required: true - type: string - tags: - - Query - /pokt-network/poktroll/application/params: - get: - summary: Parameters queries the parameters of the module. - operationId: PoktrollApplicationQuery_Params - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - max_delegated_gateways: - type: string - format: uint64 - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Query /poktroll.application.Msg/DelegateToGateway: post: operationId: PoktrollApplicationMsg_DelegateToGateway @@ -17262,18 +16865,73 @@ paths: description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg - /pokt-network/poktroll/session/get_session: - get: - summary: Queries the session given app_address, service and block_height. - operationId: PoktrollSessionQuery_GetSession + /poktroll.session.Msg/UpdateParams: + post: + summary: |- + UpdateParams defines a (governance) operation for updating the module + parameters. The authority defaults to the x/gov module account. + operationId: PoktrollSessionMsg_UpdateParams responses: '200': description: A successful response. schema: type: object - properties: - session: - type: object + description: >- + MsgUpdateParamsResponse defines the response structure for + executing a + + MsgUpdateParams message. + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: body + description: MsgUpdateParams is the Msg/UpdateParams request type. + in: body + required: true + schema: + type: object + properties: + authority: + type: string + description: >- + authority is the address that controls the module (defaults to + x/gov unless overwritten). + params: + description: |- + params defines the x/session parameters to update. + NOTE: All parameters must be supplied. + type: object + description: MsgUpdateParams is the Msg/UpdateParams request type. + tags: + - Msg + /pokt-network/poktroll/session/get_session: + get: + summary: Queries the session given app_address, service and block_height. + operationId: PoktrollSessionQuery_GetSession + responses: + '200': + description: A successful response. + schema: + type: object + properties: + session: + type: object properties: header: title: The header of the session containing lightweight data @@ -17651,10 +17309,6 @@ paths: params: description: params holds all the parameters of this module. type: object - properties: - num_blocks_per_session: - type: string - format: uint64 description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -17678,22 +17332,26 @@ paths: additionalProperties: {} tags: - Query - /poktroll.session.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines a (governance) operation for updating the module - parameters. The authority defaults to the x/gov module account. - operationId: PoktrollSessionMsg_UpdateParams + /pokt-network/poktroll/shared/params: + get: + summary: Parameters queries the parameters of the module. + operationId: PoktrollSharedQuery_Params responses: '200': description: A successful response. schema: type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + num_blocks_per_session: + type: string + format: uint64 description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. + QueryParamsResponse is response type for the Query/Params RPC + method. default: description: An unexpected error response. schema: @@ -17712,35 +17370,11 @@ paths: '@type': type: string additionalProperties: {} - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/session parameters to update. - NOTE: All parameters must be supplied. - type: object - properties: - num_blocks_per_session: - type: string - format: uint64 - description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - - Msg - /pokt-network/poktroll/shared/params: - get: - summary: Parameters queries the parameters of the module. - operationId: PoktrollSharedQuery_Params + - Query + /poktroll.shared.Msg/UpdateParam: + post: + operationId: PoktrollSharedMsg_UpdateParam responses: '200': description: A successful response. @@ -17748,11 +17382,7 @@ paths: type: object properties: params: - description: params holds all the parameters of this module. - type: object - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. + type: string default: description: An unexpected error response. schema: @@ -17771,8 +17401,21 @@ paths: '@type': type: string additionalProperties: {} + parameters: + - name: body + in: body + required: true + schema: + type: object + properties: + authority: + type: string + name: + type: string + asType: + type: string tags: - - Query + - Msg /poktroll.shared.Msg/UpdateParams: post: summary: |- @@ -17821,11 +17464,12 @@ paths: authority is the address that controls the module (defaults to x/gov unless overwritten). params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. + description: 'NOTE: All parameters must be supplied.' type: object + properties: + num_blocks_per_session: + type: string + format: uint64 description: MsgUpdateParams is the Msg/UpdateParams request type. tags: - Msg @@ -24746,507 +24390,30 @@ definitions: properties: max_expected_time_per_block: type: string - format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably take to produce - the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per block. - description: Params defines the set of Connection parameters. - ibc.core.connection.v1.Version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: |- - Version defines the versioning scheme used to negotiate the IBC verison in - the connection handshake. - cosmos.base.query.v1beta1.PageRequest: - type: object - properties: - key: - type: string - format: byte - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - offset: - type: string - format: uint64 - description: |- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key should - be set. - limit: - type: string - format: uint64 - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - count_total: - type: boolean - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in UIs. - - count_total is only respected when offset is used. It is ignored when - key - - is set. - reverse: - type: boolean - description: >- - reverse is set to true if results are to be returned in the descending - order. - - - Since: cosmos-sdk 0.43 - description: |- - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } - title: |- - PageRequest is to be embedded in gRPC request messages for efficient - pagination. Ex: - cosmos.base.query.v1beta1.PageResponse: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: |- - total is total number of results available if PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - poktroll.application.Application: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' ScalarDescriptor - to ensure deterministic encoding - stake: - title: The total amount of uPOKT the application has staked - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - service_configs: - type: array - items: - type: object - properties: - service: - title: The Service for which the application is configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - title: >- - ApplicationServiceConfig holds the service configuration the - application stakes for - title: >- - The list of services this appliccation is configured to request - service for - delegatee_gateway_addresses: - type: array - items: - type: string - description: >- - TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to - `gateway_addresses_delegated_to`. - - Ensure to rename all relevant configs, comments, variables, function - names, etc as well. - - - The Bech32 encoded addresses for all delegatee Gateways, in a - non-nullable slice - pending_undelegations: - type: object - additionalProperties: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: >- - UndelegatingGatewayList is used as the Value of - `pending_undelegations`. - - It is required to store a repeated list of strings as a map value. - description: >- - A map from sessionEndHeights to a list of Gateways. - - The key is the height of the last block of the session during which - the - - respective undelegation was committed. - - The value is a list of gateways being undelegated from. - - TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment - - so its clear to everyone why this is necessary; - https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. - title: >- - Application defines the type used to store an on-chain definition and - state for an application - poktroll.application.Params: - type: object - properties: - max_delegated_gateways: - type: string - format: uint64 - description: Params defines the parameters for the module. - poktroll.application.QueryAllApplicationsResponse: - type: object - properties: - applications: - type: array - items: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - stake: - title: The total amount of uPOKT the application has staked - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - service_configs: - type: array - items: - type: object - properties: - service: - title: The Service for which the application is configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for - a certain service but with some additional configs - that identify it? - name: - type: string - description: >- - (Optional) Semantic human readable name for the - service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of - the service is necessary - title: >- - ApplicationServiceConfig holds the service configuration the - application stakes for - title: >- - The list of services this appliccation is configured to request - service for - delegatee_gateway_addresses: - type: array - items: - type: string - description: >- - TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to - `gateway_addresses_delegated_to`. - - Ensure to rename all relevant configs, comments, variables, - function names, etc as well. - - - The Bech32 encoded addresses for all delegatee Gateways, in a - non-nullable slice - pending_undelegations: - type: object - additionalProperties: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: >- - UndelegatingGatewayList is used as the Value of - `pending_undelegations`. - - It is required to store a repeated list of strings as a map - value. - description: >- - A map from sessionEndHeights to a list of Gateways. - - The key is the height of the last block of the session during - which the - - respective undelegation was committed. - - The value is a list of gateways being undelegated from. - - TODO_DOCUMENT(@red-0ne): Need to document the flow from this - comment - - so its clear to everyone why this is necessary; - https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. - title: >- - Application defines the type used to store an on-chain definition - and state for an application - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - poktroll.application.QueryGetApplicationResponse: - type: object - properties: - application: - type: object - properties: - address: - type: string - title: >- - The Bech32 address of the application using cosmos' - ScalarDescriptor to ensure deterministic encoding - stake: - title: The total amount of uPOKT the application has staked - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - service_configs: - type: array - items: - type: object - properties: - service: - title: The Service for which the application is configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a - certain service but with some additional configs that - identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a - reminder that an optional onchain representation of the - service is necessary - title: >- - ApplicationServiceConfig holds the service configuration the - application stakes for - title: >- - The list of services this appliccation is configured to request - service for - delegatee_gateway_addresses: - type: array - items: - type: string - description: >- - TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to - `gateway_addresses_delegated_to`. - - Ensure to rename all relevant configs, comments, variables, - function names, etc as well. - - - The Bech32 encoded addresses for all delegatee Gateways, in a - non-nullable slice - pending_undelegations: - type: object - additionalProperties: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: >- - UndelegatingGatewayList is used as the Value of - `pending_undelegations`. - - It is required to store a repeated list of strings as a map - value. - description: >- - A map from sessionEndHeights to a list of Gateways. - - The key is the height of the last block of the session during - which the - - respective undelegation was committed. - - The value is a list of gateways being undelegated from. - - TODO_DOCUMENT(@red-0ne): Need to document the flow from this - comment - - so its clear to everyone why this is necessary; - https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. - title: >- - Application defines the type used to store an on-chain definition and - state for an application - poktroll.application.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - max_delegated_gateways: - type: string - format: uint64 - description: QueryParamsResponse is response type for the Query/Params RPC method. - poktroll.application.UndelegatingGatewayList: - type: object - properties: - gateway_addresses: - type: array - items: - type: string - description: |- - UndelegatingGatewayList is used as the Value of `pending_undelegations`. - It is required to store a repeated list of strings as a map value. - poktroll.shared.ApplicationServiceConfig: - type: object - properties: - service: - title: The Service for which the application is configured - type: object - properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a certain - service but with some additional configs that identify it? - name: - type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a reminder - that an optional onchain representation of the service is - necessary - title: >- - ApplicationServiceConfig holds the service configuration the application - stakes for - poktroll.shared.Service: + format: uint64 + description: >- + maximum expected time per block (in nanoseconds), used to enforce + block delay. This parameter should reflect the + + largest amount of time that the chain might reasonably take to produce + the next block under normal operating + + conditions. A safe choice is 3-5x the expected time per block. + description: Params defines the set of Connection parameters. + ibc.core.connection.v1.Version: type: object properties: - id: - type: string - description: Unique identifier for the service - title: >- - For example, what if we want to request a session for a certain - service but with some additional configs that identify it? - name: + identifier: type: string - description: (Optional) Semantic human readable name for the service - title: >- - TODO_TECHDEBT: Name is currently unused but acts as a reminder that an - optional onchain representation of the service is necessary - title: >- - Service message to encapsulate unique and semantic identifiers for a - service on the network + title: unique version identifier + features: + type: array + items: + type: string + title: list of features compatible with the specified identifier + description: |- + Version defines the versioning scheme used to negotiate the IBC verison in + the connection handshake. poktroll.application.MsgDelegateToGateway: type: object properties: @@ -25365,6 +24532,54 @@ definitions: description: |- MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message. + poktroll.application.Params: + type: object + properties: + max_delegated_gateways: + type: string + format: uint64 + description: Params defines the parameters for the module. + poktroll.shared.ApplicationServiceConfig: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a certain + service but with some additional configs that identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a reminder + that an optional onchain representation of the service is + necessary + title: >- + ApplicationServiceConfig holds the service configuration the application + stakes for + poktroll.shared.Service: + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a certain + service but with some additional configs that identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a reminder that an + optional onchain representation of the service is necessary + title: >- + Service message to encapsulate unique and semantic identifiers for a + service on the network poktroll.gateway.MsgStakeGateway: type: object properties: @@ -25771,13 +24986,133 @@ definitions: This will be deducted from the signer's account balance, and transferred to the pocket network foundation. description: Params defines the parameters for the module. - poktroll.session.Params: + poktroll.session.MsgUpdateParams: type: object properties: - num_blocks_per_session: + authority: type: string - format: uint64 + description: >- + authority is the address that controls the module (defaults to x/gov + unless overwritten). + params: + description: |- + params defines the x/session parameters to update. + NOTE: All parameters must be supplied. + type: object + description: MsgUpdateParams is the Msg/UpdateParams request type. + poktroll.session.MsgUpdateParamsResponse: + type: object + description: |- + MsgUpdateParamsResponse defines the response structure for executing a + MsgUpdateParams message. + poktroll.session.Params: + type: object description: Params defines the parameters for the module. + poktroll.application.Application: + type: object + properties: + address: + type: string + title: >- + The Bech32 address of the application using cosmos' ScalarDescriptor + to ensure deterministic encoding + stake: + title: The total amount of uPOKT the application has staked + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + service_configs: + type: array + items: + type: object + properties: + service: + title: The Service for which the application is configured + type: object + properties: + id: + type: string + description: Unique identifier for the service + title: >- + For example, what if we want to request a session for a + certain service but with some additional configs that + identify it? + name: + type: string + description: (Optional) Semantic human readable name for the service + title: >- + TODO_TECHDEBT: Name is currently unused but acts as a + reminder that an optional onchain representation of the + service is necessary + title: >- + ApplicationServiceConfig holds the service configuration the + application stakes for + title: >- + The list of services this appliccation is configured to request + service for + delegatee_gateway_addresses: + type: array + items: + type: string + description: >- + TODO_TECHDEBT: Rename `delegatee_gateway_addresses` to + `gateway_addresses_delegated_to`. + + Ensure to rename all relevant configs, comments, variables, function + names, etc as well. + + + The Bech32 encoded addresses for all delegatee Gateways, in a + non-nullable slice + pending_undelegations: + type: object + additionalProperties: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: >- + UndelegatingGatewayList is used as the Value of + `pending_undelegations`. + + It is required to store a repeated list of strings as a map value. + description: >- + A map from sessionEndHeights to a list of Gateways. + + The key is the height of the last block of the session during which + the + + respective undelegation was committed. + + The value is a list of gateways being undelegated from. + + TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment + + so its clear to everyone why this is necessary; + https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. + title: >- + Application defines the type used to store an on-chain definition and + state for an application + poktroll.application.UndelegatingGatewayList: + type: object + properties: + gateway_addresses: + type: array + items: + type: string + description: |- + UndelegatingGatewayList is used as the Value of `pending_undelegations`. + It is required to store a repeated list of strings as a map value. poktroll.session.QueryGetSessionResponse: type: object properties: @@ -26085,10 +25420,6 @@ definitions: params: description: params holds all the parameters of this module. type: object - properties: - num_blocks_per_session: - type: string - format: uint64 description: QueryParamsResponse is response type for the Query/Params RPC method. poktroll.session.Session: type: object @@ -26671,39 +26002,38 @@ definitions: title: >- SupplierServiceConfig holds the service configuration the supplier stakes for - poktroll.session.MsgUpdateParams: + poktroll.shared.Params: type: object properties: - authority: + num_blocks_per_session: type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). + format: uint64 + description: Params defines the parameters for the module. + poktroll.shared.QueryParamsResponse: + type: object + properties: params: - description: |- - params defines the x/session parameters to update. - NOTE: All parameters must be supplied. + description: params holds all the parameters of this module. type: object properties: num_blocks_per_session: type: string format: uint64 - description: MsgUpdateParams is the Msg/UpdateParams request type. - poktroll.session.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - poktroll.shared.Params: + description: QueryParamsResponse is response type for the Query/Params RPC method. + poktroll.shared.MsgUpdateParam: type: object - description: Params defines the parameters for the module. - poktroll.shared.QueryParamsResponse: + properties: + authority: + type: string + name: + type: string + asType: + type: string + poktroll.shared.MsgUpdateParamResponse: type: object properties: params: - description: params holds all the parameters of this module. - type: object - description: QueryParamsResponse is response type for the Query/Params RPC method. + type: string poktroll.shared.MsgUpdateParams: type: object properties: @@ -26713,11 +26043,12 @@ definitions: authority is the address that controls the module (defaults to x/gov unless overwritten). params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. + description: 'NOTE: All parameters must be supplied.' type: object + properties: + num_blocks_per_session: + type: string + format: uint64 description: MsgUpdateParams is the Msg/UpdateParams request type. poktroll.shared.MsgUpdateParamsResponse: type: object diff --git a/e2e/tests/parse_params_test.go b/e2e/tests/parse_params_test.go index f9e8cd306..e4c497931 100644 --- a/e2e/tests/parse_params_test.go +++ b/e2e/tests/parse_params_test.go @@ -82,7 +82,7 @@ func (s *suite) paramsMapToMsgUpdateParams(moduleName string, paramsMap paramsMa msgUpdateParams = s.newServiceMsgUpdateParams(paramsMap) // NB: gateway & supplier modules currently have no parameters default: - err := fmt.Errorf("unexpected module name %q", moduleName) + err := fmt.Errorf("ERROR: unexpected module name %q", moduleName) s.Fatal(err) panic(err) } @@ -255,8 +255,35 @@ func (s *suite) newMsgUpdateParam( }, }) } + case sharedtypes.ModuleName: + switch param.typeStr { + case "string": + msg = proto.Message(&sharedtypes.MsgUpdateParam{ + Authority: authority, + Name: param.name, + AsType: &sharedtypes.MsgUpdateParam_AsString{ + AsString: param.value.(string), + }, + }) + case "int64": + msg = proto.Message(&sharedtypes.MsgUpdateParam{ + Authority: authority, + Name: param.name, + AsType: &sharedtypes.MsgUpdateParam_AsInt64{ + AsInt64: param.value.(int64), + }, + }) + case "bytes": + msg = proto.Message(&sharedtypes.MsgUpdateParam{ + Authority: authority, + Name: param.name, + AsType: &sharedtypes.MsgUpdateParam_AsBytes{ + AsBytes: param.value.([]byte), + }, + }) + } default: - err := fmt.Errorf("unexpected module name %q", moduleName) + err := fmt.Errorf("ERROR: unexpected module name %q", moduleName) s.Fatal(err) panic(err) } diff --git a/e2e/tests/update_params.feature b/e2e/tests/update_params.feature index 57499f3a2..2d66d03eb 100644 --- a/e2e/tests/update_params.feature +++ b/e2e/tests/update_params.feature @@ -2,7 +2,7 @@ Feature: Params Namespace # TODO_DOCUMENT(@Olshansk): Document all of the on-chain governance parameters. Background: - + Scenario: An unauthorized user cannot update a module params Given the user has the pocketd binary installed And all "tokenomics" module params are set to their default values @@ -52,7 +52,7 @@ Feature: Params Namespace And all "" module params are set to their default values And an authz grant from the "gov" "module" account to the "pnf" "user" account for the "" message exists When the "pnf" account sends an authz exec message to update "" the module param - | name | value | type | + | name | value | type | | | | | Then the "" module param "" should be updated @@ -60,6 +60,7 @@ Feature: Params Namespace | module | message_type | param_name | param_value | param_type | | tokenomics | /poktroll.tokenomics.MsgUpdateParam | compute_units_to_tokens_multiplier | 68 | int64 | | proof | /poktroll.proof.MsgUpdateParam | min_relay_difficulty_bits | 12 | int64 | + | shared | /poktroll.shared.MsgUpdateParam | num_blocks_per_session | 8 | int64 | Scenario: An unauthorized user cannot update individual module params Given the user has the pocketd binary installed diff --git a/proto/poktroll/shared/tx.proto b/proto/poktroll/shared/tx.proto index 37938f942..12f0bd6dd 100644 --- a/proto/poktroll/shared/tx.proto +++ b/proto/poktroll/shared/tx.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package poktroll.shared; import "amino/amino.proto"; @@ -12,29 +13,48 @@ option go_package = "github.com/pokt-network/poktroll/x/shared/types"; // Msg defines the Msg service. service Msg { option (cosmos.msg.v1.service) = true; - + // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. - rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse); + rpc UpdateParam (MsgUpdateParam ) returns (MsgUpdateParamResponse ); } - // MsgUpdateParams is the Msg/UpdateParams request type. message MsgUpdateParams { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "poktroll/x/shared/MsgUpdateParams"; - + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "poktroll/x/shared/MsgUpdateParams"; + // authority is the address that controls the module (defaults to x/gov unless overwritten). string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // params defines the module parameters to update. - // + // NOTE: All parameters must be supplied. - Params params = 2 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} + +// MsgUpdateParam is the Msg/UpdateParam request type to update a single param. +message MsgUpdateParam { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address that controls the module (defaults to x/gov unless overwritten). + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + string name = 2; + oneof as_type { + string as_string = 3 [(gogoproto.jsontag) = "as_string"]; + int64 as_int64 = 6 [(gogoproto.jsontag) = "as_int64"]; + bytes as_bytes = 7 [(gogoproto.jsontag) = "as_bytes"]; + } +} + +// MsgUpdateParamResponse defines the response structure for executing a +// MsgUpdateParam message after a single param update. +message MsgUpdateParamResponse { + Params params = 1; +} + diff --git a/tools/scripts/authz/dao_genesis_authorizations.json b/tools/scripts/authz/dao_genesis_authorizations.json index 1982c2777..f3c826ce3 100644 --- a/tools/scripts/authz/dao_genesis_authorizations.json +++ b/tools/scripts/authz/dao_genesis_authorizations.json @@ -88,5 +88,14 @@ "msg": "\/poktroll.tokenomics.MsgUpdateParam" }, "expiration": "2500-01-01T00:00:00Z" + }, + { + "granter": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "grantee": "pokt1eeeksh2tvkh7wzmfrljnhw4wrhs55lcuvmekkw", + "authorization": { + "@type": "\/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "\/poktroll.shared.MsgUpdateParam" + }, + "expiration": "2500-01-01T00:00:00Z" } ] diff --git a/tools/scripts/params/shared_num_blocks_per_session.json b/tools/scripts/params/shared_num_blocks_per_session.json new file mode 100644 index 000000000..e2d33a017 --- /dev/null +++ b/tools/scripts/params/shared_num_blocks_per_session.json @@ -0,0 +1,12 @@ +{ + "body": { + "messages": [ + { + "@type": "/poktroll.shared.MsgUpdateParam", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "name": "num_blocks_per_session", + "as_int64": "4" + } + ] + } +} diff --git a/x/proof/keeper/msg_server_update_param.go b/x/proof/keeper/msg_server_update_param.go index 9b8770489..c20e46ca8 100644 --- a/x/proof/keeper/msg_server_update_param.go +++ b/x/proof/keeper/msg_server_update_param.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "github.com/pokt-network/poktroll/x/proof/types" ) @@ -27,7 +26,7 @@ func (k msgServer) UpdateParam( case types.ParamMinRelayDifficultyBits: value, ok := msg.AsType.(*types.MsgUpdateParam_AsInt64) if !ok { - return nil, fmt.Errorf("unsupported value type for %s param: %T", msg.Name, msg.AsType) + return nil, types.ErrProofParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } minRelayDifficultyBits := uint64(value.AsInt64) @@ -37,7 +36,7 @@ func (k msgServer) UpdateParam( params.MinRelayDifficultyBits = minRelayDifficultyBits default: - return nil, fmt.Errorf("unsupported param %q", msg.Name) + return nil, types.ErrProofParamInvalid.Wrapf("unsupported param %q", msg.Name) } if err := k.SetParams(ctx, params); err != nil { diff --git a/x/proof/types/message_update_param_test.go b/x/proof/types/message_update_param_test.go index 7b5328668..1fd4793a8 100644 --- a/x/proof/types/message_update_param_test.go +++ b/x/proof/types/message_update_param_test.go @@ -42,7 +42,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { }, expectedErr: ErrProofParamInvalid, }, { - name: "valid: correct authority and param name", + name: "valid: correct authority, param name, and type", msg: MsgUpdateParam{ Authority: sample.AccAddress(), Name: ParamMinRelayDifficultyBits, diff --git a/x/shared/keeper/msg_server_update_param.go b/x/shared/keeper/msg_server_update_param.go new file mode 100644 index 000000000..4768527cc --- /dev/null +++ b/x/shared/keeper/msg_server_update_param.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "context" + + "github.com/pokt-network/poktroll/x/shared/types" +) + +func (k msgServer) UpdateParam(ctx context.Context, msg *types.MsgUpdateParam) (*types.MsgUpdateParamResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + if k.GetAuthority() != msg.Authority { + return nil, types.ErrSharedInvalidSigner.Wrapf("invalid authority; expected %s, got %s", k.GetAuthority(), msg.Authority) + } + + params := k.GetParams(ctx) + + switch msg.Name { + case types.ParamNumBlocksPerSession: + value, ok := msg.AsType.(*types.MsgUpdateParam_AsInt64) + if !ok { + return nil, types.ErrSharedParamInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) + } + numBlocksPerSession := uint64(value.AsInt64) + + if err := types.ValidateNumBlocksPerSession(numBlocksPerSession); err != nil { + return nil, err + } + + params.NumBlocksPerSession = numBlocksPerSession + default: + return nil, types.ErrSharedParamInvalid.Wrapf("unsupported param %q", msg.Name) + } + + if err := k.SetParams(ctx, params); err != nil { + return nil, err + } + + updatedParams := k.GetParams(ctx) + return &types.MsgUpdateParamResponse{ + Params: &updatedParams, + }, nil +} diff --git a/x/shared/keeper/msg_server_update_param_test.go b/x/shared/keeper/msg_server_update_param_test.go new file mode 100644 index 000000000..65702fd45 --- /dev/null +++ b/x/shared/keeper/msg_server_update_param_test.go @@ -0,0 +1,42 @@ +package keeper_test + +import ( + "testing" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/x/shared/keeper" + + keepertest "github.com/pokt-network/poktroll/testutil/keeper" + sharedtypes "github.com/pokt-network/poktroll/x/shared/types" +) + +func TestMsgUpdateParam_UpdateNumBlocksPerSession(t *testing.T) { + var expectedNumBlocksPerSession int64 = 8 + + k, ctx := keepertest.SharedKeeper(t) + msgSrv := keeper.NewMsgServerImpl(k) + + // Set the parameters to their default values + defaultParams := sharedtypes.DefaultParams() + require.NoError(t, k.SetParams(ctx, defaultParams)) + + // Ensure the default values are different from the new values we want to set + require.NotEqual(t, uint64(expectedNumBlocksPerSession), defaultParams.NumBlocksPerSession) + + // Update the min relay difficulty bits + updateParamMsg := &sharedtypes.MsgUpdateParam{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Name: sharedtypes.ParamNumBlocksPerSession, + AsType: &sharedtypes.MsgUpdateParam_AsInt64{AsInt64: expectedNumBlocksPerSession}, + } + res, err := msgSrv.UpdateParam(ctx, updateParamMsg) + require.NoError(t, err) + + require.Equal(t, uint64(expectedNumBlocksPerSession), res.Params.NumBlocksPerSession) + + // TODO_BLOCKER: once we have more than one param per module, add assertions + // here which ensure that other params were not changed! +} diff --git a/x/shared/keeper/msg_update_params.go b/x/shared/keeper/msg_update_params.go index 8bdfb89b5..d131f648e 100644 --- a/x/shared/keeper/msg_update_params.go +++ b/x/shared/keeper/msg_update_params.go @@ -15,7 +15,7 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam } if k.GetAuthority() != req.Authority { - return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + return nil, errorsmod.Wrapf(types.ErrSharedInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/shared/module/autocli.go b/x/shared/module/autocli.go index 457ff7eff..8d872852a 100644 --- a/x/shared/module/autocli.go +++ b/x/shared/module/autocli.go @@ -23,11 +23,17 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { Tx: &autocliv1.ServiceCommandDescriptor{ Service: modulev1.Msg_ServiceDesc.ServiceName, EnhanceCustomCommand: true, // only required if you want to use the custom command - RpcCommandOptions: []*autocliv1.RpcCommandOptions{ - { - RpcMethod: "UpdateParams", - Skip: true, // skipped because authority gated - }, + RpcCommandOptions: []*autocliv1.RpcCommandOptions{ + // { + // RpcMethod: "UpdateParams", + // Skip: true, // skipped because authority gated + // }, + // { + // RpcMethod: "UpdateParam", + // Use: "update-param [name] [as-type]", + // Short: "Send a update-param tx", + // PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "name"}, {ProtoField: "asType"}}, + // }, // this line is used by ignite scaffolding # autocli/tx }, }, diff --git a/x/shared/module/simulation.go b/x/shared/module/simulation.go index 8d195231d..94808d486 100644 --- a/x/shared/module/simulation.go +++ b/x/shared/module/simulation.go @@ -23,7 +23,11 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgUpdateParam = "op_weight_msg_update_param" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateParam int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module. @@ -51,6 +55,17 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgUpdateParam int + simState.AppParams.GetOrGenerate(opWeightMsgUpdateParam, &weightMsgUpdateParam, nil, + func(_ *rand.Rand) { + weightMsgUpdateParam = defaultWeightMsgUpdateParam + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateParam, + sharedsimulation.SimulateMsgUpdateParam(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations @@ -59,6 +74,14 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // ProposalMsgs returns msgs used for governance proposals for simulations. func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + opWeightMsgUpdateParam, + defaultWeightMsgUpdateParam, + func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg { + sharedsimulation.SimulateMsgUpdateParam(am.accountKeeper, am.bankKeeper, am.keeper) + return nil + }, + ), // this line is used by starport scaffolding # simapp/module/OpMsg } } diff --git a/x/shared/simulation/update_param.go b/x/shared/simulation/update_param.go new file mode 100644 index 000000000..9a2e11016 --- /dev/null +++ b/x/shared/simulation/update_param.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/pokt-network/poktroll/x/shared/keeper" + "github.com/pokt-network/poktroll/x/shared/types" +) + +func SimulateMsgUpdateParam( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateParam{ + Authority: simAccount.Address.String(), + } + + // TODO: Handling the UpdateParam simulation + + return simtypes.NoOpMsg(types.ModuleName, sdk.MsgTypeURL(msg), "UpdateParam simulation not implemented"), nil, nil + } +} diff --git a/x/shared/types/codec.go b/x/shared/types/codec.go index ac5526374..17b958d5c 100644 --- a/x/shared/types/codec.go +++ b/x/shared/types/codec.go @@ -8,6 +8,9 @@ import ( ) func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParam{}, + ) // this line is used by starport scaffolding # 3 registry.RegisterImplementations((*sdk.Msg)(nil), diff --git a/x/shared/types/errors.go b/x/shared/types/errors.go index 9c60c7fed..5d56db228 100644 --- a/x/shared/types/errors.go +++ b/x/shared/types/errors.go @@ -8,7 +8,8 @@ import ( // x/shared module sentinel errors var ( - ErrInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") - ErrSessionParamNameInvalid = sdkerrors.Register(ModuleName, 1101, "the provided param name is invalid") - ErrSessionParamInvalid = sdkerrors.Register(ModuleName, 1102, "the provided param is invalid") + ErrSharedInvalidSigner = sdkerrors.Register(ModuleName, 1100, "expected gov account as only signer for proposal message") + ErrSharedInvalidAddress = sdkerrors.Register(ModuleName, 1101, "invalid address") + ErrSharedParamNameInvalid = sdkerrors.Register(ModuleName, 1102, "the provided param name is invalid") + ErrSharedParamInvalid = sdkerrors.Register(ModuleName, 1103, "the provided param is invalid") ) diff --git a/x/shared/types/genesis.go b/x/shared/types/genesis.go index dee271e3a..82f8c67db 100644 --- a/x/shared/types/genesis.go +++ b/x/shared/types/genesis.go @@ -10,15 +10,15 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - // this line is used by starport scaffolding # genesis/types/validate + // this line is used by starport scaffolding # genesis/types/validate return gs.Params.ValidateBasic() } diff --git a/x/shared/types/message_update_param.go b/x/shared/types/message_update_param.go new file mode 100644 index 000000000..3cb9b8f2e --- /dev/null +++ b/x/shared/types/message_update_param.go @@ -0,0 +1,67 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = (*MsgUpdateParam)(nil) + +// NewMsgUpdateParam creates a new MsgUpdateParam instance for a single +// governance parameter update. +func NewMsgUpdateParam(authority string, name string, value any) (*MsgUpdateParam, error) { + var valueAsType isMsgUpdateParam_AsType + + switch v := value.(type) { + case string: + valueAsType = &MsgUpdateParam_AsString{AsString: v} + case int64: + valueAsType = &MsgUpdateParam_AsInt64{AsInt64: v} + case []byte: + valueAsType = &MsgUpdateParam_AsBytes{AsBytes: v} + default: + return nil, fmt.Errorf("unexpected param value type: %T", value) + } + + return &MsgUpdateParam{ + Authority: authority, + Name: name, + AsType: valueAsType, + }, nil +} + +// ValidateBasic performs a basic validation of the MsgUpdateParam fields. It ensures +// the parameter name is supported and the parameter type matches the expected type for +// a given parameter name. +func (msg *MsgUpdateParam) ValidateBasic() error { + // Validate the address + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return ErrSharedInvalidAddress.Wrapf("invalid authority address %s; (%v)", msg.Authority, err) + } + + // Parameter value cannot be nil. + if msg.AsType == nil { + return ErrSharedParamInvalid.Wrap("missing param AsType") + } + + // Parameter name must be supported by this module. + switch msg.Name { + case ParamNumBlocksPerSession: + return msg.paramTypeIsInt64() + default: + return ErrSharedParamNameInvalid.Wrapf("unsupported name param %q", msg.Name) + } +} + +// paramTypeIsInt64 checks if the parameter type is int64, returning an error if not. +func (msg *MsgUpdateParam) paramTypeIsInt64() error { + if _, ok := msg.AsType.(*MsgUpdateParam_AsInt64); !ok { + return ErrSharedParamInvalid.Wrapf( + "invalid type for param %q expected %T, got %T", + msg.Name, &MsgUpdateParam_AsInt64{}, + msg.AsType, + ) + } + return nil +} diff --git a/x/shared/types/message_update_param_test.go b/x/shared/types/message_update_param_test.go new file mode 100644 index 000000000..09acc022e --- /dev/null +++ b/x/shared/types/message_update_param_test.go @@ -0,0 +1,60 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/pokt-network/poktroll/testutil/sample" +) + +func TestMsgUpdateParam_ValidateBasic(t *testing.T) { + tests := []struct { + desc string + msg MsgUpdateParam + expectedErr error + }{ + { + desc: "invalid: authority address invalid", + msg: MsgUpdateParam{ + Authority: "invalid_address", + Name: "", // Doesn't matter for this test + AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, + }, + expectedErr: ErrSharedInvalidAddress, + }, { + desc: "invalid: param name incorrect (non-existent)", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: "WRONG_num_blocks_per_session", + AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, + }, + expectedErr: ErrSharedParamNameInvalid, + }, { + desc: "invalid: incorrect param type", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: ParamNumBlocksPerSession, + AsType: &MsgUpdateParam_AsString{AsString: "invalid"}, + }, + expectedErr: ErrSharedParamInvalid, + }, { + desc: "valid: correct authority, param name, and type", + msg: MsgUpdateParam{ + Authority: sample.AccAddress(), + Name: ParamNumBlocksPerSession, + AsType: &MsgUpdateParam_AsInt64{AsInt64: 1}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.expectedErr != nil { + require.ErrorContains(t, err, tt.expectedErr.Error()) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/shared/types/params.go b/x/shared/types/params.go index a310639a5..9cfcf5bd5 100644 --- a/x/shared/types/params.go +++ b/x/shared/types/params.go @@ -56,11 +56,11 @@ func (params *Params) ValidateBasic() error { func ValidateNumBlocksPerSession(v interface{}) error { numBlocksPerSession, ok := v.(uint64) if !ok { - return ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", v) + return ErrSharedParamInvalid.Wrapf("invalid parameter type: %T", v) } if numBlocksPerSession < 1 { - return ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) + return ErrSharedParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", numBlocksPerSession) } return nil diff --git a/x/shared/types/params_test.go b/x/shared/types/params_test.go index 5c9f2e829..a2611b04a 100644 --- a/x/shared/types/params_test.go +++ b/x/shared/types/params_test.go @@ -15,12 +15,12 @@ func TestParams_ValidateNumBlocksPerSession(t *testing.T) { { desc: "invalid type", numBlocksPerSession: "invalid", - err: ErrSessionParamInvalid.Wrapf("invalid parameter type: %T", "invalid"), + err: ErrSharedParamInvalid.Wrapf("invalid parameter type: %T", "invalid"), }, { desc: "zero NumBlocksPerSession", numBlocksPerSession: uint64(0), - err: ErrSessionParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", uint64(0)), + err: ErrSharedParamInvalid.Wrapf("invalid NumBlocksPerSession: (%v)", uint64(0)), }, { desc: "valid NumBlocksPerSession", diff --git a/x/shared/types/tx.pb.go b/x/shared/types/tx.pb.go index 1d34c4e46..a16ed606b 100644 --- a/x/shared/types/tx.pb.go +++ b/x/shared/types/tx.pb.go @@ -35,8 +35,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgUpdateParams struct { // authority is the address that controls the module (defaults to x/gov unless overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // params defines the module parameters to update. - // // NOTE: All parameters must be supplied. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` } @@ -126,37 +124,212 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgUpdateParam is the Msg/UpdateParam request type to update a single param. +type MsgUpdateParam struct { + // authority is the address that controls the module (defaults to x/gov unless overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Types that are valid to be assigned to AsType: + // + // *MsgUpdateParam_AsString + // *MsgUpdateParam_AsInt64 + // *MsgUpdateParam_AsBytes + AsType isMsgUpdateParam_AsType `protobuf_oneof:"as_type"` +} + +func (m *MsgUpdateParam) Reset() { *m = MsgUpdateParam{} } +func (m *MsgUpdateParam) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParam) ProtoMessage() {} +func (*MsgUpdateParam) Descriptor() ([]byte, []int) { + return fileDescriptor_3f2a7564b43f4d89, []int{2} +} +func (m *MsgUpdateParam) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParam) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParam.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParam) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParam.Merge(m, src) +} +func (m *MsgUpdateParam) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParam) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParam.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParam proto.InternalMessageInfo + +type isMsgUpdateParam_AsType interface { + isMsgUpdateParam_AsType() + MarshalTo([]byte) (int, error) + Size() int +} + +type MsgUpdateParam_AsString struct { + AsString string `protobuf:"bytes,3,opt,name=as_string,json=asString,proto3,oneof" json:"as_string"` +} +type MsgUpdateParam_AsInt64 struct { + AsInt64 int64 `protobuf:"varint,6,opt,name=as_int64,json=asInt64,proto3,oneof" json:"as_int64"` +} +type MsgUpdateParam_AsBytes struct { + AsBytes []byte `protobuf:"bytes,7,opt,name=as_bytes,json=asBytes,proto3,oneof" json:"as_bytes"` +} + +func (*MsgUpdateParam_AsString) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsInt64) isMsgUpdateParam_AsType() {} +func (*MsgUpdateParam_AsBytes) isMsgUpdateParam_AsType() {} + +func (m *MsgUpdateParam) GetAsType() isMsgUpdateParam_AsType { + if m != nil { + return m.AsType + } + return nil +} + +func (m *MsgUpdateParam) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParam) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgUpdateParam) GetAsString() string { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsString); ok { + return x.AsString + } + return "" +} + +func (m *MsgUpdateParam) GetAsInt64() int64 { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsInt64); ok { + return x.AsInt64 + } + return 0 +} + +func (m *MsgUpdateParam) GetAsBytes() []byte { + if x, ok := m.GetAsType().(*MsgUpdateParam_AsBytes); ok { + return x.AsBytes + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*MsgUpdateParam) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*MsgUpdateParam_AsString)(nil), + (*MsgUpdateParam_AsInt64)(nil), + (*MsgUpdateParam_AsBytes)(nil), + } +} + +// MsgUpdateParamResponse defines the response structure for executing a +// MsgUpdateParam message after a single param update. +type MsgUpdateParamResponse struct { + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` +} + +func (m *MsgUpdateParamResponse) Reset() { *m = MsgUpdateParamResponse{} } +func (m *MsgUpdateParamResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamResponse) ProtoMessage() {} +func (*MsgUpdateParamResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3f2a7564b43f4d89, []int{3} +} +func (m *MsgUpdateParamResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateParamResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamResponse.Merge(m, src) +} +func (m *MsgUpdateParamResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamResponse proto.InternalMessageInfo + +func (m *MsgUpdateParamResponse) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "poktroll.shared.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "poktroll.shared.MsgUpdateParamsResponse") + proto.RegisterType((*MsgUpdateParam)(nil), "poktroll.shared.MsgUpdateParam") + proto.RegisterType((*MsgUpdateParamResponse)(nil), "poktroll.shared.MsgUpdateParamResponse") } func init() { proto.RegisterFile("poktroll/shared/tx.proto", fileDescriptor_3f2a7564b43f4d89) } var fileDescriptor_3f2a7564b43f4d89 = []byte{ - // 344 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0xc8, 0xcf, 0x2e, - 0x29, 0xca, 0xcf, 0xc9, 0xd1, 0x2f, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc9, 0xe8, 0x41, 0x64, 0xa4, 0x04, 0x13, 0x73, 0x33, - 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x44, 0x8d, 0x94, 0x78, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, - 0x6e, 0x71, 0xba, 0x7e, 0x99, 0x21, 0x88, 0x82, 0x4a, 0x48, 0x42, 0x24, 0xe2, 0xc1, 0x3c, 0x7d, - 0x08, 0x07, 0x2a, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x11, 0x07, 0xb1, 0xa0, 0xa2, 0x32, 0xe8, - 0xee, 0x28, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0xea, 0x51, 0xda, 0xcd, 0xc8, 0xc5, 0xef, 0x5b, 0x9c, - 0x1e, 0x5a, 0x90, 0x92, 0x58, 0x92, 0x1a, 0x00, 0x96, 0x11, 0x32, 0xe3, 0xe2, 0x4c, 0x2c, 0x2d, - 0xc9, 0xc8, 0x2f, 0xca, 0x2c, 0xa9, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x92, 0xb8, 0xb4, - 0x45, 0x57, 0x04, 0x6a, 0x99, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0x71, 0x70, 0x49, 0x51, 0x66, - 0x5e, 0x7a, 0x10, 0x42, 0xa9, 0x90, 0x15, 0x17, 0x1b, 0xc4, 0x6c, 0x09, 0x26, 0x05, 0x46, 0x0d, - 0x6e, 0x23, 0x71, 0x3d, 0x34, 0x8f, 0xea, 0x41, 0x2c, 0x70, 0xe2, 0x3c, 0x71, 0x4f, 0x9e, 0x61, - 0xc5, 0xf3, 0x0d, 0x5a, 0x8c, 0x41, 0x50, 0x1d, 0x56, 0x26, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0xcc, - 0xea, 0x7a, 0xbe, 0x41, 0x4b, 0x11, 0xee, 0xf0, 0x0a, 0x98, 0xd3, 0xd1, 0x5c, 0xaa, 0x24, 0xc9, - 0x25, 0x8e, 0x26, 0x14, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x6a, 0x94, 0xc1, 0xc5, 0xec, - 0x5b, 0x9c, 0x2e, 0x14, 0xc5, 0xc5, 0x83, 0xe2, 0x37, 0x05, 0x0c, 0x37, 0xa1, 0x19, 0x20, 0xa5, - 0x41, 0x48, 0x05, 0xcc, 0x0a, 0x29, 0xd6, 0x06, 0x90, 0x17, 0x9c, 0x3c, 0x4f, 0x3c, 0x92, 0x63, - 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, - 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, - 0x3f, 0x57, 0x1f, 0x64, 0xa8, 0x6e, 0x5e, 0x6a, 0x49, 0x79, 0x7e, 0x51, 0xb6, 0x3e, 0xa6, 0xcf, - 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x91, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0x86, 0xe5, 0x6f, 0x48, 0x3c, 0x02, 0x00, 0x00, + // 498 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xbf, 0x6f, 0xd3, 0x40, + 0x14, 0xf6, 0x11, 0x48, 0xea, 0x6b, 0x68, 0x85, 0x55, 0x11, 0x37, 0x42, 0x8e, 0xc9, 0x82, 0x89, + 0xa8, 0x4f, 0x94, 0xaa, 0x43, 0x36, 0x3c, 0x35, 0x43, 0x25, 0x64, 0x84, 0x90, 0xba, 0x44, 0x97, + 0xe6, 0xe4, 0x58, 0xad, 0x7d, 0x96, 0xdf, 0x15, 0x9a, 0x0d, 0x31, 0x32, 0xf1, 0x67, 0x30, 0x66, + 0x60, 0x63, 0x62, 0xeb, 0x58, 0x31, 0x31, 0x45, 0x28, 0x19, 0x22, 0xf5, 0x5f, 0x60, 0x41, 0x3e, + 0xff, 0x08, 0x71, 0x25, 0x22, 0xb1, 0x24, 0xef, 0xbe, 0xef, 0x7b, 0xdf, 0xbd, 0x77, 0xef, 0x19, + 0xeb, 0x11, 0x3f, 0x13, 0x31, 0x3f, 0x3f, 0x27, 0x30, 0xa2, 0x31, 0x1b, 0x12, 0x71, 0x69, 0x47, + 0x31, 0x17, 0x5c, 0xdb, 0xce, 0x19, 0x3b, 0x65, 0x9a, 0x0f, 0x68, 0xe0, 0x87, 0x9c, 0xc8, 0xdf, + 0x54, 0xd3, 0x6c, 0x9c, 0x72, 0x08, 0x38, 0x90, 0x00, 0x3c, 0xf2, 0xee, 0x79, 0xf2, 0x97, 0x11, + 0xbb, 0x29, 0xd1, 0x97, 0x27, 0x92, 0x1e, 0x32, 0x6a, 0xc7, 0xe3, 0x1e, 0x4f, 0xf1, 0x24, 0xca, + 0xd0, 0x47, 0xe5, 0x3a, 0x22, 0x1a, 0xd3, 0x20, 0xcb, 0x69, 0x7f, 0x43, 0x78, 0xfb, 0x18, 0xbc, + 0x37, 0xd1, 0x90, 0x0a, 0xf6, 0x4a, 0x32, 0xda, 0x21, 0x56, 0xe9, 0x85, 0x18, 0xf1, 0xd8, 0x17, + 0x63, 0x1d, 0x99, 0xc8, 0x52, 0x1d, 0xfd, 0xc7, 0xd7, 0xbd, 0x9d, 0xec, 0xb2, 0x97, 0xc3, 0x61, + 0xcc, 0x00, 0x5e, 0x8b, 0xd8, 0x0f, 0x3d, 0x77, 0x29, 0xd5, 0xba, 0xb8, 0x9a, 0x7a, 0xeb, 0x77, + 0x4c, 0x64, 0x6d, 0xee, 0x37, 0xec, 0x52, 0xa3, 0x76, 0x7a, 0x81, 0xa3, 0x5e, 0x4d, 0x5b, 0xca, + 0x97, 0xc5, 0xa4, 0x83, 0xdc, 0x2c, 0xa3, 0x7b, 0xf0, 0x71, 0x31, 0xe9, 0x2c, 0xbd, 0x3e, 0x2d, + 0x26, 0x9d, 0xc7, 0x45, 0xe1, 0x97, 0x79, 0xe9, 0xa5, 0x4a, 0xdb, 0xbb, 0xb8, 0x51, 0x82, 0x5c, + 0x06, 0x11, 0x0f, 0x81, 0xb5, 0x7f, 0x23, 0xbc, 0xb5, 0xca, 0xfd, 0x77, 0x5f, 0x1a, 0xbe, 0x1b, + 0xd2, 0x80, 0xc9, 0xae, 0x54, 0x57, 0xc6, 0xda, 0x33, 0xac, 0x52, 0xe8, 0x83, 0xd4, 0xea, 0x15, + 0xe9, 0x75, 0xff, 0x66, 0xda, 0x5a, 0x82, 0x47, 0x8a, 0xbb, 0x41, 0x33, 0x33, 0xed, 0x29, 0xde, + 0xa0, 0xd0, 0xf7, 0x43, 0x71, 0x78, 0xa0, 0x57, 0x4d, 0x64, 0x55, 0x9c, 0xfa, 0xcd, 0xb4, 0x55, + 0x60, 0x47, 0x8a, 0x5b, 0xa3, 0xd0, 0x4b, 0xc2, 0x4c, 0x3a, 0x18, 0x0b, 0x06, 0x7a, 0xcd, 0x44, + 0x56, 0xbd, 0x90, 0x4a, 0x2c, 0x95, 0x3a, 0x49, 0xd8, 0xdd, 0x5a, 0x7d, 0x33, 0x47, 0xc5, 0x35, + 0x0a, 0x7d, 0x31, 0x8e, 0x58, 0xbb, 0x87, 0x1f, 0xae, 0x36, 0x9f, 0xbf, 0x8b, 0x46, 0x8a, 0x21, + 0xa1, 0x7f, 0x0e, 0x29, 0x9f, 0xcc, 0xfe, 0x77, 0x84, 0x2b, 0xc7, 0xe0, 0x69, 0x27, 0xb8, 0xbe, + 0xb2, 0x25, 0xe6, 0xad, 0xc4, 0xd2, 0x28, 0x9a, 0xd6, 0x3a, 0x45, 0x51, 0xd4, 0x5b, 0xbc, 0xf9, + 0xf7, 0xa0, 0x5a, 0x6b, 0x12, 0x9b, 0x4f, 0xd6, 0x08, 0x72, 0xe3, 0xe6, 0xbd, 0x0f, 0xc9, 0x96, + 0x39, 0xbd, 0xab, 0x99, 0x81, 0xae, 0x67, 0x06, 0xfa, 0x35, 0x33, 0xd0, 0xe7, 0xb9, 0xa1, 0x5c, + 0xcf, 0x0d, 0xe5, 0xe7, 0xdc, 0x50, 0x4e, 0x88, 0xe7, 0x8b, 0xd1, 0xc5, 0xc0, 0x3e, 0xe5, 0x01, + 0x49, 0x3c, 0xf7, 0x42, 0x26, 0xde, 0xf3, 0xf8, 0x8c, 0xdc, 0x5e, 0xbe, 0xe4, 0x61, 0x61, 0x50, + 0x95, 0xdf, 0xcd, 0x8b, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x42, 0x5a, 0x25, 0xdf, 0x03, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -174,6 +347,7 @@ type MsgClient interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) } type msgClient struct { @@ -193,11 +367,21 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) UpdateParam(ctx context.Context, in *MsgUpdateParam, opts ...grpc.CallOption) (*MsgUpdateParamResponse, error) { + out := new(MsgUpdateParamResponse) + err := c.cc.Invoke(ctx, "/poktroll.shared.Msg/UpdateParam", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a (governance) operation for updating the module // parameters. The authority defaults to the x/gov module account. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + UpdateParam(context.Context, *MsgUpdateParam) (*MsgUpdateParamResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -207,6 +391,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) UpdateParam(ctx context.Context, req *MsgUpdateParam) (*MsgUpdateParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParam not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -230,6 +417,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_UpdateParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParam) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParam(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/poktroll.shared.Msg/UpdateParam", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParam(ctx, req.(*MsgUpdateParam)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "poktroll.shared.Msg", HandlerType: (*MsgServer)(nil), @@ -238,6 +443,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "UpdateParam", + Handler: _Msg_UpdateParam_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "poktroll/shared/tx.proto", @@ -306,6 +515,129 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgUpdateParam) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParam) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AsType != nil { + { + size := m.AsType.Size() + i -= size + if _, err := m.AsType.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParam_AsString) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam_AsString) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.AsString) + copy(dAtA[i:], m.AsString) + i = encodeVarintTx(dAtA, i, uint64(len(m.AsString))) + i-- + dAtA[i] = 0x1a + return len(dAtA) - i, nil +} +func (m *MsgUpdateParam_AsInt64) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam_AsInt64) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + i = encodeVarintTx(dAtA, i, uint64(m.AsInt64)) + i-- + dAtA[i] = 0x30 + return len(dAtA) - i, nil +} +func (m *MsgUpdateParam_AsBytes) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParam_AsBytes) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.AsBytes != nil { + i -= len(m.AsBytes) + copy(dAtA[i:], m.AsBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.AsBytes))) + i-- + dAtA[i] = 0x3a + } + return len(dAtA) - i, nil +} +func (m *MsgUpdateParamResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateParamResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -341,6 +673,70 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgUpdateParam) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.AsType != nil { + n += m.AsType.Size() + } + return n +} + +func (m *MsgUpdateParam_AsString) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AsString) + n += 1 + l + sovTx(uint64(l)) + return n +} +func (m *MsgUpdateParam_AsInt64) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += 1 + sovTx(uint64(m.AsInt64)) + return n +} +func (m *MsgUpdateParam_AsBytes) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AsBytes != nil { + l = len(m.AsBytes) + n += 1 + l + sovTx(uint64(l)) + } + return n +} +func (m *MsgUpdateParamResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -512,6 +908,291 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateParam) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParam: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParam: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AsString", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AsType = &MsgUpdateParam_AsString{string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AsInt64", wireType) + } + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AsType = &MsgUpdateParam_AsInt64{v} + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AsBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.AsType = &MsgUpdateParam_AsBytes{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tokenomics/keeper/msg_server_update_param.go b/x/tokenomics/keeper/msg_server_update_param.go index 0f1415e0f..469848a42 100644 --- a/x/tokenomics/keeper/msg_server_update_param.go +++ b/x/tokenomics/keeper/msg_server_update_param.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "github.com/pokt-network/poktroll/x/tokenomics/types" ) @@ -27,7 +26,7 @@ func (k msgServer) UpdateParam( case types.ParamComputeUnitsToTokensMultiplier: value, ok := msg.AsType.(*types.MsgUpdateParam_AsInt64) if !ok { - return nil, fmt.Errorf("unsupported value type for %s param: %T", msg.Name, msg.AsType) + return nil, types.ErrTokenomicsParamsInvalid.Wrapf("unsupported value type for %s param: %T", msg.Name, msg.AsType) } computeUnitsToTokensMultiplier := uint64(value.AsInt64) @@ -37,7 +36,7 @@ func (k msgServer) UpdateParam( params.ComputeUnitsToTokensMultiplier = computeUnitsToTokensMultiplier default: - return nil, fmt.Errorf("unsupported param %q", msg.Name) + return nil, types.ErrTokenomicsParamsInvalid.Wrapf("unsupported param %q", msg.Name) } if err := k.SetParams(ctx, params); err != nil { diff --git a/x/tokenomics/types/message_update_param_test.go b/x/tokenomics/types/message_update_param_test.go index c0898f089..4be202bfb 100644 --- a/x/tokenomics/types/message_update_param_test.go +++ b/x/tokenomics/types/message_update_param_test.go @@ -41,7 +41,7 @@ func TestMsgUpdateParam_ValidateBasic(t *testing.T) { }, expectedErr: ErrTokenomicsParamInvalid, }, { - name: "valid: correct authority and param name", + name: "valid: correct authority, param name, and type", msg: MsgUpdateParam{ Authority: sample.AccAddress(), Name: ParamComputeUnitsToTokensMultiplier, From 8993488d1c3376d67e451697da92889cb3d5f4a6 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 31 May 2024 10:13:37 +0200 Subject: [PATCH 10/11] test: ValidateClaimWindowOpenOffsetBlocks --- x/shared/types/params_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/x/shared/types/params_test.go b/x/shared/types/params_test.go index a2611b04a..f64cc33af 100644 --- a/x/shared/types/params_test.go +++ b/x/shared/types/params_test.go @@ -40,3 +40,33 @@ func TestParams_ValidateNumBlocksPerSession(t *testing.T) { }) } } + +func TestParams_ValidateClaimWindowOpenOffsetBlocks(t *testing.T) { + tests := []struct { + desc string + claimWindowOpenOffsetBlocks any + err error + }{ + { + desc: "invalid type", + claimWindowOpenOffsetBlocks: "invalid", + err: ErrSharedParamInvalid.Wrapf("invalid parameter type: %T", "invalid"), + }, + { + desc: "valid ClaimWindowOpenOffsetBlocks", + claimWindowOpenOffsetBlocks: uint64(4), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := ValidateClaimWindowOpenOffsetBlocks(tt.claimWindowOpenOffsetBlocks) + if tt.err != nil { + require.Error(t, err) + require.Contains(t, err.Error(), tt.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +} From f906bdb603af06c642a534e671b5e96bf8b9a77c Mon Sep 17 00:00:00 2001 From: Bryan White Date: Fri, 31 May 2024 10:17:49 +0200 Subject: [PATCH 11/11] test: ValidateClaimWindowCloseOffsetBlocks --- x/shared/types/params_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/x/shared/types/params_test.go b/x/shared/types/params_test.go index f64cc33af..bb68a41ce 100644 --- a/x/shared/types/params_test.go +++ b/x/shared/types/params_test.go @@ -70,3 +70,33 @@ func TestParams_ValidateClaimWindowOpenOffsetBlocks(t *testing.T) { }) } } + +func TestParams_ValidateClaimWindowCloseOffsetBlocks(t *testing.T) { + tests := []struct { + desc string + claimWindowCloseOffsetBlocks any + err error + }{ + { + desc: "invalid type", + claimWindowCloseOffsetBlocks: "invalid", + err: ErrSharedParamInvalid.Wrapf("invalid parameter type: %T", "invalid"), + }, + { + desc: "valid ClaimWindowCloseOffsetBlocks", + claimWindowCloseOffsetBlocks: uint64(4), + }, + } + + for _, tt := range tests { + t.Run(tt.desc, func(t *testing.T) { + err := ValidateClaimWindowCloseOffsetBlocks(tt.claimWindowCloseOffsetBlocks) + if tt.err != nil { + require.Error(t, err) + require.Contains(t, err.Error(), tt.err.Error()) + } else { + require.NoError(t, err) + } + }) + } +}