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.

71 lines
2.7 KiB

  1. ---
  2. order: 1
  3. parent:
  4. title: Mempool
  5. order: 2
  6. ---
  7. The mempool is a in memory pool of potentially valid transactions,
  8. both to broadcast to other nodes, as well as to provide to the
  9. consensus reactor when it is selected as the block proposer.
  10. There are two sides to the mempool state:
  11. - External: get, check, and broadcast new transactions
  12. - Internal: return valid transaction, update list after block commit
  13. ## External functionality
  14. External functionality is exposed via network interfaces
  15. to potentially untrusted actors.
  16. - CheckTx - triggered via RPC or P2P
  17. - Broadcast - gossip messages after a successful check
  18. ## Internal functionality
  19. Internal functionality is exposed via method calls to other
  20. code compiled into the tendermint binary.
  21. - ReapMaxBytesMaxGas - get txs to propose in the next block. Guarantees that the
  22. size of the txs is less than MaxBytes, and gas is less than MaxGas
  23. - Update - remove tx that were included in last block
  24. - ABCI.CheckTx - call ABCI app to validate the tx
  25. What does it provide the consensus reactor?
  26. What guarantees does it need from the ABCI app?
  27. (talk about interleaving processes in concurrency)
  28. ## Optimizations
  29. The implementation within this library also implements a tx cache.
  30. This is so that signatures don't have to be reverified if the tx has
  31. already been seen before.
  32. However, we only store valid txs in the cache, not invalid ones.
  33. This is because invalid txs could become good later.
  34. Txs that are included in a block aren't removed from the cache,
  35. as they still may be getting received over the p2p network.
  36. These txs are stored in the cache by their hash, to mitigate memory concerns.
  37. Applications should implement replay protection, read [Replay
  38. Protection](https://github.com/tendermint/tendermint/blob/8cdaa7f515a9d366bbc9f0aff2a263a1a6392ead/docs/app-dev/app-development.md#replay-protection) for more information.
  39. ## Configuration
  40. The mempool has various configurable paramet
  41. Sending incorrectly encoded data or data exceeding `maxMsgSize` will result
  42. in stopping the peer.
  43. `maxMsgSize` equals `MaxBatchBytes` (10MB) + 4 (proto overhead).
  44. `MaxBatchBytes` is a mempool config parameter -> defined locally. The reactor
  45. sends transactions to the connected peers in batches. The maximum size of one
  46. batch is `MaxBatchBytes`.
  47. The mempool will not send a tx back to any peer which it received it from.
  48. The reactor assigns an `uint16` number for each peer and maintains a map from
  49. p2p.ID to `uint16`. Each mempool transaction carries a list of all the senders
  50. (`[]uint16`). The list is updated every time mempool receives a transaction it
  51. is already seen. `uint16` assumes that a node will never have over 65535 active
  52. peers (0 is reserved for unknown source - e.g. RPC).