Skip to content

Commit

Permalink
Merge pull request #919 from ethereum/JustinDrake-patch-10
Browse files Browse the repository at this point in the history
Cleaner dust checking in transfers
  • Loading branch information
protolambda authored Apr 14, 2019
2 parents c01fb1e + a376b66 commit 2a88dff
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -2333,14 +2333,6 @@ def process_transfer(state: BeaconState, transfer: Transfer) -> None:
"""
# Verify the amount and fee aren't individually too big (for anti-overflow purposes)
assert get_balance(state, transfer.sender) >= max(transfer.amount, transfer.fee)
# Verify that we have enough ETH to send, and that after the transfer the balance will be either
# exactly zero or at least MIN_DEPOSIT_AMOUNT
assert (
get_balance(state, transfer.sender) == transfer.amount + transfer.fee or
get_balance(state, transfer.sender) >= transfer.amount + transfer.fee + MIN_DEPOSIT_AMOUNT
)
# No self-transfers (to enforce >= MIN_DEPOSIT_AMOUNT or zero balance invariant)
assert transfer.sender != transfer.recipient
# A transfer is valid in only one slot
assert state.slot == transfer.slot
# Only withdrawn or not-yet-deposited accounts can transfer
Expand All @@ -2364,6 +2356,9 @@ def process_transfer(state: BeaconState, transfer: Transfer) -> None:
decrease_balance(state, transfer.sender, transfer.amount + transfer.fee)
increase_balance(state, transfer.recipient, transfer.amount)
increase_balance(state, get_beacon_proposer_index(state, state.slot), transfer.fee)
# Verify balances are not dust
assert not (0 < get_balance(state, transfer.sender) < MIN_DEPOSIT_AMOUNT)
assert not (0 < get_balance(state, transfer.recipient) < MIN_DEPOSIT_AMOUNT)
```

#### State root verification
Expand Down

0 comments on commit 2a88dff

Please sign in to comment.