Skip to content

Consistency in key membership tests #1930

@franck44

Description

@franck44

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?

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions