WEBVTT

00:00:00.550 --> 00:00:03.650
Rechain keeps state and an ordered action log inside your

00:00:03.583 --> 00:00:04.262
canister.

00:00:05.081 --> 00:00:06.528
Follow top up eleven.

00:00:07.346 --> 00:00:10.708
A thunk reads selectors, makes a decision, and builds an

00:00:10.641 --> 00:00:11.202
action.

00:00:12.021 --> 00:00:15.291
After dispatch, it can return an application result.

00:00:16.109 --> 00:00:17.739
Here, Bob has six.

00:00:18.557 --> 00:00:22.036
The target is eleven, so we dispatch Transfer five.

00:00:22.854 --> 00:00:25.695
Each reducer checks the action against its own state.

00:00:26.513 --> 00:00:28.924
The balances reducer returns a function.

00:00:29.742 --> 00:00:32.934
That commit function subtracts five from Alice and adds five

00:00:32.867 --> 00:00:33.481
to Bob.

00:00:34.300 --> 00:00:36.775
It runs only if every reducer accepts.

00:00:37.594 --> 00:00:40.005
The prepared functions move into the queue.

00:00:40.823 --> 00:00:43.064
All accepted: run the commits.

00:00:43.883 --> 00:00:46.398
Each function updates only its owned state.

00:00:47.216 --> 00:00:50.382
The log makes room, and the action becomes block four.

00:00:51.201 --> 00:00:53.924
Its previous hash links it to the existing chain.

00:00:54.742 --> 00:00:58.064
We're slowing down one synchronous, atomic dispatch.

00:00:58.883 --> 00:01:01.788
The thunk can now return the result: id four.

00:01:04.017 --> 00:01:07.495
An action can also go straight to dispatch, without a thunk.

00:01:08.313 --> 00:01:09.943
Try transferring ten.

00:01:10.761 --> 00:01:12.261
Alice only has nine.

00:01:13.079 --> 00:01:16.141
The balances reducer rejects it, so none of the prepared

00:01:16.074 --> 00:01:17.039
functions run.

00:01:17.858 --> 00:01:20.490
No state change, and no new block.

00:01:22.683 --> 00:01:26.096
As the log grows, older blocks move to a separate archive

00:01:26.029 --> 00:01:26.656
canister.

00:01:27.474 --> 00:01:29.664
This is an awaited intercanister call.

00:01:30.482 --> 00:01:33.596
The source keeps its copy until the archive confirms the

00:01:33.529 --> 00:01:34.078
batch.

00:01:34.896 --> 00:01:37.671
Once confirmed, that space can be released.

00:01:38.490 --> 00:01:41.799
When an archive fills up, Rechain adds another as needed.

00:01:42.617 --> 00:01:45.315
The block numbers and hash links stay unchanged.

00:01:46.133 --> 00:01:49.065
Readers follow the archive locations to read the complete

00:01:48.998 --> 00:01:49.559
history.

00:01:51.783 --> 00:01:55.001
Replay the recorded actions through the reducers to rebuild

00:01:54.934 --> 00:01:55.456
state.

00:01:56.275 --> 00:01:59.714
Your canister can do this, and so can a third party reading

00:01:59.647 --> 00:02:00.274
the log.

00:02:01.092 --> 00:02:04.167
Use the same starting state and reducer rules for the same

00:02:04.100 --> 00:02:04.740
result.

00:02:05.559 --> 00:02:09.545
Record decision inputs in actions; replay doesn't rerun thunks.

00:02:10.363 --> 00:02:13.790
A reader can analyse that state, make a decision, and call

00:02:13.723 --> 00:02:14.935
your public API.

00:02:15.754 --> 00:02:18.946
Normal authorisation and reducer checks still apply.

00:02:21.150 --> 00:02:22.922
How does a reader trust the log?

00:02:23.741 --> 00:02:26.659
Rechain commits the published tip's index and hash through

00:02:26.592 --> 00:02:28.716
a Merkle root in certified data.

00:02:29.535 --> 00:02:32.180
An IC certificate authenticates that root.

00:02:32.998 --> 00:02:36.099
The reader verifies the certificate and witness, then checks

00:02:36.032 --> 00:02:37.922
the blocks against that trusted tip.

00:02:38.741 --> 00:02:41.151
A modified block fails verification.

00:02:41.970 --> 00:02:45.605
Check certificate freshness too, to reject stale proofs.

00:02:46.423 --> 00:02:50.383
Rechain's polling reader checks block hashes; certificate verification

00:02:50.316 --> 00:02:52.063
is an additional client step.

00:02:52.881 --> 00:02:55.865
Together, these checks detect a man in the middle changing

00:02:55.798 --> 00:02:56.438
the log.

00:02:58.650 --> 00:03:01.060
The same history is useful for debugging.

00:03:01.879 --> 00:03:04.628
Pick an action and compare state before and after.

00:03:05.446 --> 00:03:09.862
Here is Transfer five: Alice loses five, Bob gains five.

00:03:10.681 --> 00:03:14.459
You can see what happened, rebuild it, and understand why.

