Skip to content

Commit 428e19f

Browse files
refactor(x/distribution)!: Use KVStoreService, context.Context and return errors instead of panic (#15948)
1 parent a6ea094 commit 428e19f

37 files changed

+1022
-489
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
117117

118118
### API Breaking Changes
119119

120+
* (x/distribution) [#15948](https://github.com/cosmos/cosmos-sdk/issues/15948) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. Keeper methods also now return an `error`.
120121
* (x/bank) [#15891](https://github.com/cosmos/cosmos-sdk/issues/15891) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. Also `FundAccount` and `FundModuleAccount` from the `testutil` package accept a `context.Context` instead of a `sdk.Context`, and it's position was moved to the first place.
121122
* (x/bank) [#15818](https://github.com/cosmos/cosmos-sdk/issues/15818) `BaseViewKeeper`'s `Logger` method now doesn't require a context. `NewBaseKeeper`, `NewBaseSendKeeper` and `NewBaseViewKeeper` now also require a `log.Logger` to be passed in.
122123
* (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) `RegisterNodeService` now requires a config parameter.

UPGRADING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The following modules `NewKeeper` function now take a `KVStoreService` instead o
7373
* `x/auth`
7474
* `x/bank`
7575
* `x/consensus`
76+
* `x/distribution`
7677
* `x/feegrant`
7778
* `x/nft`
7879

@@ -91,6 +92,11 @@ The following modules `NewKeeper` function now also take a `log.Logger`:
9192

9293
* `x/bank`
9394

95+
The following modules' `Keeper` methods now take in a `context.Context` instead of `sdk.Context`. Any module that has an interfaces for them (like "expected keepers") will need to update and re-generate mocks if needed:
96+
97+
* `x/bank`
98+
* `x/distribution`
99+
94100

95101
### depinject
96102

@@ -136,8 +142,6 @@ It is now recommended to validate message directly in the message server. When t
136142

137143
#### `x/auth`
138144

139-
Methods in the `AccountKeeper` now use `context.Context` instead of `sdk.Context`. Any module that has an interface for it will need to update and re-generate mocks if needed.
140-
141145
For ante handler construction via `ante.NewAnteHandler`, the field `ante.HandlerOptions.SignModeHandler` has been updated to `x/tx/signing/HandlerMap` from `x/auth/signing/SignModeHandler`. Callers typically fetch this value from `client.TxConfig.SignModeHandler()` (which is also changed) so this change should be transparent to most users.
142146

143147
#### `x/capability`

server/grpc/gogoreflection/fix_registration.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc {
4242
for id, desc := range proto.RegisteredExtensions(m) { //nolint:staticcheck // keep for backward compatibility
4343
if id == extID {
4444
return &gogoproto.ExtensionDesc{
45-
ExtendedType: desc.ExtendedType,
46-
ExtensionType: desc.ExtensionType,
47-
Field: desc.Field,
48-
Name: desc.Name,
49-
Tag: desc.Tag,
50-
Filename: desc.Filename,
45+
ExtendedType: desc.ExtendedType, //nolint:staticcheck // keep for backward compatibility
46+
ExtensionType: desc.ExtensionType, //nolint:staticcheck // keep for backward compatibility
47+
Field: desc.Field, //nolint:staticcheck // keep for backward compatibility
48+
Name: desc.Name, //nolint:staticcheck // keep for backward compatibility
49+
Tag: desc.Tag, //nolint:staticcheck // keep for backward compatibility
50+
Filename: desc.Filename, //nolint:staticcheck // keep for backward compatibility
5151
}
5252
}
5353
}

simapp/app.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
4141
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
4242
"github.com/cosmos/cosmos-sdk/codec"
43+
"github.com/cosmos/cosmos-sdk/codec/address"
4344
"github.com/cosmos/cosmos-sdk/codec/types"
4445
"github.com/cosmos/cosmos-sdk/runtime"
4546
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
@@ -298,7 +299,7 @@ func NewSimApp(
298299
)
299300
app.MintKeeper = mintkeeper.NewKeeper(appCodec, keys[minttypes.StoreKey], app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
300301

301-
app.DistrKeeper = distrkeeper.NewKeeper(appCodec, keys[distrtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
302+
app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
302303

303304
app.SlashingKeeper = slashingkeeper.NewKeeper(
304305
appCodec, legacyAmino, keys[slashingtypes.StoreKey], app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
@@ -624,7 +625,7 @@ func (app *SimApp) AutoCliOpts() autocli.AppOptions {
624625
}
625626
}
626627

627-
return autocli.AppOptions{Modules: modules}
628+
return autocli.AppOptions{Modules: modules, AddressCodec: address.NewBech32Codec(sdk.Bech32MainPrefix)}
628629
}
629630

630631
// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.

simapp/export.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,18 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
107107
// reinitialize all validators
108108
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
109109
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
110-
scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
111-
feePool := app.DistrKeeper.GetFeePool(ctx)
110+
scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
111+
if err != nil {
112+
panic(err)
113+
}
114+
feePool, err := app.DistrKeeper.GetFeePool(ctx)
115+
if err != nil {
116+
panic(err)
117+
}
112118
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
113-
app.DistrKeeper.SetFeePool(ctx, feePool)
119+
if err := app.DistrKeeper.SetFeePool(ctx, feePool); err != nil {
120+
panic(err)
121+
}
114122

115123
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
116124
panic(err)

tests/integration/distribution/keeper/grpc_query_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ func TestGRPCValidatorOutstandingRewards(t *testing.T) {
100100
tstaking.CreateValidator(f.valAddr, valConsPk0, sdk.NewInt(initialStake), true)
101101

102102
// set outstanding rewards
103-
f.distrKeeper.SetValidatorOutstandingRewards(f.sdkCtx, f.valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})
104-
rewards := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, f.valAddr)
103+
err := f.distrKeeper.SetValidatorOutstandingRewards(f.sdkCtx, f.valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})
104+
assert.NilError(t, err)
105+
106+
rewards, err := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, f.valAddr)
107+
assert.NilError(t, err)
105108

106109
testCases := []struct {
107110
name string

tests/integration/distribution/keeper/msg_server_test.go

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
cmtabcitypes "github.com/cometbft/cometbft/abci/types"
1212
"github.com/cometbft/cometbft/proto/tendermint/types"
13-
"github.com/stretchr/testify/require"
1413
"gotest.tools/v3/assert"
1514

1615
"github.com/cosmos/cosmos-sdk/codec"
@@ -98,7 +97,7 @@ func initFixture(t testing.TB) *fixture {
9897
stakingKeeper := stakingkeeper.NewKeeper(cdc, keys[stakingtypes.StoreKey], accountKeeper, bankKeeper, authority.String())
9998

10099
distrKeeper := distrkeeper.NewKeeper(
101-
cdc, keys[distrtypes.StoreKey], accountKeeper, bankKeeper, stakingKeeper, distrtypes.ModuleName, authority.String(),
100+
cdc, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, distrtypes.ModuleName, authority.String(),
102101
)
103102

104103
authModule := auth.NewAppModule(cdc, accountKeeper, authsims.RandomGenesisAccounts, nil)
@@ -151,7 +150,8 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
151150
CommunityPool: sdk.NewDecCoins(sdk.DecCoin{Denom: "stake", Amount: math.LegacyNewDec(10000)}),
152151
})
153152
f.distrKeeper.SetParams(f.sdkCtx, distrtypes.DefaultParams())
154-
initFeePool := f.distrKeeper.GetFeePool(f.sdkCtx)
153+
initFeePool, err := f.distrKeeper.GetFeePool(f.sdkCtx)
154+
assert.NilError(t, err)
155155

156156
delAddr := sdk.AccAddress(PKS[1].Address())
157157
valConsAddr := sdk.ConsAddress(valConsPk0.Address())
@@ -195,7 +195,8 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
195195
currentRewards := distrtypes.NewValidatorCurrentRewards(decCoins, 3)
196196
f.distrKeeper.SetValidatorCurrentRewards(f.sdkCtx, f.valAddr, currentRewards)
197197
f.distrKeeper.SetValidatorOutstandingRewards(f.sdkCtx, f.valAddr, distrtypes.ValidatorOutstandingRewards{Rewards: valCommission})
198-
initOutstandingRewards := f.distrKeeper.GetValidatorOutstandingRewardsCoins(f.sdkCtx, f.valAddr)
198+
initOutstandingRewards, err := f.distrKeeper.GetValidatorOutstandingRewardsCoins(f.sdkCtx, f.valAddr)
199+
assert.NilError(t, err)
199200

200201
testCases := []struct {
201202
name string
@@ -258,9 +259,10 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
258259
},
259260
}
260261
height := f.app.LastBlockHeight()
261-
require.Panics(t, func() {
262-
f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx)
263-
})
262+
263+
_, err = f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx)
264+
assert.Error(t, err, "previous proposer not set")
265+
264266
for _, tc := range testCases {
265267
tc := tc
266268
t.Run(tc.name, func(t *testing.T) {
@@ -275,15 +277,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
275277
panic(fmt.Errorf("expected block height to be %d, got %d", height, f.app.LastBlockHeight()))
276278
}
277279

278-
prevProposerConsAddr := f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx)
279-
assert.Assert(t, prevProposerConsAddr.Empty() == false)
280-
assert.DeepEqual(t, prevProposerConsAddr, valConsAddr)
281-
var previousTotalPower int64
282-
for _, voteInfo := range f.sdkCtx.VoteInfos() {
283-
previousTotalPower += voteInfo.Validator.Power
284-
}
285-
assert.Equal(t, previousTotalPower, int64(100))
286-
287280
if tc.expErr {
288281
assert.ErrorContains(t, err, tc.expErrMsg)
289282
} else {
@@ -300,11 +293,21 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
300293
assert.Assert(t, initBalance.IsAllLTE(curBalance))
301294

302295
// check rewards
303-
curFeePool := f.distrKeeper.GetFeePool(f.sdkCtx)
296+
curFeePool, _ := f.distrKeeper.GetFeePool(f.sdkCtx)
304297
rewards := curFeePool.GetCommunityPool().Sub(initFeePool.CommunityPool)
305-
curOutstandingRewards := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, f.valAddr)
298+
curOutstandingRewards, _ := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, f.valAddr)
306299
assert.DeepEqual(t, rewards, initOutstandingRewards.Sub(curOutstandingRewards.Rewards))
307300
}
301+
302+
prevProposerConsAddr, err := f.distrKeeper.GetPreviousProposerConsAddr(f.sdkCtx)
303+
assert.NilError(t, err)
304+
assert.Assert(t, prevProposerConsAddr.Empty() == false)
305+
assert.DeepEqual(t, prevProposerConsAddr, valConsAddr)
306+
var previousTotalPower int64
307+
for _, voteInfo := range f.sdkCtx.VoteInfos() {
308+
previousTotalPower += voteInfo.Validator.Power
309+
}
310+
assert.Equal(t, previousTotalPower, int64(100))
308311
})
309312
}
310313
}
@@ -328,7 +331,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
328331
{
329332
name: "empty delegator address",
330333
preRun: func() {
331-
params := f.distrKeeper.GetParams(f.sdkCtx)
334+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
332335
params.WithdrawAddrEnabled = true
333336
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
334337
},
@@ -342,7 +345,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
342345
{
343346
name: "empty withdraw address",
344347
preRun: func() {
345-
params := f.distrKeeper.GetParams(f.sdkCtx)
348+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
346349
params.WithdrawAddrEnabled = true
347350
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
348351
},
@@ -356,7 +359,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
356359
{
357360
name: "both empty addresses",
358361
preRun: func() {
359-
params := f.distrKeeper.GetParams(f.sdkCtx)
362+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
360363
params.WithdrawAddrEnabled = true
361364
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
362365
},
@@ -370,7 +373,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
370373
{
371374
name: "withdraw address disabled",
372375
preRun: func() {
373-
params := f.distrKeeper.GetParams(f.sdkCtx)
376+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
374377
params.WithdrawAddrEnabled = false
375378
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
376379
},
@@ -384,7 +387,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
384387
{
385388
name: "valid msg with same delegator and withdraw address",
386389
preRun: func() {
387-
params := f.distrKeeper.GetParams(f.sdkCtx)
390+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
388391
params.WithdrawAddrEnabled = true
389392
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
390393
},
@@ -397,7 +400,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
397400
{
398401
name: "valid msg",
399402
preRun: func() {
400-
params := f.distrKeeper.GetParams(f.sdkCtx)
403+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
401404
params.WithdrawAddrEnabled = true
402405
assert.NilError(t, f.distrKeeper.SetParams(f.sdkCtx, params))
403406
},
@@ -421,7 +424,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
421424
assert.ErrorContains(t, err, tc.expErrMsg)
422425

423426
// query the delegator withdraw address
424-
addr := f.distrKeeper.GetDelegatorWithdrawAddr(f.sdkCtx, delAddr)
427+
addr, _ := f.distrKeeper.GetDelegatorWithdrawAddr(f.sdkCtx, delAddr)
425428
assert.DeepEqual(t, addr, delAddr)
426429
} else {
427430
assert.NilError(t, err)
@@ -433,7 +436,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
433436
assert.NilError(t, err)
434437

435438
// query the delegator withdraw address
436-
addr := f.distrKeeper.GetDelegatorWithdrawAddr(f.sdkCtx, delAddr)
439+
addr, _ := f.distrKeeper.GetDelegatorWithdrawAddr(f.sdkCtx, delAddr)
437440
assert.DeepEqual(t, addr.String(), tc.msg.WithdrawAddress)
438441
}
439442
})
@@ -529,11 +532,11 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) {
529532
), balance)
530533

531534
// check remainder
532-
remainder := f.distrKeeper.GetValidatorAccumulatedCommission(f.sdkCtx, f.valAddr).Commission
535+
remainder, _ := f.distrKeeper.GetValidatorAccumulatedCommission(f.sdkCtx, f.valAddr)
533536
assert.DeepEqual(t, sdk.DecCoins{
534537
sdk.NewDecCoinFromDec("mytoken", math.LegacyNewDec(1).Quo(math.LegacyNewDec(4))),
535538
sdk.NewDecCoinFromDec("stake", math.LegacyNewDec(1).Quo(math.LegacyNewDec(2))),
536-
}, remainder)
539+
}, remainder.Commission)
537540
}
538541
})
539542

