Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLA+: Updating the fastsync spec after model checking #466

Merged
merged 34 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a868173
adapted fastsync for apalache
konnov May 15, 2020
2fbe722
bugfix for CorrectBlocks
konnov May 18, 2020
3b3d423
the minimalistic model of blockchain for fastsync
konnov May 19, 2020
b6a140f
fixed safety
konnov May 19, 2020
2896966
introduced height again
konnov May 19, 2020
07e802c
fixed CorrectBlocks
konnov May 21, 2020
1289aa0
simplified the blockchain spec
konnov May 25, 2020
074d2c5
decreasing the search space, to give TLC a chance
konnov May 25, 2020
1137a83
added Termination2
konnov May 25, 2020
853b740
a few fixes
konnov May 26, 2020
09c00be
a better way of using the abstract hashes
konnov May 27, 2020
c8bb4eb
configuration files for the repeatable experiments
konnov May 27, 2020
5b4073b
INVARIANT -> PROPERTY
konnov May 28, 2020
ec8be58
increased apalache timeout
konnov May 28, 2020
cee09ed
doubled the timeouts for apalache and tlc
konnov May 28, 2020
204a2bd
formatting
konnov May 28, 2020
b97d83b
new timeouts for the experiments
konnov May 28, 2020
1993777
fixed termination after the example by tlc
konnov May 29, 2020
3dfa3e8
comment on hash abstraction
konnov May 29, 2020
dabf570
TerminationCorr
konnov May 29, 2020
13b7170
added comments on the properties
konnov May 29, 2020
dc0ab21
increase tlc timeout to 12 hrs
konnov May 30, 2020
28484ce
increased tlc timeout to 24h
konnov Jun 1, 2020
4310960
simplifying block execution + comments
konnov Jul 20, 2020
b471edd
the experiments with 2 faulty processes
konnov Jul 20, 2020
420bef4
a model for 2 faulty processes
konnov Jul 20, 2020
6a064b1
cleaning up the spec a bit
konnov Jul 21, 2020
bf535f8
updates from verification/fastsync_apalache.tla after model checking
konnov Jul 21, 2020
1a431cb
copied Tinychain.tla from verification
konnov Jul 21, 2020
2ee8b8b
updated the spec name
konnov Jul 28, 2020
67ae7c3
Update docs/spec/fastsync/Tinychain.tla
konnov Aug 7, 2020
28e877b
Update docs/spec/fastsync/fastsync.tla
konnov Aug 7, 2020
52eec6f
Update docs/spec/fastsync/fastsync.tla
konnov Aug 7, 2020
057c81f
addressing Josef's comments
konnov Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions docs/spec/fastsync/Tinychain.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
-------------------------- MODULE Tinychain ----------------------------------
(* A very abstract model of Tendermint blockchain. Its only purpose is to highlight
the relation between validator sets, next validator sets, and last commits.
*)

EXTENDS Integers

\* type annotation
a <: b == a

\* the type of validator sets, e.g., STRING
VST == STRING

\* LastCommit type.
\* It contains:
\* 1) the flag of whether the block id equals to the hash of the previous block, and
\* 2) the set of the validators who have committed the block.
\* In the implementation, blockId is the hash of the previous block, which cannot be forged.
\* We abstract block id into whether it equals to the hash of the previous block or not.
LCT == [blockIdEqRef |-> BOOLEAN, committers |-> VST]
konnov marked this conversation as resolved.
Show resolved Hide resolved

\* Block type.
\* A block contains its height, validator set, next validator set, and last commit.
\* Moreover, it contains the flag that tells us whether the block is equal to the one
\* on the reference chain (this is an abstraction of hash).
konnov marked this conversation as resolved.
Show resolved Hide resolved
BT == [height |-> Int, hashEqRef |-> BOOLEAN, wellFormed |-> BOOLEAN,
VS |-> VST, NextVS |-> VST, lastCommit |-> LCT]

