8080 {\Large Protocol Specification}
8181}
8282
83- \date {November 4 , 2019}
83+ \date {November 5 , 2019}
8484
8585\maketitle
8686
@@ -721,9 +721,9 @@ \chapter{State Transition}\label{chap-state-transit}
721721executing ordered set of instructions. These instructions are known as
722722{\tmem {extrinsics}}. In Polkadot, the execution logic of the state-transition
723723function is encapsulated in Runtime as defined in Definition
724- \ref {defn-state-machine }. Runtime is presented as a Wasm blob in(if?) ordered
725- be easily upgradable. Nonetheless, the Polkadot Runtime Environment needs to
726- be in constant interaction with Runtime. The detail of such interaction is
724+ \ref {defn-state-machine }. Runtime is presented as a Wasm blob in order to be
725+ easily upgradable. Nonetheless, the Polkadot Runtime Environment needs to be
726+ in constant interaction with Runtime. The detail of such interaction is
727727further described in Section \ref {sect-entries-into-runtime }.
728728
729729In Section \ref {sect-extrinsics }, we specify the procedure of the process
@@ -797,12 +797,12 @@ \subsection{Loading the Runtime Code \ \ }\label{sect-loading-runtime-code}
797797\end {notation }
798798
799799The initial runtime code of the chain is embedded as an extrinsics into the
800- chain initialization JSON file and is submitted to Polkadot RE (see Section
801- \ref {sect-genisis-block }).
800+ chain initialization JSON file (representing the genesis block) and is
801+ submitted to Polkadot RE (see Section \ref {sect-genisis-block }).
802802
803- Subsequent calls to the runtime have the ability to call the storage API (see
804- Section \ref {sect-runtime -api }) to insert a new Wasm blob into runtime storage
805- slot to upgrade the runtime.
803+ Subsequent calls to the runtime have the ability to, in turn, call the storage
804+ API (see Section \ref {sect-re -api }) to insert a new Wasm blob into runtime
805+ storage slot to upgrade the runtime.
806806
807807\subsection {Code Executor }
808808
@@ -880,29 +880,42 @@ \subsubsection{The Return Value from a Runtime
880880
881881\section {Extrinsics }\label {sect-extrinsics }
882882
883- The block body consists of an array of extrinsics. Nonetheless, Polkadot RE
884- does not specify or limit the internals of each extrinsics. From Polkadot RE
885- point of view, each extrinsics is simply a SCALE-encoded byte array (see
886- Definition \ref { defn-scale-byte-array }) .
883+ The block body consists of an array of extrinsics. In a broad sense
884+ exterinsics are data from outside of the state which can trigger the state
885+ transition. This section describe the specification of extrinsics and their
886+ inclusion in the block .
887887
888888\subsection {Preliminaries }
889889
890+ The extrinsics are dividedd into two main categories defined as follows:
891+
890892\begin {definition }
891- \label {defn-account-key }{\tmstrong {Account key $ (\tmop {sk}^a,
892- \tmop {pk}^a)$ }} is a pair of Ristretto SR25519 used to sign extrinsics among
893- other accounts and blance-related functions.
893+ {\tmstrong {Transaction extrinsics}} are extrinsics which are signed using
894+ either of the key types described in section \ref {sect-cryptographic-keys }
895+ and broadcasted between the nodes. {\tmstrong {Inherents extrinsics}} are
896+ unsigned extrinsics which are generated by Polkadot RE and only included in
897+ the block produced by the node itself. They are broadcasted as part of the
898+ produced block rather than being gossiped as individual extrinsics
894899\end {definition }
895900
896- \subsection {Extrinsics Submission }
901+ Polkadot RE does not specify or limit the internals of each extrinsics and
902+ those are dealt with by the Runtime. From Polkadot RE point of view, each
903+ extrinsics is simply a SCALE-encoded byte array (see Definition
904+ \ref {defn-scale-byte-array }).
905+
906+ \subsection {Transactions }
897907
898- Extrinsic submission is made by sending a {\tmem {Transactions}} network
908+ \subsubsection {Transaction Submission }
909+
910+ Transaction submission is made by sending a {\tmem {Transactions}} network
899911message. The structure of this message is specified in Section
900912\ref {sect-msg-transactions }. Upon receiving a Transactions message, Polkadot
901- RE decodes the transaction and calls \tmverbatim {validate\_ trasaction} runtime
902- function, defined in Section \ref {sect-rte-validate-transaction }, to check the
903- validity of the extrinsic. If \tmverbatim {validate\_ transaction} considers the
904- submitted extrinsics as a valid one, Polkadot RE makes the extrinsics
905- available for the consensus engine for inclusion in future blocks.
913+ RE decodes and decouple the transactions and calls
914+ \tmverbatim {validate\_ trasaction} Runtime entry, defined in Section
915+ \ref {sect-rte-validate-transaction }, to check the validity of each of received
916+ transaction. If \tmverbatim {validate\_ transaction} considers the submitted
917+ transaction as a valid one, Polkadot RE makes the transaction available for
918+ the consensus engine for inclusion in future blocks.
906919
907920\subsection {Transaction Queue }
908921
@@ -911,12 +924,12 @@ \subsection{Transaction Queue}
911924transactions are submitted to the node through the {\tmem {transactions}}
912925network message specified in Section \ref {sect-msg-transactions }. Upon
913926receiving a transactions message, Polkadot RE separates the submitted
914- transactions in the transactions message into individual extrinsics and passes
915- them to the Runtime by executing Algorithm \ref { algo-validate-transactions } to
916- validate and store them for inclusion into future blocks. To that aim,
917- Polkodot RE should keep a {\tmem {transaction pool{ \index {transaction pool}}}}
918- and a { \tmem {transaction queue}}{ \index {transaction queue }} defined as
919- follows:
927+ transactions in the transactions message into individual transactions and
928+ passes them to the Runtime by executing Algorithm
929+ \ref { algo- validate-transactions } to validate and store them for inclusion into
930+ future blocks. To that aim, Polkodot RE should keep a {\tmem {transaction
931+ pool{ \index {transaction pool}} }} and a { \tmem {transaction
932+ queue}}{ \index {transaction queue}} defined as follows:
920933
921934\begin {definition }
922935 The {\tmstrong {Transaction Queue}} of a block producer node, formally
@@ -933,7 +946,7 @@ \subsection{Transaction Queue}
933946\custombinding {4}{\noindent }\begin {tabular }{l}
934947 \hline
935948 \tmtextsc {Algorithm 4. }
936- \label {algo-validate-transactions }{\tmname {Validate-Extrinsics -and-Store}}($ M_T
949+ \label {algo-validate-transactions }{\tmname {Validate-Transactions -and-Store}}($ M_T
937950 :$ Transaction Message)\\
938951 \hline
939952\end {tabular }
@@ -1011,6 +1024,33 @@ \subsection{Transaction Queue}
10111024
10121025\hrulefill {\medskip }
10131026
1027+ \subsubsection {Inherents }
1028+
1029+ Block inherent data represent the totality of inherent extrinsics included in
1030+ each block. In general, these data are collected or generated by Polkadot RE
1031+ and handed to Runtime for inclusion in the block. Table
1032+ \ref {tabl-inherent-data } lists these inherent data, their identifiers, and
1033+ types.
1034+
1035+ \begin {table }[h]
1036+ \begin {tabular }{lll}
1037+ \hline
1038+ Identifier & Type & Description\\
1039+ \hline
1040+ timstap0 & u64 & Unix epoch time in number of seconds\\
1041+ babeslot & u64 & Babe Slot Number\tmrsup {\ref {defn-epoch-slot }}\\
1042+ \hline
1043+ \end {tabular }
1044+ \caption {\label {tabl-inherent-data }List of inherent data}
1045+ \end {table }
1046+
1047+ \begin {definition }
1048+ \label {defn-func-inherent-data }The function
1049+ {\tmname {Block-Inherents-Data($ B_n$ )}} return the inherent data defined in
1050+ Table \ref {tabl-inherent-data } corresponding to Block $ B$ as a SCALE encoded
1051+ dictionary as defined in Definition \ref {defn-scale-list }.
1052+ \end {definition }
1053+
10141054\section {State Replication }\label {sect-state-replication }
10151055
10161056Polkadot nodes replicate each other's state by syncing the history of the
@@ -1139,33 +1179,6 @@ \subsubsection{Justified Block Header}
11391179 authorities, which have voted for the block to be stored and is formally
11401180 referred to as $ A (B)$ . An authority Id is 32bit.
11411181\end {itemize }
1142-
1143- \subsubsection {Block Inherent Data }
1144-
1145- Block inherent data represent the totality of extrinsics included in each
1146- block. In general, these data are collected or generated by Polkadot RE and
1147- handed to Runtime for inclusion in the block. Table \ref {tabl-inherent-data }
1148- lists these inherent data, their identifiers, and types.
1149-
1150- \begin {table }[h]
1151- \begin {tabular }{lll}
1152- \hline
1153- Identifier & Type & Description\\
1154- \hline
1155- timstap0 & u64 & Unix epoch time in number of seconds\\
1156- babeslot & u64 & Babe Slot Number\tmrsup {\ref {defn-epoch-slot }}\\
1157- \hline
1158- \end {tabular }
1159- \caption {\label {tabl-inherent-data }List of inherent data}
1160- \end {table }
1161-
1162- \begin {definition }
1163- \label {defn-func-inherent-data }The function
1164- {\tmname {Block-Inherents-Data($ B_n$ )}} return the inherent data defined in
1165- Table \ref {tabl-inherent-data } corresponding to Block $ B$ as a SCALE encoded
1166- dictionary as defined in Definition \ref {defn-scale-list }.
1167- \end {definition }
1168-
11691182\subsubsection {Block Body }\label {sect-block-body }
11701183
11711184The Block Body consists of array extrinsics each encoded as a byte array. The
@@ -1463,9 +1476,10 @@ \subsection{Preliminaries}
14631476 are indexed sequentially, and we refer to the $ n^{\tmop {th}}$ epoch since
14641477 genesis by $ \mathcal {E}_n$ . Each epoch is divided into equal length periods
14651478 known as block production {\tmstrong {slots}}, sequentially indexed in each
1466- epoch. The index of each slot is called {\tmstrong {slot number}}. Each slot
1467- is awarded to a subset of block producers during which they are allowed to
1468- generate a block.
1479+ epoch. The index of each slot is called {\tmstrong {slot number}}. The equal
1480+ length duration of each slots is called the {\tmstrong {slot duration}} and
1481+ indicated by $ \mathcal {T}$ . Each slot is awarded to a subset of block
1482+ producers during which they are allowed to generate a block.
14691483\end {definition }
14701484
14711485\begin {notation }
@@ -1606,6 +1620,9 @@ \subsection{Slot Number Calculation}
16061620
16071621\hrulefill {\medskip }
16081622
1623+ $ \mathcal {T}$ is the slot duration defined in Definition
1624+ \ref {defn-epoch-slot }.
1625+
16091626\subsection {Block Production }
16101627
16111628At each epoch, each block producer should run Algorithm
@@ -1681,7 +1698,7 @@ \subsection{Block Production}
16811698
16821699{\state {{\tmname {Add-Digest-Item}}($ B_s$ ,Seal,$ S_B$ )}}
16831700
1684- {\state {{\tmname {Broadcast-Block}}($ B_s, H_{ \tmop {BABE}} (B_s) $ )}}}}
1701+ {\state {{\tmname {Broadcast-Block}}($ B_s$ )}}}}
16851702
16861703\hrulefill {\medskip }
16871704
@@ -1692,9 +1709,10 @@ \subsection{Epoch Randomness}\label{sect-epoch-randomness}
16921709
16931710At the end of epoch $ \mathcal {E}_n$ , each block producer is able to compute
16941711the randomness seed it needs in order to participate in the block production
1695- lottery in epoch $ \mathcal {E}_{n + 2}$ . The computation of the seed is
1696- described in Algorithm \ref {algo-epoch-randomness } which uses the concept of
1697- epoch subchain described in Definition \ref {defn-epoch-subchain }.
1712+ lottery in epoch $ \mathcal {E}_{n + 2}$ . For epoch 0 and 1, the randomness seed
1713+ is provided in the genesis block. The computation of the seed is described in
1714+ Algorithm \ref {algo-epoch-randomness } which uses the concept of epoch subchain
1715+ described in Definition \ref {defn-epoch-subchain }.
16981716
16991717\custombinding {10}{\noindent }\begin {tabular }{l}
17001718 \hline
@@ -1848,9 +1866,6 @@ \subsection{Blocks Building Process}\label{sect-block-building}
18481866
18491867{\algorithmic {{\state {$ P_B \leftarrow _{}$ {\tmname {Head($ C_{\tmop {Best}}$ )}}}}
18501868
1851- {\state {$ H_h (P_B) \leftarrow $ {\tmname {Call-Runtime-Entry}}$ \left (
1852- \text {\tmverbatim {block\_ hash\_ from\_ id}}, H_i (P_B) \right )$ }}
1853-
18541869{\state {$ \tmop {Head} (B) \leftarrow $ ($ H_p \leftarrow H_h (P_B), H_i \leftarrow
18551870H_i (P_B) + 1 , H_r \leftarrow \phi , H_e \leftarrow \phi , H_d \leftarrow
18561871\phi $ )}}
@@ -1881,7 +1896,7 @@ \subsection{Blocks Building Process}\label{sect-block-building}
18811896{\state {{\tmname {Drop(Ready-Extrinsic-Queue,$ E$ )}}{\END }{\END }}}
18821897
18831898{\state {$ \tmop {Head} (B) \leftarrow $ {\tmname {Call-Runtime-Entry}}$ \left (
1884- \text {\tmverbatim {finalize\_ block}}, E \right )$ {\END }}}}}
1899+ \text {\tmverbatim {finalize\_ block}}, B \right )$ {\END }}}}}
18851900
18861901\hrulefill {\medskip }
18871902
@@ -2295,6 +2310,41 @@ \section{Randomness}\label{sect-randomness}
22952310
22962311\section {VRF }\label {sect-vrf }
22972312
2313+ \section {Cryptographic Keys }\label {sect-cryptographic-keys }
2314+
2315+ Various type keys are used in Polkadot to prove the identity of the actor. In
2316+ the following section we specify the detail of those keys and comment on their
2317+ usage
2318+
2319+ \begin {definition }
2320+ \label {defn-account-key }{\tmstrong {Account key $ (\tmop {sk}^a,
2321+ \tmop {pk}^a)$ }} is a key pair of type of either of schemes listed in Table
2322+ \ref {tabl-account-key-schemes }:
2323+ {\center {\begin {table }[h]
2324+ \begin {tabular }{ll}
2325+ \hline
2326+ Key scheme & Description\\
2327+ \hline
2328+ SR25519 & \\
2329+ ED25519 & \\
2330+ secp256k1 & Only for outgoing transfer transaction\\
2331+ \hline
2332+ \end {tabular }
2333+ \caption {\label {tabl-account-key-schemes }List of public key scheme which
2334+ can be used for an account key}
2335+ \end {table }}}
2336+ Account key can be used to sign transactions among other accounts and
2337+ blance-related functions.
2338+ \end {definition }
2339+
2340+ \begin {definition }
2341+ {\tmstrong {Controller key}} {\todo {TBS}}
2342+ \end {definition }
2343+
2344+ \begin {definition }
2345+ {\tmstrong {Session key}} {\todo {TBS}}
2346+ \end {definition }
2347+
22982348\chapter {Auxiliary Encodings }\label {sect-encoding }
22992349
23002350\section {SCALE Codec }\label {sect-scale-codec }
0 commit comments