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.

101 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. \* @type: (ROUND -> Set(MESSAGE), Set(MESSAGE), Int) => Bool;
  18. ProduceFaults(msgFun, From, k) ==
  19. \E f \in [1..k -> From]:
  20. msgFun = [r \in Rounds |-> {m \in {f[i]: i \in 1..k}: m.round = r}]
  21. \* As TLC explodes with faults, we may have initial states without faults
  22. InitNoFaults ==
  23. /\ round = [p \in Corr |-> 0]
  24. /\ step = [p \in Corr |-> "PROPOSE"]
  25. /\ decision = [p \in Corr |-> NilValue]
  26. /\ lockedValue = [p \in Corr |-> NilValue]
  27. /\ lockedRound = [p \in Corr |-> NilRound]
  28. /\ validValue = [p \in Corr |-> NilValue]
  29. /\ validRound = [p \in Corr |-> NilRound]
  30. /\ msgsPropose = [r \in Rounds |-> EmptyMsgSet]
  31. /\ msgsPrevote = [r \in Rounds |-> EmptyMsgSet]
  32. /\ msgsPrecommit = [r \in Rounds |-> EmptyMsgSet]
  33. /\ evidence = EmptyMsgSet
  34. (*
  35. A specialized version of Init that injects NFaultyProposals proposals,
  36. NFaultyPrevotes prevotes, NFaultyPrecommits precommits by the faulty processes
  37. *)
  38. InitFewFaults ==
  39. /\ round = [p \in Corr |-> 0]
  40. /\ step = [p \in Corr |-> "PROPOSE"]
  41. /\ decision = [p \in Corr |-> NilValue]
  42. /\ lockedValue = [p \in Corr |-> NilValue]
  43. /\ lockedRound = [p \in Corr |-> NilRound]
  44. /\ validValue = [p \in Corr |-> NilValue]
  45. /\ validRound = [p \in Corr |-> NilRound]
  46. /\ ProduceFaults(msgsPrevote',
  47. [type: {"PREVOTE"}, src: Faulty, round: Rounds, id: Values],
  48. NFaultyPrevotes)
  49. /\ ProduceFaults(msgsPrecommit',
  50. [type: {"PRECOMMIT"}, src: Faulty, round: Rounds, id: Values],
  51. NFaultyPrecommits)
  52. /\ ProduceFaults(msgsPropose',
  53. [type: {"PROPOSAL"}, src: Faulty, round: Rounds,
  54. proposal: Values, validRound: Rounds \cup {NilRound}],
  55. NFaultyProposals)
  56. /\ evidence = EmptyMsgSet
  57. \* Add faults incrementally
  58. NextWithFaults ==
  59. \* either the protocol makes a step
  60. \/ Next
  61. \* or a faulty process sends a message
  62. \//\ UNCHANGED <<round, step, decision, lockedValue,
  63. lockedRound, validValue, validRound, evidence>>
  64. /\ \E p \in Faulty:
  65. \E r \in Rounds:
  66. \//\ UNCHANGED <<msgsPrevote, msgsPrecommit>>
  67. /\ \E proposal \in ValidValues \union {NilValue}:
  68. \E vr \in RoundsOrNil:
  69. BroadcastProposal(p, r, proposal, vr)
  70. \//\ UNCHANGED <<msgsPropose, msgsPrecommit>>
  71. /\ \E id \in ValidValues \union {NilValue}:
  72. BroadcastPrevote(p, r, id)
  73. \//\ UNCHANGED <<msgsPropose, msgsPrevote>>
  74. /\ \E id \in ValidValues \union {NilValue}:
  75. BroadcastPrecommit(p, r, id)
  76. (******************************** PROPERTIES ***************************************)
  77. \* simple reachability properties to see that the spec is progressing
  78. NoPrevote == \A p \in Corr: step[p] /= "PREVOTE"
  79. NoPrecommit == \A p \in Corr: step[p] /= "PRECOMMIT"
  80. NoValidPrecommit ==
  81. \A r \in Rounds:
  82. \A m \in msgsPrecommit[r]:
  83. m.id = NilValue \/ m.src \in Faulty
  84. NoHigherRounds == \A p \in Corr: round[p] < 1
  85. NoDecision == \A p \in Corr: decision[p] = NilValue
  86. =============================================================================