Changes
authorAli Younis <ayounis@uci.edu>
Thu, 3 Nov 2016 22:10:59 +0000 (15:10 -0700)
committerAli Younis <ayounis@uci.edu>
Thu, 3 Nov 2016 22:10:59 +0000 (15:10 -0700)
doc2/iotcloud.tex

index 712f1521734bce14d93959bab5debfb3bf8ab00a..96d8b7f95b77b40abbc201c0e59d820c45520310 100644 (file)
@@ -46,7 +46,7 @@ $trans$ is a transaction entry , $\tuple{seq, id, KV, Guard}$  \\
 $lastmsg$ is a last message entry, $\tuple{seq, id}$ \\\r
 $qstate$ is a queue state entry, $\tuple{size}$ \\\r
 $colres$ is a collision resolution entry, $\tuple{id, seq_{old}, seq_{new}, true \lor false}$ \\\r
-$newkey$ is a new key entry, $\tuple{seq, k, id}$, $id$ is ID of arbitrator \\\r
+$newkey$ is a new key entry, $\tuple{k, id}$, $id$ is ID of arbitrator \\\r
 $commit$ is a commit transaction entry, $\tuple{seq_{trans},KV}$, id is id of arbitrator \\\r
 $abort$ is an abort transaction entry, $\tuple{seq_{trans},id_{trans}}$ \\\r
 \r
@@ -78,7 +78,8 @@ $Arbitrator$ = set of $\tuple{k,id}$ containing the key and its arbitrating devi
 $LastSlot$ = set of $\tuple{id, seq}$ containing the machine ID and the largest sequence number from that machine ID.\\\r
 $LocalSlots$ = set of slots that are in the clients local buffer (initially $\emptyset$), data is decrypted.\\\r
 $RejectedSlotList$ = ordered list of the sequence numbers of slots that this client tried to insert but were rejected.\\\r
-\r
+$CommittedKV$ = set of committed key value pairs (initially $\emptyset$).\r
+$SpeculatedKV$ = set of speculated key value pairs (initially $\emptyset$).\r
 \r
 \subsection{Helper Functions}\r
 The following helper functions are needed:\\\r
@@ -136,7 +137,22 @@ Get the next sequence number for insertion into the block chain.\\
 Get the arbitrator for a given key.\\\r
 \begin{algorithmic}[1]\r
 \Function{GetArbitrator}{$k$}\r
-    \State $\tuple{k_1,id_1} \gets \tuple{k_2,id_2} $ \textit{such that} $ \tuple{k_2,id_2} \in Arbitrator \land k_2=k$    \r
+    \State $\tuple{k_1,id_1} \gets \tuple{k_2,id_2} $ \textit{such that} $ \tuple{k_2,id_2} \in Arbitrator \land k_2=k$\r
+    \State \Return{$id_1$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+% Get Arbitrator KV\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Get Arbitrator for KV Set:}\\\r
+Get the arbitrator for a given key value set.\\\r
+\begin{algorithmic}[1]\r
+\Function{GetArbitratorKV}{$KV$}\r
+    \State $\tuple{k,v} \gets \tuple{k',v'}$ such that $\tuple{k',v'} \in KV$\r
+    \State $\tuple{k_1,id_1} \gets \tuple{k_2,id_2} $ \textit{such that} $ \tuple{k_2,id_2} \in Arbitrator \land k_2=k$\r
     \State \Return{$id_1$}\r
 \EndFunction\r
 \end{algorithmic}\r
@@ -389,7 +405,7 @@ Check if an abort data entry is live or not.  Abort is dead if the device whos t
 \noindent\fbox{%\r
 \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
 \textbf{Check Transaction Live:}\\\r
-A transaction is dead if there is an abort for that transaction or if there is a commit for that a transaction that came after this transaction.  Since transactions must be commited in order of there insertion, seeing a transaction that is commited and has a larger sequence number than the transaction in question means that the transaction in question was commited at some point.\\\r
+A transaction is dead if there is an abort for that transaction or if there is a commit for that a transaction that came after this transaction.  Since transactions must be committed in order of there insertion, seeing a transaction that is committed and has a larger sequence number than the transaction in question means that the transaction in question was committed at some point.\\\r
 \begin{algorithmic}[1]\r
 \Function{CheckTransLive}{$trans_a$}\r
     \State $\tuple{seq_a, id_a, KV_a, Guard_a} \gets trans_a$\r
@@ -804,50 +820,237 @@ Checks that the block chain size is correct when there is a gap in the block cha
 \end{varwidth}% \r
 }\r
 \r
