Skip to content

Commit

Permalink
Add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Mar 2, 2019
1 parent 00804da commit fa327a1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,10 @@ For each `proposer_slashing` in `block.body.proposer_slashings`, run the followi
```python
def process_proposer_slashing(state: BeaconState,
proposer_slashing: ProposerSlashing) -> None:
"""
Process ``ProposerSlashing`` transaction.
Note that this function mutates ``state``.
"""
proposer = state.validator_registry[proposer_slashing.proposer_index]
# Verify that the slot is the same
assert proposer_slashing.proposal_1.slot == proposer_slashing.proposal_2.slot
Expand Down Expand Up @@ -1663,6 +1667,10 @@ For each `attester_slashing` in `block.body.attester_slashings`, run the followi
```python
def process_attester_slashing(state: BeaconState,
attester_slashing: AttesterSlashing) -> None:
"""
Process ``AttesterSlashing`` transaction.
Note that this function mutates ``state``.
"""
attestation1 = attester_slashing.slashable_attestation_1
attestation2 = attester_slashing.slashable_attestation_2
# Check that the attestations are conflicting
Expand Down Expand Up @@ -1693,6 +1701,10 @@ For each `attestation` in `block.body.attestations`, run the following function:

```python
def process_attestation(state: BeaconState, attestation: Attestation) -> None:
"""
Process ``Attestation`` transaction.
Note that this function mutates ``state``.
"""
# Can't submit attestations that are too far in history (or in prehistory)
assert attestation.data.slot >= GENESIS_SLOT
assert state.slot < attestation.data.slot + SLOTS_PER_EPOCH
Expand Down Expand Up @@ -1803,6 +1815,10 @@ For each `exit` in `block.body.voluntary_exits`, run the following function:

```python
def process_exit(state: BeaconState, exit: VoluntaryExit) -> None:
"""
Process ``VoluntaryExit`` transaction.
Note that this function mutates ``state``.
"""
validator = state.validator_registry[exit.validator_index]
# Verify the validator has not yet exited
assert validator.exit_epoch > get_delayed_activation_exit_epoch(get_current_epoch(state))
Expand All @@ -1828,7 +1844,11 @@ Verify that `len(block.body.transfers) <= MAX_TRANSFERS` and that all transfers
For each `transfer` in `block.body.transfers`, run the following function:

```python
def process_exit(state: BeaconState, transfer: Transfer) -> None:
def process_transfer(state: BeaconState, transfer: Transfer) -> None:
"""
Process ``Transfer`` transaction.
Note that this function mutates ``state``.
"""
# Verify the amount and fee aren't individually too big (for anti-overflow purposes)
assert state.validator_balances[transfer.from] >= max(transfer.amount, transfer.fee)
# Verify that we have enough ETH to send, and that after the transfer the balance will be either
Expand Down

0 comments on commit fa327a1

Please sign in to comment.