From: rtrimana Date: Thu, 4 Aug 2016 00:26:21 +0000 (-0700) Subject: Adding liveness and more states - half baked, need to recheck the states, especially... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=commitdiff_plain;h=2f40bba605f99bfdbebe57a6c3085bdff40cd221 Adding liveness and more states - half baked, need to recheck the states, especially for ss and cr entries --- diff --git a/doc/iotcloud.tex b/doc/iotcloud.tex index 5276310..a795fa8 100644 --- a/doc/iotcloud.tex +++ b/doc/iotcloud.tex @@ -209,6 +209,8 @@ $sv_s = \tuple{s, E(Dat_s)} = \textit{DT = set of $\tuple{k,v}$ on client} \\ \textit{MS = associative array of $\tuple{id, s_{last}}$ of all clients on client (initially empty)} \\ +\textit{$LV$ = live set of $de$ entries on client, contains + $\tuple{de,s}$ entries} \\ \textit{$MS_g$ = set MS to save all $\tuple{id, s_{last}}$ pairs while traversing DT after a request to server (initially empty)} \\ \textit{SK = Secret Key} \\ @@ -231,6 +233,8 @@ $GetMacId(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=id$ \\ $GetPrevHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_p$ \\ $GetCurrHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_c$ \\ $GetDatEnt(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=DE$ \\ +$GetLivEntLastS(LV_s,de_s)= s$ \textit{such that} $\tuple{de, s} \in LV_s +\wedge \forall \tuple{de_s, s_s} \in LV_s, de_s = de$ \\ $GetKV($key-value data entry$)=\tuple{k_s,v_s}$ \\ $GetSS($slot-sequence data entry$)=\tuple{id,s_{last}}$ \\ $GetQS($queue-state data entry$)=qs_s$ \\ @@ -271,8 +275,7 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Function{GetQueSta}{$Dat_s$} -\State $DE_s \gets GetDatEnt(DE_s)$ +\Function{GetQueSta}{$DE_s$} \State $de_{qs} \gets de_s$ \textit{such that} $de_s \in DE_s, de_s \in D \land de_s = qs$ \If{$de_{qs} \neq \emptyset$} @@ -285,40 +288,16 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Function{GetSlotSeq}{$Dat_s$} -\State $DE_s \gets GetDatEnt(Dat_s)$ -\State $de_{ss} \gets de_s$ \textit{such that} $de_s \in DE_s, - de_s \in D \land de_s = ss$ -\If{$de_{ss} \neq \emptyset$} - \State $\tuple{id_{ret},s_{last_{ret}}} \gets GetSS(de_{ss})$ -\Else - \State $\tuple{id_{ret},s_{last_{ret}}} \gets \emptyset$ -\EndIf -\State \Return{$\tuple{id_{ret},s_{last_{ret}}}$} +\Function{GetSlotSeq}{$DE_s$} +\State $DE_{ss} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = ss\}$ +\State \Return{$DE_{ss}$} \EndFunction \end{algorithmic} \begin{algorithmic}[1] -\Function{GetColRes}{$Dat_s$} %\Comment{At most 2 $cr$ entries in a slot} -\State $DE_s \gets GetDatEnt(Dat_s)$ -\State $de_{cr} \gets de_s$ \textit{such that} $de_s \in DE_s, - de_s \in D \land de_s = cr$ -\If{$de_{cr} \neq \emptyset$} - \State $\tuple{s_{ret},id_{ret}} \gets GetCR(de_{cr})$ -\Else - \State $\tuple{s_{ret},id_{ret}} - \gets \emptyset$ -\EndIf -%\State $de_{r_{cr}} \gets de_s$ \textit{such that} $de_s \in DE_s, -% de_s \in D \land de_s = cr \land de_s \neq de_{cr}$ -%\If{$de_{r_{cr}} \neq \emptyset$} -% \State $\tuple{s_{r_{ret}},id_{r_{ret}}} \gets GetCR(de_{r_{cr}})$ -%\Else -% \State $\tuple{s_{r_{ret}},id_{r_{ret}}} -% \gets \emptyset$ -%\EndIf -%\State \Return{$\{\tuple{s_{ret},id_{ret}},\tuple{s_{r_{ret}},id_{r_{ret}}}\}$} -\State \Return{$\{\tuple{s_{ret},id_{ret}}\}$} +\Function{GetColRes}{$DE_s$} +\State $DE_{cr} \gets \{de_s | de_s \in DE_s, de_s \in D \land de_s = cr\}$ +\State \Return{$DE_{cr}$} \EndFunction \end{algorithmic} @@ -334,6 +313,51 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \EndFunction \end{algorithmic} +\begin{algorithmic}[1] +\Function{UpdateKVLivEnt}{$LV_s,de_s,s_s$} +\State $s_t \gets GetLivEntLastS(LV_s,de_s)$ +\If{$s_t = \emptyset$} + \State $LV_s \gets LV_s \cup \{\tuple{de_s,s_s}\}$\Comment{First occurrence} +\Else + \If{$s_s > s_t$}\Comment{Update entry with a later s} + \State $LV_s \gets (LV_s - \{\tuple{de_s,s_t}\}) \cup + \{\tuple{de_s,s_s}\}$ + \EndIf +\EndIf +\State \Return{$LV_s$} +\EndFunction +\end{algorithmic} + +\begin{algorithmic}[1] +\Function{UpdateSSLivEnt}{$LV_s,MS_s,de_s$} +\State $s_t \gets GetLivEntLastS(LV_s,de_s)$ +\If{$s_t = \emptyset$} + \State $LV_s \gets LV_s \cup \{\tuple{de_s,s_s}\}$\Comment{First occurrence} +\EndIf +\State $\tuple{id_s,s_{s_{last}}} \gets GetSS(de_s)$ +\State $s_t \gets MS_s[id_s]$ +\If{$s_t > s_{s_{last}}$}\Comment{Remove if dead} + \State $LV_s \gets LV_s - \{\tuple{de_s,s_{s_{last}}}\}$ +\EndIf +\State \Return{$LV_s$} +\EndFunction +\end{algorithmic} + +\begin{algorithmic}[1] +\Function{UpdateCRLivEnt}{$LV_s,MS_s,de_s$} +\State $s_t \gets GetLivEntLastS(LV_s,de_s)$ +\If{$s_t = \emptyset$} + \State $LV_s \gets LV_s \cup \{\tuple{de_s,s_s}\}$\Comment{First occurrence} +\EndIf +\State $\tuple{s_s,id_s} \gets GetCR(de_s)$ +\State $s_t \gets MinLastSeqN(MS_s)$ +\If{$s_t > s_s$}\Comment{Remove if dead} + \State $LV_s \gets LV_s - \{\tuple{de_s,s_s}\}$ +\EndIf +\State \Return{$LV_s$} +\EndFunction +\end{algorithmic} + \begin{algorithmic}[1] \Procedure{CheckLastSeqN}{$MS_s,MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$} \For {$\tuple{id, s_t}$ in $MS_t$} @@ -384,9 +408,9 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \end{algorithmic} \begin{algorithmic}[1] -\Function{UpdateDT}{$DT_s,Dat_s$} -\State $DE_s \gets GetDatEnt(Dat_s)$ +\Function{UpdateDT}{$DT_s,DE_s,LV_s,s_s$} \ForAll{$de_s \in DE_s$} + \State $LV_s \gets \Call{UpdateKVLivEnt}{LV_s,de_s,s_s}$ \If{$de_s$ \textit{such that} $de_s \in D \land de_s = kv$} \State $\tuple{k_s,v_s} \gets GetKV(de_s)$ \State $\tuple{k_s,v_t} \gets GetKeyVal(DT_s,k_s)$ @@ -427,7 +451,7 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \State \Call{Error}{'Invalid current HMAC value'} \EndIf \State $hmac_{p_g} \gets Hmac(DE_g,SK)$\Comment{Update $hmac_{p_g}$ for next check} - \State $qs_g \gets \Call{GetQueSta}{Dat_g}$\Comment{Handle qs} + \State $qs_g \gets \Call{GetQueSta}{DE_g}$\Comment{Handle qs} \If{$qs_g \neq \emptyset \land qs_g > max_g$} \State $max_g \gets qs_g$ \EndIf @@ -435,17 +459,24 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \State $id_g \gets GetMacId(Dat_g)$\Comment{Handle last s} \State $MS_g \gets \Call{UpdateLastSeqN}{id_g,s_g,MS_g}$ %Check for last s in DE in Dat - \State $\tuple{id_d,s_{d_{last}}} \gets \Call{GetSlotSeq}{Dat_g}$\Comment{Handle ss} - \If{$\tuple{id_d,s_{d_{last}}} \neq \emptyset$} - \State $MS_g \gets \Call{UpdateLastSeqN}{id_d,s_{d_{last}},MS_g}$ + \State $DE_{g_{ss}} \gets \Call{GetSlotSeq}{DE_g}$\Comment{Handle ss} + \If{$DE_{g_{ss}} \neq \emptyset$} + \ForAll{$de_{g_{ss}} \in DE_{g_{ss}}$} + \State $\tuple{id_d,s_{d_{last}}} \gets GetSS(de_{g_{ss}})$ + \State $MS_g \gets \Call{UpdateLastSeqN}{id_d,s_{d_{last}},MS_g}$ + \State $LV \gets \Call{UpdateSSLivEnt}{LV,MS,de_{g_{ss}}}$ + \EndFor + \EndIf + \State $DE_{g_{cr}} \gets \Call{GetColRes}{DE_g}$\Comment{Handle cr} + \If{$DE_{g_{cr}} \neq \emptyset$} + \ForAll{$de_{g_{cr}} \in DE_{g_{cr}}$} + \State $\tuple{s_e,id_e} \gets GetCR(de_{g_{cr}})$ + \State $\Call{CheckCollision}{MS,SM,\tuple{s_e,id_e}}$ + \State $LV \gets \Call{UpdateCRLivEnt}{LV,MS,de_{g_{cr}}}$ + \EndFor \EndIf - %\State $\{\tuple{s_e,id_e},\tuple{s_f,id_f}\} \gets - % \Call{GetColRes}{Dat_g}$\Comment{Handle cr} - \State $\{\tuple{s_e,id_e}\} \gets \Call{GetColRes}{Dat_g}$\Comment{Handle cr} - \State $\Call{CheckCollision}{MS,SM,\tuple{s_e,id_e}}$\Comment{From normal slot} - %\State $\Call{CheckCollision}{MS,SM,\tuple{s_f,id_f}}$\Comment{From reinsertion} \State $sl_{last} \gets \Call{StoreLastSlot}{MS,sl_{last},s_g,sv_g,id_g}$ - \State $DT \gets \Call{UpdateDT}{DT,Dat_g}$ + \State $DT \gets \Call{UpdateDT}{DT,DE_g,LV,s_g}$ \EndFor \State $SM \gets SM_{curr}$ \If{$m + |SL_g| \leq max_g$}\Comment{Check actual size against $max_g$} @@ -499,9 +530,18 @@ collision in reinserting the last slot (sent in the following slot)} \\ $\tuple{s_{last},sv_{last},id_{last}}$ (initially $\emptyset$)} \\ \textit{$th_p$ = threshold number of dead slots for a resize to happen} \\ \textit{$m'_p$ = offset added to $max$ for resize} \\ +\textit{$reinsert_{qs}$ = boolean to decide $qs$($max_g$) reinsertion} \\ \textit{$KV$ = set of $\tuple{ck, \tuple{k,v}}$ of kv entries on client} \\ +%\textit{$LV_{kv}$ = live set of $kv$ entries on client, contains a few +% $\tuple{kv,s_{last}}$ entries} \\ +%\textit{$LV_{ss}$ = live set of $ss$ entries on client, contains a few +% $\tuple{ss,s_{last}}$ entries} \\ +%\textit{$LV_{cr}$ = live set of $cr$ entries on client, contains a few +% $\tuple{cr,s_{last}}$ entries} \\ \textit{$SL_p$ = set of returned slots on client} \\ -\textit{SK = Secret Key} \\ \\ +\textit{SK = Secret Key} \\ +\textit{$CR$ = set of $cr$ entries on client} \\ \\ +\textit{$SS$ = set of $ss$ entries on client} \\ \\ \textbf{Helper Functions} \\ $CreateDat(s,id,hmac_p,DE,hmac_c)=Dat_s=\tuple{s,id,hmac_p,DE,hmac_c}$ \\ $CreateCR(s,id)=\tuple{s,id}$ \\ @@ -515,18 +555,24 @@ $GetSV(sl = \tuple{s,sv,id})=sv$ \\ $GetID(sl = \tuple{s,sv,id})=id$ \\ $GetColSeqN(SL_s,s_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv} \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s = s_s$ \\ -$GetKV(KV_s,k_s)= \tuple{ck,\tuple{k, v}}$ \textit{such that} +$GetKVPair(KV_s,k_s)= \tuple{ck,\tuple{k, v}}$ \textit{such that} $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \forall \tuple{ck_s,\tuple{k_s, v_s}} \in KV_s, k = k_s$ \\ +%$GetKVLastSeqN(LV_{kv},kv_s)= s_{last}$ \textit{such that} $\tuple{kv, s_{last}} \in LV_{kv} +%\wedge \forall \tuple{kv_s, s_{s_{last}}} \in LV_{kv}, s_{last} \geq s_{s_{last}}$ \\ +%$GetSSLastSeqN(LV_{ss},ss_s)= s_{last}$ \textit{such that} $\tuple{ss, s_{last}} \in LV_{ss} +%\wedge \forall \tuple{ss_s, s_{s_{last}}} \in LV_{ss}, s_{last} \geq s_{s_{last}}$ \\ +%$GetCRLastSeqN(LV_{cr},cr_s)= s_{last}$ \textit{such that} $\tuple{cr, s_{last}} \in LV_{cr} +%\wedge \forall \tuple{cr_s, s_{s_{last}}} \in LV_{cr}, s_{last} \geq s_{s_{last}}$ \\ \begin{algorithmic}[1] -\Function{PutKVPair}{$\tuple{k_s,v_s}$} -\State $\tuple{ck_s,\tuple{k_s,v_t}} \gets GetKV(KV,k_s)$ +\Function{PutKVPair}{$KV_s,\tuple{k_s,v_s}$} +\State $\tuple{ck_s,\tuple{k_s,v_t}} \gets GetKVPair(KV,k_s)$ \If{$\tuple{ck_s,\tuple{k_s,v_t}} = \emptyset$} - \State $KV \gets KV \cup \{\tuple{ck_p, \tuple{k_s,v_s}}\}$ + \State $KV_s \gets KV_s \cup \{\tuple{ck_p, \tuple{k_s,v_s}}\}$ \State $ck_p \gets ck_p + 1$ \Else - \State $KV \gets (KV - \{\tuple{ck_s, \tuple{k_s,v_t}}\}) \cup + \State $KV_s \gets (KV_s - \{\tuple{ck_s, \tuple{k_s,v_t}}\}) \cup \{\tuple{ck_s, \tuple{k_s,v_s}}\}$ \EndIf \State \Return{$KV_s$} @@ -534,13 +580,13 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \end{algorithmic} \begin{algorithmic}[1] -\Function{CheckResize}{$MS_s,th_s,max'_t,m'_s$} +\Function{CheckResize}{$MS_s,th_s,max_t,m'_s$} \State $s_{last_{min}} \gets MinLastSeqN(MS_s)$ \State $s_{last_{max}} \gets MaxLastSeqN(MS_s)$ -\State $n_{live} \gets s_{last_{max}} - s_{last_{min}}$\Comment{Number of live slots} -\State $n_{dead} \gets max'_t - n_{live}$ +\State $n_{live} \gets s_{last_{max}} - s_{last_{min}} + 1$\Comment{Number of live slots} +\State $n_{dead} \gets max_t - n_{live}$ \If{$n_{dead} \leq th_s$} - \State $max'_s \gets max'_t + m'_s$ + \State $max'_s \gets max_t + m'_s$ \Else \State $max'_s \gets \emptyset$ \EndIf @@ -549,11 +595,11 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \end{algorithmic} \begin{algorithmic}[1] -\Function{CheckNeedSS}{$MS_s,max'_t$}\Comment{Check if $ss$ is needed} +\Function{CheckNeedSS}{$MS_s,max_t$}\Comment{Check if $ss$ is needed} \State $s_{last_{min}} \gets MinLastSeqN(MS_s)$ \State $s_{last_{max}} \gets MaxLastSeqN(MS_s)$ \State $n_{live} \gets s_{last_{max}} - s_{last_{min}}$\Comment{Number of live slots} -\State $n_{dead} \gets max'_t - n_{live}$ +\State $n_{dead} \gets max_t - n_{live}$ \State \Return {$n_{dead} = 0$} \EndFunction \end{algorithmic} @@ -571,29 +617,67 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \end{algorithmic} \begin{algorithmic}[1] -\Function{ReinsertLastSlot}{$MS_s,SK_s,sl_{s_{last}},max'_s,hmac_{p_s}$} -\State $s_s \gets MaxLastSeqN(MS_s)$ +\Procedure{CheckLastSlot}{$sl_{s_{last}}$} +\State $s_s \gets GetLastS(sl_{s_{last}})$ \State $sv_s \gets GetSV(sl_{s_{last}})$ \State $Dat_s \gets Decrypt(SK,sv_s)$ \State $DE_s \gets GetDatEnt(Dat_s)$ -\State $hmac_{c_s} \gets Hmac(DE_s,SK_s)$ -\State $Dat_s \gets CreateDat(s_s,id_{self},hmac_{p_s},DE_p,hmac_{c_s})$ -\State $hmac_{p_s} \gets hmac_{c_s}$ -\State $\tuple{stat_s,SL_s} \gets \Call{PutSlot}{s_s,sv_s,max'_s}$ -\State $cr_s \gets \Call{HandleCollision}{\tuple{stat_s,SL_s}}$ -\State \Return{$\tuple{cr_s,hmac_{p_p}}$} +\ForAll{$de_s \in DE_s$} + \State $live \gets \Call{CheckLiveness}{s_s,de_s}$ + \If{$live$} + \If{$de_s = kv$} + \State $\tuple{k_s,v_s} \gets GetKV(de_s)$ + \State $KV \gets \Call{PutKVPair}{KV,\tuple{k_s,v_s}}$ + \EndIf + \If{$de_s = ss$} + \State $ss_s \gets GetSS(de_s)$ + \State $SS \gets SS \cup ss_s$ + \EndIf + \If{$de_s = qs$} + \State $reinsert_{qs} \gets true$ + \EndIf + \If{$de_s = cr$} + \State $cr_s \gets GetCR(de_s)$ + \State $CR \gets CR \cup cr_s$ + \EndIf + \EndIf +\EndFor +\EndProcedure +\end{algorithmic} + +\begin{algorithmic}[1] +\Function{CheckLiveness}{$s_s,de_s$} +\State $live \gets true$ +\If{$de_s = kv \lor de_s = ss \lor de_s = cr$} + \State $s_l \gets GetLivEntLastS(LV,de_s)$ + \If{$s_l = \emptyset \lor s_s < s_l$} + \State $live \gets false$ + \EndIf +\ElsIf{$de_s = qs$} + \State $qs_s \gets GetQS(de_s)$ + \If{$qs_s \neq max_g$} + \State $live \gets false$ + \EndIf +\Else + \State \Call{Error}{'Unrecognized $de$ type'} +\EndIf +\State \Return{$live$} \EndFunction \end{algorithmic} -\note{Shouldn't this function do something pretty sophisticated about seeing what data we actually need to keep from the last slot and not just insert the entire thing?} \begin{algorithmic}[1] -\Function{AddSlotSeq}{$DE_s,sl_s,cp_s$}\Comment{Insert a $ss$} -\State $DE_{ret} \gets \emptyset$ +\Function{CreateSlotSeq}{$sl_s$} \State $id_s \gets GetID(sl_s)$ \State $s_{s_{last}} \gets GetLastS(sl_s)$ \State $ss_s \gets CreateSS(id_s,s_{s_{last}})$ -\State $DE_{ret} \gets DE_s \cup ss_s$ -\State $cp_s \gets cp_s - 1$ +\State \Return{$\tuple{ss_s}$} +\EndFunction +\end{algorithmic} + +\begin{algorithmic}[1] +\Function{AddSlotSeq}{$DE_s,SS_s,cp_s$}\Comment{Insert a $ss$} +\State $DE_{ret} \gets DE_s \cup SS_s$ +\State $cp_s \gets cp_s - |SS_s|$ \State \Return{$\tuple{DE_{ret},cp_s}$} \EndFunction \end{algorithmic} @@ -609,10 +693,10 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \end{algorithmic} \begin{algorithmic}[1] -\Function{AddCollRes}{$DE_s,cr_p,cp_s$}\Comment{Insert a $cr$} +\Function{AddColRes}{$DE_s,CR_s,cp_s$}\Comment{Insert a $cr$} \State $DE_{ret} \gets \emptyset$ -\State $DE_{ret} \gets DE_s \cup cr_p$ -\State $cp_s \gets cp_s - 1$ +\State $DE_{ret} \gets DE_s \cup CR_s$ +\State $cp_s \gets cp_s - |CR_s|$ \State \Return{$\tuple{DE_{ret},cp_s}$} \EndFunction \end{algorithmic} @@ -635,18 +719,31 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \begin{algorithmic}[1] \Procedure{PutDataEntries}{$th_p,m'_p$} \State $success \gets false$ +\State $CR_p \gets \emptyset$ \While{$\neg success$} \State $DE_p \gets \emptyset$ \State $s_p \gets MaxLastSeqN(MS)$ \State $cp_p \gets cp$ - \State $max'_p \gets \Call{CheckResize}{MS,th_p,max'_g,m'_p}$ + \State $max'_p \gets \Call{CheckResize}{MS,th_p,max_g,m'_p}$ \If{$max'_p \neq \emptyset$} - \State $\tuple{DE_p,cp_p} \gets \Call{AddQueueState}{DE_p,max'_p,cp_p}$\Comment{Add qs} + \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max'_p,cp_p}$\Comment{Add qs} + \Else\Comment{Check if there is $qs$ reinsertion} + \If{$reinsert_{qs}$} + \State $\tuple{DE_p,cp_p} \gets \Call{AddQueSta}{DE_p,max_g,cp_p}$ + \State $reinsert_{qs} \gets false$ + \EndIf + \EndIf + \If{$SS \neq \emptyset$}\Comment{Reinsert $ss$ entries} + %\State $\tuple{DE_p,cp_p} \gets \Call{ReinsertSS}{DE_p,SS,cp_p}$ + \State $\tuple{DE_p,cp_p} \gets \Call{AddSlotSeq}{DE_p,SS,cp_p}$ \EndIf - \State $need_p \gets \Call{CheckNeedSS}{MS,max'_g}$ - \If{$need_p$} - \State $\tuple{DE_p,cp_p} \gets \Call{AddSlotSequence}{DE_p,sl_{last},cp_p}$\Comment{Add ss} + \If{$CR \neq \emptyset$}\Comment{Add $cr$ entries} + \State $\tuple{DE_p,cp_p} \gets \Call{AddColRes}{DE_p,CR,cp_p}$ \EndIf + %\State $need_p \gets \Call{CheckNeedSS}{MS,max_g}$ + %\If{$need_p$} + % \State $\tuple{DE_p,cp_p} \gets \Call{AddSlotSeq}{DE_p,sl_{last},cp_p}$\Comment{Add ss} + %\EndIf \State $DE_p \gets \Call{GetKVPairs}{DE_p,KV,cp_p}$\Comment{Add kv pairs} \State $hmac_{c_p} \gets Hmac(DE_p,SK)$ \State $Dat_p \gets CreateDat(s_p,id_{self},hmac_{p_p},DE_p,hmac_{c_p})$ @@ -656,11 +753,8 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \State $success \gets stat_p$ \If{$\neg success$} \State $cr_p \gets \Call{HandleCollision}{SL_p}$ + \State $CR_p \gets CR_p \cup cr_p$ \EndIf - %\If{$need_p$} - % \State $\tuple{cr_{p_{last}},hmac_{p_p}} \gets - % \Call{ReinsertLastSlot}{MS,SK,sl_{last},max'_p,hmac_{p_p}}$ - %\EndIf \EndWhile \If{$|DE_p| = cp$}\Comment{Check and advance $ck_g$} \State $ck_g \gets ck_g + cp_s$\Comment{Middle of KV set} @@ -668,6 +762,14 @@ $\tuple{ck,\tuple{k, v}} \in KV_s \wedge \State $ck_g \gets 0$\Comment{End of KV set} \EndIf \State $MS \gets \Call{UpdateLastSeqN}{id_{self},s_p,MS}$ +\State $SS \gets \emptyset$ +\State $CR \gets CR_p$ +\State $need_p \gets \Call{CheckNeedSS}{MS,max_g}$ +\If{$need_p$} + \State $ss_p \gets \Call{CreateSlotSeq}{sl_{last}}$ + \State $SS \gets SS \cup ss_p$\Comment{Add ss} + \State $\Call{CheckLastSlot}{sl_{last}}$\Comment{SL on server is full} +\EndIf \EndProcedure \end{algorithmic}