You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
4.0 KiB

  1. ------------------ MODULE TendermintAccDebug_004_draft -------------------------
  2. (*
  3. A few definitions that we use for debugging TendermintAcc3, which do not belong
  4. to the specification itself.
  5. * Version 3. Modular and parameterized definitions.
  6. Igor Konnov, 2020.
  7. *)
  8. EXTENDS TendermintAccInv_004_draft
  9. \* make them parameters?
  10. NFaultyProposals == 0 \* the number of injected faulty PROPOSE messages
  11. NFaultyPrevotes == 6 \* the number of injected faulty PREVOTE messages
  12. NFaultyPrecommits == 6 \* the number of injected faulty PRECOMMIT messages
  13. \* Given a set of allowed messages Msgs, this operator produces a function from
  14. \* rounds to sets of messages.
  15. \* Importantly, there will be exactly k messages in the image of msgFun.
  16. \* We use this action to produce k faults in an initial state.
  17. ProduceFaults(msgFun, From, k) ==
  18. \E f \in [1..k -> From]:
  19. msgFun = [r \in Rounds |-> {m \in {f[i]: i \in 1..k}: m.round = r}]
  20. \* As TLC explodes with faults, we may have initial states without faults
  21. InitNoFaults ==
  22. /\ round = [p \in Corr |-> 0]
  23. /\ step = [p \in Corr |-> "PROPOSE"]
  24. /\ decision = [p \in Corr |-> NilValue]
  25. /\ lockedValue = [p \in Corr |-> NilValue]
  26. /\ lockedRound = [p \in Corr |-> NilRound]
  27. /\ validValue = [p \in Corr |-> NilValue]
  28. /\ validRound = [p \in Corr |-> NilRound]
  29. /\ msgsPropose = [r \in Rounds |-> EmptyMsgSet]
  30. /\ msgsPrevote = [r \in Rounds |-> EmptyMsgSet]
  31. /\ msgsPrecommit = [r \in Rounds |-> EmptyMsgSet]
  32. /\ evidence = EmptyMsgSet
  33. (*
  34. A specialized version of Init that injects NFaultyProposals proposals,
  35. NFaultyPrevotes prevotes, NFaultyPrecommits precommits by the faulty processes
  36. *)
  37. InitFewFaults ==
  38. /\ round = [p \in Corr |-> 0]
  39. /\ step = [p \in Corr |-> "PROPOSE"]
  40. /\ decision = [p \in Corr |-> NilValue]
  41. /\ lockedValue = [p \in Corr |-> NilValue]
  42. /\ lockedRound = [p \in Corr |-> NilRound]
  43. /\ validValue = [p \in Corr |-> NilValue]
  44. /\ validRound = [p \in Corr |-> NilRound]
  45. /\ ProduceFaults(msgsPrevote',
  46. SetOfMsgs([type: {"PREVOTE"}, src: Faulty, round: Rounds, id: Values]),
  47. NFaultyPrevotes)
  48. /\ ProduceFaults(msgsPrecommit',
  49. SetOfMsgs([type: {"PRECOMMIT"}, src: Faulty, round: Rounds, id: Values]),
  50. NFaultyPrecommits)
  51. /\ ProduceFaults(msgsPropose',
  52. SetOfMsgs([type: {"PROPOSAL"}, src: Faulty, round: Rounds,
  53. proposal: Values, validRound: Rounds \cup {NilRound}]),
  54. NFaultyProposals)
  55. /\ evidence = EmptyMsgSet
  56. \* Add faults incrementally
  57. NextWithFaults ==
  58. \* either the protocol makes a step
  59. \/ Next
  60. \* or a faulty process sends a message
  61. \//\ UNCHANGED <<round, step, decision, lockedValue,
  62. lockedRound, validValue, validRound, evidence>>
  63. /\ \E p \in Faulty:
  64. \E r \in Rounds:
  65. \//\ UNCHANGED <<msgsPrevote, msgsPrecommit>>
  66. /\ \E proposal \in ValidValues \union {NilValue}:
  67. \E vr \in RoundsOrNil:
  68. BroadcastProposal(p, r, proposal, vr)
  69. \//\ UNCHANGED <<msgsPropose, msgsPrecommit>>
  70. /\ \E id \in ValidValues \union {NilValue}:
  71. BroadcastPrevote(p, r, id)
  72. \//\ UNCHANGED <<msgsPropose, msgsPrevote>>
  73. /\ \E id \in ValidValues \union {NilValue}:
  74. BroadcastPrecommit(p, r, id)
  75. (******************************** PROPERTIES ***************************************)
  76. \* simple reachability properties to see that the spec is progressing
  77. NoPrevote == \A p \in Corr: step[p] /= "PREVOTE"
  78. NoPrecommit == \A p \in Corr: step[p] /= "PRECOMMIT"
  79. NoValidPrecommit ==
  80. \A r \in Rounds:
  81. \A m \in msgsPrecommit[r]:
  82. m.id = NilValue \/ m.src \in Faulty
  83. NoHigherRounds == \A p \in Corr: round[p] < 1
  84. NoDecision == \A p \in Corr: decision[p] = NilValue
  85. =============================================================================