Closed
Milestone Dec 2, 2021–Apr 30, 2022

Strengthen token delegations

The consistency of a delegate's stake with respect to its delegators' balances is a critical property for Tenderbake, as it must enforce the stake balances invariants: tzip!172 (comment 677243929) The fact that the consistency of a delegate's stake with respect to its delegators' balances is enforced at multiple locations makes code maintenance and reviews more cumbersome. These locations include crediting a contract, spending from a contract, freezing fees, punishing a delegate, etc.; as well as the delegation management which is performed by Delegate_storage.set.

Design
With the transfer function of the Token module, it becomes possible to locate stake movements inside the token module so that the associated invariants are enforced in a single module.

Tasks

  • Move references to Stake_storage.add_stake and Stake_storage.remove_stake related to transfers and delegations in the Token module
  • Remove redundant representations: (1) remove Token.DelegateBalance constructor as it becomes redundant with the constructor Token.Contract, and (2) unify the types Receipt.balance and Token.[source | container | sink]
  • Reduce the number of calls to add_stake and remove_stake depending on the nature of transfers (e.g. no stake updating needed when the source and the sink share the same delegate)
  • Work items 0
  • Merge requests 1
  • Participants 0
  • Labels 0
Loading
Loading
Loading
Loading
100% complete
100%
Start date
Dec 2, 2021
Dec 2 2021
-
Apr 30 2022
Due date
Apr 30, 2022 (Past due)
0
Work items 0 New issue
Open: 0 Closed: 0
None
Total weight
None
1
Merge requests 1
Open: 1 Closed: 0 Merged: 0
0
Releases
None
Reference: tezos/tezos%"Strengthen token delegations"