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/executor: skip proposing timeout if batch received during timeout #4083

Merged
merged 1 commit into from
Jun 25, 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
1 change: 1 addition & 0 deletions .changelog/4083.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/worker/executor: skip proposer timeout if batch was received
19 changes: 17 additions & 2 deletions go/worker/compute/executor/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func (n *Node) proposeTimeoutLocked(roundCtx context.Context) error {
)
n.proposingTimeout = true
tx := roothash.NewRequestProposerTimeoutTx(0, nil, n.commonNode.Runtime.ID(), n.commonNode.CurrentBlock.Header.Round)
go func() {
go func(round uint64) {
// Wait a bit before actually proposing a timeout, to give the current
// scheduler some time to propose a batch in case it just received it.
//
Expand All @@ -769,8 +769,23 @@ func (n *Node) proposeTimeoutLocked(roundCtx context.Context) error {
select {
case <-time.After(proposeTimeoutDelay):
case <-roundCtx.Done():
n.logger.Info("not requesting proposer timeout, round context canceled")
return
}

// Make sure we are still in the right state/round.
n.commonNode.CrossNode.Lock()
if _, ok := n.state.(StateWaitingForBatch); !ok || round != n.commonNode.CurrentBlock.Header.Round {
n.logger.Info("not requesting proposer timeout",
"height", n.commonNode.Height,
"current_block_round", n.commonNode.CurrentBlock.Header.Round,
"proposing_round", round,
"state", n.state,
)
n.commonNode.CrossNode.Unlock()
return
}
n.commonNode.CrossNode.Unlock()

err := consensus.SignAndSubmitTx(roundCtx, n.commonNode.Consensus, n.commonNode.Identity.NodeSigner, tx)
switch err {
Expand All @@ -790,7 +805,7 @@ func (n *Node) proposeTimeoutLocked(roundCtx context.Context) error {
n.proposingTimeout = false
n.commonNode.CrossNode.Unlock()
}
}()
}(n.commonNode.CurrentBlock.Header.Round)

return nil
}
Expand Down