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.

61 lines
2.0 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. "github.com/tendermint/tendermint/types"
  4. )
  5. //------------------------------------------------------
  6. // blockchain services types
  7. // NOTE: Interfaces used by RPC must be thread safe!
  8. //------------------------------------------------------
  9. //go:generate ../scripts/mockery_generate.sh BlockStore
  10. //------------------------------------------------------
  11. // blockstore
  12. // BlockStore defines the interface used by the ConsensusState.
  13. type BlockStore interface {
  14. Base() int64
  15. Height() int64
  16. Size() int64
  17. LoadBaseMeta() *types.BlockMeta
  18. LoadBlockMeta(height int64) *types.BlockMeta
  19. LoadBlock(height int64) *types.Block
  20. SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit)
  21. PruneBlocks(height int64) (uint64, error)
  22. LoadBlockByHash(hash []byte) *types.Block
  23. LoadBlockPart(height int64, index int) *types.Part
  24. LoadBlockCommit(height int64) *types.Commit
  25. LoadSeenCommit() *types.Commit
  26. }
  27. //-----------------------------------------------------------------------------
  28. // evidence pool
  29. //go:generate ../scripts/mockery_generate.sh EvidencePool
  30. // EvidencePool defines the EvidencePool interface used by State.
  31. type EvidencePool interface {
  32. PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
  33. AddEvidence(types.Evidence) error
  34. Update(State, types.EvidenceList)
  35. CheckEvidence(types.EvidenceList) error
  36. }
  37. // EmptyEvidencePool is an empty implementation of EvidencePool, useful for testing. It also complies
  38. // to the consensus evidence pool interface
  39. type EmptyEvidencePool struct{}
  40. func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) {
  41. return nil, 0
  42. }
  43. func (EmptyEvidencePool) AddEvidence(types.Evidence) error { return nil }
  44. func (EmptyEvidencePool) Update(State, types.EvidenceList) {}
  45. func (EmptyEvidencePool) CheckEvidence(evList types.EvidenceList) error { return nil }
  46. func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote) {}