Skip to content

Add invalid large withdrawable epoch test - #2887

Merged
djrtwo merged 7 commits into
ethereum:devfrom
jtraglia:add-invalid-withdrawable-epoch-test
May 16, 2022
Merged

Add invalid large withdrawable epoch test#2887
djrtwo merged 7 commits into
ethereum:devfrom
jtraglia:add-invalid-withdrawable-epoch-test

Conversation

@jtraglia

@jtraglia jtraglia commented May 6, 2022

Copy link
Copy Markdown
Member

PR Description

I believe this is an impossible situation to be in, but this PR tests an edge case in initiate_validator_exit. It is possible to cause an overflow when calculating a new withdrawable epoch. When fuzzing state transitions, we discovered that one of the clients would crash in this situation; so we should add a test.

@dapplion

dapplion commented May 9, 2022

Copy link
Copy Markdown
Member

What's the value of this test if it's impossible to occur in any practical situation?

@jtraglia

jtraglia commented May 9, 2022

Copy link
Copy Markdown
Member Author

I believe there is value in having all of the clients behave the same even in impossible situations. The spec states that "state transitions that cause a uint64 overflow or underflow are also considered invalid." This test is just verifying that the clients consider this state transition as invalid.

@ralexstokes ralexstokes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test looks good although I'd suggest tightening the scope of what we are testing

the logic you target is in initiate_validator_exit so we can test that function instead of the broader process_registry_updates

I'd suggest doing the same setup you have here but testing just that one function (and moving this code to reflect the corresponding spec structure)

@jtraglia

jtraglia commented May 9, 2022

Copy link
Copy Markdown
Member Author

Good idea. I agree with tightening scope. Where do you suggest I move this test to?

I was thinking epoch_processing/test_initiate_validator_exit but I'm not sure it would fit the scheme. All of the files in that directory are testing methods directly called in process_epoch.

@jtraglia

jtraglia commented May 9, 2022

Copy link
Copy Markdown
Member Author

Moved it to test/phase0/helper_functions/test_misc.py which matches the spec table of contents.

@hwwhww

hwwhww commented May 10, 2022

Copy link
Copy Markdown
Contributor

Hey @jtraglia @ralexstokes

  • To be compatible with testgen, we don't use pytest in test cases. That's why there are helpers like expect_assertion_error to replace with pytest.raises(Exception). @jtraglia I can push commits to your PR if it's okay.
  • The test vectors for clients should be defined in test formats. We have to determine if (i) we will add more unit tests in client test vectors or (ii) keep using the "well-defined" epoch-processing/block-processing helpers to test everything.

I'm sligntly inclined to (ii) because it may be fragmental to create a new test format only for initiate_validator_exit.

@djrtwo

djrtwo commented May 10, 2022

Copy link
Copy Markdown
Contributor

I would prefer to keep this as testing the epoch processing functions directly to be able to build tests in a generic way.

You can also add a unit test (or a few) for initiate_validator_exit for internal spec consistency purposes, but I'd still bubble it up into some of our standard test-gen test types

@ralexstokes

Copy link
Copy Markdown
Member

yeah I agree that making a new test format is a lot of overhead and I thought we would have already exposed this function to the testgen infra so in my original comment I thought it would be a much simpler change :)

in this case I think we can either revert to the original process_registry_updates test or test a voluntary exit with the mutated state

@jtraglia

Copy link
Copy Markdown
Member Author

@hwwhww Thank you for your review. Feel free to make changes.

Do I need to yield 'pre', state before the call to run_process_registry_updates too?

@hwwhww
hwwhww force-pushed the add-invalid-withdrawable-epoch-test branch from 0ac25bc to 89e7a10 Compare May 10, 2022 17:02

@hwwhww hwwhww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtraglia
lgtm! I run the testgen locally and it works.

Do I need to yield 'pre', state before the call to run_process_registry_updates too?

No, run_process_registry_updates run yield 'pre', state before exception happens.

I pushed a commit for test format (89e7a10)

@jtraglia

Copy link
Copy Markdown
Member Author

Great. Thank you!

@djrtwo
djrtwo merged commit 1d82d33 into ethereum:dev May 16, 2022
@jtraglia
jtraglia deleted the add-invalid-withdrawable-epoch-test branch April 11, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants