WEBVTT

00:00:00.500 --> 00:00:02.244
You probably know this design.

00:00:03.145 --> 00:00:06.387
A few stateless services, and one database that holds every

00:00:06.400 --> 00:00:06.895
fact.

00:00:07.793 --> 00:00:11.439
At Matinee, a small cinema, selling a seat means checking the

00:00:11.452 --> 00:00:14.356
show, charging the customer and writing the ticket.

00:00:15.254 --> 00:00:17.546
One transaction, in one place.

00:00:18.444 --> 00:00:21.413
It is a good design, and it is easy to reason about.

00:00:22.312 --> 00:00:25.749
As the app grows, everything meets at that one database.

00:00:26.647 --> 00:00:29.864
When writes compete there, more servers alone do not help.

00:00:30.762 --> 00:00:32.298
So teams split the data.

00:00:33.197 --> 00:00:37.272
Now one sale spans several places, with waiting, retries and

00:00:37.285 --> 00:00:39.811
races that are hard to see and harder to test.

00:00:41.933 --> 00:00:44.120
The actor model starts from the other end.

00:00:45.021 --> 00:00:48.718
An actor is code, its own private memory, and an inbox.

00:00:49.617 --> 00:00:53.028
Only that code can change that memory, and it runs one message

00:00:53.041 --> 00:00:53.731
at a time.

00:00:54.630 --> 00:00:57.169
On the Internet Computer an actor is a canister.

00:00:58.067 --> 00:01:01.765
Its memory persists, and a trap rolls back the writes made during

00:01:01.778 --> 00:01:02.508
that message.

00:01:03.406 --> 00:01:06.466
RSX draws the same line again inside the actor.

00:01:07.364 --> 00:01:10.411
The box office has a shows module and a tickets module.

00:01:11.310 --> 00:01:14.330
Each owns its saved memory, and the others must ask through

00:01:14.343 --> 00:01:15.125
its service.

00:01:16.023 --> 00:01:19.083
Yet inside one call they still check and change things together,

00:01:19.278 --> 00:01:20.711
like the transaction you know.

00:01:21.609 --> 00:01:24.630
The shapes of that memory, and of each message, are written

00:01:24.643 --> 00:01:26.765
as types, and the build checks them.

00:01:27.664 --> 00:01:29.200
Upgrades are checked too.

00:01:30.099 --> 00:01:33.692
New code states which saved memory it expects, and any change

00:01:33.705 --> 00:01:35.567
of shape is a migration you write.

00:01:36.466 --> 00:01:39.812
Data arriving from outside is still checked when it arrives.

00:01:40.711 --> 00:01:44.226
Money answers to someone else, so the wallet is a second actor.

00:01:45.125 --> 00:01:47.481
And every cinema gets its own box office.

00:01:48.380 --> 00:01:52.104
Separate actors share no memory, so their work can overlap across

00:01:52.117 --> 00:01:53.093
many machines.

00:01:53.992 --> 00:01:56.258
That is sharding, drawn as ownership.

00:01:57.156 --> 00:01:59.513
How much it gains depends on the design.

00:02:00.411 --> 00:02:02.442
The line between actors has a price.

00:02:03.341 --> 00:02:04.799
Run the same sale again.

00:02:05.698 --> 00:02:07.638
It now sends a message and waits.

00:02:08.536 --> 00:02:12.013
While it waits, other messages run, even in the same actor.

00:02:12.911 --> 00:02:16.218
And the answer can be yes, no, or not known yet.

00:02:17.117 --> 00:02:20.424
In everyday code this is where the tangle of flags and retries

00:02:20.437 --> 00:02:21.075
begins.

00:02:23.233 --> 00:02:25.537
Takt lets you write the sale as a workflow.

00:02:26.438 --> 00:02:27.349
Hold the seat.

00:02:28.248 --> 00:02:29.276
Charge the wallet.

00:02:30.175 --> 00:02:32.649
Then confirm the ticket, or release the seat.

00:02:33.547 --> 00:02:35.565
The workflow is a graph you can read.

00:02:36.464 --> 00:02:39.836
A person or an AI can write it, and the build checks it against

00:02:39.849 --> 00:02:40.656
your types.

00:02:41.555 --> 00:02:45.149
Its progress is saved, so you can see where each sale is.

00:02:46.047 --> 00:02:47.714
Reactor carries the message.

00:02:48.612 --> 00:02:51.867
It keeps each one until the other side confirms it was stored,

00:02:52.115 --> 00:02:55.292
resends the same bytes if it must, and delivers in order for

00:02:55.305 --> 00:02:55.956
that peer.

00:02:56.854 --> 00:02:58.703
Rechain keeps the wallet's history.

00:02:59.602 --> 00:03:00.956
The charge is an action.

00:03:01.854 --> 00:03:05.253
Reducers check it against their own state, and either all accept

00:03:05.266 --> 00:03:06.503
or nothing changes.

00:03:07.401 --> 00:03:10.878
Each accepted action becomes a block, linked to the one before.

00:03:11.776 --> 00:03:14.758
That makes the log tamper-evident, for the actions you choose

00:03:14.771 --> 00:03:15.513
to record.

00:03:16.412 --> 00:03:20.852
Ashroot is an optional layer of tables, indexes and relationships.

00:03:21.750 --> 00:03:25.461
A unique index means seat C4 for show seven is sold once.

00:03:26.360 --> 00:03:29.406
A relationship means a ticket cannot point at a show that does

00:03:29.420 --> 00:03:30.214
not exist.

00:03:31.112 --> 00:03:34.420
Under it are the collections: ordered maps and sets, like a

00:03:34.433 --> 00:03:38.391
database index, and others, such as approximate filters, when

00:03:38.404 --> 00:03:39.498
a feature needs them.

00:03:41.633 --> 00:03:43.143
You can rehearse all of this.

00:03:44.043 --> 00:03:47.741
A test runs the whole sale in a fixed order, including the awkward

00:03:47.754 --> 00:03:51.101
cases, and counts the instructions each step executes.

00:03:51.999 --> 00:03:53.093
That measures work.

00:03:53.991 --> 00:03:57.116
Time and fees on a live network are separate questions.

00:03:58.015 --> 00:04:01.036
Rules you write down can also go to formal tools.

00:04:01.934 --> 00:04:05.632
The SDK checks parts of its own memory foundations this way,

00:04:05.879 --> 00:04:07.676
each proof with a stated scope.

00:04:08.575 --> 00:04:11.648
A proof covers what you specify, and nothing more.

00:04:12.546 --> 00:04:15.840
So keep the database way of thinking, and add one question:

00:04:16.062 --> 00:04:17.234
who owns each fact?

00:04:18.132 --> 00:04:21.088
RSX gives you the tools to hold those lines.

00:04:21.986 --> 00:04:23.744
Private, typed memory.

00:04:24.642 --> 00:04:25.905
Checked upgrades.

00:04:26.804 --> 00:04:30.098
Workflows, delivery, history and integrity.

00:04:30.997 --> 00:04:34.213
Next, we open one module and see what it owns.

