Skip to content
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

[Morse->Shannon Migration] refactor: app staking logic as keeper methods #1091

Merged
merged 144 commits into from
Mar 11, 2025
Merged
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
7cdced6
refactor: fixture generator testutil
bryanchriswhite Jan 29, 2025
7811f49
scaffold: message import-morse-claimable-accounts --module migration …
bryanchriswhite Feb 13, 2025
bb0809a
chore: update types/fields
bryanchriswhite Feb 13, 2025
dc4be6f
feat: implement MsgImportMorseClaimableAccounts
bryanchriswhite Feb 14, 2025
2edeb3f
fix: linter errors
bryanchriswhite Feb 14, 2025
66d7870
chore: add omitted files
bryanchriswhite Feb 14, 2025
1b102b7
chore: self-review improvement
bryanchriswhite Feb 14, 2025
fa66108
fix: imports
bryanchriswhite Feb 14, 2025
c9fd7be
chore: self-review improvements
bryanchriswhite Feb 14, 2025
ac5ab60
refactor: morse src address & shannon dest address
bryanchriswhite Feb 17, 2025
fc252cf
scaffold: message claim_morse_account --module migration --signer sha…
bryanchriswhite Feb 17, 2025
9b0af5e
chore: update types, fix test, regenerate protobufs
bryanchriswhite Feb 17, 2025
a1ec09c
chore: update autocli
bryanchriswhite Feb 17, 2025
42481a2
fix: imports
bryanchriswhite Feb 17, 2025
29f2e65
chore: self review improvements
bryanchriswhite Feb 17, 2025
5af7f01
chore: self review improvements
bryanchriswhite Feb 17, 2025
9bf879f
refactor: add bank & acct mod deps to migration mod
bryanchriswhite Feb 17, 2025
0bcc12b
chore: add mint permission to migration module
bryanchriswhite Feb 17, 2025
869f596
chore: add EventMorseAccountClaimed proto type
bryanchriswhite Feb 17, 2025
774713d
feat: implement morse account claiming
bryanchriswhite Feb 17, 2025
44165d4
test: unit Morse account claiming
bryanchriswhite Feb 17, 2025
9280288
test: integration morse account claim
bryanchriswhite Feb 17, 2025
8e1a533
chore: add migration module mocks pkg
bryanchriswhite Feb 18, 2025
93004e6
chore: validation, testing, etc.
bryanchriswhite Feb 18, 2025
0848fb1
chore: self-review improvements
bryanchriswhite Feb 18, 2025
30bfca5
refactor: s/QueryGetMorseClaimable(.+)/QueryMorseClaimable$1
bryanchriswhite Feb 18, 2025
10208dc
chore: add app/supplier keepers as migration module deps
bryanchriswhite Feb 18, 2025
49ee23f
chore: add gateway keeper dep
bryanchriswhite Feb 19, 2025
952bf17
refactor: extract keeper methods from msgServer handler
bryanchriswhite Feb 19, 2025
b49e9ad
test: refactor testutil
bryanchriswhite Feb 19, 2025
a87716e
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 19, 2025
139a9e9
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 19, 2025
f08fd00
test: refactor testutil
bryanchriswhite Feb 19, 2025
3b7f77f
scaffold: message claim_morse_application --module migration --signer…
bryanchriswhite Feb 18, 2025
6038939
fix: errors
bryanchriswhite Feb 18, 2025
3411b29
refactor: base integration suite bank client
bryanchriswhite Feb 19, 2025
7128b83
test: refactor integration test to a suite
bryanchriswhite Feb 19, 2025
c4fed01
chore: self-review improvements
bryanchriswhite Feb 19, 2025
3ac4f03
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 19, 2025
285ef33
fix: post-merge
bryanchriswhite Feb 19, 2025
3236fb4
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 19, 2025
20c5230
Merge branch 'issues/1034/refactor/query' into issues/1034/scaffold/m…
bryanchriswhite Feb 19, 2025
81e447f
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
Olshansk Feb 20, 2025
1ffb73b
chore: review feedback improvements
bryanchriswhite Feb 20, 2025
bbfd600
fix: typo
bryanchriswhite Feb 20, 2025
c4b0375
chore: review feedback improvements
bryanchriswhite Feb 20, 2025
5a17194
fix: test
bryanchriswhite Feb 20, 2025
52d865f
chore: chore: review feedback improvements
bryanchriswhite Feb 21, 2025
3c0ba65
Merge remote-tracking branch 'pokt/main' into issues/1034/scaffold/ms…
bryanchriswhite Feb 21, 2025
4a14f00
fix: typo & test
bryanchriswhite Feb 21, 2025
a4ef433
chore: review feedback improvements
bryanchriswhite Feb 24, 2025
fbed024
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
bryanchriswhite Feb 24, 2025
5e13640
chore: review feedback improvements
bryanchriswhite Feb 24, 2025
69f6d9d
Merge branch 'issues/1034/scaffold/msg_import_morse' into issues/1034…
bryanchriswhite Feb 24, 2025
958bdac
fix: imports
bryanchriswhite Feb 24, 2025
2bce02e
Merge branch 'issues/1034/scaffold/msg_claim_morse_account' into issu…
bryanchriswhite Feb 24, 2025
7ca2cfe
fix: typo
bryanchriswhite Feb 24, 2025
c3e4671
fix: linter error
bryanchriswhite Feb 24, 2025
78f495f
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 24, 2025
9fd7a2f
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 24, 2025
d61192b
chore: review feedback improvements
bryanchriswhite Feb 24, 2025
bd68c22
Merge branch 'issues/1034/scaffold/msg_import_morse' into issues/1034…
bryanchriswhite Feb 24, 2025
e11777a
chore: review feedback improvements
bryanchriswhite Feb 24, 2025
61d2414
Merge branch 'issues/1034/scaffold/msg_claim_morse_account' into issu…
bryanchriswhite Feb 24, 2025
5a0c571
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 24, 2025
ca368b9
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 24, 2025
3f425ed
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Feb 24, 2025
6fba262
chore: regenerate protobufs
bryanchriswhite Feb 24, 2025
b0744b6
chore: review feedback improvements
bryanchriswhite Feb 24, 2025
0be7bfd
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
Olshansk Feb 24, 2025
c1c25f1
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
Olshansk Feb 24, 2025
502e138
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
bryanchriswhite Feb 25, 2025
c847898
test: stub out E2E migration.feature
bryanchriswhite Feb 25, 2025
8e2ca9b
chore: review feedback improvements
bryanchriswhite Feb 25, 2025
11fcb03
chore: self-review improvements
bryanchriswhite Feb 25, 2025
1d5a496
chore: review feedback improvements
bryanchriswhite Feb 25, 2025
bb8f367
fix: test
bryanchriswhite Feb 25, 2025
6274e5c
Merge branch 'main' into issues/1034/scaffold/msg_import_morse
bryanchriswhite Feb 26, 2025
0d6c6c7
chore: update comments
bryanchriswhite Feb 26, 2025
db9c7d9
Merge branch 'issues/1034/scaffold/msg_import_morse' into issues/1034…
bryanchriswhite Feb 26, 2025
fe47fef
Merge branch 'issues/1034/scaffold/msg_claim_morse_account' into issu…
bryanchriswhite Feb 26, 2025
5dd602a
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 26, 2025
8f5be38
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 26, 2025
3bf673c
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Feb 26, 2025
320e6e4
refactor: extract application staking logic to keeper methods
bryanchriswhite Feb 26, 2025
88521b6
Empty commit
bryanchriswhite Feb 26, 2025
6c4d867
chore: remove inaccurate comment
bryanchriswhite Feb 26, 2025
d2a7faa
moveme: feat/morse_claim_account
bryanchriswhite Feb 26, 2025
11b3859
Merge branch 'issues/1034/scaffold/msg_import_morse' into issues/1034…
bryanchriswhite Feb 26, 2025
d047381
Merge branch 'issues/1034/scaffold/msg_claim_morse_account' into issu…
bryanchriswhite Feb 26, 2025
d861f8d
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 26, 2025
761e6c5
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 26, 2025
b0ed098
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Feb 26, 2025
b468144
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Feb 26, 2025
5d47f38
chore: review feedback improvements
bryanchriswhite Feb 26, 2025
f2e5a19
Merge branch 'issues/1034/scaffold/msg_import_morse' into issues/1034…
bryanchriswhite Feb 26, 2025
bd217c6
Merge remote-tracking branch 'pokt/main' into issues/1034/scaffold/ms…
bryanchriswhite Feb 27, 2025
3cc8442
fix: linter error
bryanchriswhite Feb 27, 2025
9b01383
Empty commit
bryanchriswhite Feb 27, 2025
9c58cdc
Merge branch 'issues/1034/scaffold/msg_claim_morse_account' into issu…
bryanchriswhite Feb 27, 2025
9098a11
chore: review feedback improvements
bryanchriswhite Feb 27, 2025
17cd6d6
Merge remote-tracking branch 'pokt/main' into issues/1034/feat/claim_…
bryanchriswhite Feb 27, 2025
8d05fbd
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Feb 27, 2025
f0db398
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Feb 27, 2025
ca2e6ab
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Feb 27, 2025
a36d875
chore: regenerate protobufs
bryanchriswhite Feb 27, 2025
460c632
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Feb 27, 2025
7c8a2ee
Merge branch 'main' into issues/1034/feat/claim_morse_account
bryanchriswhite Mar 3, 2025
321c0c3
test: refactor & cleanup testutils
bryanchriswhite Mar 3, 2025
adb8119
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Mar 3, 2025
0a98b07
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Mar 3, 2025
151f592
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Mar 3, 2025
7fdb32f
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 3, 2025
9ed6a36
refactor: MorseStateExport & MorseClaimableAccount fixtures
bryanchriswhite Mar 6, 2025
3678306
chore: review feedback improvements
bryanchriswhite Mar 6, 2025
6c29d2a
chore: review feedback improvements
bryanchriswhite Mar 6, 2025
1fa496f
Merge remote-tracking branch 'pokt/main' into issues/1034/feat/claim_…
bryanchriswhite Mar 6, 2025
3f2a510
chore: regenerate protobufs
bryanchriswhite Mar 6, 2025
1e6e39c
chore: review feedback improvements
bryanchriswhite Mar 6, 2025
bddf3e6
chore: regenerate protobufs
bryanchriswhite Mar 6, 2025
7453e3a
chore: self-review improvements
bryanchriswhite Mar 6, 2025
706d90e
chore: review feedback improvements
bryanchriswhite Mar 6, 2025
dd2fcab
fix: typo
bryanchriswhite Mar 6, 2025
4918cfa
chore: review feedback improvements
bryanchriswhite Mar 6, 2025
739f2b1
self-review improvements
bryanchriswhite Mar 6, 2025
9a06f0d
Merge branch 'issues/1034/feat/claim_morse_account' into issues/1034/…
bryanchriswhite Mar 6, 2025
b159b59
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Mar 7, 2025
b229044
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Mar 7, 2025
79af2d1
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 7, 2025
4a40dff
Merge remote-tracking branch 'pokt/main' into issues/1034/refactor/query
bryanchriswhite Mar 7, 2025
9bad77b
Merge branch 'issues/1034/refactor/query' into issues/1034/migration/…
bryanchriswhite Mar 7, 2025
e91d99a
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Mar 7, 2025
14557c1
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 7, 2025
f67f416
Merge remote-tracking branch 'pokt/main' into issues/1034/migration/deps
bryanchriswhite Mar 7, 2025
2a133a4
Merge branch 'issues/1034/migration/deps' into issues/1034/scaffold/m…
bryanchriswhite Mar 7, 2025
2400a76
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 7, 2025
d91a528
Merge remote-tracking branch 'pokt/main' into issues/1034/scaffold/ms…
bryanchriswhite Mar 7, 2025
06b734f
fix: linter error
bryanchriswhite Mar 7, 2025
6d8a7b9
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 7, 2025
e96e1e8
Merge branch 'main' into issues/1034/scaffold/msg_claim_morse_applica…
Olshansk Mar 7, 2025
317945d
Merge branch 'main' into issues/1034/scaffold/msg_claim_morse_applica…
Olshansk Mar 10, 2025
4ea63d4
chore: review feedback improvements
bryanchriswhite Mar 11, 2025
4d3772d
Merge branch 'issues/1034/scaffold/msg_claim_morse_application' into …
bryanchriswhite Mar 11, 2025
f738c31
Merge remote-tracking branch 'pokt/main' into issues/1034/refactor/st…
bryanchriswhite Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions x/application/keeper/msg_server_stake_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

