Skip to content

Commit

Permalink
Enabled snapshot by default
Browse files Browse the repository at this point in the history
See PR #529
  • Loading branch information
dadamu authored Jul 8, 2021
1 parent 5e604e3 commit 96dff74
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Require chain name to be lowercase ([#533](https://github.com/desmos-labs/desmos/pull/533))
- Improved pagination ([#544](https://github.com/desmos-labs/desmos/pull/544))
- Renamed `PollData` and `PollAnswer` to `Poll` and `ProvidedAnswer` ([#536]((https://github.com/desmos-labs/desmos/issues/536)))
- Enabled snapshot by default ([#529](https://github.com/desmos-labs/desmos/pull/529))

# Version 0.17.0
## Changes
Expand Down
39 changes: 39 additions & 0 deletions app/desmos/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cmd

// DONTCOVER

import (
"path/filepath"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/types/module"
cosmosgenutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
)

// initCmd returns a command that initializes all files needed for Tendermint
// and the respective application.
func initCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
cmd := cosmosgenutilcli.InitCmd(mbm, defaultNodeHome)
defaultRun := cmd.RunE
cmd.RunE = func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
err := defaultRun(cmd, args)
if err != nil {
return err
}
// Set app.toml file
appConfig := srvconfig.DefaultConfig()
appConfig.Pruning = "custom"
appConfig.PruningKeepRecent = "100"
appConfig.PruningKeepEvery = "500"
appConfig.PruningInterval = "10"

appConfig.StateSync.SnapshotInterval = 500
srvconfig.WriteConfigFile(filepath.Join(clientCtx.HomeDir, "config", "app.toml"), appConfig)
return nil
}
return cmd
}
2 changes: 1 addition & 1 deletion app/desmos/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
authclient.Codec = encodingConfig.Marshaler

rootCmd.AddCommand(
cosmosgenutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
initCmd(app.ModuleBasics, app.DefaultNodeHome),
cosmosgenutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.MigrationsListCmd(),
genutilcli.MigrateGenesisCmd(),
Expand Down
2 changes: 2 additions & 0 deletions docs/fullnode/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Inside Desmos, there are various types of pruning strategies that can be applied

- `everything`: all saved states will be deleted, storing only the current state; pruning at 10 block intervals

- `custom`: allow pruning options to be manually specified through 'pruning-keep-recent', 'pruning-keep-every', and 'pruning-interval'

### Hardware requirements

You can easily understand how using a pruning strategy of `nothing` will use more disk space than `everything`. For this
Expand Down
25 changes: 25 additions & 0 deletions docs/fullnode/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,31 @@ trust_hash = "E8ED7A890A64986246EEB02D7D8C4A6D497E3B60C0CAFDDE30F2EE385204C314"
trust_period = "168h0m0s"
```

## (Optional) Edit snapshot config

Currently, the `snapshot` feature is enabled by the default. This means that your node will periodically create snapshots of the chain state and make them public, allowing other nodes to quickly join the network by syncing the application state at a given height.

By default, we have set Desmos to take snapshots every 500 blocks, and persist the last 2 snapshots, deleting older ones. If you want to provide other nodes with more (or less) frequent snapshots, you can do this by editing a couple of things inside your `~/.desmos/config/app.toml` file, under the `state-sync` section:

```toml
# snapshot-interval specifies the block interval at which local state sync snapshots are
# taken (0 to disable). Must be a multiple of pruning-keep-every.
snapshot-interval = 500
# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all).
snapshot-keep-recent = 2
```

**Note: Make sure that snapshot-interval is a multiple of `pruning-keep-every` in the `base` section**

```toml
pruning-keep-recent = "100"
pruning-keep-every = "500"
pruning-interval = "10"
```

You can find out more about pruning [here](overview.md#understanding-pruning).

## (Optional) Change your database backend

If you would like to run your node using [Facebook's RocksDB](https://github.com/facebook/rocksdb) as the database
Expand Down

0 comments on commit 96dff74

Please sign in to comment.