consensus-specs icon indicating copy to clipboard operation
consensus-specs copied to clipboard

feat: improve randomize_state field coverage for fork transition testing

Open richardgreg opened this issue 4 months ago • 10 comments

feat: improve randomize_state field coverage for fork transition testing

Description

  • This PR improves the randomize_state function to populate beacon state fields with realistic non-default values during testing.
  • Currently, when clients forget to copy fields during upgrades, tests don't catch these bugs because 0 == 0 assertions still pass, as demonstrated in the issue description with the Teku client. By using realistic test values, missing field copies now cause test failures
  • randomize_state field population now extended to all forks

Relations

Fixes #4535

Co-authored by Claude

richardgreg avatar Sep 16 '25 09:09 richardgreg

@jtraglia, do you think it is necessary to populate the fields for previous forks?

richardgreg avatar Sep 19 '25 14:09 richardgreg

@jtraglia, do you think it is necessary to populate the fields for previous forks?

Yes, it would be valuable to do this. Please complete the TODO items you've stated in the functions.

Sorry I just haven't had enough time to properly review your PR. Given that this change will affect lots tests for several forks, it will require a more extensive review. In the mean time, I've started the CI checks for this.

I would like for @leolara to review it too. He's in charge of testing here.

jtraglia avatar Sep 19 '25 14:09 jtraglia

Hi @leolara, what are your thoughts?

richardgreg avatar Sep 30 '25 09:09 richardgreg

@richardgreg the reftests are failing in this branch: https://github.com/ethereum/consensus-specs/actions/runs/18327061427/job/52193981595

leolara avatar Oct 08 '25 02:10 leolara

@richardgreg let me know if I should try to run the tests again

leolara avatar Oct 09 '25 21:10 leolara

@richardgreg let me know if I should try to run the tests again

@leolara sure. You can go ahead and do it. My branch is up-to-date and it generates the reftests locally. I'm hoping that will fix any conflict arising in the CI

richardgreg avatar Oct 10 '25 10:10 richardgreg

Trying here: https://github.com/ethereum/consensus-specs/actions/runs/18891974203

leolara avatar Oct 28 '25 23:10 leolara

@richardgreg the reference tests are failing in this branch, please check the logs there https://github.com/ethereum/consensus-specs/actions/runs/18891974203 and see if you can fix it

leolara avatar Nov 01 '25 12:11 leolara

https://github.com/ethereum/consensus-specs/actions/runs/18891974203

Right, Leo. I'm investigating it

richardgreg avatar Nov 02 '25 09:11 richardgreg

@leolara In this latest push, Altair now inherits Phase 0's fields. The bug was likely due to BLS signature verification failing. Altair not inheriting Phase 0 fields including randao_mixes most likely contributed to that. It's hard to confirm ref tests pass locally because of the amount of time it takes 😅

So I went quite all in this issue without much external input. From what you've seen so far, what are your thoughts on the fields chosen to be randomized for each fork?

richardgreg avatar Nov 04 '25 07:11 richardgreg