Some functions, e.g. on_block, explicitly checks that a key is in a map before using it:
def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
block = signed_block.message
# Parent block must be known
assert block.parent_root in store.block_states
Others, like get_ancestors don't, e.g. in the following root is not checked to be in store.blocks' keys.
def get_ancestor(store: Store, root: Root, slot: Slot) -> Root:
block = store.blocks[root]
Is there a reason for this discrepancy?
How is the choice of pre-conditions decided for each function?
Some functions, e.g. on_block, explicitly checks that a key is in a map before using it:
Others, like get_ancestors don't, e.g. in the following
rootis not checked to be instore.blocks' keys.Is there a reason for this discrepancy?
How is the choice of pre-conditions decided for each function?