Skip to content

Commit 29c986e

Browse files
Nicholas Clarkenc6
authored andcommitted
Add section on determinism
1 parent 335488a commit 29c986e

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/ledger/concepts/blocks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ The full details and implications of this split are covered in
4040
For now, we can assume that the contents of the header are not important for
4141
the ledger processing.
4242

43+
## The block body
44+
4345
The block body itself is split into four parts. This division is not conceptually
4446
necessary but is helpful for efficient processing:
4547

src/ledger/concepts/determinism.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Determinism
2+
3+
An important principle that occurs in a few places throughout the Cardano ledger
4+
is that of determinism. Perhaps one way to summarise is would be to say: "the
5+
transaction is all you need" - that is, when trying to compute the results of
6+
a transaction, you need only look at the transaction itself rather than
7+
computing with the full ledger state.
8+
9+
There are two important instantiations of this principle:
10+
11+
## Transaction Determinism
12+
13+
This instance tells us that, given a transaction is valid, its outputs are
14+
determined fully by the transaction itself. It may be necessary to look at
15+
certain parts of the ledger state to determine whether it is valid - for
16+
example, to check that the inputs have not been spent - but assuming it is
17+
valid, the outputs created will be exactly as described in the transaction.
18+
19+
## Script determinism
20+
21+
This instance tells us that, assuming a transaction passes phase 1 validation,
22+
the validity of a script is determined only by data contained in the transaction
23+
and in the transaction outputs that it spends or references.
24+
25+
## Implications for Node Implementors
26+
27+
These properties allow node implementors to safely make certain assumptions
28+
which can speed up transaction and block processing.
29+
30+
1. When processing historical blocks, nodes need only consider (or even
31+
deserialise) [transaction bodies](./blocks.md), since the rest of the
32+
block payload can only impact the block _validity_, which is already known
33+
for historical blocks.
34+
2. Many of the more expensive checks of transaction validity need only be
35+
carried out once. In particular, the cryptographic verification and script
36+
execution need only be carried out once, when the transaction first enters
37+
the mempool. Subsequently it is required only to check that the inputs still
38+
exist.
39+
40+
To take advantage of these properties, ledger implementers must distinguish
41+
between these checks in the ledger in such a way as to allow transactions to be
42+
(re-)processed without repeating expensive computation.

0 commit comments

Comments
 (0)