fix transfer invariant, credits to @holiman for finding the edge case (#916)

This commit is contained in:
Diederik Loerakker 2019-04-14 19:18:00 +10:00 committed by Justin
parent f88f08178e
commit be86f966f8
1 changed files with 2 additions and 0 deletions

View File

@ -2416,6 +2416,8 @@ def process_transfer(state: BeaconState, transfer: Transfer) -> None:
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