Skip to content

Commit

Permalink
fix transfer invariant, credits to @holiman for finding the edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Apr 14, 2019
1 parent f88f081 commit 8e4c3d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,9 @@ 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
)
# Since the sender may decide to send to themselves, and lose a fee to the proposer (could be someone else),
# the above invariant may be broken. Hence, disallow transfers to yourself.
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 Down

1 comment on commit 8e4c3d8

@holiman
Copy link

@holiman holiman commented on 8e4c3d8 Apr 14, 2019 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.