Skip to content

Commit 2404232

Browse files
authored
Merge pull request #6 from notional-labs/staking_api
update getParams for consumerkeeper and add SlashWithInfractionReason
2 parents c73c836 + ce7dfa4 commit 2404232

File tree

10 files changed

+30
-11
lines changed

10 files changed

+30
-11
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ require (
175175
require github.com/confio/ics23/go v0.9.0 // indirect
176176

177177
replace (
178-
github.com/cosmos/cosmos-sdk => github.com/notional-labs/cosmos-sdk v0.47.2-0.20230414131805-781d3665d7a0
178+
github.com/cosmos/cosmos-sdk => github.com/notional-labs/cosmos-sdk v0.47.2-0.20230424022356-49c2e39f3fe6
179179
github.com/cosmos/ibc-go/v7 => github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230417042817-8072b1e9aabc
180180

181181
// following versions might cause unexpected behavior

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi
919919
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
920920
github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
921921
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
922-
github.com/notional-labs/cosmos-sdk v0.47.2-0.20230414131805-781d3665d7a0 h1:SsOek50tnVAUTHaH65bNwbg5UzPf5soh5x2j/DPGGTY=
923-
github.com/notional-labs/cosmos-sdk v0.47.2-0.20230414131805-781d3665d7a0/go.mod h1:14tO5KQaTrl2q3OxBnDRfue7TRN9zkXS0cLutrSqkOo=
922+
github.com/notional-labs/cosmos-sdk v0.47.2-0.20230424022356-49c2e39f3fe6 h1:/66obfC6FRb8phL73iqj1N7yrKw/7vfwdTkaJ9AO4/o=
923+
github.com/notional-labs/cosmos-sdk v0.47.2-0.20230424022356-49c2e39f3fe6/go.mod h1:14tO5KQaTrl2q3OxBnDRfue7TRN9zkXS0cLutrSqkOo=
924924
github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230417042817-8072b1e9aabc h1:2qZf+B37YnoHcmXnB87VfcrVC50I+LZWeWu4ZEAddsc=
925925
github.com/notional-labs/ibc-go/v7 v7.0.0-rc0.0.20230417042817-8072b1e9aabc/go.mod h1:BFh8nKWjr5zeR2OZfhkzdgDzj1+KjRn3aJLpwapStj8=
926926
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

legacy_ibc_testing/testing/app.go

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func SetupWithGenesisValSet(t *testing.T, appIniter AppIniter, valSet *tmtypes.V
6565
t.Helper()
6666
app, genesisState := appIniter()
6767

68+
baseapp.SetChainID(chainID)(app.GetBaseApp())
69+
6870
// set genesis accounts
6971
authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs)
7072
genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis)

tests/difference/core/driver/setup.go

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
abci "github.com/cometbft/cometbft/abci/types"
1010
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
1111
tmtypes "github.com/cometbft/cometbft/types"
12+
"github.com/cosmos/cosmos-sdk/baseapp"
1213
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1314
cosmosEd25519 "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
1415
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@@ -244,6 +245,8 @@ func (b *Builder) newChain(
244245
) *ibctesting.TestChain {
245246
app, genesis := appInit()
246247

248+
baseapp.SetChainID(chainID)(app.GetBaseApp())
249+
247250
stateBytes, senderAccounts := b.getAppBytesAndSenders(chainID, app, genesis, validators)
248251

249252
app.InitChain(

x/ccv/consumer/keeper/genesis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState)
114114

115115
// ExportGenesis returns the CCV consumer module's exported genesis
116116
func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisState) {
117-
params := k.GetParams(ctx)
117+
params := k.GetConsumerParams(ctx)
118118
if !params.Enabled {
119119
return consumertypes.DefaultGenesisState()
120120
}

x/ccv/consumer/keeper/genesis_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func TestInitGenesis(t *testing.T) {
123123
assertHeightValsetUpdateIDs(t, ctx, &ck, defaultHeightValsetUpdateIDs)
124124

125125
require.Equal(t, validator.Address.Bytes(), ck.GetAllCCValidator(ctx)[0].Address)
126-
require.Equal(t, gs.Params, ck.GetParams(ctx))
126+
require.Equal(t, gs.Params, ck.GetConsumerParams(ctx))
127127
},
128128
}, {
129129
"restart a chain without an established CCV channel",
@@ -150,7 +150,7 @@ func TestInitGenesis(t *testing.T) {
150150
assertHeightValsetUpdateIDs(t, ctx, &ck, defaultHeightValsetUpdateIDs)
151151
assertProviderClientID(t, ctx, &ck, provClientID)
152152
require.Equal(t, validator.Address.Bytes(), ck.GetAllCCValidator(ctx)[0].Address)
153-
require.Equal(t, gs.Params, ck.GetParams(ctx))
153+
require.Equal(t, gs.Params, ck.GetConsumerParams(ctx))
154154
},
155155
}, {
156156
"restart a chain with an established CCV channel",
@@ -194,7 +194,7 @@ func TestInitGenesis(t *testing.T) {
194194
assertHeightValsetUpdateIDs(t, ctx, &ck, updatedHeightValsetUpdateIDs)
195195
assertProviderClientID(t, ctx, &ck, provClientID)
196196

197-
require.Equal(t, gs.Params, ck.GetParams(ctx))
197+
require.Equal(t, gs.Params, ck.GetConsumerParams(ctx))
198198
},
199199
},
200200
}

