Skip to content

Commit

Permalink
create separate event emission for ibc software upgrades vs an upgrad…
Browse files Browse the repository at this point in the history
…ed client (#4594)

* add new event type

* update event name
  • Loading branch information
charleenfei authored Sep 8, 2023
1 parent 386ea01 commit f2e7b0d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
17 changes: 17 additions & 0 deletions modules/core/02-client/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ func emitUpgradeClientProposalEvent(ctx sdk.Context, title string, height int64)
})
}

// emitScheduleIBCSoftwareUpgradeEvent emits a schedule IBC software upgrade event
func emitScheduleIBCSoftwareUpgradeEvent(ctx sdk.Context, title string, height int64, upgradeClientState exported.ClientState) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeScheduleIBCSoftwareUpgrade,
sdk.NewAttribute(types.AttributeKeyUpgradePlanTitle, title),
sdk.NewAttribute(types.AttributeKeyUpgradePlanHeight, fmt.Sprintf("%d", height)),
sdk.NewAttribute(types.AttributeKeyClientType, upgradeClientState.ClientType()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, upgradeClientState.GetLatestHeight().String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
}

// emitSubmitMisbehaviourEvent emits a client misbehaviour event
func emitSubmitMisbehaviourEvent(ctx sdk.Context, clientID string, clientState exported.ClientState) {
ctx.EventManager().EmitEvents(sdk.Events{
Expand Down
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ func (k Keeper) ScheduleIBCSoftwareUpgrade(ctx sdk.Context, plan upgradetypes.Pl
return err
}

// emitting an event for handling client upgrade proposal
emitUpgradeClientProposalEvent(ctx, plan.Name, plan.Height)
// emitting an event for scheduling an upgrade plan
emitScheduleIBCSoftwareUpgradeEvent(ctx, plan.Name, plan.Height, cs)

return nil
}
15 changes: 8 additions & 7 deletions modules/core/02-client/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ const (

// IBC client events vars
var (
EventTypeCreateClient = "create_client"
EventTypeUpdateClient = "update_client"
EventTypeUpgradeClient = "upgrade_client"
EventTypeSubmitMisbehaviour = "client_misbehaviour"
EventTypeUpgradeChain = "upgrade_chain"
EventTypeUpgradeClientProposal = "upgrade_client_proposal"
EventTypeRecoverClient = "recover_client"
EventTypeCreateClient = "create_client"
EventTypeUpdateClient = "update_client"
EventTypeUpgradeClient = "upgrade_client"
EventTypeSubmitMisbehaviour = "client_misbehaviour"
EventTypeUpgradeChain = "upgrade_chain"
EventTypeUpgradeClientProposal = "upgrade_client_proposal"
EventTypeScheduleIBCSoftwareUpgrade = "schedule_ibc_software_upgrade"
EventTypeRecoverClient = "recover_client"

AttributeValueCategory = fmt.Sprintf("%s_%s", ibcexported.ModuleName, SubModuleName)
)

0 comments on commit f2e7b0d

Please sign in to comment.