[go: up one dir, main page]

DAL: Abstract shard indices

Follow up from !7207 (comment 1226399569)

Currently, in the DAL node we represent shard indices as int list.

In L1, assigned indices are represented as (first_index, power) pair where [first_index;first_index+1;...;first_index+power-1] is the assigned shard indices. Hence instead of representing indices as int list in the DAL node, we can directly use (first_index, power) via some abstraction that looks like:

  module Shard_indices : sig
    type t
    val make : first_index:int -> power:int -> t
    val to_list : t -> int list
    val encoding : t encoding
  end

And then return the Shard_indicies.encoding in GET /profile/<public_key_hash>/<level>/shards. The encoded version can look like the below in JSON:

{
  first_index: int;
  power: int
}

Notes:

  • Consider pros/cons of int list v.s. Shard_indices.t.
    • Pros of int list: Can adapt to future changes where assigned shard indices are not consecutive (e.g. randomized)
    • Pros of Shard_indices.t: Much more compact representation.
  • We need to think where to place this module. Ideally we want to expose them to DAL RPC clients so clients can decode the indices.