-% Initialize the expected size of the block chain\r
+\r
+% % Initialize the expected size of the block chain\r
+% \noindent\fbox{%\r
+% \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+% \textbf{Initialize the expected size of the block chain:}\\\r
+% Initialize the expected size of the block chain based on the size at the server.\\\r
+% \begin{algorithmic}[1]\r
+% \Function{InitExpSize}{$seq_a$}\r
+%     \State $startingsize \gets 0$\\\r
+\r
+%     \If{$seq_a < max\_size$} \Comment{Check whether saves slots are full on server}\r
+%         \State $startingsize \gets seq_a$\r
+%     \Else\r
+%         \State $startingsize \gets max\_size$\r
+%     \EndIf\\\r
+    \r
+%     \State \Return{$startingsize$}\r
+% \EndFunction\r
+% \end{algorithmic}\r
+% \end{varwidth}% \r
+% }\r
+\r
+% % Update the expected size of the block chain\r
+% \noindent\fbox{%\r
+% \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+% \textbf{Update the expected size of the block chain:}\\\r
+% Update the expected size of the block chain.\\\r
+% \begin{algorithmic}[1]\r
+% \Function{UpdateExpSize}{$size_a$}\r
+%     \State $size_a \gets size_a + 1$\\\r
+    \r
+%     \If{$size_a > max\_size$}\Comment{Expected size $\leq max\_size$}\r
+%         \State $ssize_a \gets max_\_size$\r
+%     \EndIf\\\r
+    \r
+%     \State \Return{$size_a$}\r
+% \EndFunction\r
+% \end{algorithmic}\r
+% \end{varwidth}% \r
+% }\r
+\r
+\r
+\r
+% Update Last Message\r
 \noindent\fbox{%\r
 \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
-\textbf{Initialize the expected size of the block chain:}\\\r
-Initialize the expected size of the block chain based on the size at the server.\\\r
+\textbf{Process Commit Data Entry:}\\\r
+Process a commit entry.  Updates the local copy of commits.\\\r
 \begin{algorithmic}[1]\r
-\Function{InitExpSize}{$seq_a$}\r
-    \State $startingsize \gets 0$\\\r
-\r
-    \If{$seq_a < max\_size$} \Comment{Check whether saves slots are full on server}\r
-       \State $startingsize \gets seq_a$\r
+\Function{UpdateLastMessage}{$seq_a, id_a, LstSlt_a, updateinglocal_a$}\r
+    \State $\tuple{id_{old}, seq_{old}} \gets \tuple{id', seq'}$ such that $\tuple{id', seq'} \in LastSlot \land id'=id$\\\r
+    \r
+    \If{$id_a = LOCAL\_ID$}\r
+        \If{$\lnot updateinglocal_a \land (seq_a \neq seq_{old})$}\r
+            \LeftComment{This client did not make any updates so its latest sequence number should not change}\r
+            \State \Call{Error}{"Mismatch on local machine sequence number"}\r
+        \EndIf\r
     \Else\r
-        \State $startingsize \gets max\_size$\r
+        \If{$seq_{old} > seq_a$}\r
+            \State \Call{Error}{"Rollback on remote machine sequence number"}\r
+        \EndIf\r
     \EndIf\\\r
     \r
-    \State \Return{$startingsize$}\r
+    \State $LastSlot \gets LastSlot \setminus \{\tuple{id, seq} | \tuple{id, seq} \in LastSlot, id=id_a\}$\r
+    \State $LastSlot \gets LastSlot \cup \{\tuple{id_a, seq_a}\}$\r
+    \r
+    \State \Return{$LstSlt_a \setminus \{\tuple{id, seq} | \tuple{id, seq} \in LstSlt_a, id=id_a\}$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+% Process Commit Data Entry\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Process Commit Data Entry:}\\\r
+Process a commit entry.  Updates the local copy of commits.\\\r
+\begin{algorithmic}[1]\r
+\Function{ProcessCommit}{$commit_a$}\r
+    \State $\tuple{seq_{a_{trans}},KV_a} \gets commit_a$\r
+    \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in CommittedKV \land \tuple{k',v'}\in KV_a \land k'=k\}$\r
+    \State $CommittedKV \gets (CommittedKV \setminus DKV) \cup KV_a$\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+% Process Queue State Data Entry\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Process Queue State Entry:}\\\r
+Process a queue state entry. Updates the max size of the block chain\\\r
+\begin{algorithmic}[1]\r
+\Function{ProcessQState}{$qstate_a$}\r
+    \State $\tuple{size_a} \gets qstate_a$\r
+    \State $max\_size \gets size_a$ \Comment{Update the max size we can have}\r
 \EndFunction\r
 \end{algorithmic}\r
 \end{varwidth}% \r
 }\r
 \r
