[go: up one dir, main page]

Proto: Add ticket-balance storage module

Context

This is the first of a series of MRs for introducing a ticket accounting feature in the protocol as described in this document.

Fixes: 1732.

This MR introduces a storage module used for the ticket-balance table.

The new table is for tracking ticket ownership. It's a mapping ticket type and owner to amounts. The table keys consist hashes of:

  • ticketer - the creator of a ticket.
  • content - the content of a ticket.
  • owner - the contract currently holding parts of the ticket type.

For instance:

Ticketer x Content x Owner Amount
(KT789, "T1", KT789) 1
(KT789, "T1", KT123) 5
(KT700, Unit, KT800) 7
... ...

The top-level API for modifying the table is exposed through a module Alpha_context.Ticket_balance.

It defines a type token which represents a ticket type (a pair of ticket creator and content).

It provides a function adjust_balance for updating the ticket-balance table:

  val adjust_balance :
    context ->
    key_hash ->
    delta:Z.t ->
    (Z.t * context) tzresult Lwt.t

Manually testing the MR

No manual tests required.Unit tests for this MR are run with:

> dune exec src/proto_alpha/lib_protocol/test/test_ticket_repr.exe

and

dune exec src/proto_alpha/lib_protocol/test/main.exe -- test "^ticket storage$"

Here's a dummy MR for verifying opam.

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, the Development Version section of CHANGES.md for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Joel Bjornson

Merge request reports

Loading