x/ccv/consumer/keeper/grpc_query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (k Keeper) QueryParams(c context.Context,
3434
return nil, status.Errorf(codes.InvalidArgument, "empty request")
3535
}
3636

37-
p := k.GetParams(ctx)
37+
p := k.GetConsumerParams(ctx)
3838

3939
return &types.QueryParamsResponse{Params: p}, nil
4040
}

x/ccv/consumer/keeper/params.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"time"
55

66
sdk "github.com/cosmos/cosmos-sdk/types"
7+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
78

89
"github.com/cosmos/interchain-security/x/ccv/consumer/types"
910
ccvtypes "github.com/cosmos/interchain-security/x/ccv/types"
1011
)
1112

1213
// GetParams returns the params for the consumer ccv module
13-
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
14+
func (k Keeper) GetConsumerParams(ctx sdk.Context) types.Params {
1415
return types.NewParams(
1516
k.GetEnabled(ctx),
1617
k.GetBlocksPerDistributionTransmission(ctx),
@@ -30,6 +31,11 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
3031
k.paramStore.SetParamSet(ctx, &params)
3132
}
3233

34+
// GetParams implement from staking keeper
35+
func (k Keeper) GetParams(ctx sdk.Context) stakingtypes.Params {
36+
return stakingtypes.DefaultParams()
37+
}
38+
3339
// GetEnabled returns the enabled flag for the consumer module
3440
func (k Keeper) GetEnabled(ctx sdk.Context) bool {
3541
var enabled bool

x/ccv/consumer/keeper/params_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ func TestParams(t *testing.T) {
2929
types.DefaultSoftOptOutThreshold,
3030
) // these are the default params, IBC suite independently sets enabled=true
3131

32-
params := consumerKeeper.GetParams(ctx)
32+
params := consumerKeeper.GetConsumerParams(ctx)
3333
require.Equal(t, expParams, params)
3434

3535
newParams := types.NewParams(false, 1000,
3636
"channel-2", "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm",
3737
7*24*time.Hour, 25*time.Hour, "0.5", 500, 24*21*time.Hour, "0.05")
3838
consumerKeeper.SetParams(ctx, newParams)
39-
params = consumerKeeper.GetParams(ctx)
39+
params = consumerKeeper.GetConsumerParams(ctx)
4040
require.Equal(t, newParams, params)
4141

4242
consumerKeeper.SetBlocksPerDistributionTransmission(ctx, 10)

x/ccv/consumer/keeper/validators.go

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keeper
33
import (
44
"time"
55

6+
"cosmossdk.io/math"
67
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
78

89
abci "github.com/cometbft/cometbft/abci/types"
@@ -149,6 +150,13 @@ func (k Keeper) Slash(ctx sdk.Context, addr sdk.ConsAddress, infractionHeight, p
149150
)
150151
}
151152

153+
// implement for stakingkeeper Interface
154+
func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, infractionType stakingtypes.Infraction) math.Int {
155+
k.Slash(ctx, consAddr, infractionHeight, power, slashFactor, infractionType)
156+
// Only return to comply with the interface restriction
157+
return math.ZeroInt()
158+
}
159+
152160
// Jail - unimplemented on CCV keeper
153161
//
154162
// This method should be a no-op even during a standalone to consumer changeover.

0 commit comments

Comments
 (0)