@@ -546,7 +549,7 @@ func TestMsgFundCommunityPool(t *testing.T) {
546549

547550
// reset fee pool
548551
f.distrKeeper.SetFeePool(f.sdkCtx, distrtypes.InitialFeePool())
549-
initPool := f.distrKeeper.GetFeePool(f.sdkCtx)
552+
initPool, _ := f.distrKeeper.GetFeePool(f.sdkCtx)
550553
assert.Assert(t, initPool.CommunityPool.Empty())
551554

552555
initTokens := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(100))
@@ -624,7 +627,8 @@ func TestMsgFundCommunityPool(t *testing.T) {
624627
assert.NilError(t, err)
625628

626629
// query the community pool funds
627-
assert.DeepEqual(t, initPool.CommunityPool.Add(sdk.NewDecCoinsFromCoins(amount...)...), f.distrKeeper.GetFeePool(f.sdkCtx).CommunityPool)
630+
feePool, _ := f.distrKeeper.GetFeePool(f.sdkCtx)
631+
assert.DeepEqual(t, initPool.CommunityPool.Add(sdk.NewDecCoinsFromCoins(amount...)...), feePool.CommunityPool)
628632
assert.Assert(t, f.bankKeeper.GetAllBalances(f.sdkCtx, addr).Empty())
629633
}
630634
})
@@ -750,7 +754,7 @@ func TestMsgUpdateParams(t *testing.T) {
750754
assert.NilError(t, err)
751755

752756
// query the params and verify it has been updated
753-
params := f.distrKeeper.GetParams(f.sdkCtx)
757+
params, _ := f.distrKeeper.GetParams(f.sdkCtx)
754758
assert.DeepEqual(t, distrtypes.DefaultParams(), params)
755759
}
756760
})
@@ -765,7 +769,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) {
765769
f.distrKeeper.SetFeePool(f.sdkCtx, distrtypes.FeePool{
766770
CommunityPool: sdk.NewDecCoins(sdk.DecCoin{Denom: "stake", Amount: math.LegacyNewDec(10000)}),
767771
})
768-
initialFeePool := f.distrKeeper.GetFeePool(f.sdkCtx)
772+
initialFeePool, _ := f.distrKeeper.GetFeePool(f.sdkCtx)
769773

770774
initTokens := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(100))
771775
f.bankKeeper.MintCoins(f.sdkCtx, distrtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)))
@@ -828,7 +832,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) {
828832
assert.NilError(t, err)
829833

830834
// query the community pool to verify it has been updated
831-
communityPool := f.distrKeeper.GetFeePoolCommunityCoins(f.sdkCtx)
835+
communityPool, _ := f.distrKeeper.GetFeePoolCommunityCoins(f.sdkCtx)
832836
newPool, negative := initialFeePool.CommunityPool.SafeSub(sdk.NewDecCoinsFromCoins(tc.msg.Amount...))
833837
assert.Assert(t, negative == false)
834838
assert.DeepEqual(t, communityPool, newPool)
@@ -928,7 +932,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
928932
assert.NilError(t, err)
929933

930934
// check validator outstanding rewards
931-
outstandingRewards := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, val)
935+
outstandingRewards, _ := f.distrKeeper.GetValidatorOutstandingRewards(f.sdkCtx, val)
932936
for _, c := range tc.msg.Amount {
933937
x := outstandingRewards.Rewards.AmountOf(c.Denom)
934938
assert.DeepEqual(t, x, sdk.NewDecFromInt(c.Amount))

x/distribution/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/distribution/
286286
```
287287

288288
```go
289-
func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error
289+
func (k Keeper) SetWithdrawAddr(ctx context.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error
290290
if k.blockedAddrs[withdrawAddr.String()] {
291291
fail with "`{withdrawAddr}` is not allowed to receive external funds"
292292
}
@@ -351,7 +351,7 @@ This message sends coins directly from the sender to the community pool.
351351
The transaction fails if the amount cannot be transferred from the sender to the distribution module account.
352352
353353
```go
354-
func (k Keeper) FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error {
354+
func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error {
355355
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount); err != nil {
356356
return err
357357
}
@@ -375,7 +375,7 @@ Initializing a delegation increments the validator period and keeps track of the
375375
376376
```go
377377
// initialize starting info for a new delegation
378-
func (k Keeper) initializeDelegation(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) {
378+
func (k Keeper) initializeDelegation(ctx context.Context, val sdk.ValAddress, del sdk.AccAddress) {
379379
// period has already been incremented - we want to store the period ended by this delegation action
380380
previousPeriod := k.GetValidatorCurrentRewards(ctx, val).Period - 1
381381

0 commit comments

Comments
 (0)