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/worker/compute/executor: Do not propose batch on epoch transition #5260

Merged
merged 1 commit into from
May 22, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changelog/5260.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/worker/compute/executor: Do not propose batch on epoch transition

Previously a compute node could propose a new batch just before the
epoch transition happened, resulting in computation that will be
discarded anyway.
20 changes: 17 additions & 3 deletions go/worker/compute/executor/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,20 @@ func (n *Node) handleScheduleBatch(force bool) { // nolint: gocyclo
return
}

// If the next block will be an epoch transition block, do not propose anything as it will be
// reverted anyway (since the committee will change).
epochState, err := n.commonNode.Consensus.Beacon().GetFutureEpoch(n.roundCtx, n.commonNode.CurrentBlockHeight)
if err != nil {
n.logger.Error("failed to fetch future epoch state",
"err", err,
)
return
}
if epochState != nil && epochState.Height == n.commonNode.CurrentBlockHeight+1 {
n.logger.Debug("not scheduling a batch, next consensus block is an epoch transition")
return
}

rtState, roundResults, err := n.getRtStateAndRoundResults(n.roundCtx, n.commonNode.CurrentBlockHeight)
if err != nil {
n.logger.Debug("not scheduling a batch",
Expand Down Expand Up @@ -550,12 +564,12 @@ func (n *Node) handleScheduleBatch(force bool) { // nolint: gocyclo
// Check what the runtime supports.
rt := n.commonNode.GetHostedRuntime()
if rt == nil {
n.logger.Debug("not scheduling a batch as the runtime is not yet ready")
n.logger.Debug("not scheduling a batch, the runtime is not yet ready")
return
}
rtInfo, err := rt.GetInfo(n.roundCtx)
if err != nil {
n.logger.Warn("not scheduling a batch as the runtime is broken",
n.logger.Warn("not scheduling a batch, the runtime is broken",
"err", err,
)
return
Expand Down Expand Up @@ -600,7 +614,7 @@ func (n *Node) handleScheduleBatch(force bool) { // nolint: gocyclo
}

// If we are not a transaction scheduler, we can't really schedule.
n.logger.Debug("not scheduling a batch as we are not a transaction scheduler")
n.logger.Debug("not scheduling a batch, not a transaction scheduler")
return
}

Expand Down