-% Update the expected size of the block chain\r
+% Process Collision Resolution Entry\r
 \noindent\fbox{%\r
 \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
-\textbf{Update the expected size of the block chain:}\\\r
-Update the expected size of the block chain.\\\r
+\textbf{Process Queue State Entry:}\\\r
+Process a collision resolution entry.\\\r
 \begin{algorithmic}[1]\r
-\Function{UpdateExpSize}{$size_a$}\r
-    \State $size_a \gets size_a + 1$\\\r
+\Function{ProcessColres}{$colres_a, NewSlots_a$}\r
+    \State $\tuple{id_a, seq_{a_{old}}, seq_{a_{new}}, isequal_a}$\r
+    \State $AllSlots \gets LocalSlots \cup NewSlots_a$\r
+    \State $index \gets seq_{a_{old}}$\\\r
+    \r
+    \While{$index <= seq_{a_{new}}$}\r
+        \State $slt \gets \tuple{seq' Dat'}$ such that $\tuple{seq' Dat'} \in AllSlots \land seq'=index$\r
+        \r
+        \If{$\exists \tuple{seq' Dat'} \in AllSlots, seq' = index$}\r
+            \State $\tuple{seq, Dat} \gets \tuple{seq' Dat'}$ such that $\tuple{seq' Dat'} \in AllSlots \land seq'=index$\r
+            \State $\tuple{seq,id,DE,hmac_p,hmac_c} \gets Dat$\r
+            \If{$isequal_a \neq (id=id_a)$}\r
+                \State \Call{Error}{"Trying to insert rejected messages for slot"}\r
+            \EndIf\r
+        \EndIf\\\r
+        \State $index \gets index + 1$\r
+    \EndWhile\r
     \r
-    \If{$size_a > max\_size$}\Comment{Expected size $\leq max\_size$}\r
-           \State $ssize_a \gets max_\_size$\r
-    \EndIf\\\r
     \r
-    \State \Return{$size_a$}\r
 \EndFunction\r
 \end{algorithmic}\r
 \end{varwidth}% \r
 }\r
 \r
+% Process New Key Data Entry\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Process New Key Entry:}\\\r
+Process a queue state entry. Adds a key to the key arbitrator set\\\r
+\begin{algorithmic}[1]\r
+\Function{ProcessNewkey}{$newkey_a$}\r
+    \State $\tuple{seq_a, k_a, id_a} \gets newkey_a$\r
+    \State $Arbitrator \gets Arbitrator \cup \{\tuple{k_a,id_a}\}$\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+% Process Process Data Entry\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Process Data Entry:}\\\r
+Process the data entry based on what kind of entry it is.\\\r
+\begin{algorithmic}[1]\r
+\Function{ProcessDatEntry}{$slot_a, NewSlots_a,LstSlt_a$}\r
+    \If{$datentry_a$ is a $commit$}\r
+        \State \Call{ProcessCommit}{$dataentry_a$}\r
+        \r
+    \ElsIf{$datentry_a$ is a $abort$}\r
+        \LeftComment{Do Nothing in this case}\r
+        \r
+    \ElsIf{$datentry_a$ is a $trans$}\r
+        \LeftComment{Do Nothing in this case}\r
+    \r
+    \ElsIf{$datentry_a$ is a $lastmsg$}\r
+        \State $\tuple{seq_a, id_a} \gets dataentry_a$\r
+        \State $LstSlt_a \gets$ \Call{UpdateLastMessage}{$seq_a, id_a, LstSlt_a, false$}\r
+    \r
+    \ElsIf{$datentry_a$ is a $colres$}\r
+        \State \Call{ProcessColres}{$dataentry_a, NewSlots_a$}\r
+        \r
+    \ElsIf{$datentry_a$ is a $qstate$}\r
+        \State \Call{ProcessQState}{$dataentry_a$}\r
+        \r
+    \ElsIf{$datentry_a$ is a $newkey$}\r
+        \State \Call{ProcessNewkey}{$dataentry_a$}\r
+        \r
+    \Else\r
+        \State \Call{Error}{"Unknown data entry type."}\r
+    \EndIf\r
+    \r
+    \State \Return{$LstSlt_a$}    \r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
 \r
 \r
