Skip to content

Commit

Permalink
On-chain Domain Resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
SunMi Lee committed Jun 22, 2021
1 parent 4363fa5 commit 97d9e69
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions dips/dip-182.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
dip: 182
title: On-Chain Domain Resolution
authors: Sunmi Lee (@sunmilee), David Wolinsky (@davidiw)
status: Draft
type: Informational
created: 06/08/2021
last_updated: 06/015/2021
issue: https://github.com/diem/dip/issues/182
---

# Summary

This DIP describes the on-chain domain name resolution process.

On-chain domain name resolution allows organizations to be able to define their product names, and for VASPs to look up other VASPs using the product names.
Having a human-readable VASP identifier gives Diem Ecosystem the ability enumerate all VASPs by their names, which is useful for merchant purposes as well as p2p transaction.
For example, given a VASP domain name in a payment transaction, VASPs can look up where to route the payment correctly using an approved and accurate mapping of VASP identifier to an on-chain address.

# On-chain data

## Domain Format
A VASP domain name is a unique string that is mapped to a VASP. Specification:
* Case insensitive
* Valid regular expression: `^[a-zA-Z0-9][a-zA-Z0-9.]*$`
* Maximum length: 63 characters (64 including `@`)

## DiemID Domain

```
resource struct DiemIdDomains {
domains: vector<DiemIdDomain>,
}
struct DiemIdDomain {
domain: vector<u8>, // Utf-8 encoded
}
```
* Field definitions:
* `domain` - name of a DiemID domain
* The `DiemIdDomains` resource can only be published into an account with `Role == PARENT_VASP_ROLE_ID`.
* The `DiemIdDomains` contains a list of `DiemIdDomain` structs that are associated with a VASP. As such, it is possible to register more than one DiemID Domain for a given VASP
* Only the special TreasuryCompliance account (address `0xB1E55ED`) can manipulate a DiemIdDomains resource:
* Only TC account can create and publish a `DiemIdDomains` resource
* Only TC account can add, remove or update a `DiemIdDomain` within `DiemIdDomains` resource
* `DiemIDDomains` resource will be created in an empty state as part of creating a `ParentVASP` account resource, and existing `ParentVASP` accounts without `DiemIDDomains` will have the resource instantiated by the DiemRoot account
* In order to register a DiemID domain, a VASP needs to submit a request to Diem Association. After approval, Diem Association will use TreasuryCompliance account to issue an on-chain transaction to register a DiemID Domain

## DiemID Domain Events

The Move contract that manages DiemID domains must emit an event every time DiemID domain is created, removed or updated. Those events are critical for applications to be able to efficiently index existing DiemID domains.
An application can be built to listen for these events to construct a mapping of DiemID domains to VASP accounts for lookup of onchain addresses given a DiemID domain.
While DiemID domains are published into VASP account resource, DiemID domain events are published under the TreasuryCompliance account. We consolidate events under single account to allow indexers to follow a single event stream.

To store events, `DiemIdDomainManager` resource is published under the TreasuryCompliance account(address `0xB1E55ED`).

```
resource struct DiemIdDomainManager {
/// Events are emmitted
diem_id_domain_events: Event::EventHandle<Self::DiemIdDomainEvent>,
}
struct DiemIdDomainEvent {
removed: bool,
domain: DiemIdDomain,
address: address,
}
```

* Fields definition:
* `removed` - `true`, if DiemIdDomain was removed, `false` if it was created or updated
* `domain` - exact copy of `DiemIdDomain` that was added/removed from `DiemIdDomains` resource of a VASP account
* `address` - address of an account where `DiemIdDomain` was added or removed

0 comments on commit 97d9e69

Please sign in to comment.