Skip to content

Commit

Permalink
fix!: remove duplicate event emission (backport #2282) (#2300)
Browse files Browse the repository at this point in the history
* fix!: remove duplicate event emission (#2282)

* remove duplicate event emission

* add changelog entry

(cherry picked from commit 47b786a)

# Conflicts:
#	x/ccv/provider/keeper/consumer_lifecycle.go

* fix backport

---------

Co-authored-by: Marius Poke <marius.poke@posteo.de>
  • Loading branch information
mergify[bot] and mpoke authored Sep 25, 2024
1 parent 5eb6d8c commit e2469d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/2282-duplicate-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove duplicate event emission on cached context.
([\#2282](https://github.com/cosmos/interchain-security/pull/2282))
3 changes: 0 additions & 3 deletions x/ccv/consumer/keeper/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ func (k Keeper) EndBlockRD(ctx sdk.Context) {
if err := k.SendRewardsToProvider(cachedCtx); err != nil {
k.Logger(ctx).Error("attempt to sent rewards to provider failed", "error", err)
} else {
// The cached context is created with a new EventManager so we merge the event
// into the original context
ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events())
// write cache
writeCache()
}
Expand Down
9 changes: 2 additions & 7 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,6 @@ func (k Keeper) BeginBlockInit(ctx sdk.Context) {
continue
}

// The cached context is created with a new EventManager so we merge the event
// into the original context
ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events())
// write cache
writeFn()

Expand Down Expand Up @@ -589,15 +586,13 @@ func (k Keeper) BeginBlockCCR(ctx sdk.Context) {

for _, prop := range propsToExecute {
// stop consumer chain in a cached context to handle errors
cachedCtx, writeFn, err := k.StopConsumerChainInCachedCtx(ctx, prop)
_, writeFn, err := k.StopConsumerChainInCachedCtx(ctx, prop)
if err != nil {
// drop the proposal
ctx.Logger().Info("consumer chain could not be stopped: %w", err)
continue
}
// The cached context is created with a new EventManager so we merge the event
// into the original context
ctx.EventManager().EmitEvents(cachedCtx.EventManager().Events())

// write cache
writeFn()

Expand Down

0 comments on commit e2469d3

Please sign in to comment.