Skip to content

Proto: refactor `Delegate_storage`

Eugen Zalinescu requested to merge eugenz@delegate_storage_refactoring into master

This is part 2 of the old "Split delegate storage". It contains in particular a simplification of Delegate.registered and a refactoring Delegate_storage.set.

Here is the original description of some of the commits.

  • Proto: move set_active into Stake_storage

    It merges Delegate_storage.set_active into Stake_storage.set_active. The functions in Delegate_storage do not require access to the part of Storage for which Delegate_storage is responsible. Merging the two functions simplifies the interfaces and avoids having three distinct set_active functions.

  • Proto: simplify Delegate.registered

    The function Contract_delegate_storage.registered is based on an invariant ensured by Delegate_storage (i.e. a delegate is always self-delegated), so it's better to move the function. Then, we simplify the function implementation by requiring only one read access into the context. EZ: see comments !5054 (comment 922878720) and !5054 (comment 950770494) and !5054 (comment 959818217) for more info

  • Proto: merge Seed.cycle_end into Delegate.cycle_end

    This is to enforce a little bit more the following comment in seed_storage.ml: (* NB: the clearing of past seeds is done elsewhere by the caller *).

  • Proto: introduce Alpha_context.Contract.Delegate

    Move the functions Alpha_context.Delegate.{init,set,find} into Alpha_context.Contract.Delegate. These functions basically handle the field 'delegate' of a contract. They do not handle storage related to a given delegate, like other function in Alpha_context.Delegate.

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • [n/a] For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR

Merge request reports

Loading