-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Supplier] Add MsgUpdateParam
to application module
#849
Merged
Merged
Changes from 139 commits
Commits
Show all changes
156 commits
Select commit
Hold shift + click to select a range
d1cd5e6
scaffold: message update-param --module gateway --signer authority na…
bryanchriswhite 91eecfc
chore: update gateway MsgUpdateParam fields
bryanchriswhite ef62280
chore: update MsgUpdateParamResponse fields
bryanchriswhite f7a6e5b
chore: comment out autocli for gateway module param updates
bryanchriswhite 8957f1c
fix: linter error
bryanchriswhite 3016ca3
revert: premature changes
bryanchriswhite 899effb
feat: add min_stake gateway module param
bryanchriswhite 83c1d74
chore: cleanup makefiles and param update JSON files
bryanchriswhite 55e6a31
chore: add gateway module param make targets
bryanchriswhite ddd68bb
refctor: consolidate param config types
bryanchriswhite fa8caf6
tests: improve error messaging
bryanchriswhite ae006e2
tests: add coverage over gateway min stake param updates
bryanchriswhite e92e3b1
chore: add as_coin as_type type 😉
bryanchriswhite b2e1267
chore: add app MsgUpdateParam to genesis authorizations
bryanchriswhite 0373fa2
fix: typo
bryanchriswhite da7894a
chore: cleanup makefiles
bryanchriswhite 015c537
wip: fixing tests
bryanchriswhite 1ac6c48
tests: add tests
bryanchriswhite db366f6
tests: remove erroneous case
bryanchriswhite 60bef17
test: gateway staking below minimum fails
bryanchriswhite a21687f
feat: gateway min stake validation & grpc status error returns
bryanchriswhite 7e9f857
chore: cleanup comments
bryanchriswhite 4140710
scaffold: message update-param --module examplemod --signer authority…
bryanchriswhite 0a8d922
chore: update MsgUpdateParam fields
bryanchriswhite c88edd6
chore: comment out application MsgUpdateParam autocli
bryanchriswhite da51239
chore: add application MsgUpdateParam to dao genesis authorizations
bryanchriswhite 45c5a99
chore: update NewMsgUpdateParam constructor
bryanchriswhite d987e09
fix: simulations generated code
bryanchriswhite 0da255d
chore: add min_stake param to application module params
bryanchriswhite 4542628
chore: update params config for param updates test suite
bryanchriswhite b81ca9e
chore: add parameter validation
bryanchriswhite cdff4b3
chore: add param update make targets and JSON msgs
bryanchriswhite be24753
chore: add default application min_stake param of 1 POKT to genesis c…
bryanchriswhite 45b6e5c
chore: update MsgUpdateParamResponse & add AsUint64 AsType type
bryanchriswhite b3e139a
feat: implement MsgUpdateParam handler
bryanchriswhite 872202b
test: MsgUpdateParam handler
bryanchriswhite a49d69b
feat: implement NewMsgUpdateParam constructor
bryanchriswhite d63a429
chore: add min_stake validation
bryanchriswhite 9040bf0
chore: tidy up
bryanchriswhite 4340590
chore: review feedback improvements
bryanchriswhite 4b8e95b
Merge branch 'main' into issues/612/chore/gateway-msg-update-param
bryanchriswhite 352afa1
chore: review feedback improvements
bryanchriswhite 6afdaef
fix: linter errors
bryanchriswhite 0839ae4
chore: review feedback improvements
bryanchriswhite 34b0d6d
Merge remote-tracking branch 'pokt/issues/612/chore/gateway-msg-updat…
bryanchriswhite f48fa66
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite 6c5e13f
chore: review feedback improvements
bryanchriswhite a77877b
fix: test error message
bryanchriswhite 9f65d25
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite 28962ba
Merge remote-tracking branch 'pokt/main' into issues/612/param/min-st…
bryanchriswhite 497ecd9
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite d92eb59
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite 941b801
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 36e5f2e
chore: update message_update_param_test.go
bryanchriswhite 2baa173
fix: genesis tests
bryanchriswhite 7018149
chore: use AsInt64 to update MaxDelegatedGateways for consistency
bryanchriswhite c36fe79
chore: ensure application stake handler returns grpc status errors
bryanchriswhite eab9417
tests: update app stake msg handler unit tests
bryanchriswhite da9b322
feat: enforce application min stake when staking
bryanchriswhite 5e47c98
fix: failing unit tests
bryanchriswhite 323299e
chore: add PreGeneratedAccountIterator#MustNext()
bryanchriswhite d888548
chore: update require deps for RingClient
bryanchriswhite e87564d
refactor: extract application unbonding to method
bryanchriswhite 7d5c17b
test: app is unbonded when settlement lowers stake below min
bryanchriswhite 030f2ef
feat: unbond app when stake drops below min when settling
bryanchriswhite 3e77f7c
chore: add TODO_NEXT comments
bryanchriswhite 090ca9a
fix: failing tests
bryanchriswhite c14ad46
chore: add TODOs & update comments
bryanchriswhite d0b4187
chore: add TODOs & update comments
bryanchriswhite 891a858
chore: review feedback improvements
bryanchriswhite 08e99ba
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite da9a240
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite d85d969
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 47da555
Merge branch 'issues/612/application/min-stake-param' into issues/612…
bryanchriswhite 0f55e91
Merge branch 'issues/612/application/staking' into issues/612/applica…
bryanchriswhite d98b22b
test: simplify
bryanchriswhite ccc3f53
fix: e2e test
bryanchriswhite 47e0993
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite c08abfd
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite 8336d76
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 9386791
Merge branch 'issues/612/application/min-stake-param' into issues/612…
bryanchriswhite 0a72a83
Merge branch 'issues/612/application/staking' into issues/612/applica…
bryanchriswhite ce5b693
chore: increase genesis app stakes so E2E tests don't burn them out
bryanchriswhite 2d2e815
scaffold: message update-param --module examplemod --signer authority…
bryanchriswhite bb0267d
chore: update MsgUpdateParam & MsgUpdateParamResponse field types
bryanchriswhite 83b7311
chore: comment out autoCLI
bryanchriswhite fd42c5e
chore: add supplier MsgUpdateParam to DAO genesis authorizations
bryanchriswhite 63bc125
chore: add supplier param invalid error
bryanchriswhite f3bb3e0
chore: update NewMsgUpdateParam() & MsgUpdateParam#ValidateBasic()
bryanchriswhite acb6622
chore: update msgServer#UpdateParam()
bryanchriswhite 935a40f
chore: update param update test module param config
bryanchriswhite b29843e
Empty commit
bryanchriswhite 8c25061
Empty commit
bryanchriswhite 3f59041
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite ce328bb
fix: linter errors
bryanchriswhite 17b6420
fix: failing tests & add TODO_UPNEXT comments
bryanchriswhite 4e259c9
chore: apply improvements
bryanchriswhite 2808925
chore: add godoc style comment to min_stake params field
bryanchriswhite 197af04
chore: add godoc style comment to min_stake params field
bryanchriswhite 2a33127
chore: improvements:
bryanchriswhite 3280142
chore: improve logging & ensure gRPC status error returns
bryanchriswhite 98d1c96
chore: improve logging & ensure gRPC status error returns
bryanchriswhite c256eae
chore: review feedback improvements
bryanchriswhite 0d36e0f
Merge remote-tracking branch 'pokt/main' into issues/612/param/min-st…
bryanchriswhite 00914b0
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite f3fa183
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite f4b8284
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 12d1b43
Merge branch 'issues/612/application/min-stake-param' into issues/612…
bryanchriswhite 30b48f4
test: simplify coin equality assertions
bryanchriswhite b3a3236
Merge branch 'issues/612/application/staking' into issues/612/applica…
bryanchriswhite 1c309b8
Empty commit
bryanchriswhite e7ff959
Merge branch 'issues/612/param/min-stake-gateway' into issues/612/gat…
bryanchriswhite 1257f6e
Merge branch 'main' into issues/612/gateway/logic
bryanchriswhite b972e3b
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite 0f4a82d
chore: add review feedback TODOs
bryanchriswhite 44257f3
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 561a1aa
Merge branch 'issues/612/application/min-stake-param' into issues/612…
bryanchriswhite f176fe4
Merge branch 'issues/612/application/staking' into issues/612/applica…
bryanchriswhite ef4e0ad
chore: reconcile PreGeneratedAccountIterator#MustNext()
bryanchriswhite 4d2c2d9
chore: review feedback improvements
bryanchriswhite 5ba2a48
fix: typo
bryanchriswhite 3e4ef9e
fix: linter errors
bryanchriswhite 8c7eadf
Empty commit
bryanchriswhite a28ff88
Empty commit
bryanchriswhite cd5e420
chore: review feedback improvements
bryanchriswhite cc95ebf
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite 65158ad
Merge branch 'main' into issues/612/gateway/logic
bryanchriswhite 70f8985
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite 698991a
Empty commit
bryanchriswhite 6c689e8
Merge branch 'issues/612/gateway/logic' into issues/612/app/msg-updat…
bryanchriswhite c2bf664
Merge branch 'main' into issues/612/app/msg-update-param
bryanchriswhite 0d63e07
fix: linter error
bryanchriswhite 7753572
Merge branch 'issues/612/app/msg-update-param' into issues/612/applic…
bryanchriswhite 5556f4a
Merge remote-tracking branch 'pokt/main' into issues/612/application/…
bryanchriswhite 1faf4ab
chore: regenerate protobufs
bryanchriswhite 48ba5dd
Merge branch 'issues/612/application/min-stake-param' into issues/612…
bryanchriswhite d91dde7
Merge branch 'main' into issues/612/application/staking
bryanchriswhite 5e5d8a4
Merge branch 'issues/612/application/staking' into issues/612/applica…
bryanchriswhite e119e97
Merge branch 'issues/612/application/burning' into issues/612/supplie…
bryanchriswhite 7e9bd33
Empty commit
bryanchriswhite 69c2755
Empty commit
bryanchriswhite 1f7e201
Merge branch 'main' into issues/612/application/staking
bryanchriswhite 0fa9ab8
Merge remote-tracking branch 'pokt/issues/612/application/staking' in…
bryanchriswhite d91671e
Merge remote-tracking branch 'pokt/main' into issues/612/application/…
bryanchriswhite c89ee93
chore: quick fixes
bryanchriswhite ed0d795
fix: linter error
bryanchriswhite 0be55c6
Empty commit
bryanchriswhite 14a5c79
chore: review feedback improvements
bryanchriswhite 735ca2a
test: fix application min stake integration test
bryanchriswhite 1c25798
chore: review feedback improvements
bryanchriswhite d2dfbd2
chore: regenerate protobufs
bryanchriswhite b220177
Empty commit
bryanchriswhite 530ce2a
Merge branch 'issues/612/application/burning' into issues/612/supplie…
bryanchriswhite 788d506
Merge remote-tracking branch 'pokt/main' into issues/612/supplier/msg…
bryanchriswhite 071149b
fix: flaky test
bryanchriswhite 395126d
fix: linter error
bryanchriswhite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
package application | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
cosmoslog "cosmossdk.io/log" | ||
"cosmossdk.io/math" | ||
cosmostypes "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/pokt-network/poktroll/app/volatile" | ||
"github.com/pokt-network/poktroll/cmd/poktrolld/cmd" | ||
_ "github.com/pokt-network/poktroll/pkg/polylog/polyzero" | ||
"github.com/pokt-network/poktroll/testutil/keeper" | ||
testproof "github.com/pokt-network/poktroll/testutil/proof" | ||
"github.com/pokt-network/poktroll/testutil/sample" | ||
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" | ||
sharedtypes "github.com/pokt-network/poktroll/x/shared/types" | ||
) | ||
|
||
type applicationMinStakeTestSuite struct { | ||
suite.Suite | ||
|
||
ctx context.Context | ||
keepers keeper.TokenomicsModuleKeepers | ||
|
||
serviceId, | ||
appBech32, | ||
supplierBech32 string | ||
|
||
appStake *cosmostypes.Coin | ||
|
||
numRelays, | ||
numComputeUnitsPerRelay uint64 | ||
} | ||
|
||
func TestApplicationMinStakeTestSuite(t *testing.T) { | ||
cmd.InitSDKConfig() | ||
|
||
suite.Run(t, new(applicationMinStakeTestSuite)) | ||
} | ||
|
||
func (s *applicationMinStakeTestSuite) SetupTest() { | ||
s.keepers, s.ctx = keeper.NewTokenomicsModuleKeepers(s.T(), cosmoslog.NewNopLogger()) | ||
|
||
s.serviceId = "svc1" | ||
s.appBech32 = sample.AccAddress() | ||
s.supplierBech32 = sample.AccAddress() | ||
s.appStake = &apptypes.DefaultMinStake | ||
s.numRelays = 10 | ||
s.numComputeUnitsPerRelay = 1 | ||
|
||
// Set block height to 1. | ||
s.ctx = cosmostypes.UnwrapSDKContext(s.ctx).WithBlockHeight(1) | ||
} | ||
|
||
func (s *applicationMinStakeTestSuite) TestAppCannotStakeLessThanMinStake() { | ||
s.T().Skip("this case is well covered in x/application/keeper/msg_server_stake_application_test.go") | ||
} | ||
|
||
func (s *applicationMinStakeTestSuite) TestAppIsUnbondedIfBelowMinStakeWhenSettling() { | ||
// Assert that the application's initial bank balance is 0. | ||
appBalance := s.getAppBalance() | ||
require.Equal(s.T(), int64(0), appBalance.Amount.Int64()) | ||
|
||
// Add service 1 | ||
s.addService() | ||
|
||
// Stake an application for service 1 with min stake. | ||
s.stakeApp() | ||
|
||
// Stake a supplier for service 1. | ||
s.stakeSupplier() | ||
|
||
// Get the session header. | ||
sessionHeader := s.getSessionHeader() | ||
|
||
// Create a claim whose settlement amount drops the application below min stake | ||
claim := s.getClaim(sessionHeader) | ||
|
||
// Process TLMs for the claim. | ||
err := s.keepers.Keeper.ProcessTokenLogicModules(s.ctx, claim) | ||
require.NoError(s.T(), err) | ||
|
||
// Assert that the application was unbonded. | ||
_, isAppFound := s.keepers.ApplicationKeeper.GetApplication(s.ctx, s.appBech32) | ||
require.False(s.T(), isAppFound) | ||
|
||
// Assert that the application's stake was returned to its bank balance. | ||
expectedAppBurn := math.NewInt(int64(s.numRelays * s.numComputeUnitsPerRelay * sharedtypes.DefaultComputeUnitsToTokensMultiplier)) | ||
expectedAppBalance := s.appStake.SubAmount(expectedAppBurn) | ||
appBalance = s.getAppBalance() | ||
require.Equal(s.T(), expectedAppBalance.Amount.Int64(), appBalance.Amount.Int64()) | ||
|
||
} | ||
|
||
// addService adds the test service to the service module state. | ||
func (s *applicationMinStakeTestSuite) addService() { | ||
s.keepers.ServiceKeeper.SetService(s.ctx, sharedtypes.Service{ | ||
Id: s.serviceId, | ||
ComputeUnitsPerRelay: 1, | ||
OwnerAddress: sample.AccAddress(), // random address. | ||
}) | ||
} | ||
|
||
// stakeApp stakes an application for service 1 with min stake. | ||
func (s *applicationMinStakeTestSuite) stakeApp() { | ||
s.keepers.ApplicationKeeper.SetApplication(s.ctx, apptypes.Application{ | ||
Address: s.appBech32, | ||
Stake: s.appStake, | ||
ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{{ServiceId: s.serviceId}}, | ||
}) | ||
} | ||
|
||
// stakeSupplier stakes a supplier for service 1. | ||
func (s *applicationMinStakeTestSuite) stakeSupplier() { | ||
// TODO_UPNEXT(@bryanchriswhite, #612): Replace supplierStake with suppleirtypes.DefaultMinStake. | ||
supplierStake := cosmostypes.NewInt64Coin(volatile.DenomuPOKT, 1000000) // 1 POKT. | ||
s.keepers.SupplierKeeper.SetSupplier(s.ctx, sharedtypes.Supplier{ | ||
OwnerAddress: s.supplierBech32, | ||
OperatorAddress: s.supplierBech32, | ||
Stake: &supplierStake, | ||
Services: []*sharedtypes.SupplierServiceConfig{ | ||
{ | ||
ServiceId: s.serviceId, | ||
RevShare: []*sharedtypes.ServiceRevenueShare{ | ||
{ | ||
Address: s.supplierBech32, | ||
RevSharePercentage: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
// getSessionHeader gets the session header for the test session. | ||
func (s *applicationMinStakeTestSuite) getSessionHeader() *sessiontypes.SessionHeader { | ||
sdkCtx := cosmostypes.UnwrapSDKContext(s.ctx) | ||
currentHeight := sdkCtx.BlockHeight() | ||
sessionRes, err := s.keepers.SessionKeeper.GetSession(s.ctx, &sessiontypes.QueryGetSessionRequest{ | ||
ApplicationAddress: s.appBech32, | ||
ServiceId: s.serviceId, | ||
BlockHeight: currentHeight, | ||
}) | ||
require.NoError(s.T(), err) | ||
|
||
return sessionRes.GetSession().GetHeader() | ||
} | ||
|
||
// getClaim creates a claim whose settlement amount drops the application below min stake. | ||
func (s *applicationMinStakeTestSuite) getClaim( | ||
sessionHeader *sessiontypes.SessionHeader, | ||
) *prooftypes.Claim { | ||
claimRoot := testproof.SmstRootWithSumAndCount(s.numRelays*s.numComputeUnitsPerRelay, s.numRelays) | ||
|
||
return &prooftypes.Claim{ | ||
SupplierOperatorAddress: s.supplierBech32, | ||
SessionHeader: sessionHeader, | ||
RootHash: claimRoot, | ||
} | ||
} | ||
|
||
// getAppBalance returns the bank module balance for the application. | ||
func (s *applicationMinStakeTestSuite) getAppBalance() *cosmostypes.Coin { | ||
appBalRes, err := s.keepers.BankKeeper.Balance(s.ctx, &banktypes.QueryBalanceRequest{ | ||
Address: s.appBech32, Denom: volatile.DenomuPOKT, | ||
}) | ||
require.NoError(s.T(), err) | ||
|
||
return appBalRes.GetBalance() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference is to have the
option
s separate from fields by one blank line. I have not surveyed the proto messages to see what's more consistent nor am I aware of any particular convention about this. Do you have a strong opinion or a rationale you could chare?