-
Notifications
You must be signed in to change notification settings - Fork 523
agreement: handle pseudonode enqueueing failures #2741
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
Merged
tsachiherman
merged 14 commits into
algorand:master
from
tsachiherman:tsachi/agreementinchannel
Nov 17, 2021
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0e66ade
agreement proposed changes.
tsachiherman 4b62524
Merge branch 'master' into tsachi/agreementinchannel
tsachiherman 537c642
Add unit tests.
tsachiherman 6854100
add unit test.
tsachiherman bb251a9
Merge branch 'master' into tsachi/agreementinchannel
tsachiherman 920a147
Merge branch 'master' into tsachi/agreementinchannel
tsachiherman 1cedfae
fix merge conflict
tsachiherman 7f1bcc6
Merge branch 'master' into tsachi/agreementinchannel
tsachiherman ae70fc6
Merge branch 'master' into tsachi/agreementinchannel
tsachiherman 4196c40
Add cancelled in case of early context expiration.
tsachiherman df6a303
Add index
tsachiherman d72b05e
simplifying the loops.
tsachiherman 75c9e4d
Make "pseudonode input channel is full" error more detailed.
tsachiherman e81e4ad
update errors.
tsachiherman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright (C) 2019-2021 Algorand, Inc. | ||
| // This file is part of go-algorand | ||
| // | ||
| // go-algorand is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as | ||
| // published by the Free Software Foundation, either version 3 of the | ||
| // License, or (at your option) any later version. | ||
| // | ||
| // go-algorand is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| package agreement | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/algorand/go-algorand/test/partitiontest" | ||
| "github.com/algorand/go-algorand/util/execpool" | ||
| ) | ||
|
|
||
| type expiredExecPool struct { | ||
| execpool.ExecutionPool | ||
| } | ||
|
|
||
| func (fp *expiredExecPool) EnqueueBacklog(enqueueCtx context.Context, t execpool.ExecFunc, arg interface{}, out chan interface{}) error { | ||
| // generate an error, to see if we correctly report that on the verifyVote() call. | ||
| return context.Canceled | ||
| } | ||
|
|
||
| // Test async vote verifier against a full execution pool. | ||
| func TestVerificationAgainstFullExecutionPool(t *testing.T) { | ||
| partitiontest.PartitionTest(t) | ||
| mainPool := execpool.MakePool(t) | ||
| defer mainPool.Shutdown() | ||
|
|
||
| voteVerifier := MakeAsyncVoteVerifier(&expiredExecPool{mainPool}) | ||
| defer voteVerifier.Quit() | ||
| verifyErr := voteVerifier.verifyVote(context.Background(), nil, unauthenticatedVote{}, 0, message{}, make(chan<- asyncVerifyVoteResponse, 1)) | ||
| require.Error(t, context.Canceled, verifyErr) | ||
| verifyEqVoteErr := voteVerifier.verifyEqVote(context.Background(), nil, unauthenticatedEquivocationVote{}, 0, message{}, make(chan<- asyncVerifyVoteResponse, 1)) | ||
| require.Error(t, context.Canceled, verifyEqVoteErr) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, inside of EnqueueBacklog it is also doing a select on
case <-avv.ctx.Done()(passed in as enqueueCtx, alongside a select for backlog.ctx.Done()) which will cause EnqueueBacklog to return ctx.Err(). If you have two pending selects like that on the stack, is it deterministic which one will fire first?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is this comment warning "instead, enqueue so the worker will set the error value and return the cancelled vote properly." However if the waiting inside EnqueueBacklog() is interrupted by one of the Done()s it's waiting on, it will never reach the worker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we have two pending selects isn't an issue. The one in
verifyVotewould be evaluated when we get to that point, and if it's not canceled yet, it would go to thedefaultstatement, executingEnqueueBacklog, where it would also block on the same channel.As for the comment, I think it's a bug - I think that the intent was to have a
fallthroughhere. But I would leave that to a separate PR, as it's not really related to this change. ( i.e. in out case, we're passing a TODO context, which would never expire and therefore this statement would never be executed )There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are other callers (unauthenticatedBundle.verify and cryptoVerifier.voteFillWorker) passing a valid context into verifyVote — just not pseudonode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I'm aware of that - that's why I did not attempted to change this code ;-)