# IP-OS
### the interplanetary operating system
`a mad science grab bag`
Martin Becze - @wanderer
---
## The File System
### Reading
`ipfs mount`
`cd /ipfs/<hash>`
```graphviz
digraph hierarchy {
nodesep=.5 // increases the separation between nodes
node [color=purple,fontname=Courier,shape=box] //All nodes will this shape and colour
edge [color=Blue, style=solid] //All the lines look like this
root->{QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8ZS hash1 hashN}
QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8ZS->{file1 file2}
hashN
}
```
---
## The File System
### Running
`ipfs add -r /bin/`
`/ipfs/<hash>/<program>`
---
### Writing
https://github.com/ipfs/faq/issues/64 <!-- .element: class="fragment" data-fragment-index="0" -->
`cd /ipfs/` <!-- .element: class="fragment" data-fragment-index="1" -->
`touch hello.txt`<!-- .element: class="fragment" data-fragment-index="1" -->
`echo "hello world" >> hello.text` <!-- .element: class="fragment" data-fragment-index="1" -->
where is the hash?
---
## Mounting Individual Roots
```
mount /ipfs/QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8ZS ~/Music
```
<!-- .element: class="fragment" data-fragment-index="0" -->
```
cd ~Music && wget https://lolz.com/all_your_music_belongs_to_us-1997.mp3
```
<!-- .element: class="fragment" data-fragment-index="1" -->
where is the hash? <!-- .element: class="fragment" data-fragment-index="2" -->
---
### utils
pwd - **p**rint **w**orking **d**irectory
POSIX C functions getcwd() or getwd()
---
### utils
pwdh - **p**rint **w**orking **d**irectory **h**ash
POSIX C functions ???
---
### IPNS
```
mount /ipns/QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8ZS ~/Music
```
<!-- .element: class="fragment" data-fragment-index="0" -->
- a public key is a read capability <!-- .element: class="fragment" data-fragment-index="1" -->
- writable if we have the write capability (private key) <!-- .element: class="fragment" data-fragment-index="1" -->
---
## Multiple IPNS identities
fine grain control over sharing sub-graphs (aka folders)<!-- .element: class="fragment" data-fragment-index="0" -->
```
cd ~Music
mkLink --ipns
> /ipns/QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8Z
```
<!-- .element: class="fragment" data-fragment-index="0" -->
```
mkLink .
> `/ipns/Qmf8xbzdSi3xbqZHnDtSnwk8dfmgBmNCrV6jYeKtCG2x4`
```
<!-- .element: class="fragment" data-fragment-index="1" -->
```
`lsLink .`
> `QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8Z`
> `Qmf8xbzdSi3xbqZHnDtSnwk8dfmgBmNCrV6jYeKtCG2x4`
```
<!-- .element: class="fragment" data-fragment-index="2" -->
`rmLink`<!-- .element: class="fragment" data-fragment-index="3" -->
revokes a capability to read<!-- .element: class="fragment" data-fragment-index="3" -->
---
## Linking
Link to my friends music into my local Music folder
`ln -s /ipns/QmP9STVxFdBAdTfWGQHC45mZgBTWPL1gH9M5urzQchd8Z ~/Music/friends/brad`<!-- .element: class="fragment" data-fragment-index="0" -->
`cd ~Music/friends/brad`<!-- .element: class="fragment" data-fragment-index="1" -->
`/<ipfs hash>/ipfs/<friends_folder_hash>/<ipns links>/`<!-- .element: class="fragment" data-fragment-index="2" -->
---
## Flexible Link Handlers
`ipfs rm -r ~/Music/dont share`
```graphviz
digraph hierarchy {
nodesep=1.0 // increases the separation between nodes
node [color=purple,fontname=Courier,shape=box]
edge [color=Blue, style=solid] //All the lines look like this
Music->{"dont share" hash1 hashN}
"dont share"->{file1 file2}
hashN
}
```
---
## What is WebAssembly?
> WebAssembly or wasm is a new, portable, size- and load-time-efficient binary format that aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.
---
## What is WebAssembly?
- Fast & Efficient <!-- .element: class="fragment" data-fragment-index="1" -->
- Secure Sandbox <!-- .element: class="fragment" data-fragment-index="2" -->
- Toolchain Compatibility <!-- .element: class="fragment" data-fragment-index="3" -->
- Extensible <!-- .element: class="fragment" data-fragment-index="4" -->
- The Combined Powers of the Web!<!-- .element: class="fragment" data-fragment-index="5" --><br><!-- .element: class="fragment" data-fragment-index="5" -->
---
## The Extensible Web Manifesto
- Contain new security surface area.<!-- .element: class="fragment" data-fragment-index="0" -->
- Reduce the rate of growth in complexity, and therefore bugs, in implementations.<!-- .element: class="fragment" data-fragment-index="1" -->
- Allow browser vendors and library authors to iterate on libraries that provide developer-friendly, high-level APIs.<!-- .element: class="fragment" data-fragment-index="2" -->
---
## What we face today