+% Delete Local Slots\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Delete Local Slots:}\\\r
+Deletes local slots that are deleted at the server.  This keeps the size of the local block chain bounded.\\\r
+\begin{algorithmic}[1]\r
+\Function{DeleteLocalSlots}{$ $}\r
+    \State $\tuple{seq_{max}, Dat_{max}} \gets $ \Call{MaxSlot}{$LocalSlots$}\r
+    \State $seq_{min} \gets seq_{max} - max\_size$ \Comment{Min sequence number we should keep}\r
+    \State $LSDelete \gets \emptyset$\r
+        \r
+    \If{$|LocalSlots| \leq max\_size$}\r
+        \State \Return{} \Comment{Nothing to delete}\r
+    \EndIf\\\r
+    \r
+    \State $LSDelete \gets \{\tuple{seq', Dat'}|\tuple{seq', Dat'} \in LocalSlots, seq' > seq_{min}\}$\r
+    \State $LocalSlots \gets LocalSlots \setminus LSDelete$    \r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
 \r
+% Create Speculative KV\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Create Speculative KV:}\\\r
+Speculates on what the most recent key value pairs will be based on the latest committed key value pairs and the uncommitted transactions.\\\r
+\begin{algorithmic}[1]\r
+\Function{SpeculateKV}{$ $}\r
+    \State $AllTrans \gets$ \Call{GetTrans}{}\r
+    \State $LiveTrans \gets \{t| t\in AllTrans, $\Call{CheckTransLive}{$t$}$\}$\r
+    \State $CurrKV \gets CommittedKV$\r
+    \State $DKV \gets \emptyset$\r
 \r
