Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human-readable hat ids #35

Open
spengrah opened this issue Jul 16, 2022 · 1 comment
Open

Human-readable hat ids #35

spengrah opened this issue Jul 16, 2022 · 1 comment
Labels
community feature idea New feature idea or request

Comments

@spengrah
Copy link
Member

spengrah commented Jul 16, 2022

Hat ids are uint256 bitmaps that use the following structure to achieve an "address" for each hat that includes information about the tree of admins for the hat:

  • The first 4 bytes are reserved for top hat id (we can think of this as the "domain" of a given hat, often corresponding to the DAO the hat belongs to)
  • The remaining 28 bytes each represent a single hat level, fitting 1 admin hat and 255 "child" hats.

Displaying the id as a binary number would require way too much space, but displaying it as a base-10 number occludes the above address semantics. Displaying the id in hex is a good compromise, since it exposes bytes as described above.

But, starting with hex we can make hat ids even more human-readable by...

  1. inserting dots between hat levels
  2. trimming trailing hat levels (trailing empty bytes)

The result would look something like this:
For hat id 0x0000000101010000000000000000000000000000000000000000000000 -- which is the first hat at the second hat level, whose admin is the first hat at the first hat level, whose admin is the first top hat -- the human-readable id would be...

00000001.01.01 or perhaps even 1.01.01

@spengrah spengrah added the community feature idea New feature idea or request label Jul 16, 2022
@spengrah
Copy link
Member Author

spengrah commented Jul 18, 2022

A key question is whether it makes sense to include this logic in the contract itself as well as the subgraph.

A couple benefits of including it in the contract

  • users can read the human-friendly id when viewing contract state via block explorers
  • we can include it in the URI, enabling front ends to directly display the human-friendly id without needing to read from the subgraph

The main drawback is increase in contract size/scope

@spengrah spengrah moved this to Icebox in MVP Jul 19, 2022
@spengrah spengrah added this to MVP Jul 19, 2022
@spengrah spengrah added the beta In-scope for the beta protocol label Aug 17, 2022
@spengrah spengrah removed the beta In-scope for the beta protocol label Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community feature idea New feature idea or request
Projects
Status: Icebox
Development

No branches or pull requests

1 participant