Skip to content

Commit

Permalink
#414: add history variables to Lightclient_A_1.tla
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-kuprianov committed Aug 4, 2020
1 parent 0ac86a3 commit e435ae3
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions docs/spec/lightclient/verification/Lightclient_A_1.tla
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,24 @@ VARIABLES
lightBlockStatus, (* a function from heights to block statuses *)
latestVerified (* the latest verified block *)

(* the variables of the lite client *)
lcvars == <<state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified>>
(* the light client history variables *)
VARIABLES
prevVerified, (* the latest verified block in the previous state *)
prevChecked, (* the block that was checked in the previous state *)
prevVerdict (* the verdict in the previous state *)

InitHistory(verified, checked, verdict) ==
/\ prevVerified = verified
/\ prevChecked = checked
/\ prevVerdict = verdict

NextHistory(verified, checked, verdict) ==
/\ prevVerified' = verified
/\ prevChecked' = checked
/\ prevVerdict' = verdict

(* the variables of the lite client *)
lcvars == <<state, nextHeight, fetchedLightBlocks, lightBlockStatus, latestVerified>>

(******************* Blockchain instance ***********************************)

Expand Down Expand Up @@ -135,6 +151,7 @@ LCInit ==
/\ lightBlockStatus = [h \in {TRUSTED_HEIGHT} |-> "StateVerified"]
\* the latest verified block the the trusted block
/\ latestVerified = trustedLightBlock
/\ NextHistory(trustedLightBlock, trustedLightBlock, "OK")

\* block should contain a copy of the block from the reference chain, with a matching commit
CopyLightBlockFromChain(block, height) ==
Expand Down Expand Up @@ -207,6 +224,7 @@ VerifyToTargetLoop ==
/\ nprobes' = nprobes + 1
\* Verify the current block
/\ LET verdict == ValidAndVerified(latestVerified, current) IN
NextHistory(latestVerified, current, verdict) /\
\* Decide whether/how to continue
CASE verdict = "OK" ->
/\ lightBlockStatus' = LightStoreUpdateStates(lightBlockStatus, nextHeight, "StateVerified")
Expand Down Expand Up @@ -244,7 +262,8 @@ VerifyToTargetLoop ==
VerifyToTargetDone ==
/\ latestVerified.header.height >= TARGET_HEIGHT
/\ state' = "finishedSuccess"
/\ UNCHANGED <<nextHeight, nprobes, fetchedLightBlocks, lightBlockStatus, latestVerified>>
/\ UNCHANGED <<nextHeight, nprobes, fetchedLightBlocks, lightBlockStatus, latestVerified>>
/\ UNCHANGED <<prevVerified, prevChecked, prevVerdict>>

(********************* Lite client + Blockchain *******************)
Init ==
Expand Down

0 comments on commit e435ae3

Please sign in to comment.