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

refactor: ibc core runtime env #7601

Merged
merged 113 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
a1ef65e
go mod changes
tac0turtle Sep 6, 2024
a0bf113
remove cometabci direct dep
tac0turtle Sep 6, 2024
5a331ed
fix all errors
tac0turtle Sep 8, 2024
6d49de2
appmodule & simapp cleanup
tac0turtle Sep 8, 2024
ad88b3c
08wasm fixes
tac0turtle Sep 8, 2024
fec6f52
get 08-wasm compiling
tac0turtle Sep 8, 2024
fc0f25a
another simapp
tac0turtle Sep 8, 2024
3e5029e
another simapp
tac0turtle Sep 8, 2024
10440c8
pass in environment
tac0turtle Sep 8, 2024
d779d86
fix compilation errors
tac0turtle Sep 8, 2024
2a11f2e
some fixes
tac0turtle Sep 9, 2024
d029e19
build
tac0turtle Sep 9, 2024
c055483
fix other simapps
tac0turtle Sep 9, 2024
26d765e
linting
tac0turtle Sep 9, 2024
2ee5548
remove unsed code
tac0turtle Sep 10, 2024
0832575
Merge branch 'feat/upgrade-sdk-v0.52' into marko/gomod_change
tac0turtle Sep 23, 2024
11e5c51
go mod changes
tac0turtle Sep 23, 2024
db4ab33
add pool module
tac0turtle Sep 23, 2024
da38c64
anothersimapp
tac0turtle Sep 23, 2024
455a2e8
linting fixes
tac0turtle Sep 23, 2024
471123e
protocol pool module accounts
tac0turtle Sep 23, 2024
8c99de3
callback fixes
tac0turtle Sep 23, 2024
c01a5ed
simapp fixes
tac0turtle Sep 23, 2024
16d4530
register interfaces
tac0turtle Sep 24, 2024
ab2191b
fix feeibc
tac0turtle Sep 24, 2024
4a5d564
changes++
tac0turtle Sep 24, 2024
b2978bb
Merge branch 'feat/upgrade-sdk-v0.52' into marko/gomod_change
tac0turtle Sep 24, 2024
97ce6b8
fix missed conflict
tac0turtle Sep 24, 2024
58e6cbe
fix wasm client
tac0turtle Sep 24, 2024
ba0f7ce
linting fixes
tac0turtle Sep 24, 2024
5e94346
Merge branch 'main' into marko/gomod_change
tac0turtle Oct 21, 2024
4af6896
fix tests
tac0turtle Oct 21, 2024
bb85a9a
linting
tac0turtle Oct 21, 2024
9dc1460
fix simapp tests
tac0turtle Oct 21, 2024
a073c5d
erge branch 'main' into marko/gomod_change
tac0turtle Nov 6, 2024
6ef7fc1
fix some tests
tac0turtle Nov 6, 2024
ac74c7d
fix e2e go mod
tac0turtle Nov 6, 2024
85c06e1
go mod changes
tac0turtle Nov 6, 2024
4eb9438
remove grandpa
tac0turtle Nov 6, 2024
e06d2c5
Gomod changes and minor updates (#7549)
alpe Nov 11, 2024
d9d7072
chore: use same tags for all go mods
chatton Nov 18, 2024
452a287
chore: update go mod files, revert callbacks simapp changes
chatton Nov 18, 2024
b24e6aa
chore: fix tendermint client test suite
chatton Nov 18, 2024
b02eb86
chore: fix tests in TestAnteDecoratorCheckTx
chatton Nov 19, 2024
b6e75a8
chore: fix event tests
chatton Nov 19, 2024
a9baeec
chore: fix compiler error in simapp
damiannolan Nov 19, 2024
b54b4b6
deps: update to latest of cosmossdk.io/store main to fix proofs test
damiannolan Nov 19, 2024
61aea60
chore: tidy all
chatton Nov 20, 2024
0eb8205
fix: remove ibcmock module acc from blocked addrs
damiannolan Nov 20, 2024
8c94751
chore: fix proto failures and Gov errors
chatton Nov 20, 2024
386b258
chore: fix ica test
chatton Nov 20, 2024
bfd2454
chore: fix a few compiler errs in 08-wasm
damiannolan Nov 20, 2024
0ec2d48
fix: update ica account already exists test to front run account crea…
damiannolan Nov 20, 2024
37da9f5
chore: fix ica test for address gen
damiannolan Nov 20, 2024
b75b061
Merge pull request #7580 from cosmos/cian/damian/sdk-52
damiannolan Nov 20, 2024
610ff2d
Merge branch 'main' into marko/gomod_change
damiannolan Nov 21, 2024
cec1953
chore: re-add log to returned error
chatton Nov 21, 2024
5f115f4
chore: update go mods
chatton Nov 21, 2024
d7d1713
chore: fixed build errors in wasm app.go
chatton Nov 21, 2024
a195296
chore: cleanup callbacks simapp
damiannolan Nov 21, 2024
47eb259
chore: fixing simulation functions
chatton Nov 21, 2024
6ca4a43
chore: reconfigure simd cmd and fix TestInitCmd
damiannolan Nov 21, 2024
346d83d
feat: adding runtime Environment
damiannolan Nov 21, 2024
29ce5f2
chore: run make lint-fix
damiannolan Nov 21, 2024
7e7d17d
chore: remove duplicate import
damiannolan Nov 21, 2024
7e2f699
chore: rm duplicate import
damiannolan Nov 22, 2024
7cb2468
chore: migrate to env KVStoreService in icacontroller
damiannolan Nov 25, 2024
cb93c24
chore: fix duplicate import
damiannolan Nov 25, 2024
f828f09
chore: rm kv store service
damiannolan Nov 25, 2024
d488054
chore: refactor events to use environment
damiannolan Nov 25, 2024
92ecec1
chore: make lint-fix
damiannolan Nov 25, 2024
4660322
chore: make tidy-all
damiannolan Nov 25, 2024
e267e42
chore: rm msg service router from icacontroller
damiannolan Nov 25, 2024
ab1f3f3
fix: remove 32 bit arm arch from callbacks ci builds
damiannolan Nov 25, 2024
8b67d8d
test: try cache false for callbacks linter
damiannolan Nov 25, 2024
e27966b
chore: pin to updated interchaintest fork
chatton Nov 26, 2024
b6fba89
chore: revert relayer count to 10
chatton Nov 26, 2024
c23234d
chore: continued work on upgrading e2e tests to 0.52
chatton Nov 26, 2024
d83116d
chore: transfer e2e passing
chatton Nov 27, 2024
82c5a66
chore: fix upgrade build errors
chatton Nov 27, 2024
06d40e4
chore: bump interchaintest
chatton Nov 27, 2024
a128c03
chore: update sample config
chatton Nov 27, 2024
55b4fbe
chore: reconfigure protoany to use gogoproto any in favour of codec t…
damiannolan Nov 27, 2024
b92bc67
chore: tidy imports in e2e
damiannolan Nov 27, 2024
f9b7314
fix: address failure in module safe query ica e2e test
damiannolan Dec 2, 2024
94a4685
bump golangci version to 1.60
bznein Dec 2, 2024
4f37cf6
lint: remove duplicate import
damiannolan Dec 2, 2024
e24c60f
chore: use gogoprotoany in favour of codec types any. rm ProtoCodecMa…
damiannolan Dec 4, 2024
d70f0c4
chore: bump go version in Dockerfile
damiannolan Dec 4, 2024
5b89030
chore: add todo
damiannolan Dec 4, 2024
5ea5802
lint: fix unnecessary cast
damiannolan Dec 4, 2024
0e64412
deps: upgrade sdk to head of release/v0.52.x, upgrade store to latest…
damiannolan Dec 4, 2024
6feb83d
refactor: ibc core runtime env
damiannolan Nov 26, 2024
0afd019
chore: propagate errors from event emission
damiannolan Dec 4, 2024
9620934
refactore: update 09-localhost to use runtime.environment
bznein Dec 5, 2024
17170df
Merge branch 'main' into damian/core-runtime-env
damiannolan Dec 18, 2024
6e8275e
chore: rm e2e-wasm
damiannolan Dec 18, 2024
4cb4ded
chore: revert height_test diffs
damiannolan Dec 19, 2024
ec921c8
Merge branch 'main' into damian/core-runtime-env
damiannolan Dec 19, 2024
828f42c
chore: handle errors in event emission msg_server
damiannolan Dec 19, 2024
842008d
refactor: remove many usages of sdk.UnwrapSDKContext
damiannolan Dec 19, 2024
823fe2a
chore: linting
damiannolan Dec 19, 2024
78c5094
chore: fix missing height field in header.Info in test chain
damiannolan Dec 19, 2024
f35cb91
Merge branch 'main' into damian/core-runtime-env
damiannolan Dec 19, 2024
074263b
refactor: use branch service in timeout handler
damiannolan Dec 19, 2024
4319769
refactor: use branch service in other msg server handlers
damiannolan Dec 19, 2024
67ccc82
chore: address linter complaints
damiannolan Dec 19, 2024
4765ef4
chore: some code cleanup
damiannolan Dec 19, 2024
01ef960
Update modules/core/keeper/msg_server.go
damiannolan Dec 19, 2024
6150ac6
Merge branch 'main' into damian/core-runtime-env
damiannolan Dec 19, 2024
6c3e11f
fix: correctly check error in acknowledgePacket
damiannolan Dec 20, 2024
4224996
chore: replace more occurrences of UnwrapSDKContext with service usage
damiannolan Dec 20, 2024
85ac10a
Merge branch 'main' into damian/core-runtime-env
damiannolan Dec 20, 2024
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
6 changes: 5 additions & 1 deletion modules/apps/callbacks/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ func NewSimApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr, app.ConsensusParamsKeeper)