cosmoslog "cosmossdk.io/log"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -21,16 +22,45 @@ func (k msgServer) StakeApplication(ctx context.Context, msg *types.MsgStakeAppl
)

logger := k.Logger().With("method", "StakeApplication")
// Update the staking configurations of a existing app or stake a new app
stakedApp, err := k.Keeper.StakeApplication(ctx, logger, msg)
if err != nil {
// DEV_NOTE: If the error is non-nil, StakeApplication SHOULD ALWAYS return a gRPC status error.
return nil, err
}

isSuccessful = true

return &types.MsgStakeApplicationResponse{
Application: stakedApp,
}, nil
}

// StakeApplication stakes (or updates) the application according to the given msg by applying the following logic:
// - the msg is validated
// - if the application is not found, it is created (in memory) according to the valid msg
// - if the application is found and is not unbonding, it is updated (in memory) according to the msg
// - if the application is found and is unbonding, it is updated (in memory; and no longer unbonding)
// - additional stake validation (e.g. min stake, etc.)
// - the positive difference between the msg stake and any current stake is transferred
// from the staking application's account, to the application module's accounts.
// - the (new or updated) application is persisted.
// - an EventApplicationUnbondingCanceled event is emitted if the application was unbonding.
// - an EventApplicationStaked event is emitted.
func (k Keeper) StakeApplication(
ctx context.Context,
logger cosmoslog.Logger,
msg *types.MsgStakeApplication,
) (_ *types.Application, err error) {
logger.Info(fmt.Sprintf("About to stake application with msg: %v", msg))

if err := msg.ValidateBasic(); err != nil {
if err = msg.ValidateBasic(); err != nil {
logger.Error(fmt.Sprintf("invalid MsgStakeApplication: %v", err))
return nil, status.Error(codes.InvalidArgument, err.Error())
}

// Check if the application already exists or not
var (
err error
coinsToEscrow sdk.Coin
wasAppUnbonding bool
)
Expand Down Expand Up @@ -103,6 +133,7 @@ func (k msgServer) StakeApplication(ctx context.Context, msg *types.MsgStakeAppl
k.SetApplication(ctx, foundApp)
logger.Info(fmt.Sprintf("Successfully updated application stake for app: %+v", foundApp))

// Collect events for emission.
events := make([]sdk.Msg, 0)

// If application unbonding was canceled, emit the corresponding event.
Expand All @@ -128,14 +159,10 @@ func (k msgServer) StakeApplication(ctx context.Context, msg *types.MsgStakeAppl
return nil, status.Error(codes.Internal, err.Error())
}

isSuccessful = true

return &types.MsgStakeApplicationResponse{
Application: &foundApp,
}, nil
return &foundApp, nil
}

func (k msgServer) createApplication(
func (k Keeper) createApplication(
_ context.Context,
msg *types.MsgStakeApplication,
) types.Application {
Expand All @@ -148,7 +175,7 @@ func (k msgServer) createApplication(
}
}

func (k msgServer) updateApplication(
func (k Keeper) updateApplication(
_ context.Context,
app *types.Application,
msg *types.MsgStakeApplication,
Expand Down