Appendix C. Serialisation Codec (Element Encoding Method)
C.1.1. Trivial Encoding
以下有四種簡單的編碼情況:
(C.1) 空值
空值將會輸出空的序列
(C.2) octet-sequence
八位元序列輸入,不需要做任何轉換 (因為就是要轉換成八位元)
(C.3) tuple
分別將 tuple 中的成員進行序列化後,將序列結果串在一起。
(C.4) 多參數
將輸入的多個參數以 tuple 形式進行序列化
C.1.2. Integer Encoding
將自然數轉換為固定長度的八位元組序列 (octet-sequence), 使用 little-endian 編碼方式進行。(little-endian 會將結果,由左邊開始放置)
以下為簡易的整數轉換 ()
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
以下為通用版的整數轉換 (支持到 => unsigned int64)
三個條件對應不同編碼計算:
於 3.4 Numbers 中的定義: and
因此 的範圍是
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Yccinamoroll3741: 分段處理提升效率, 太小的數字不需要用到 2^64 這麼大
所以 integer encoding 是 256 進位, 但是需要用到的 byte 數量會動態調整(dynamic array)
Eugene:
這個公式會依照數值的大小回傳不同長度的八位元組序列 ( 會依照 大小而改變)
Eugene:
Q: 為什麼輸出的 長度會是 1~9?
A: 因為第一個位置都是用來作為識別使用, 可以辨識出該輸入 的數值範圍與長度
Eugene: 以 APPENDIX C. Block Serialization 的定義上,會定義 的大小,例如 C.22 案例, 會影響輸出序列的大小。(實際也可以透過 x 來反推最佳的 大小)
Eq. 303 符號代表長度與內容:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Eq. 305 Bit sequence Encoding:
簡單把 bit 轉成 8 位元組
Eq. 306 Dictionary Encoding:
"key:value" pair 的長度 + key : value
Eq. 307 Set Encoding:
同 Sequence Encoding 但因為 Set 本身沒有排序,所以要依照小到大排序
Eq. 308 Block Encoding:
C.2 Block Serialization
區塊的序列化是將 header 以及 extrinsic data 依照順序以 tuple 的形式放入進行序列化, 可以參考 equations 4.2, 4.3 以及 5.1 (關於 header 以及 extrinsic data 的定義)
-
equation 4.2
-
equation 4.3
-
equation 5.1
C.13
以 tuple 的方式將 header 以及所有的 extrinsic data 放入進行序列化
C.14
(tickets)
tickets 用來決定哪個驗證者負責產生區塊
tickets 資料大小是可變動的,因此透過 的序列化方式進行。(序列化其長度與內容)
深入閱讀:6.7 The Extrinsic and Tickets. 有關於 的介紹, 前往 Extrinsic 筆記
C.15
(preimages)
- : preimage, Preimage lookups 是區塊鏈中提供靜態數據查詢的一種機制
- 可以在區塊鏈中儲存靜態數據,透過任意的 key/value pairs 進行儲存。(提供給 Refine 階段快速查詢數據使用)
- 使用 hash 作為索引,查詢到原始數據
- 資料來源是 extrinsic data
- : service of identifier (用來作為索引)
- 需要排序(參考 3.7.1 sequence 有介紹排序規則)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
深入閱讀 9. Service Account 以及 9.2 Preimage Lookups
C.16
(reports)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
TODO: 11.4 Work Report Guarantees. 有關於 的介紹, 尚未閱讀
C.17
(The Assurances Extrinsic)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
TODO: 11.2 Package Availability Assurances. 有關於 的介紹, 尚未閱讀
C.18
(The disputes extrinsic)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
深入閱讀:10.2 Extrinsic. 有關於 的介紹, 前往 Extrinsic 筆記
C.19
= 連結以下兩個序列化結果
- : a block seal
- : 定義於 C.20
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Seal (seal signature) 是以什麼格式記錄? sealing keys?
C.20
會使用於 C.19
- : parent hash
- : prior state root
- : extrinsic hash
- : a time slot index
- : the epoch
- : winning tickets
- : offenders markders
- : a Bandersnatch block author index
- : the entropy-rielding VRF signatrue
- : 定義於 APPENDIC C.8, 用來判斷輸入是否為空值,會有不同的輸出。
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- :定義於 APPENDIC C.5, 用來對於整數型態的編碼, 此處限制了 的狀況進行整數編碼。


C.21
- : The set of refinement contexts

TODO: 11. REPORTING AND ASSURANCE, 11.1.2 Refinement Context . 有關於 的介紹, 尚未閱讀
C.22
- : The set of availability specifications

TODO: 11. REPORTING AND ASSURANCE, 11.1.3 Availability . 有關於 的介紹, 尚未閱讀
C.23
- : The set of work results

TODO: 11. REPORTING AND ASSURANCE, 11.1.4 Work Result . 有關於 的介紹, 尚未閱讀
C.24
- : The set of work-reports

TODO: 11. REPORTING AND ASSURANCE, 11.1.1 Work Report . 有關於 的介紹, 尚未閱讀
C.25
- : The set of work-packages. See equation 14.2

TODO: 14.3. Packages and Items 有關於 的介紹, 尚未閱讀
C.26
: The set of work items. See equation 14.3

TODO: 14.3. Packages and Items 有關於 的介紹, 尚未閱讀
C.27
: The set of seal-key tickets. See equation 6.6. Not used as the set of complex numbers.

6.2. Safrole Basic State 有關於 的介紹, 前往 6.2 Safrole Basic State 筆記
C.28
會使用於 C.23
- : The set of work execution erros
- : The set of octet strings/"blobs". Subscript denotes length. See section 3.7

C.29
會使用於 C.26
