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

fix!: remove duplicate event emission (backport #2282) #2300

Open
wants to merge 2 commits into
base: release/v4.5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading