🐛 Potential side effects with multiprocessing mode #3473
Merged
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.
@hwwhww said there was an issue when the multiprocessing mode was activated:
For example, the
minimal/capella/fork_choice/ex_ante/pyspec_tests/ex_ante_attestations_is_greater_than_proposer_boost_with_boost
test should NOT exist because we’ve added the decorator “@with_presets([MAINNET], reason="to create non-duplicate committee”)
” (consensus-specs/tests/core/pyspec/eth2spec/test/phase0/fork_choice/test_ex_ante.py
Lines 121 to 124 in 4814305
Its like the decorator
@with_presets([MAINNET], reason="to create non-duplicate committee")
was ignored.What I did was to only consider 2 tests in
eth2spec/test/phase0/fork_choice/test_ex_ante.py
:test_ex_ante_attestations_is_greater_than_proposer_boost_with_boost
andtest_ex_ante_vanilla
. What I discovered is the fact that thegenerate_test_vector
was running both time the test method oftest_ex_ante_vanilla
. From the below:consensus-specs/tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py
Lines 233 to 264 in 8d6a405
test_ex_ante_attestations_is_greater_than_proposer_boost_with_boost
was the first test to be submitted in the listall_test_case_params
, and when started the second iteration offor tprov in test_providers:
then the item inall_test_case_params
was modified: the valueall_test_case_params[0].test_case.case_fn()
runned the methodtest_ex_ante_vanilla
and not anymore the methodtest_ex_ante_attestations_is_greater_than_proposer_boost_with_boost
(to test that, I changed both method, one raised aAssertionError
and the other one aValueError
; and I runnedtest_case.case_fn()
to check what was the error raised.)It seems that the method
generate_from_tests
ineth2spec/gen_helpers/gen_from_tests/gen.py
have a side effect on the lambda function provided toTestCase.case_fn
=> liketfn
was modified when theTestCase
oftest_ex_ante_vanilla
was generated. That's why the decorator seems to be ignored.Honestly I don't know why the lambda function is impacted, my opinion is that this succesion of
yield
may generates this side effect.What I did to fix this was to generate the lambda function by another method outside the scope of
generate_from_tests
and it seems to work.