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.

66 lines
2.1 KiB

add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
5 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
5 years ago
add support for block pruning via ABCI Commit response (#4588) * Added BlockStore.DeleteBlock() * Added initial block pruner prototype * wip * Added BlockStore.PruneBlocks() * Added consensus setting for block pruning * Added BlockStore base * Error on replay if base does not have blocks * Handle missing blocks when sending VoteSetMaj23Message * Error message tweak * Properly update blockstore state * Error message fix again * blockchain: ignore peer missing blocks * Added FIXME * Added test for block replay with truncated history * Handle peer base in blockchain reactor * Improved replay error handling * Added tests for Store.PruneBlocks() * Fix non-RPC handling of truncated block history * Panic on missing block meta in needProofBlock() * Updated changelog * Handle truncated block history in RPC layer * Added info about earliest block in /status RPC * Reorder height and base in blockchain reactor messages * Updated changelog * Fix tests * Appease linter * Minor review fixes * Non-empty BlockStores should always have base > 0 * Update code to assume base > 0 invariant * Added blockstore tests for pruning to 0 * Make sure we don't prune below the current base * Added BlockStore.Size() * config: added retain_blocks recommendations * Update v1 blockchain reactor to handle blockstore base * Added state database pruning * Propagate errors on missing validator sets * Comment tweaks * Improved error message Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> * use ABCI field ResponseCommit.retain_height instead of retain-blocks config option * remove State.RetainHeight, return value instead * fix minor issues * rename pruneHeights() to pruneBlocks() * noop to fix GitHub borkage Co-authored-by: Anton Kaliaev <anton.kalyaev@gmail.com>
5 years ago
  1. package state
  2. import (
  3. "context"
  4. "github.com/tendermint/tendermint/types"
  5. )
  6. //------------------------------------------------------
  7. // blockchain services types
  8. // NOTE: Interfaces used by RPC must be thread safe!
  9. //------------------------------------------------------
  10. //go:generate ../../scripts/mockery_generate.sh BlockStore
  11. //------------------------------------------------------
  12. // blockstore
  13. // BlockStore defines the interface used by the ConsensusState.
  14. type BlockStore interface {
  15. Base() int64
  16. Height() int64
  17. Size() int64
  18. LoadBaseMeta() *types.BlockMeta
  19. LoadBlockMeta(height int64) *types.BlockMeta
  20. LoadBlock(height int64) *types.Block
  21. SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
  22. PruneBlocks(height int64) (uint64, error)
  23. LoadBlockByHash(hash []byte) *types.Block
  24. LoadBlockMetaByHash(hash []byte) *types.BlockMeta
  25. LoadBlockPart(height int64, index int) *types.Part
  26. LoadBlockCommit(height int64) *types.Commit
  27. LoadSeenCommit() *types.Commit
  28. }
  29. //-----------------------------------------------------------------------------
  30. // evidence pool
  31. //go:generate ../../scripts/mockery_generate.sh EvidencePool
  32. // EvidencePool defines the EvidencePool interface used by State.
  33. type EvidencePool interface {
  34. PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
  35. AddEvidence(context.Context, types.Evidence) error
  36. Update(context.Context, State, types.EvidenceList)
  37. CheckEvidence(context.Context, types.EvidenceList) error
  38. }
  39. // EmptyEvidencePool is an empty implementation of EvidencePool, useful for testing. It also complies
  40. // to the consensus evidence pool interface
  41. type EmptyEvidencePool struct{}
  42. func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) {
  43. return nil, 0
  44. }
  45. func (EmptyEvidencePool) AddEvidence(context.Context, types.Evidence) error { return nil }
  46. func (EmptyEvidencePool) Update(context.Context, State, types.EvidenceList) {}
  47. func (EmptyEvidencePool) CheckEvidence(ctx context.Context, evList types.EvidenceList) error {
  48. return nil
  49. }
  50. func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote) {}