+    \ForAll{$\tuple{seq_t, id_t, KV_t, Guard_t} \in LiveTrans$ ordered by $seq'$} \r
+        \If{\Call{EvaluateGuard}{$Guard_t, CurrKV$}}\r
+            \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in CurrKV \land \tuple{k',v'}\in KV_t \land k'=k\}$\r
+            \State $CurrKV \gets (CurrKV \setminus DKV) \cup KV_t$\r
+        \EndIf\r
+    \EndFor\r
+    \r
+    \State \Return{$CurrKV$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
 \r
 \r
 % Validate and Update \r
@@ -856,52 +1059,55 @@ Update the expected size of the block chain.\\
 \textbf{Validate Update:}\\\r
 Validate the block chain and insert into the local block chain.\\\r
 \begin{algorithmic}[1]\r
-\Function{ValidateUpdate}{$NewSlots_a$}\r
+\Function{ValidateUpdate}{$NewSlots_a, updatinglocal_a$}\r
     \State $\tuple{seq_{oldest}, Dat_{oldest}} \gets$ \Call{MinSlot}{$NewSlots_a$}\r
     \State $\tuple{seq_{newest}, Dat_{newest}} \gets$ \Call{MaxSlot}{$NewSlots_a$}\r
-    \r
-    \State $currsize \gets $\Call{InitExpSize}{$seq_{oldest}$}\\\r
+    \State $\tuple{seq_{local}, Dat_{local}} \gets$ \Call{MaxSlot}{$LocalSlots$}\r
+    \State $LastSlotTmp \gets LastSlot$\\\r
+    %\State $currsize \gets $\Call{InitExpSize}{$seq_{oldest}$}\\\r
     \r
     \State \Call{CheckSlotsHmacAndSeq}{$NewSlots_a$} \Comment{Check all the HMACs}\r
     \State \Call{CheckHmacChain}{$NewSlots_a$} \Comment{Check HMAC Chain} \r
     \State \Call{CheckOldSlots}{$NewSlots_a$} \Comment{Check if new slots are actually old slots} \r
     \State \Call{CheckSize}{$NewSlots_a$} \Comment{Check if the size is correct}\\\r
     \r
-    \ForAll{$slot_a \in NewSlots_a$} \Comment{Process each slot}\r
+    \ForAll{$slot_a \in NewSlots_a$ in order of sequence number}\r
+        \If{$slot_a \in LocalSlots$} \Comment{Client already has this slot}\r
+            \State $NewSlots_a \gets NewSlots_a \setminus \{slot_a\}$\r
+            \State Continue\r
+        \EndIf\\\r
+    \r
         \State $\tuple{seq_{a_1}, \tuple{seq_{a_2},id_a,DE_a,hmac_{a_p},hmac_{a_c}}} \gets slot_a$\r
+        \State $LstSlt_a \gets$ \Call{UpdateLastMessage}{$seq_{a_1}, id_a, LstSlt_a, updatinglocal_a$}\\\r
+        \r
         \ForAll{$de_a \in DE_a$} \Comment{Process each data entry}\r
-            \r
+            \State $LstSlt_a \gets $ \Call{ProccessDatEntry}{$de_a, NewSlots_a,LstSlt_a$}\r
         \EndFor\\\r
     \r
-        \State $currsize \gets $ \Call{UpdateExpSize}{$currsize$}\\\r
+        %\State $currsize \gets $ \Call{UpdateExpSize}{$currsize$}\\\r
         \State $LocalSlots \gets LocalSlots \cup \{slot_a\}$ \Comment{Add to local Chain}\r
-    \EndFor\r
-\r
+    \EndFor\\\r
+    \r
+    \If{$seq_{oldest} > (seq_{local} +1) \land LastSlotTmp \neq \emptyset$}\r
+        \LeftComment{There was a gap so there should be a complete set of information on each previously seen client}\r
+        \State \Call{Error}{"Missing records for machines"}\r
+    \EndIf\\\r
     \r
-    %Delete from local chain to maintain size    \r
+    \State \Call{DeleteLocalSlots}{ } \Comment{Delete old slots from local}\r
+    \State $SpeculatedKV \gets $\Call{SpeculateKV}{ } \Comment{Speculate on what will be latest KV set}\r
     \r
 \EndFunction\r
 \end{algorithmic}\r
 \end{varwidth}% \r
 }\r
 \r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
 % Decrypt Validate Insert Slots\r
 \noindent\fbox{%\r
 \begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
 \textbf{Decrypt Validate Insert Slots:}\\\r
 Decrypts slots, validates (checks for malicious activity) slots and inserts the slots into the local block chain.\\\r
 \begin{algorithmic}[1]\r
-\Function{DecryptValidateInsert}{$NewSlots_a$}\r
+\Function{DecryptValidateInsert}{$NewSlots_a, updatinglocal_a$}\r
     \State $DecryptedSlots \gets \emptyset$\r
     \State $DDat \gets NULL$\\\r
     \r
@@ -909,7 +1115,7 @@ Decrypts slots, validates (checks for malicious activity) slots and inserts the
         \State $DDat \gets $ \Call{Decrypt}{$EDat'$}\r
         \State $DecryptedSlots \gets DecryptedSlots \cup \tuple{seq',DDat}$\r
     \EndFor\\\r
-    \State \Call{ValidateUpdate}{$DecryptedSlots$}\r
+    \State \Call{ValidateUpdate}{$DecryptedSlots, updatinglocal_a$}\r
 \EndFunction\r
 \end{algorithmic}\r
 \end{varwidth}% \r
@@ -1042,11 +1248,15 @@ This rescue is not mandatory.  This is trying to fill the remaining portion of t
     \r
     \LeftComment{Get all the latest commits}\r
     \ForAll{$\tuple{seq_{trans}',KV'} \in LiveCommits$}\r
-        \State $CurrKV \gets CUrrKV \cup KV'$\r
+        \State $CurrKV \gets CurrKV \cup KV'$\r
     \EndFor\\\r
     \r
-    \ForAll{$\tuple{seq_t, id_t, KV_t, Guard_t} \in LiveTrans$ ordered by $seq'$}    \r
-        \If{\Call{EvaluateGuard}{$Guard_t, CurrKV$}}\r
+    \ForAll{$\tuple{seq_t, id_t, KV_t, Guard_t} \in LiveTrans$ ordered by $seq'$} \r
+        \If{\Call{GetArbitratorKV}{$KV_t$} $\neq LOCAL\_ID$}\r
+            \State Continue \Comment{Client not arbitrator for this transaction}\r
+        \EndIf\\\r
+    \r
+        \If{$\lnot$\Call{EvaluateGuard}{$Guard_t, CurrKV$}}\r
             \State $abortde \gets $\Call{CreateAbort}{$seq_t, id_t$}\r
             \LeftComment{No more space so we cant arbitrate any further}\r
             \If($lnot$\Call{DeHasSpace}{$DE_a, abortde$})\r
@@ -1054,9 +1264,9 @@ This rescue is not mandatory.  This is trying to fill the remaining portion of t
             \EndIf\r
             \State $DE_a \gets DE_a \cup abortde$\r
         \Else\r
-            \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in KV \land \tuple{k',v'}\in KV_t \land k'=v'\}$\r
+            \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in KV \land \tuple{k',v'}\in KV_t \land k'=k\}$\r
             \State $KVTmp \gets (KV \setminus DKV) \cup KV'$\r
-            \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in CurrKV \land \tuple{k',v'}\in KVTmp \land k'=v'\}$\r
+            \State $DKV \gets \{\tuple{k,v}| \tuple{k,v} \in CurrKV \land \tuple{k',v'}\in KVTmp \land k'=k\}$\r
             \State $CurrKV \gets (CurrKV \setminus DKV) \cup KVTmp$\r
             \State $commitde \gets $ \Call{CreateCommit}{$seq_t,KVTmp$}\r
             \r
@@ -1172,7 +1382,7 @@ Try to insert a transaction into the block chain. Does resizing, rescues and ins
     \State $\tuple{sendsuccess, newslots} \gets $ \Call{SendToServer}{$seq, DE, newsize$}\\\r
     \r
     \LeftComment{Insert the slots into the local bloakc chain}\r
-    \State \Call{DecryptValidateInsert}{$newslots$}\\\r
+    \State \Call{DecryptValidateInsert}{$newslots, true$}\\\r
     \r
     \State \Return{$transinserted \land success$} \Comment{Return if  succeeded or not}\r
     \r
@@ -1207,6 +1417,50 @@ Puts a key value pair into the key value pair buffer\\
 \end{varwidth}% \r
 }\r
 \r
+% Get KV Pair Speculative\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Get KV Pair Speculative:}\\\r
+Get the value for the key while speculating.\\\r
+\begin{algorithmic}[1]\r
+\Function{GetValueSpeculate}{$k_a$}\r
+    \State $\tuple{k,v} \gets \tuple{k,v}$ \textit{such that} $\tuple{k,v} \in SpeculatedKV \land k = k_a$\r
+\State \Return{$v$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+\r
+% Update\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Update}\\\r
+Sync with the server and get all the latest slots.\\\r
+\begin{algorithmic}[1]\r
+\Function{Update}{$ $}\r
+    \State $\tuple{seq, Dat} \gets $ \Call{MaxSlot}{$LocalSlots$}\r
+    \State $NewSlots \gets$ \Call{GetSlots}{$seq$}\r
+    \State \Call{DecryptValidateInsert}{$NewSlots, false$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r
+\r
+% Get KV Pair Committed\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Get KV Pair Committed:}\\\r
+Get the value for the key which have been committed.\\\r
+\begin{algorithmic}[1]\r
+\Function{GetValueCommit}{$k_a$}\r
+    \State $\tuple{k,v} \gets \tuple{k,v}$ \textit{such that} $\tuple{k,v} \in Committed \land k = k_a$\r
+    \State \Return{$v$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
 \r
 % Put guard condition\r
 \noindent\fbox{%\r
@@ -1262,6 +1516,4 @@ Commits the transaction into the block chain.  Keeps attempting to insert the tr
 \r
 \r
 \r
-\r
-\r
 \end{document}\r