Skip to content

Commit

Permalink
go/worker/executor: skip timeout if batch received during timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Jun 25, 2021
1 parent 99abb0f commit 5ebfea7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 5ebfea7

Please sign in to comment.