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

go/consensus/tendermint: Only reset executor pool after emitting block #4323

Merged
merged 1 commit into from
Oct 21, 2021
Merged
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
5 changes: 5 additions & 0 deletions .changelog/4323.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/consensus/tendermint: Only reset executor pool after emitting block

Make sure to only reset the executor pool after any timeouts have been
cleared (e.g. when an empty block is emitted) as otherwise there could be a
stale timeout.
16 changes: 13 additions & 3 deletions go/consensus/tendermint/apps/roothash/roothash.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,16 @@ func (app *rootHashApplication) suspendUnpaidRuntime(
return err
}

rtState.Suspended = true
rtState.ExecutorPool = nil

// Emity an empty block signalling that the runtime was suspended.
if err := app.emitEmptyBlock(ctx, rtState, block.Suspended); err != nil {
return fmt.Errorf("failed to emit empty block: %w", err)
}

// Make sure to only reset the executor pool after any timeouts have been cleared as otherwise
// the emitEmptyBlock method will forget to clear them.
rtState.Suspended = true
rtState.ExecutorPool = nil

return nil
}

Expand Down Expand Up @@ -516,6 +518,14 @@ func (app *rootHashApplication) processRoundTimeout(ctx *tmapi.Context, state *r
return fmt.Errorf("failed to get runtime state: %w", err)
}

if rtState.ExecutorPool == nil {
// This should NEVER happen as the timeout should be cleared before the pool is reset.
ctx.Logger().Error("no executor pool",
"runtime_id", runtimeID,
)
return fmt.Errorf("no executor pool")
}

if !rtState.ExecutorPool.IsTimeout(ctx.BlockHeight()) {
// This should NEVER happen.
ctx.Logger().Error("no scheduled timeout",
Expand Down