This commit is contained in:
Jay Graber 2020-06-09 14:30:21 -07:00
parent 39997a25f5
commit 513e07bc26
1 changed files with 41 additions and 49 deletions

View File

@ -1,61 +1,40 @@
# GUN # Gun
GUN is a decentralized graph database, and an ecosystem of tools. Gun is a distributed database with a graph structure. Related libraries include a constellation of tools for merging conflicting data and handling routing and security.
The stack includes: In GunDB's graph store, entries are [JSON objects under UUID keys](https://gun.eco/docs/Porting-GUN). Data is stored in browser localStorage by default, with backup "supernode" servers to ensure persistence. Peers connect over websockets to other peers, and choose what data to synchronize and persist.
- [ERA](https://www.youtube.com/watch?v=1HJdrBk3BlE) (economic system) ### Identity
- [AXE](http://axe.eco) (routing)
- [DAM](https://gun.eco/docs/DAM) (networking) Gun's SEA module provides the capability to create a [public/private keypair](https://github.com/amark/gun/wiki/Auth) for a user.
- [RAD](https://gun.eco/docs/RAD) (storage)
- [SEA](https://gun.eco/docs/SEA) (security)
- [GUN](http://gun.eco) (data)
- [HAM](https://gun.eco/distributed/matters.html) (conflict resolution)
### Network structure ### Network structure
Decentralized/p2p. Uses data replication via message passing. Gun uses websockets to transfer data between peers. When a client puts something in a graph, a message is sent to the network and other clients that have subscribed to that data pick it up and update their state. Those who are offline will eventually receive those updates.
It daisy-chains, [routes](https://gun.eco/docs/Routing), & relays messages. Gun uses a flooding algorithm for message propagation, called [DAM](https://gun.eco/docs/DAM) (Daisy-chain ad-hoc mesh-network). DAM's API allows for the swapping out of transport layers (websockets, WebRTC, etc). A proposed future [routing](https://gun.eco/docs/Routing) protocol, the [AXE protocol](https://web.stanford.edu/~nadal/A-Decentralized-Data-Synchronization-Protocol.pdf), includes a mechanism for monetization through bandwidth-based payments.
It also works over most existing transports: WebRTC, UDP multicast, TCP/HTTP -> Websocket, etc. ### Data
## Identity Gun saves data two ways, in a client browser's localStorage, and through [RAD](https://gun.eco/docs/RAD), a storage adaptor that stores data on disk using a radix tree. Clients subscribe to the data they need from the "superpeer", a persistent node storing data on disk that should be run with most applications to ensure availability of data when other browser-based peers are offline. Superpeers are servers running node.js and persisting data on disk. Clients may serve the data they have to other clients as well.
GUN supports multi-device login that is cryptographically secure yet uses "normal" UX. (?) This technique can be extended to secure password resets (no servers). Peers connect to graphs relevant to their application's logic. There is no universally shared graph across the network.
There is a password recovery mechanism using a 3-Friend-Authorization approach. GunDB uses CRDTs (Conflict-free Replicated Data Types). Conflicts are handled by a [conflict resolution algorithm](https://gun.eco/docs/Conflict-Resolution-with-Guns) that uses lexical sort. Gun is eventually consistent, not strongly consistent, meaning that peers will eventually converge upon the last updated value.
Iris adds a [reputation system](https://medium.com/@mmalmi/learning-to-trust-strangers-167b652a654f) to SEA which provides the underlying cryptographic Security, Encryption, & Authorization. Gun focuses on mutability by not using an append-only CRDT, instead allowing insertion and deletion into the graph. [Deletion](https://stackoverflow.com/questions/37758618/how-to-delete-data-in-gun-db) works by inserting `null` at the deleted node, de-referencing it.
#### Data
- Data models (graphs, key/value, document, table, relational, hyper-graphs)
- Data availability ([AP](https://gun.eco/docs/CAP-Theorem), strongly eventually consistent)
#### Monetization
- Business models (Open Source, donation, enterprise, + decentralized PaaS, dBaaS, SaaS, Marketplace)
- Payment (AXE bandwidth credits)
#### Filtering #### Filtering
- Queries (GUN, [GraphQL](https://github.com/brysgo/graphql-gun), historical prototypes of SQL, Mango [Mongo]) There is a [GraphQL](https://github.com/brysgo/graphql-gun) API for the gun p2p graph database.
#### Moderation
Iris and NAB (see above link).
- Protocol level (no)
- Server level (no)
- User level (yes)
- Content level (yes)
### Privacy and Access Control ### Privacy and Access Control
1. Cryptographic keys are assigned to roles, groups, or data points. Privacy and access control can be built on top of GunDB's graph by encrypting data for the intended user. Gun's encryption utilities, [SEA](https://gun.eco/docs/SEA) (Security, Encryption, and Authorization), intend to make it easier to add private space to applications.
2. This information is either used to derive a shared ECDH secret to decrypt (read)
3. Or used to load collaborative multi-writer edits (signed). For access control, cryptographic keys are assigned to roles, groups, or data points. This information is either used to derive a shared ECDH secret to decrypt (read), or to load collaborative multi-writer edits (signed).
Iris, a decentralized social network building on Gun, has a [library](https://github.com/irislib/iris-lib) for encrypted GUN channels and contact list management.
### Interoperablity ### Interoperablity
@ -63,22 +42,35 @@ Plugins, such as backup storage on centralized databases or file systems, can be
### Scalability ### Scalability
A user reported a [70% cost savings](https://twitter.com/cagataycali/status/1245442681251205120) on cloud bills on a project with 1M+ page loads a month.
### Metrics ### Metrics
- 11K+ [github](https://github.com/amark/gun) stars - 11K+ [github](https://github.com/amark/gun) stars
- 10M ~ 30M monthly [downloads](https://www.jsdelivr.com/package/npm/gun) - 10M ~ 30M monthly [downloads](https://www.jsdelivr.com/package/npm/gun)
### Monetization
The GUN protocol is developed by a VC-funded company.
### Implementations ### Implementations
- [Internet Archive](https://news.ycombinator.com/item?id=17685682) (library meta-data) - [HackerNoon](https://hackernoon.com/state-of-hacker-noon-2019-2020-8w1ls3axx) integrated Gun for annotations
- [HackerNoon](https://hackernoon.com/state-of-hacker-noon-2019-2020-8w1ls3axx) (annotations) - [Meething](https://meething.space/) is a Mozilla backed secure & decentralized video conferencing that uses GUN
- [Meething](https://meething.space/) (Mozilla backed secure & decentralized video conferencing powered by GUN) - [Party](https://party.lol/), an encrypted messaging browser extension, uses Gun
- Iris, Notabug, DTube, others... - [Notabug](https://notabug.io/t/notabug/comments/59382d2a08b7d7073415b5b6ae29dfe617690d74/welcome-to-notabug), a decentralized Reddit clone, uses Gun
[Party](https://party.lol/) - [DTube](https://d.tube/) uses GunDB for messaging
[Notabug](https://notabug.io/t/notabug/comments/59382d2a08b7d7073415b5b6ae29dfe617690d74/welcome-to-notabug) - [Iris](https://irislib.github.io/), a web-of-trust based social network, is built on Gun
### Related
Comparisons can be made to other databases designed for p2p use cases:
[OrbitDB](https://github.com/orbitdb/orbit-db) - see under [IPFS.md](IPFS.md)
[HyperDB](https://github.com/mafintosh/hyperdb) - see under [hypercore.md](hypercore.md)
[KappaDB](https://github.com/kappa-db)
### Links ### Links
[Whitepaper](https://stanford.edu/~nadal/A-Decentralized-Data-Synchronization-Protocol.pdf) [Site](gun.eco)
[Documentation Clarification](https://github.com/amark/gun/issues/597)