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

test: wait until new block is committed to BlockQueue #4381

Merged
merged 2 commits into from
Aug 10, 2022
Merged
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
10 changes: 10 additions & 0 deletions ledger/internal/eval_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,16 @@ func endBlock(t testing.TB, ledger *ledger.Ledger, eval *internal.BlockEvaluator
require.NoError(t, err)
err = ledger.AddValidatedBlock(*validatedBlock, agreement.Certificate{})
require.NoError(t, err)
// `rndBQ` gives the latest known block round added to the ledger
// we should wait until `rndBQ` block to be committed to blockQueue,
// in case there is a data race, noted in
// https://github.com/algorand/go-algorand/issues/4349
// where writing to `callTxnGroup` after `dl.fullBlock` caused data race,
// because the underlying async goroutine `go bq.syncer()` is reading `callTxnGroup`.
// A solution here would be wait until all new added blocks are committed,
// then we return the result and continue the execution.
rndBQ := ledger.Latest()
jannotti marked this conversation as resolved.
Show resolved Hide resolved
ledger.WaitForCommit(rndBQ)
return validatedBlock
}

Expand Down