Skip to content

Commit

Permalink
feat: emitting an event when handling a client upgrade proposal (back…
Browse files Browse the repository at this point in the history
…port #1570) (#1766)

* feat: emitting an event when handling a client upgrade proposal (#1570)

* feat: emitting an event when handling a client upgrade proposal

* refactor: only emit event if err is nil

* refactor: idiotmatic go:

(cherry picked from commit 8422d0c)

# Conflicts:
#	CHANGELOG.md
#	modules/core/02-client/keeper/events.go

* fix conflicts

* add new line

* remove unused import

Co-authored-by: Sean King <[email protected]>
Co-authored-by: crodriguezvega <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2022
1 parent a061fab commit bb3d1cf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (core/02-client) [\#1570](https://github.com/cosmos/ibc-go/pull/1570) Emitting an event when handling an upgrade client proposal.
* (app/20-transfer) [\#1680](https://github.com/cosmos/ibc-go/pull/1680) Adds migration to correct any malformed trace path information of tokens with denoms that contains slashes. The transfer module consensus version has been bumped to 2.
* (app/20-transfer) [\#1730](https://github.com/cosmos/ibc-go/pull/1730) parse the ics20 denomination provided via a packet using the channel identifier format specified by ibc-go.

Expand Down
20 changes: 20 additions & 0 deletions modules/core/02-client/keeper/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package keeper

import (
"fmt"

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

"github.com/cosmos/ibc-go/v2/modules/core/02-client/types"
)

// 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)),
),
)
}
9 changes: 8 additions & 1 deletion modules/core/02-client/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,12 @@ func (k Keeper) HandleUpgradeProposal(ctx sdk.Context, p *types.UpgradeProposal)

// sets the new upgraded client in last height committed on this chain is at plan.Height,
// since the chain will panic at plan.Height and new chain will resume at plan.Height
return k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz)
if err = k.upgradeKeeper.SetUpgradedClient(ctx, p.Plan.Height, bz); err != nil {
return err
}

// emitting an event for handling client upgrade proposal
EmitUpgradeClientProposalEvent(ctx, p.Title, p.Plan.Height)

return nil
}
23 changes: 13 additions & 10 deletions modules/core/02-client/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ import (

// IBC client events
const (
AttributeKeyClientID = "client_id"
AttributeKeySubjectClientID = "subject_client_id"
AttributeKeyClientType = "client_type"
AttributeKeyConsensusHeight = "consensus_height"
AttributeKeyHeader = "header"
AttributeKeyClientID = "client_id"
AttributeKeySubjectClientID = "subject_client_id"
AttributeKeyClientType = "client_type"
AttributeKeyConsensusHeight = "consensus_height"
AttributeKeyHeader = "header"
AttributeKeyUpgradePlanTitle = "title"
AttributeKeyUpgradePlanHeight = "height"
)

// IBC client events vars
var (
EventTypeCreateClient = "create_client"
EventTypeUpdateClient = "update_client"
EventTypeUpgradeClient = "upgrade_client"
EventTypeSubmitMisbehaviour = "client_misbehaviour"
EventTypeUpdateClientProposal = "update_client_proposal"
EventTypeCreateClient = "create_client"
EventTypeUpdateClient = "update_client"
EventTypeUpgradeClient = "upgrade_client"
EventTypeSubmitMisbehaviour = "client_misbehaviour"
EventTypeUpdateClientProposal = "update_client_proposal"
EventTypeUpgradeClientProposal = "upgrade_client_proposal"

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

0 comments on commit bb3d1cf

Please sign in to comment.