Fix false success and racy counters in generate_eoa_transactions#215
Open
damilolaedwards wants to merge 1 commit into
Open
Fix false success and racy counters in generate_eoa_transactions#215damilolaedwards wants to merge 1 commit into
damilolaedwards wants to merge 1 commit into
Conversation
Two problems in the result accounting. The success, revert and unknown counters were plain ints incremented from per transaction receipt callbacks that run in their own goroutines, so concurrent increments raced and lost updates. And the task only waited for those callbacks when awaitReceipt was set, but failOnReject and failOnSuccess derive the result from the same counts; with awaitReceipt off (the default) the verdict read zeroed counters before the receipts arrived and reported success even when every transaction reverted. Make the counters atomic, and wait for the receipt callbacks whenever the result depends on their counts (awaitReceipt, failOnReject or failOnSuccess). Extract that condition into a helper so it can be tested.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Two problems in the result accounting of
generate_eoa_transactions.ints incremented from per-transaction receipt callbacks, which spamoor runs in their own goroutines. Concurrent increments raced and lost updates.awaitReceiptwas set. ButfailOnRejectandfailOnSuccessderive the result from the same counts, andawaitReceiptis off by default. So withfailOnReject: trueand the defaultawaitReceipt: false, the verdict read zeroed counters before the receipts arrived and reported success even when every transaction reverted, silently defeating the requested check.Fix
atomic.Int64so callback increments are not lost.awaitReceipt,failOnRejectorfailOnSuccessis set. The condition is extracted into a helper so it can be tested.Tests
The wait condition is covered including the
failOnRejectwithoutawaitReceiptcase that previously skipped the wait, and a concurrent increment test confirms the counters do not lose updates and are race free.go build ./...,go vet, and the package tests under-racepass.