Skip to content

Commit 0cac59d

Browse files
authored
docs(cells): fix standard cell representation description (#3442)
1 parent b89ccdd commit 0cac59d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/src/content/docs/book/cells.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ The standard [`Cell{:tact}`](#cells) representation is a common serialization fo
6161

6262
Then, the data bits of the cell themselves are serialized as $\lceil\frac{b}{8}\rceil$ 8-bit octets (bytes). If $b$ is not a multiple of eight, a binary `1` followed by up to six binary `0`s is appended to the data bits.
6363

64-
Next, 2 bytes store the depth of the refs, i.e., the number of cells between the root of the cell tree (the current cell) and the deepest reference, including it. For example, a cell containing only one reference and no further references would have a depth of 1, while the referenced cell would have a depth of 0.
64+
Next, for every referenced cell, 2 bytes in Big Endian format store the depth of the refs, i.e., the number of cells between the root of the cell tree (the current cell) and the deepest reference, including it. For example, a cell containing only one reference and no further references would have a depth of 1, while the referenced cell would have a depth of 0.
6565

66-
Finally, for every referenced cell, the [SHA-256][sha-2] hash of its standard representation is stored, occupying 32 bytes per referenced cell, recursively repeating the said algorithm. Note that cyclic cell references are not allowed, so this recursion always terminates in a well-defined manner.
66+
Finally, for every referenced cell, the [SHA-256][sha-2] hash of its standard representation is stored, occupying 32 bytes per referenced cell, recursively repeating the said algorithm. Note that cyclic cell references are not allowed, so this algorithm always terminates. If there are no referenced cells, neither depths nor hashes are stored.
67+
68+
:::note
69+
70+
This process of obtaining the standard cell representation differs for cells that contain [exotic cells](#cells-kinds) in their subtree or are exotic themselves.
71+
72+
:::
6773

6874
If we were to compute the hash of the standard representation of this cell, all bytes from the above steps would be concatenated together and then hashed using the [SHA-256][sha-2] hash function. This is the algorithm behind the [`HASHCU` and `HASHSU` instructions](https://docs.ton.org/learn/tvm-instructions/instructions) of [TVM][tvm] and the respective [`Cell.hash(){:tact}`](/ref/core-cells#cellhash) and [`Slice.hash(){:tact}`](/ref/core-cells#slicehash) functions of Tact.
6975

0 commit comments

Comments
 (0)