From 596ca4e5915271466abc79fe7f12bc9504c86af6 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Wed, 17 Aug 2022 11:18:18 -0400 Subject: [PATCH] config: Move `discard_abci_responses` flag into its own storage section (#9275) * config: Move discard_abci_responses flag into its own storage section Signed-off-by: Thane Thomson * Update config comment to highlight space saving tradeoff Signed-off-by: Thane Thomson Signed-off-by: Thane Thomson --- cmd/tendermint/commands/rollback.go | 2 +- config/config.go | 41 +++++++++++++++++++++++------ config/toml.go | 13 ++++++--- node/node.go | 4 +-- p2p/transport_test.go | 30 --------------------- 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/cmd/tendermint/commands/rollback.go b/cmd/tendermint/commands/rollback.go index 1270c0ac6..7e7190fb5 100644 --- a/cmd/tendermint/commands/rollback.go +++ b/cmd/tendermint/commands/rollback.go @@ -78,7 +78,7 @@ func loadStateAndBlockStore(config *cfg.Config) (*store.BlockStore, state.Store, return nil, nil, err } stateStore := state.NewStore(stateDB, state.StoreOptions{ - DiscardABCIResponses: config.RPC.DiscardABCIResponses, + DiscardABCIResponses: config.Storage.DiscardABCIResponses, }) return blockStore, stateStore, nil diff --git a/config/config.go b/config/config.go index a04c45e3b..3eea2b7b5 100644 --- a/config/config.go +++ b/config/config.go @@ -77,6 +77,7 @@ type Config struct { // https://github.com/tendermint/tendermint/issues/9279 DeprecatedFastSyncConfig map[interface{}]interface{} `mapstructure:"fastsync"` Consensus *ConsensusConfig `mapstructure:"consensus"` + Storage *StorageConfig `mapstructure:"storage"` TxIndex *TxIndexConfig `mapstructure:"tx_index"` Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"` } @@ -91,6 +92,7 @@ func DefaultConfig() *Config { StateSync: DefaultStateSyncConfig(), BlockSync: DefaultBlockSyncConfig(), Consensus: DefaultConsensusConfig(), + Storage: DefaultStorageConfig(), TxIndex: DefaultTxIndexConfig(), Instrumentation: DefaultInstrumentationConfig(), } @@ -106,6 +108,7 @@ func TestConfig() *Config { StateSync: TestStateSyncConfig(), BlockSync: TestBlockSyncConfig(), Consensus: TestConsensusConfig(), + Storage: TestStorageConfig(), TxIndex: TestTxIndexConfig(), Instrumentation: TestInstrumentationConfig(), } @@ -423,11 +426,6 @@ type RPCConfig struct { // pprof listen address (https://golang.org/pkg/net/http/pprof) PprofListenAddress string `mapstructure:"pprof_laddr"` - - // Set false to ensure ABCI responses are persisted. - // ABCI responses are required for /BlockResults RPC queries, and - // to reindex events in the command-line tool. - DiscardABCIResponses bool `mapstructure:"discard_abci_responses"` } // DefaultRPCConfig returns a default configuration for the RPC server @@ -452,9 +450,8 @@ func DefaultRPCConfig() *RPCConfig { MaxBodyBytes: int64(1000000), // 1MB MaxHeaderBytes: 1 << 20, // same as the net/http default - TLSCertFile: "", - TLSKeyFile: "", - DiscardABCIResponses: false, + TLSCertFile: "", + TLSKeyFile: "", } } @@ -1092,6 +1089,34 @@ func (cfg *ConsensusConfig) ValidateBasic() error { return nil } +//----------------------------------------------------------------------------- +// StorageConfig + +// StorageConfig allows more fine-grained control over certain storage-related +// behavior. +type StorageConfig struct { + // Set to false to ensure ABCI responses are persisted. ABCI responses are + // required for `/block_results` RPC queries, and to reindex events in the + // command-line tool. + DiscardABCIResponses bool `mapstructure:"discard_abci_responses"` +} + +// DefaultStorageConfig returns the default configuration options relating to +// Tendermint storage optimization. +func DefaultStorageConfig() *StorageConfig { + return &StorageConfig{ + DiscardABCIResponses: false, + } +} + +// TestStorageConfig returns storage configuration that can be used for +// testing. +func TestStorageConfig() *StorageConfig { + return &StorageConfig{ + DiscardABCIResponses: false, + } +} + // ----------------------------------------------------------------------------- // TxIndexConfig // Remember that Event has the following structure: diff --git a/config/toml.go b/config/toml.go index c77bbfe5a..a284e4358 100644 --- a/config/toml.go +++ b/config/toml.go @@ -263,9 +263,6 @@ tls_key_file = "{{ .RPC.TLSKeyFile }}" # pprof listen address (https://golang.org/pkg/net/http/pprof) pprof_laddr = "{{ .RPC.PprofListenAddress }}" -# Flag that enables discarding of abci responses -discard_abci_responses = {{ .RPC.DiscardABCIResponses}} - ####################################################### ### P2P Configuration Options ### ####################################################### @@ -485,6 +482,16 @@ create_empty_blocks_interval = "{{ .Consensus.CreateEmptyBlocksInterval }}" peer_gossip_sleep_duration = "{{ .Consensus.PeerGossipSleepDuration }}" peer_query_maj23_sleep_duration = "{{ .Consensus.PeerQueryMaj23SleepDuration }}" +####################################################### +### Storage Configuration Options ### +####################################################### + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = {{ .Storage.DiscardABCIResponses}} + ####################################################### ### Transaction Indexer Configuration Options ### ####################################################### diff --git a/node/node.go b/node/node.go index e78751756..dd1a7b96f 100644 --- a/node/node.go +++ b/node/node.go @@ -431,7 +431,7 @@ func createEvidenceReactor(config *cfg.Config, dbProvider DBProvider, } evidenceLogger := logger.With("module", "evidence") evidencePool, err := evidence.NewPool(evidenceDB, sm.NewStore(stateDB, sm.StoreOptions{ - DiscardABCIResponses: config.RPC.DiscardABCIResponses, + DiscardABCIResponses: config.Storage.DiscardABCIResponses, }), blockStore) if err != nil { return nil, nil, err @@ -717,7 +717,7 @@ func NewNode(config *cfg.Config, } stateStore := sm.NewStore(stateDB, sm.StoreOptions{ - DiscardABCIResponses: config.RPC.DiscardABCIResponses, + DiscardABCIResponses: config.Storage.DiscardABCIResponses, }) state, genDoc, err := LoadStateFromDBOrGenesisDocProvider(stateDB, genesisDocProvider) diff --git a/p2p/transport_test.go b/p2p/transport_test.go index 2bd114160..90b074256 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -453,19 +453,9 @@ func TestTransportMultiplexDialRejectWrongID(t *testing.T) { _, err := dialer.Dial(*addr, peerConfig{}) if err != nil { t.Logf("connection failed: %v", err) -<<<<<<< HEAD if e, ok := err.(ErrRejected); ok { if !e.IsAuthFailure() { t.Errorf("expected auth failure, got %v", e) -||||||| parent of fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) - if err, ok := err.(ErrRejected); ok { - if !err.IsAuthFailure() { - t.Errorf("expected auth failure, got %v", err) -======= - if e, ok := err.(ErrRejected); ok { - if !e.IsAuthFailure() { - t.Errorf("expected auth failure, got %v", err) ->>>>>>> fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -500,19 +490,9 @@ func TestTransportMultiplexRejectIncompatible(t *testing.T) { }() _, err := mt.Accept(peerConfig{}) -<<<<<<< HEAD if e, ok := err.(ErrRejected); ok { if !e.IsIncompatible() { t.Errorf("expected to reject incompatible, got %v", e) -||||||| parent of fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) - if err, ok := err.(ErrRejected); ok { - if !err.IsIncompatible() { - t.Errorf("expected to reject incompatible, got %v", err) -======= - if e, ok := err.(ErrRejected); ok { - if !e.IsIncompatible() { - t.Errorf("expected to reject incompatible, got %v", err) ->>>>>>> fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) } } else { t.Errorf("expected ErrRejected, got %v", err) @@ -537,19 +517,9 @@ func TestTransportMultiplexRejectSelf(t *testing.T) { }() if err := <-errc; err != nil { -<<<<<<< HEAD if e, ok := err.(ErrRejected); ok { if !e.IsSelf() { t.Errorf("expected to reject self, got: %v", e) -||||||| parent of fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) - if err, ok := err.(ErrRejected); ok { - if !err.IsSelf() { - t.Errorf("expected to reject self, got: %v", err) -======= - if e, ok := err.(ErrRejected); ok { - if !e.IsSelf() { - t.Errorf("expected to reject self, got: %v", err) ->>>>>>> fbd754b4d (Backport of sam/abci-responses (#9090) (#9159)) } } else { t.Errorf("expected ErrRejected, got %v", err)