From be86f966f87958856584b3f20c095abf910a3d0c Mon Sep 17 00:00:00 2001 From: Diederik Loerakker Date: Sun, 14 Apr 2019 19:18:00 +1000 Subject: [PATCH] fix transfer invariant, credits to @holiman for finding the edge case (#916) --- specs/core/0_beacon-chain.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index f6427f1d4..df9ace80b 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -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