app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appCodec,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")),
app.GetSubspace(ibcexported.ModuleName),
app.UpgradeKeeper,
govModuleAddr,
)

// NOTE: The mock ContractKeeper is only created for testing.
Expand Down
12 changes: 10 additions & 2 deletions modules/core/02-client/abci.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v9/modules/core/02-client/keeper"
Expand All @@ -9,7 +11,11 @@ import (
)

// BeginBlocker is used to perform IBC client upgrades
func BeginBlocker(ctx sdk.Context, k *keeper.Keeper) {
func BeginBlocker(goCtx context.Context, k *keeper.Keeper) {
// TODO: In order to fully migrate away from sdk.Context here we will need to depend on comet service in order
// to consume the full block header as Env only contains header.Info (where we cannot access next vals hash)
Comment on lines +15 to +16
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create issue

ctx := sdk.UnwrapSDKContext(goCtx)

plan, err := k.GetUpgradePlan(ctx)
if err == nil {
// Once we are at the last block this chain will commit, set the upgraded consensus state
Expand All @@ -29,7 +35,9 @@ func BeginBlocker(ctx sdk.Context, k *keeper.Keeper) {
// SetUpgradedConsensusState always returns nil, hence the blank here.
_ = k.SetUpgradedConsensusState(ctx, plan.Height, bz)

keeper.EmitUpgradeChainEvent(ctx, plan.Height)
if err := k.EmitUpgradeChainEvent(ctx, plan.Height); err != nil {
k.Logger.Error("error in events emission", "error", err.Error())
}
}
}
}
42 changes: 18 additions & 24 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package keeper

import (
errorsmod "cosmossdk.io/errors"
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
errorsmod "cosmossdk.io/errors"

"github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
Expand All @@ -15,7 +15,7 @@ import (
// client identifier. The light client module is responsible for setting any client-specific data in the store
// via the Initialize method. This includes the client state, initial consensus state and any associated
// metadata. The generated client identifier will be returned if a client was successfully initialized.
func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, consensusState []byte) (string, error) {
func (k *Keeper) CreateClient(ctx context.Context, clientType string, clientState, consensusState []byte) (string, error) {
if clientType == exported.Localhost {
return "", errorsmod.Wrapf(types.ErrInvalidClientType, "cannot create client of type: %s", clientType)
}
Expand All @@ -36,16 +36,18 @@ func (k *Keeper) CreateClient(ctx sdk.Context, clientType string, clientState, c
}

initialHeight := clientModule.LatestHeight(ctx, clientID)
k.Logger(ctx).Info("client created at height", "client-id", clientID, "height", initialHeight.String())
k.Logger.Info("client created at height", "client-id", clientID, "height", initialHeight.String())

defer telemetry.ReportCreateClient(clientType)
emitCreateClientEvent(ctx, clientID, clientType, initialHeight)
if err := k.emitCreateClientEvent(ctx, clientID, clientType, initialHeight); err != nil {
return "", err
}

return clientID, nil
}

// UpdateClient updates the consensus state and the state root from a provided header.
func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error {
func (k *Keeper) UpdateClient(ctx context.Context, clientID string, clientMsg exported.ClientMessage) error {
clientModule, err := k.Route(ctx, clientID)
if err != nil {
return err
Expand All @@ -63,33 +65,27 @@ func (k *Keeper) UpdateClient(ctx sdk.Context, clientID string, clientMsg export
if foundMisbehaviour {
clientModule.UpdateStateOnMisbehaviour(ctx, clientID, clientMsg)

k.Logger(ctx).Info("client frozen due to misbehaviour", "client-id", clientID)
k.Logger.Info("client frozen due to misbehaviour", "client-id", clientID)

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID)
emitSubmitMisbehaviourEvent(ctx, clientID, clientType)

return nil
return k.emitSubmitMisbehaviourEvent(ctx, clientID, clientType)
}

consensusHeights := clientModule.UpdateState(ctx, clientID, clientMsg)

k.Logger(ctx).Info("client state updated", "client-id", clientID, "heights", consensusHeights)
k.Logger.Info("client state updated", "client-id", clientID, "heights", consensusHeights)

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpdateClient(foundMisbehaviour, clientType, clientID)
emitUpdateClientEvent(ctx, clientID, clientType, consensusHeights, k.cdc, clientMsg)

return nil
return k.emitUpdateClientEvent(ctx, clientID, clientType, consensusHeights, k.cdc, clientMsg)
}

// UpgradeClient upgrades the client to a new client state if this new client was committed to
// by the old client at the specified upgrade height
func (k *Keeper) UpgradeClient(
ctx sdk.Context,
clientID string,
upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof []byte,
) error {
func (k *Keeper) UpgradeClient(ctx context.Context, clientID string, upgradedClient, upgradedConsState, upgradeClientProof, upgradeConsensusStateProof []byte) error {
clientModule, err := k.Route(ctx, clientID)
if err != nil {
return err
Expand All @@ -104,21 +100,20 @@ func (k *Keeper) UpgradeClient(
}

latestHeight := clientModule.LatestHeight(ctx, clientID)
k.Logger(ctx).Info("client state upgraded", "client-id", clientID, "height", latestHeight.String())
k.Logger.Info("client state upgraded", "client-id", clientID, "height", latestHeight.String())

clientType := types.MustParseClientIdentifier(clientID)
defer telemetry.ReportUpgradeClient(clientType, clientID)
emitUpgradeClientEvent(ctx, clientID, clientType, latestHeight)

return nil
return k.emitUpgradeClientEvent(ctx, clientID, clientType, latestHeight)
}

// RecoverClient will invoke the light client module associated with the subject clientID requesting it to
// recover the subject client given a substitute client identifier. The light client implementation
// is responsible for validating the parameters of the substitute (ensuring they match the subject's parameters)
// as well as copying the necessary consensus states from the substitute to the subject client store.
// The substitute must be Active and the subject must not be Active.
func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClientID string) error {
func (k *Keeper) RecoverClient(ctx context.Context, subjectClientID, substituteClientID string) error {
clientModule, err := k.Route(ctx, subjectClientID)
if err != nil {
return errorsmod.Wrap(types.ErrRouteNotFound, subjectClientID)
Expand All @@ -142,11 +137,10 @@ func (k *Keeper) RecoverClient(ctx sdk.Context, subjectClientID, substituteClien
return err
}

k.Logger(ctx).Info("client recovered", "client-id", subjectClientID)
k.Logger.Info("client recovered", "client-id", subjectClientID)

clientType := types.MustParseClientIdentifier(subjectClientID)
defer telemetry.ReportRecoverClient(clientType, subjectClientID)
emitRecoverClientEvent(ctx, subjectClientID, clientType)

return nil
return k.emitRecoverClientEvent(ctx, subjectClientID, clientType)
}
189 changes: 99 additions & 90 deletions modules/core/02-client/keeper/events.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package keeper

import (
"context"
"fmt"
"strconv"
"strings"

"cosmossdk.io/core/event"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -15,23 +17,24 @@ import (
)

// emitCreateClientEvent emits a create client event
func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, initialHeight exported.Height) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCreateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) emitCreateClientEvent(ctx context.Context, clientID, clientType string, initialHeight exported.Height) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeCreateClient,
event.NewAttribute(types.AttributeKeyClientID, clientID),
event.NewAttribute(types.AttributeKeyClientType, clientType),
event.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// emitUpdateClientEvent emits an update client event
func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string, consensusHeights []exported.Height, _ codec.BinaryCodec, _ exported.ClientMessage) {
func (k *Keeper) emitUpdateClientEvent(ctx context.Context, clientID string, clientType string, consensusHeights []exported.Height, _ codec.BinaryCodec, _ exported.ClientMessage) error {
var consensusHeightAttr string
if len(consensusHeights) != 0 {
consensusHeightAttr = consensusHeights[0].String()
Expand All @@ -42,95 +45,101 @@ func emitUpdateClientEvent(ctx sdk.Context, clientID string, clientType string,
consensusHeightsAttr[i] = height.String()
}

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpdateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
// Deprecated: AttributeKeyConsensusHeight is deprecated and will be removed in a future release.
// Please use AttributeKeyConsensusHeights instead.
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeightAttr),
sdk.NewAttribute(types.AttributeKeyConsensusHeights, strings.Join(consensusHeightsAttr, ",")),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeUpdateClient,
event.NewAttribute(types.AttributeKeyClientID, clientID),
event.NewAttribute(types.AttributeKeyClientType, clientType),
// Deprecated: AttributeKeyConsensusHeight is deprecated and will be removed in a future release.
// Please use AttributeKeyConsensusHeights instead.
event.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeightAttr),
event.NewAttribute(types.AttributeKeyConsensusHeights, strings.Join(consensusHeightsAttr, ",")),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// emitUpgradeClientEvent emits an upgrade client event
func emitUpgradeClientEvent(ctx sdk.Context, clientID, clientType string, latestHeight exported.Height) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpgradeClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) emitUpgradeClientEvent(ctx context.Context, clientID, clientType string, latestHeight exported.Height) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeUpgradeClient,
event.NewAttribute(types.AttributeKeyClientID, clientID),
event.NewAttribute(types.AttributeKeyClientType, clientType),
event.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// emitSubmitMisbehaviourEvent emits a client misbehaviour event
func emitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientType string) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeSubmitMisbehaviour,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) emitSubmitMisbehaviourEvent(ctx context.Context, clientID string, clientType string) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeSubmitMisbehaviour,
event.NewAttribute(types.AttributeKeyClientID, clientID),
event.NewAttribute(types.AttributeKeyClientType, clientType),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// emitRecoverClientEvent emits a recover client event
func emitRecoverClientEvent(ctx sdk.Context, clientID, clientType string) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeRecoverClient,
sdk.NewAttribute(types.AttributeKeySubjectClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) emitRecoverClientEvent(ctx context.Context, clientID, clientType string) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeRecoverClient,
event.NewAttribute(types.AttributeKeySubjectClientID, clientID),
event.NewAttribute(types.AttributeKeyClientType, clientType),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// emitScheduleIBCSoftwareUpgradeEvent emits a schedule IBC software upgrade event
func emitScheduleIBCSoftwareUpgradeEvent(ctx sdk.Context, title string, height int64) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeScheduleIBCSoftwareUpgrade,
sdk.NewAttribute(types.AttributeKeyUpgradePlanTitle, title),
sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) emitScheduleIBCSoftwareUpgradeEvent(ctx context.Context, title string, height int64) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeScheduleIBCSoftwareUpgrade,
event.NewAttribute(types.AttributeKeyUpgradePlanTitle, title),
event.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)),
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}

// EmitUpgradeChainEvent emits an upgrade chain event.
func EmitUpgradeChainEvent(ctx sdk.Context, height int64) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeUpgradeChain,
sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)),
sdk.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
func (k *Keeper) EmitUpgradeChainEvent(ctx context.Context, height int64) error {
if err := k.EventService.EventManager(ctx).EmitKV(
types.EventTypeUpgradeChain,
event.NewAttribute(types.AttributeKeyUpgradePlanHeight, strconv.FormatInt(height, 10)),
event.NewAttribute(types.AttributeKeyUpgradeStore, upgradetypes.StoreKey), // which store to query proof of consensus state from
); err != nil {
return err
}

return k.EventService.EventManager(ctx).EmitKV(
sdk.EventTypeMessage,
event.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
)
}
Loading
Loading