Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with mutation in test generation #2673

Merged
merged 1 commit into from
Oct 15, 2021
Merged

fix issue with mutation in test generation #2673

merged 1 commit into from
Oct 15, 2021

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Oct 15, 2021

Mutation issues in spec generators.

next_slots_with_attestations creates a copy of the state, but _transition_until_active assumes that the original state passed in is mutated with the transition. This means that post is yielded incorrectly due to no affects on state from _transition_until_active.

This just returns the mutated state to be used for the yield.

Note, we have a pretty bad mismatch between some transition functions mutating and some copying and returning the new state. This PR does not address this fundamental issue. just fixes a discrete test generation error.

Copy link
Collaborator

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

LGTM, this fixes the issue in test running the spec tests in ZRNT.

For context, previous testing problem showed that the yielded post state was not the last, but some state before transition of all blocks:

proto transition_with_deposit_right_after_fork (master *+)$ for i in {0..26}; do zcli pretty altair SignedBeaconBlock --preset-phase0=minimal --preset-altair=minimal ssz_snappy:blocks_${i}.ssz_snappy | grep state_root ; done

    "state_root": "0x85bd6b2f1c2200078d799f547c81adb0eef92ff7b0ccf07119da4df4c64f5ae6",
    "state_root": "0xa123a4cc5d666272a981892b10b2e4a10bc98d56147b5f265df94845b628fb46",
    "state_root": "0xd9ef8bc058b7821caf028677c849d6cac4bed01880dd9288c49a849efbf371c5",
    "state_root": "0xbb4ef61f4150843737b48c7e404c4d16615e3f0f6da453a99060f5d1d7bf146a",
    "state_root": "0xcd7d51a19ce75d8759387817bab377e39d7d960eacdc139a8646580c7a0ecd77",
    "state_root": "0x11ebac78a8e00cb7f4a1873bc0c2bc1310d09471f44618739f4a85cfdaabf2cc",
    "state_root": "0x51b032de065a3b0e8fa6e623c9b8f4b51ff1b70749cb261c6edce2142605128d",
    "state_root": "0xd336f3635684628880904c25d3fe1932c034b8779a87998dfd2cbabd998ddbdb",
    "state_root": "0x28c73560282fbdb40e58c44d5e3d547e5b76f3803e74c4bc93cac0590bb1a435",
    "state_root": "0x6bf79cca785616ae3185fb9eecfc8ec02ff6ff1fabb0568cb798c2e0ea914edf",
    "state_root": "0x1e5b0a6faa50fa7c2d7960927d8e3bbeee9aec20bb7a1374547afb087a4ad26b",
    "state_root": "0x4c2c2888a11e24f617a31f3120ab556d78ce9c04715ad6385bc959047c2b36d9",
    "state_root": "0xa55ce61e6c02346623472cfbcb39ce19fbb0eca9683c369f9bd97bcd7740d879",
    "state_root": "0x574e151b06eaa62c9b8d35df099ea5f6fd4220e58afa3c74ae64ac81627c825a",
    "state_root": "0x9c9f10a298338354cf412e6c82788e78466fe9ed78a4709f3004d7f69e19d0f0",
    "state_root": "0x5241fefbd11aa0ed94ce513edcfcb88b48b9a7ff8c2a4add6b5b9c59363f247e",
    "state_root": "0xd6cbf42139434e80ca2658ef29eca555997d38fda7a2e7c4aff0f01c91fce0f8",
    "state_root": "0xea06c1d5bd0e126339a46981d105ebce47aa4f4c7334e41cd6a652489924e912",
    "state_root": "0x0c057e2e8f2d3edd9aaf861a1fefd7ef8d5937e13d8168219bd126b872a5f5cd",
    "state_root": "0xb8210083437b178deb8db8a84075a4f3a2a8ad22d955bf1217a5599b347d7c28",
    "state_root": "0x33ee0d2b502ddece42782f577292f791546e528c28e7859957cce10045c37afc",
    "state_root": "0x5f79dc3783f62c0ff80e94cf1cbdd8b91163c2d9c1cb0ca5dc1b2a9b0543ed42",
    "state_root": "0x4ffeecb085152f2ab502f665a28487c9e27ca61e9c6d2e2cc52ea96ccf3bafd4",
    "state_root": "0x28f82e79d51882758a3c4679fb1c5921f7754fe9e3a09fa05889a4b28cdd42a5",
    "state_root": "0xe00ae2bfd04bf6ccbdb06fc510dbead2ccd3f3a01b532d6f406782a3c5139fea",
    "state_root": "0xe88ea4066362151c507cfc5059411f84f72cb02c2f0a9943c126234eb67afb16",
    "state_root": "0xea1f6676ebfb262218f20022d18ccc7da004900e3d0353e8fb58c96b8eb2ccef",

proto transition_with_deposit_right_after_fork (master *+)$ zcli root altair BeaconState --preset-phase0=minimal --preset-altair=minimal ssz_snappy:post.ssz_snappy

0x28c73560282fbdb40e58c44d5e3d547e5b76f3803e74c4bc93cac0590bb1a435

@protolambda protolambda merged commit 6852c5a into dev Oct 15, 2021
@protolambda protolambda deleted the fix-test branch October 15, 2021 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants