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.

53 lines
2.5 KiB

5 years ago
  1. /*
  2. Package evidence handles all evidence storage and gossiping from detection to block proposal.
  3. For the different types of evidence refer to the `evidence.go` file in the types package
  4. or https://github.com/tendermint/spec/blob/master/spec/consensus/light-client/accountability.md.
  5. Gossiping
  6. The core functionality begins with the evidence reactor (see reactor.
  7. go) which operates both the sending and receiving of evidence.
  8. The `Receive` function takes a list of evidence and does the following:
  9. 1. Checks that it does not already have the evidence stored
  10. 2. Verifies the evidence against the node's state (see state/validation.go#VerifyEvidence)
  11. 3. Stores the evidence to a db and a concurrent list
  12. The gossiping of evidence is initiated when a peer is added which starts a go routine to broadcast currently
  13. uncommitted evidence at intervals of 60 seconds (set by the by broadcastEvidenceIntervalS).
  14. It uses a concurrent list to store the evidence and before sending verifies that each evidence is still valid in the
  15. sense that it has not exceeded the max evidence age and height (see types/params.go#EvidenceParams).
  16. There are two buckets that evidence can be stored in: Pending & Committed.
  17. 1. Pending is awaiting to be committed (evidence is usually broadcasted then)
  18. 2. Committed is for those already on the block and is to ensure that evidence isn't submitted twice
  19. All evidence is proto encoded to disk.
  20. Proposing
  21. When a new block is being proposed (in state/execution.go#CreateProposalBlock),
  22. `PendingEvidence(maxNum)` is called to send up to the maxNum number of uncommitted evidence, from the evidence store,
  23. prioritized in order of age. All evidence is checked for expiration.
  24. When a node receives evidence in a block it will use the evidence module as a cache first to see if it has
  25. already verified the evidence before trying to verify it again.
  26. Once the proposed evidence is submitted,
  27. the evidence is marked as committed and is moved from the broadcasted set to the committed set.
  28. As a result it is also removed from the concurrent list so that it is no longer gossiped.
  29. Minor Functionality
  30. As all evidence (including POLC's) are bounded by an expiration date, those that exceed this are no longer needed
  31. and hence pruned. Currently, only committed evidence in which a marker to the height that the evidence was committed
  32. and hence very small is saved. All updates are made from the `Update(block, state)` function which should be called
  33. when a new block is committed.
  34. */
  35. package evidence