---
## What we face today
- SHA1
- EC arithmetic
- BN arithmetic
- pairing functions
---
## What we face today
Big Trusted Computing bases are really bad for symmetric computation platform
---
## The Extendable Future

---
## IPLD & Translators
> A translator is simply a normal program acting as an object server and participating in the Hurd's distributed virtual file system. It is so-called because it typically exports a file system [...] and thus translates object
---
## IPLD & Translators
```graphviz
digraph hierarchy {
rankdir=LR;
data -> Translator
Translator->Vertex
data [shape=Mdiamond];
Vertex [shape=Msquare];
}
```
---
>Another way of putting it is that it translates from one representation of a data structure into another representation
- IPLD modules are Translators <!-- .element: class="fragment" data-fragment-index="0" -->
- If you wrote IPLD translators WASM... <!-- .element: class="fragment" data-fragment-index="1" -->
- Only have to implement one Translators for all implementations
- Translaters themselves could be resolved by IPFS
- less dependencies in implementations
- More modularity overall
- Implemented In userspace <!-- .element: class="fragment" data-fragment-index="2" -->
---
## Example: Ethereum
```graphviz
digraph hierarchy {
node [color=purple,fontname=Courier,shape=box]
edge [color=Blue, style=solid] //All the lines look like this
Block->{"prev Block" accounts transaction}
accounts -> {account1 account2 accountN}
accountN -> {nonce balance storage}
storage -> {key1 key2 keyn}
accountN [color=red,fontname=Courier,shape=box]
}
```
https://github.com/ipld/js-ipld-eth-block
---
## What if Ethereum contracts where just programs in a general purpose OS backed by a content addressable file system?
---
## What do we want from a userspace?
- run symmetric computations (ie Blockchain) <!-- .element: class="fragment" data-fragment-index="0" -->
- Deterministic by default
- sandboxed
- reuse legacy programs written in C/C++ <!-- .element: class="fragment" data-fragment-index="1" -->
- simple and well specified <!-- .element: class="fragment" data-fragment-index="2" -->
---
## Linux
- complicated
- not completely determistic
- sandboxed is not the default
- subgraph & qubes OS
---
## Actor Model

- Each contract or program is an Actor or Servers running in a Microkernel
- Easy to sandbox
---
## bigraphs

- Forest is the place graph, which is the Merkle DAG
- Hypergraph/link graph is the channels of communication between the actors
- Robin Milner
---
# bigraphs

---
## Micro-kernel
> a microkernel (also known as μ-kernel) is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS)
---
## Ethereum
Big ball of mud

---
## Modular Ethereum

---
## Modular Ethereum

- github.com/ewasm/ewasm-kernel
---
## Modular Ethereum
- modularity is important! <!-- .element: class="fragment" data-fragment-index="0" -->
- Conway's law "organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations" <!-- .element: class="fragment" data-fragment-index="1" -->
---
## Vertices are programs
> A server responds to requests by client to navigate the hierarchy, and to create, remove, read, and write vertices [...] Another possibility for a server is to synthesize vertices on demand, perhaps based on information on data structures inside the kernel [...] User programs can also act as servers.
- Plan9 Manual
---
## Everything is File
- Everything is a Vertex
- has a VALUE
- and EDGES
---
## Everything is File
- Everything is a Vertex
- has a VALUE = code
- and EDGES = ports
---
## System API
- get and set ports
- store and retrieve values
---
## Inter-Process Communication
- channels - lines of communication
- ports - the internal name for a channel that each program has
- duplex, read-only, write-only
---
## Capabilities
- Ports have two capabilities
- read
- write
- Delegatable
- a Merkle link is a read-only capability
- http://cap-lore.com/
- http://erights.org/
---
## Messages
- Atomic
- Non-Atomic
- scalability / cross-shard communication
- unforgeable
- from
- to
- immutable payload
---
# ubiquitous systems

- pushes computation to the edges
- Internet of tooster-ovens!
---
# ubiquitous systems
> Such a system, or its component agents, will be self-aware, posses beliefs about their environments, posses goals, enter negotiation to achieve goals, and be able to adapt to changing circumstances without human intervention.
- Robin Milner
---
# ubiquitous systems
- computation systems made to appear anytime and everywhere<!-- .element: class="fragment" data-fragment-index="0" -->
- omnipresent<!-- .element: class="fragment" data-fragment-index="1" -->
- pushes computation to the edges<!-- .element: class="fragment" data-fragment-index="2" -->
- Homogenesis Operating system<!-- .element: class="fragment" data-fragment-index="3" -->
- not necessarily a singleton!
---
## What would this look like?

---
## What would this look like?

---
## How to get there.
- Practical over perfect <!-- .element: class="fragment" data-fragment-index="0" -->
- Embrace Iteration (everything is a prototype) <!-- .element: class="fragment" data-fragment-index="1" -->
- Keep it modular and follow the UNIX philosophy <!-- .element: class="fragment" data-fragment-index="2" -->
- Be your own core dev!<!-- .element: class="fragment" data-fragment-index="3" -->