-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
738 lines (694 loc) · 27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<meta name="Description" content="Put your description here." />
<base href="/" />
<script type="module">
import "reveal.js/dist/reveal.css";
import "reveal.js/dist/theme/black.css";
import "reveal.js/plugin/highlight/monokai.css";
import "@mythosthesia/reveal-course-preset/styles.css";
</script>
<style>
.popover-anchor {
position: relative;
}
.dna,
.cell,
.zome,
.coordinator-zomes,
.integrity-zomes,
.source-chain,
.happ-bundle,
.box,
.dna-bundle,
.dht-shard,
.conductor,
.happ {
padding: 12px;
border-width: 3px;
border-color: rgb(209, 209, 209);
border-style: solid;
background-color: unset !important;
}
.dna,
.cell,
.source-chain,
.happ-bundle,
.coordinator-zomes,
.integrity-zomes,
.box,
.dna-bundle,
.dht-shard,
.conductor,
.happ {
display: flex;
align-items: center;
justify-content: center;
}
.zome {
text-align: center;
background-color: blue !important;
}
.coordinator-zomes,
.integrity-zomes {
border-style: dashed;
}
</style>
<title>Holochain Lesson 1</title>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Holochain Fundamentals</h1>
</section>
<!-- <section>
<h2>Holochain Architecture</h2>
<div class="row">
<div class="column" style="margin-left: 80px; flex: 1">
<div class="column">
<div class="zome">Zome 1</div>
<div class="zome">Zome 2</div>
<div class="zome">Zome 3</div>
</div>
<div class="column" style="margin-top: 30px">
<div class="happ-bundle column">
Happ Bundle
<div class="dna-bundle column">
DNA Bundle 1
<div class="zome">Zome 1 (crate)</div>
<div class="zome">Zome 2 (crate)</div>
<div class="zome">Zome 3 (crate)</div>
</div>
<div class="dna-bundle column">
DNA Bundle 2
<div class="zome">Zome 4 (crate)</div>
</div>
</div>
</div>
</div>
<div
style="
margin-left: 24px;
position: relative;
flex: 1;
justify-content: center;
align-items: center;
padding: 40px;
"
class="column"
>
<div
class="column"
style="margin-top: 30px; margin-bottom: 400px"
>
<div class="cell column">
Cell 1
<div class="dna">DNA 1</div>
<div class="source-chain">Source Chain</div>
<div class="dht-shard">DHT Shard</div>
</div>
</div>
<div
class="conductor column"
style="
position: absolute;
height: 100%;
width: 100%;
justify-content: start;
"
>
<span>Conductor</span>
<div class="column happ" style="">
Happ 1
<div class="column" style="margin-top: 244px">
<div class="cell column">
Cell 2
<div class="dna"></div>
<div class="source-chain"></div>
<div class="dht-shard"></div>
</div>
</div>
</div>
<div class="row" style="align-self: end">
<div class="box">App Interface</div>
<div class="box">Admin Interface</div>
</div>
</div>
</div>
<div class="column" style="align-items: center">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="272px"
height="232px"
viewBox="-0.5 -0.5 572 532"
>
<defs />
<g>
<ellipse
cx="40"
cy="210"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="530"
cy="210"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="440"
cy="490"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="290"
cy="40"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="150"
cy="490"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<path
d="M 121.72 461.72 L 40 250"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 68.28 181.72 L 250.4 50.16"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 190 490 L 400 490"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 468.28 461.72 L 530 250"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 501.72 181.72 L 330 40"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 490 210 L 80 210"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 150 450 L 290 80"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 440 450 L 290 80"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 411.72 461.72 L 68.28 238.28"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 178.28 461.72 L 501.72 238.28"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
</g>
</svg>
<span>DHT for DNA 1</span>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1"
width="272px"
height="232px"
viewBox="-0.5 -0.5 572 532"
>
<defs />
<g>
<ellipse
cx="40"
cy="210"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="530"
cy="210"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="440"
cy="490"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="290"
cy="40"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<ellipse
cx="150"
cy="490"
rx="40"
ry="40"
fill="rgb(255, 255, 255)"
stroke="rgb(0, 0, 0)"
pointer-events="all"
/>
<path
d="M 121.72 461.72 L 40 250"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 68.28 181.72 L 250.4 50.16"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 190 490 L 400 490"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 468.28 461.72 L 530 250"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 501.72 181.72 L 330 40"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 490 210 L 80 210"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 150 450 L 290 80"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 440 450 L 290 80"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 411.72 461.72 L 68.28 238.28"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
<path
d="M 178.28 461.72 L 501.72 238.28"
fill="none"
stroke="white"
stroke-miterlimit="10"
pointer-events="stroke"
/>
</g>
</svg>
<span>DHT for DNA 2</span>
</div>
</div> -->
<!-- TODO: I think we need to explain the basics of validation rules in this 10.000 ft view, to connect dots and create curiosity for the weekend-->
<!-- </section> -->
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Desirable features of a peer-to-peer network
- Scalable
- No consensus, peers can change state without having all the other peers agree
- Data availability
- Resilient to network partitions
- Consistency
- Data never reaches an irreconcilable state
- Resilient to bad actors
- If some node is not behaving according to the rules of the game, they can be easily identified and protected against
- Security and Privacy
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Hash-Table
- Key-value store that allocates a bigger chunk of memory than necessary
- To insert a value, we hash the **key**, and put the content in the position of memory that corresponds to that hash
- Constant lookup and write time
### Cryptographic Hash-Table
- Key-value store where the key is the cryptographic hash of the **value**
- After lookup, you can hash the retrieved value again, compare it to the input key, and verify that you are not being lied to
### Distributed cryptographic Hash-Table (DHTs)
- Cryptographic Hash-Table where the hash-table is spread accross many nodes
- Each node can make a get request with the hash of some value, and the network will return the value itself
- Each node may share some responsability to host data and route queries
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Agent
- Defined by a private-public key pair
- For cryptographically signing
- Others can cryptographically verify these signatures
- Action Ledger
- Sequence of all the actions that an agent has taken in a social container
- Signed by the agent
- Merkle trees can create unfalsifiable ledgers
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Merkle Trees
- A merkle tree (technically a DAG) is one where new nodes reference one or more prior nodes by its hash
- It's impossible to change a node in a merkle tree without changing all of downstream nodes as well (or else invalidating the hashes)
- Undetected tampering is impossible
- A merkle chain is a merkle tree without branching
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Integrity Code and Data
- Using cryptography to achieve a binding network integrity contract
- Unique integrity hash specifies a unique network
- The integrity hash is generated from:
- Integrity Code (shared by all peers)
- Defining Validation Rules
- Integrity Data (shared by all peers)
- Properties
- Arbitrary configuration data
- Network Seed
- Glorified property to uniquify equivalent looking networks
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Personal Code and Data
- Personal Code
- User configurable client behaviour that won't infringe on their integrity code constraints
- Private to each user unless disclosed
- Personal Data
- Items in the action ledger are private until disclosed
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### DNA & Zomes
- DNA
- Holochain's implementation of integrity & personal code pattern
- Bundle of reusable source code modules
- Called "zomes" in Holochain
- Each zome is a rust crate
- Integrity Zomes
- In Holochain, your integrity code is your ticket into a unique DHT
- They define validation rules
- Coordinator Zomes
- Reusable modules of personal code
- Contains things like CRUD functions and event hooks
</fragment>
</section>
<section>
<div style="flex: 1">
<div class="column dna fragment">
<span> DNA (for A Collaborative Document Editor) </span>
<div
class="column fragment coordinator-zomes"
style="width: 90%; margin: 8px"
>
<span style="margin-bottom: 8px">Coordinator Zome Bundle</span>
<div class="row">
<div class="fragment zome">Document Coordinator Zome</div>
<div class="fragment zome">Comments Coordinator Zome</div>
<div class="fragment zome">Roles Coordinator Zome</div>
</div>
</div>
<div
class="column fragment integrity-zomes"
style="width: 90%; margin: 8px"
>
<span style="margin-bottom: 8px">Integrity Zome Bundle</span>
<div class="row">
<div class="fragment zome">Document Integrity Zome</div>
<div class="fragment zome">Comments Integrity Zome</div>
<div class="fragment zome popover-anchor">
Roles Integrity Zome
<simple-popover class="fragment fade-in-then-out">
<p>
For example: an agent might only be allowed to update
the document if they have the "Editor" role
</p>
</simple-popover>
</div>
</div>
</div>
</div>
</div>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Cell
- Unique per-agent instantiation of a DNA
- Is identified by the union of:
- Agent ID
- Integrity hash
- Called "DNA hash" throughout Holochain docs
- Has access to:
- A private data storage: the source chain
- A shared and public data storage: the DHT
- Only accessible via permissioned zome function calls:
- By an external process connected to the Conductor (eg. GUIs)
- By other cells from its network (with the same integrity hash)
- By other cells in the same conductor
- Can receive these parameters when it is instantiated:
- New properties or network seed
- Which would change the resulting integrity hash
- Membrane proof
- Which may be required to instantiate the Cell
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Source Chain
- Holochain's implementation of an agent's unfalsifiable action ledger
- Each Cell controls its own local source chain
- The chain contains all the actions that a Cell has taken
- An action is announced publicly within the scope of the network
- If any action was private, then agents would be able to fork their chain undetected
- An action may be accompanied or not by some entry (as determined by the application)
- Entries may be private or public
- The union of an action and its entry (if existent) is called a "record"
- An action contains:
- Hash of the previous action
- Author's public key
- Timestamp
- Entry hash, if it's accompanied by an entry
- An action is signed by its author
- At boot time, each source chain will be instantiated with 3 records:
- DNA: includes the integrity hash
- AgentValidationPackage: joining proof that satisfies the requirements that the validation rules declare, making the 3rd record valid
- Create record of its own agent public key
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Holochain's DHT (I)
- Two types of network queries:
- Get a value from its hash
- Get the metadata attached to a given hash
- Guarantees:
- 1st guarantee: data integrity:
- You can verify that the data is correct since you can hash it again like in any cryptographic hash-table.
- Records are guaranteed to come from its author because they are signed.
- 2nd guarantee: the DHT is resilient:
- Censorship resistance: it would be impractical for the network to selectively censor a piece of data in the hash-table
- Availability: pieces of data will likely still be in the network even in outage scenarios
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Holochain's DHT (II)
- Guarantees (continued):
- 3rd guarantee: eventual consistency
- The data state converges to being free of internal contradiction
- Relativity does not allow for a universally correct sequence of events
- So order of events in distributed systems is hard!
- The DHT is a CRDT (Conflict-free Replicated Data Types)
- Data structure that only implements commutative operations
- State machine that derives state from a series of operations
- Any agent given the same operations will arrive at the same end state (regardless of order)
</fragment>
<!-- TODO: how to say this exactly? There is a guarantee that operations will get to you eventually -->
<!-- TODO: ask Art. - Reveals its own temporary inconsistencies
- Holochain provides a way to resolve the temporary inconsistencies-->
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### hApp (Holochain App)
- A local collection of cells, among which an agent id is shared
- Can depend on cells from other hApps
- Each cell has its own role within the hApp
- Eg: in a file storage app, you may have two cells installed:
- “main”: the DHT that everyone joins to using the app
- “file_storage_provider”: only joined by high-storage nodes
</fragment>
</section>
<section>
<!-- prettier-ignore -->
<fragment language="markdown" animate="by-line with-ancestry">
### Conductor: the Holochain node
- Local process housing all of your running happs
- Offers a sandboxed execution environment to each cell
- Provides limited capacities
- No access to OS level APIs (eg. filesystem, http)
- Provides a mechanism of communication across cells
- Manages all network communications
- Exposes two types of interface, accessible via websockets:
- App Interface
- Can route zome function calls to appropriate cell
- Can route push signals from cells to subscribers
- Admin Interface
- Cannot be accessed from an app
- Receives admin commands to manage apps (eg. install, uninstall, enable, or list apps)
</fragment>
</section>
<section>
<h1>That's it!</h1>
</section>
<!-- <section>
<h3>DNA manifest & bundle</h3>
<fragment language="markdown" animate="by-line with-ancestry">
- Manifest declares:
- Human readable name
- Zomes that will be included in the DNA
- Their names
- The location of their compiled source code
- Provisional properties
- Provisional UID
- Manifest is packaged into a DNA bundle
</fragment>
</section>
<section>
<h3>hApp manifest & bundle</h3>
<fragment language="markdown" animate="by-line with-ancestry">
- Manifest declares:
- Human readable name
- DNAs that will be included in the hApp
- Their role ids (names)
- The location of their DNA bundle
- Provisionging strategy: whether to create a new cell on
install
- Manifest is packaged into a hApp bundle
- The conductor can directly install hApp bundles
</fragment>
</section>
-->
<!-- TODO: Talk about DHT Ops at the end of this lesson or in the beginning of the next one? -->
</div>
</div>
<script type="module">
import Reveal from "reveal.js";
import { plugins, config } from "@mythosthesia/reveal-course-preset";
let deck = new Reveal();
deck.initialize(config);
</script>
</body>
</html>