-
Notifications
You must be signed in to change notification settings - Fork 650
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
feat: emitting an event when handling a client upgrade proposal (backport #1570) #1590
Changes from 2 commits
7e7b5fe
42ba8b6
6171dd3
f403f6c
15e4316
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/v2/modules/core/02-client/types" | ||
"github.com/cosmos/ibc-go/v2/modules/core/exported" | ||
) | ||
|
||
// EmitCreateClientEvent emits a create client event | ||
func EmitCreateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that all these other We have this problem in the other v2 back ports as well... |
||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeCreateClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientEvent emits an update client event | ||
func EmitUpdateClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState, consensusHeight exported.Height, headerStr string) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeUpdateClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()), | ||
sdk.NewAttribute(types.AttributeKeyHeader, headerStr), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientEvent emits an upgrade client event | ||
func EmitUpgradeClientEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvents(sdk.Events{ | ||
sdk.NewEvent( | ||
types.EventTypeUpgradeClient, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
sdk.NewEvent( | ||
sdk.EventTypeMessage, | ||
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), | ||
), | ||
}) | ||
} | ||
|
||
// EmitUpdateClientProposalEvent emits an update client proposal event | ||
func EmitUpdateClientProposalEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeUpdateClientProposal, | ||
sdk.NewAttribute(types.AttributeKeySubjectClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, clientState.GetLatestHeight().String()), | ||
), | ||
) | ||
} | ||
|
||
// EmitUpgradeClientProposalEvent emits an upgrade client proposal event | ||
func EmitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeUpgradeClientProposal, | ||
sdk.NewAttribute(types.AttributeKeyUpgradePlanTitle, title), | ||
sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)), | ||
), | ||
) | ||
} | ||
|
||
// EmitSubmitMisbehaviourEvent emits a client misbehaviour event | ||
func EmitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeSubmitMisbehaviour, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
), | ||
) | ||
} | ||
|
||
// EmitSubmitMisbehaviourEventOnUpdate emits a client misbehaviour event on a client update event | ||
func EmitSubmitMisbehaviourEventOnUpdate(ctx sdk.Context, clientID string, clientState exported.ClientState, consensusHeight exported.Height, headerStr string) { | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent( | ||
types.EventTypeSubmitMisbehaviour, | ||
sdk.NewAttribute(types.AttributeKeyClientID, clientID), | ||
sdk.NewAttribute(types.AttributeKeyClientType, clientState.ClientType()), | ||
sdk.NewAttribute(types.AttributeKeyConsensusHeight, consensusHeight.String()), | ||
sdk.NewAttribute(types.AttributeKeyHeader, headerStr), | ||
), | ||
) | ||
} |
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.
Shouldn't this be in the unreleased section at the top of changelog? i.e. targeted for
v2.1.2