Skip to content

Commit

Permalink
config: Move discard_abci_responses flag into its own storage secti…
Browse files Browse the repository at this point in the history
…on (#9275)

* config: Move discard_abci_responses flag into its own storage section

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update config comment to highlight space saving tradeoff

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Co-authored-by: Thane Thomson <connect@thanethomson.coma>
  • Loading branch information
tnasu and Thane Thomson committed Jul 19, 2023
1 parent 7461069 commit 56c0b62
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/ostracon/commands/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 33 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Config struct {
StateSync *StateSyncConfig `mapstructure:"statesync"`
FastSync *FastSyncConfig `mapstructure:"fastsync"`
Consensus *ConsensusConfig `mapstructure:"consensus"`
Storage *StorageConfig `mapstructure:"storage"`
TxIndex *TxIndexConfig `mapstructure:"tx_index"`
Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"`
}
Expand All @@ -93,6 +94,7 @@ func DefaultConfig() *Config {
StateSync: DefaultStateSyncConfig(),
FastSync: DefaultFastSyncConfig(),
Consensus: DefaultConsensusConfig(),
Storage: DefaultStorageConfig(),
TxIndex: DefaultTxIndexConfig(),
Instrumentation: DefaultInstrumentationConfig(),
}
Expand All @@ -108,6 +110,7 @@ func TestConfig() *Config {
StateSync: TestStateSyncConfig(),
FastSync: TestFastSyncConfig(),
Consensus: TestConsensusConfig(),
Storage: TestStorageConfig(),
TxIndex: TestTxIndexConfig(),
Instrumentation: TestInstrumentationConfig(),
}
Expand Down Expand Up @@ -465,11 +468,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
Expand Down Expand Up @@ -497,9 +495,8 @@ func DefaultRPCConfig() *RPCConfig {
MaxBodyBytes: int64(1000000), // 1MB
MaxHeaderBytes: 1 << 20, // same as the net/http default

TLSCertFile: "",
TLSKeyFile: "",
DiscardABCIResponses: false,
TLSCertFile: "",
TLSKeyFile: "",
}
}

Expand Down Expand Up @@ -1169,6 +1166,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:
Expand Down
13 changes: 10 additions & 3 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,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 ###
#######################################################
Expand Down Expand Up @@ -541,6 +538,16 @@ max_txs = {{ .Consensus.MaxTxs }}
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 ###
#######################################################
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,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
Expand Down Expand Up @@ -762,7 +762,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)
Expand Down

0 comments on commit 56c0b62

Please sign in to comment.