diff options
author | Hang Su <hang.su@algorand.com> | 2022-08-09 15:23:45 -0400 |
---|---|---|
committer | Hang Su <hang.su@algorand.com> | 2022-08-09 15:23:45 -0400 |
commit | 01f78c9ae35ac2916474c0a8bbb062102a316197 (patch) | |
tree | 014ebf6f6ae91159dfa018c8f3bc5535b2fa4829 | |
parent | 0b7b7e64295d40af8ea3f20ea4e2a044750b82ad (diff) |
comments to explain fix reasonbq-wait
-rw-r--r-- | ledger/internal/eval_blackbox_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ledger/internal/eval_blackbox_test.go b/ledger/internal/eval_blackbox_test.go index 8fc260d2c..11c51f9aa 100644 --- a/ledger/internal/eval_blackbox_test.go +++ b/ledger/internal/eval_blackbox_test.go @@ -533,6 +533,14 @@ 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() ledger.WaitForCommit(rndBQ) return validatedBlock |