CONSTANTS
(*
A set of abstract values, each value representing a set of validators.
For the purposes of this specification, they can be any values,
e.g., "s1", "s2", etc.
*)
VALIDATOR_SETS,
(* a nil validator set that is outside of VALIDATOR_SETS *)
NIL_VS,
(* The maximal height, up to which the blockchain may grow *)
MAX_HEIGHT

Heights == 1..MAX_HEIGHT

\* the set of all possible commits
konnov marked this conversation as resolved.
Show resolved Hide resolved
Commits == [blockIdEqRef: BOOLEAN, committers: VALIDATOR_SETS]

\* the set of all possible blocks, not necessarily valid ones
konnov marked this conversation as resolved.
Show resolved Hide resolved
Blocks ==
[height: Heights, hashEqRef: BOOLEAN, wellFormed: BOOLEAN,
VS: VALIDATOR_SETS, NextVS: VALIDATOR_SETS, lastCommit: Commits]

\* Does the chain contain a sound sequence of blocks that could be produced by
\* a 2/3 of faulty validators. This operator can be used to initialise the chain!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"faulty validators" ?

IsCorrectChain(chain) ==
\* restrict the structure of the blocks, to decrease the TLC search space
LET OkCommits == [blockIdEqRef: {TRUE}, committers: VALIDATOR_SETS]
OkBlocks == [height: Heights, hashEqRef: {TRUE}, wellFormed: {TRUE},
VS: VALIDATOR_SETS, NextVS: VALIDATOR_SETS, lastCommit: OkCommits]
IN
/\ chain \in [1..MAX_HEIGHT -> OkBlocks]
/\ \A h \in 1..MAX_HEIGHT:
LET b == chain[h] IN
/\ b.height = h \* the height is correct
/\ h > 1 =>
LET p == chain[h - 1] IN
/\ b.VS = p.NextVS \* the validators propagate from the previous block
/\ b.lastCommit.committers = p.VS \* and they are the committers
konnov marked this conversation as resolved.
Show resolved Hide resolved


\* The basic properties of blocks on the blockchain:
\* They should pass the validity check and they may verify the next block.

\* Does the block pass the consistency check against the next validators of the previous block
IsMatchingValidators(block, nextVS) ==
\* simply check that the validator set is propagated correctly.
\* (the implementation tests hashes and the application state)
block.VS = nextVS

\* Does the block verify the commit (of the next block)
PossibleCommit(block, commit) ==
\* the commits are signed by the block validators
/\ commit.committers = block.VS
\* The block id in the commit matches the block hash (abstract comparison).
\* (The implementation has extensive tests for that.)
\* this is an abstraction of: commit.blockId = hash(block)
\*
\* These are possible scenarios on the concrete hashes:
\*
\* scenario 1: commit.blockId = 10 /\ hash(block) = 10 /\ hash(ref) = 10
\* scenario 2: commit.blockId = 20 /\ hash(block) = 20 /\ block.VS /= ref.VS
\* scenario 3: commit.blockId = 50 /\ hash(block) = 100
\* scenario 4: commit.blockId = 10 /\ hash(block) = 100
\* scenario 5: commit.blockId = 100 /\ hash(block) = 10
/\ commit.blockIdEqRef = block.hashEqRef
\* the following test would be cheating, as we do not have access to the
\* reference chain:
\* /\ commit.blockIdEqRef

\* Basic invariants

\* every block has the validator set that is chosen by its predecessor
ValidBlockInv(chain) ==
\A h \in 2..MAX_HEIGHT:
IsMatchingValidators(chain[h], chain[h - 1].NextVS)

\* last commit of every block is signed by the validators of the predecessor
VerifiedBlockInv(chain) ==
\A h \in 2..MAX_HEIGHT:
PossibleCommit(chain[h - 1], chain[h].lastCommit)

==================================================================================
Loading