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

BeaconChain #1413

Closed
wants to merge 6 commits into from
Closed

BeaconChain #1413

wants to merge 6 commits into from

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Oct 19, 2018

What was wrong?

#1381 - BeaconChain

How was it fixed?

  • Basically copied from PoW Chain, but changed header to block.
  • Made BeaconChainDB.persist_block return Blocks instead of Hashes
  • Added create_serenity_block_from_parent as PoW chain does, but at this moment I'm not sure if we will need it.
  • Made BaseBeaconBlock have some @overload initialization functions like: https://github.com/ethereum/py-evm/blob/master/eth/rlp/headers.py.
    • I'm not sure if it's okay to not have type hint in the third __init__. But also don't know how to add type hint in this case.
    • If I added the same type hint as the second __init__, mypy shows: Overloaded function implementation does not accept all possible arguments of signature 1. Should I use this workaround? @cburgdorf any chance you can take a look? 🙏

TODO

More tests.

Cute Animal Picture

by_jess2284

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

from_genesis looks like it might be missing some validation. Once the genesis_crystallized_state and genesis_active_state have been persisted, are there cross checks that should be done against the genesis_block to verify that they all match up (the same way that eth.chains.Chain.from_genesis checks that the state_root that resulted from persisting the genesis_state matches whatever state_root is on the genesis parameters (or header)

pass

@classmethod
def get_sm_configuration(cls) -> Tuple[Tuple[int, Type['BaseBeaconStateMachine']], ...]:
Copy link
Member

Choose a reason for hiding this comment

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

I think you can drop this method, likely getting dropped from the main Chain implementation (it was only added to be able to fetch this stuff over a multiprocessing pipe but that is no longer a viable API, see #1299 )


@abstractmethod
def get_sm(self, block: BaseBeaconBlock) -> 'BaseBeaconStateMachine':
raise NotImplementedError("Chain classes must implement this method")
Copy link
Member

Choose a reason for hiding this comment

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

should be pass

class BeaconChain(BaseBeaconChain):
"""
A Chain is a combination of one or more StateMachine classes. Each StateMachine is associated
with a range of blocks. The Chain class acts as a wrapper around these other
Copy link
Member

Choose a reason for hiding this comment

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

s/blocks/slots/

StateMachine classes, delegating operations to the appropriate StateMachine depending on the
current block slot number.
"""
logger = logging.getLogger("eth.beacon.chains.chain.BeaconChain")
Copy link
Member

Choose a reason for hiding this comment

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

extra chain in the path, suggest just eth.beacon.chains.BeaconChain

@hwwhww hwwhww mentioned this pull request Oct 19, 2018
18 tasks
assert chain.get_sm_class_for_block_slot(num) is SM_B


def test_vm_not_found_if_no_matching_block_number(genesis_block):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
def test_vm_not_found_if_no_matching_block_number(genesis_block):
def test_sm_not_found_if_no_matching_block_slot(genesis_block):

@hwwhww hwwhww mentioned this pull request Jan 2, 2019
@hwwhww
Copy link
Contributor Author

hwwhww commented Jan 12, 2019

Replace with ethereum/trinity#156

@hwwhww hwwhww closed this Jan 12, 2019
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