CAD014: Convex Name System
The Convex name system (CNS) is a globally accessible naming service available on the CVM. It performs the important function of providing trusted names for user accounts and other services on the CVM, and acts as a root of trust for the broader ecosystem of lattice technology services.
Motivation
Similar to DNS on the Internet, there is a need for a naming system which provides:
- Meaningful human readable names
- A mapping to resources on the network
- Secure facilities for managing this information
User API
The CNS user API is a library implemented as standard by the *registry* (account #9, or @cns). Users need not use this library to access CNS (alternative implementations are possible, as is direct usage of the CNS SPI), but it is the canonical way to do so and it recommended in most cases.
resolve
The resolve function gets the value referred to by a CNS name. This is the most fundamental CNS function.
(@convex.cns/resolve 'convex.asset)
=> #18
This is equivalent to using the core macro resolve:
(resolve convex.asset)
=> #18
And is also equivalent to just using the resolution symbol @ directly:
@convex.asset
=> #18
The resolve function returns nil if the CNS name referred to does not exist.
read
The read function is similar to `resolve, but returns the entire CNS record:
()
Specification
CNS Base Address
CNS is defined to have a specific base address, the account #9 in the genesis state, which is also specified by *registry*. This is the actor from which all standard CNS lookups begin.
CNS Records
A CNS record is a logical entry in CNS.
A CNS record MUST contain the following logical values:
- Value : The entity referred to be the CNS record, which SHOULD be an address or a scoped reference e.g/
[#45 :some-key] - Controller : The controller that enables access to update the CNS record, which SHOULD be a valid trust monitor
- Metadata : Optional metadata attached to the CNS Record
- Child : Optional CNS node that handles child namespaces (typically a scoped address)
Any of the logical values MAY be nil
CNS paths
Records in CNS MUST be specified specified by a path.
Paths can be represented in at least two forms:
- A dot delimited symbol e.g.
convex.asset - A vector of strings e.g.
["convex" "asset"]
Normally the user API makes use of symbols, while the CNS internal SPI uses vectors of strings. The rationale for this is:
- Dot delimited symbols are preferred for conciseness and human readability
- A vector of strings is more convenient and efficient for programmatic manipulation and internal database representation.
CNS Nodes
CNS nodes are elements of the CNS tree that maintain mappings of names to records.
Typically, a CNS Node stores a map of names to records, but different implementations MAY implement such mappings in any way they chose, including creating mapping dynamically.
Note: there is a correspondence between CNS records and nodes: each CNS record may optionally specify the CNS node (Child) that represents any children.