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

Incorporate state_transition.py into state transition spec #1018

Merged
merged 19 commits into from
May 14, 2019

Conversation

JustinDrake
Copy link
Collaborator

@JustinDrake JustinDrake commented May 1, 2019

This PR incorporates state_transition.py (along with a significant cleanup) into the state transition spec. This limits "magic" outside of the spec and addresses #946. We generally reduce fluff, increase readability, and reduce line count (20 lines in the spec, 140 lines overall). A bug is also fixed with the addition of assert state.slot < block.slot in state_transition.

The state transition spec should be reasonably self-contained, limiting the amount of "magic" outside of it. This PR is a first step in this direction, specifically for operation processing.
@JustinDrake JustinDrake changed the title Start moving state_transition.py to state transitition spec Start moving state_transition.py to state transition spec May 1, 2019
@JustinDrake JustinDrake changed the title Start moving state_transition.py to state transition spec Incorporate state_transition.py into state transition spec May 1, 2019
@JustinDrake JustinDrake requested review from hwwhww and djrtwo and removed request for hwwhww May 1, 2019 12:21
@JustinDrake JustinDrake added general:presentation Presentation (as opposed to content) general:bug Something isn't working labels May 1, 2019
Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

My first pass.

Generally, I think that's the right direction 👍, but I'd be inclined to favor to see more description in code comment to help understand. :)

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
process_randao(state, block)
process_eth1_data(state, block)
process_operations(state, block.body)
# verify_block_state_root(state, block)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say enable it in the spec, and hack it in the tests.

/cc @djrtwo

Copy link
Contributor

Choose a reason for hiding this comment

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

a bit torn here.

options:

  1. uncomment and leave as is
  2. add verify_state_root boolean in process_block and state_transition and a note about in which context you would run it as True or False (receiving a block vs building a block)
  3. have verify_block_state_root live outside of the state transition function entirely and as a note on block validity below.

I think I like (2) the best, but am open to debate.
*

Copy link
Collaborator Author

@JustinDrake JustinDrake May 3, 2019

Choose a reason for hiding this comment

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

My suggestion would be for the test bench to populate the state_root immediately prior to verification in case it is set to ZERO_HASH. That way we can keep the spec clean. Could that work?

Copy link
Contributor

Choose a reason for hiding this comment

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

some sort of monkey patch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes

@JustinDrake
Copy link
Collaborator Author

JustinDrake commented May 2, 2019

Thanks @hwwhww for the good feedback :) I agree regarding comments. The state_transition function now has ~1 comment per line of code.

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

like it. a few notes

specs/core/0_beacon-chain.md Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
process_randao(state, block)
process_eth1_data(state, block)
process_operations(state, block.body)
# verify_block_state_root(state, block)
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit torn here.

options:

  1. uncomment and leave as is
  2. add verify_state_root boolean in process_block and state_transition and a note about in which context you would run it as True or False (receiving a block vs building a block)
  3. have verify_block_state_root live outside of the state transition function entirely and as a note on block validity below.

I think I like (2) the best, but am open to debate.
*

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
@djrtwo
Copy link
Contributor

djrtwo commented May 7, 2019

unsure of the exception handling. See #1059 (comment)

@djrtwo
Copy link
Contributor

djrtwo commented May 8, 2019

I think we should revert the exception handling here and get it merged and discuss otherwise in #1059

@JustinDrake
Copy link
Collaborator Author

I think we should revert the exception handling here

Done. Feel free to merge :)

Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

removing approve to discuss state root validation

@djrtwo
Copy link
Contributor

djrtwo commented May 13, 2019

@JustinDrake We didn't decide on how to handle state root validation. I moved the process_state_root rfunction out to state_transition and added a flag. this seems natural to me for clients as they will certainly have a flag to be able to run either way, and defaulting to false translates easily to our current testing infrastructure.

Waiting for comment before merge

@JustinDrake
Copy link
Collaborator Author

I moved the process_state_root rfunction out to state_transition

Makes sense. I like the idea of inlining it!

and added a flag

We probably want to clean this up eventually but don't want to block this PR. Suggest merging :)

@djrtwo djrtwo merged commit 23b1cb2 into dev May 14, 2019
@djrtwo djrtwo deleted the JustinDrake-patch-14 branch May 14, 2019 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:bug Something isn't working general:presentation Presentation (as opposed to content)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants